HP Forums
Why solve() is not solving? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Why solve() is not solving? (/thread-6514.html)



Why solve() is not solving? - tiamattia - 07-07-2016 01:22 PM

Hello,

I'm trying to solve a complex equation. This is the function i defined "gamma":
[attachment=3722]

If i write:
[attachment=3723]

The calculator says:
[attachment=3724]

As you can see in the second image, no result is returned. Why? Is there a way to solve this or i have to write it in explicit form?


RE: Why solve() is not solving? - ww63 - 07-07-2016 02:34 PM

Maybe, because the Gamma function isn't a function, that can be described analytical. So you can only solve witha numreical algorithm?


RE: Why solve() is not solving? - tiamattia - 07-07-2016 02:39 PM

I tried to use fsolve() with no success. Now i've re-wrote the function using 2*pi*f instead of omega and both solve and fsolve converge to a solution.


RE: Why solve() is not solving? - Tim Wessman - 07-07-2016 04:19 PM

(07-07-2016 01:22 PM)tiamattia Wrote:  I'm trying to solve a complex equation. This is the function i defined "gamma":

Can you show how you defined it? It should work provided your definition is correct.


RE: Why solve() is not solving? - tiamattia - 07-07-2016 05:11 PM

Hello Tim,
I defined it with this cmd:
[attachment=3725]


RE: Why solve() is not solving? - Tim Wessman - 07-07-2016 08:31 PM

Did you just replace omega by 2*pi*f or make any other changes?

Note, you can just copy/paste your text directly from the emulator if you are using that. Makes it easier rather then pictures everyone has to type and hope they didn't make a mistake.


RE: Why solve() is not solving? - tiamattia - 07-07-2016 10:22 PM

Yes, this is what i'm executing:
Code:

Cmd: √(-ω^2*μ*ε*0.00000125664*8.85419e−12+()*ω*μ*σ*0.00000125664)▶gamma(ω,σ,ε,μ)
Result: (ω,σ,ε,μ)->√((-ω²)*μ*ε*0.00000125664*8.85419e−12+()*ω*μ*σ*0.00000125664)
Cmd: gamma(1,1,1,1) 
Result: 7.92666386315e−4+7.92666386322e−4*
Cmd: solve(gamma(x,1,1,1) = 7.92666386315e−4+7.92666386322e−4*())
Result: []
Cmd: fsolve(gamma(x,1,1,1) = 7.92666386315e−4+7.92666386322e−4*(), x = 1)
Result: 4.88592031168e−9+5.90761930892e−7*
As you can see, the result of fsolve is way different from 1.

Cmd: √(-(2*π*f)^2*μ*ε*0.00000125664*8.85419e−12+()*2*π*f*μ*σ*0.00000125664)▶gamma(f,σ,ε​,μ)
Result: (f,σ,ε,μ)->√((-(2*π*f)²)*μ*ε*0.00000125664*8.85419e−12+()*2*π*f*μ*σ*0.00000125664)
Cmd: gamma(1,1,1,1)
Result: 1.98691997624e−3+1.98691997635e−3*
Cmd: solve(gamma(x,1,1,1)=1.98691997624e−3+1.98691997635e−3*)
The emulator crashes after this command. The calc instead solves this. The result is: {0.999999999998+5.53621719455e−11*}
Cmd: fsolve((gamma(x,1,1,1)) = (1.98691997624e−3+1.98691997635e−3*()),x = 1)
The emulator crashes after this command. The calc instead solves this. The result is: 0.999999999998

(I'm using the character sigma (lower case) σ, that is an alias of the character sigma (upper case) ∑ which is the summation function, as a variable. I don't think this is the problem beacuse i'm using it in both situations...)


RE: Why solve() is not solving? - parisse - 07-08-2016 07:28 AM

There is an invalid char in your definition (charcode E003). This makes the equation a symbolic equation depending on this variable (i.e. gamma(x,1,1,1) depends on x and this variable),


RE: Why solve() is not solving? - tiamattia - 07-08-2016 12:01 PM

That's i, the imaginary unit. It is defined it in the private user area of the calc charachter map.


RE: Why solve() is not solving? - roadrunner - 07-08-2016 02:00 PM

Did you type purge(x) before the solve and fsolve commands? The reason I ask is when I can cut and pasted your equations into the emulator I obtained the expected results: {1.00000005156}. When I typed x:=3 first I got empty brackets: [].

-road


RE: Why solve() is not solving? - tiamattia - 07-08-2016 04:56 PM

I tried, still not solving


RE: Why solve() is not solving? - parisse - 07-09-2016 07:58 AM

I checked with the emulator and got 1.0.


RE: Why solve() is not solving? - roadrunner - 07-09-2016 12:48 PM

(07-08-2016 04:56 PM)tiamattia Wrote:  I tried, still not solving

Did you try doing a reset on the emulator? That may be what is needed.

-road


RE: Why solve() is not solving? - tiamattia - 07-09-2016 01:57 PM

No, i haven't tried yet. I will try as soos as I can.