HP Forums

Full Version: fsolve accuracy with complex variables [SOLVED]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The following equation:
|x|^2-200*x+500+500*i = 0 (eq1)

where x is a complex variable, can be solved splitting it into two separate equations, one for the real part and another for the imaginary part. Applying this method, one gets the solution:
197.43587635+2.5*i (sol1)

Substituting sol1 into eq1, gives the exact value 0. Now, I was trying to solve this same equation using the function fsolve:

fsolve(|x|^2-200*x+500+500*i,x,190+i)

The calculator (firmware 8051) returns the value:
197.501663563-2.56405881565*i (sol2)

Trying different initials guesses leads to the same solution. The real parts of sol1 and sol2 are quite close, but not the imaginary parts.

Also: ABS(sol1)-ABS(sol2) = -0.066603127, and ARG(sol1)-ARG(sol2) = 2.56433999704E-2 (in radiants). So, depending on how you look at it, the solution given by fsolve is not so bad.

Does anyone know how to improve the calculator's accuracy?
Have you experimented with Epsilon on page 2 of the CAS settings? I don't know that it would help, but might improve convergence accuracy, albeit with a time cost.

-Dale-
Unfortunately the solver simplified abs(x)^2 to x^2 (fsolve is essentially a real solver), this will happen with non holomorphic functions like re/im/conj/abs.
You can set z:=x+i*y; Z:=abs(z)^2-200*z+500+500*i; then solve([re(Z),im(Z)],[x,y]) for exact and fsolve for approx solutions.
Thank you very much for your answers.

My Epsilon is set to 1e-12. Changing it to different values made no difference.

The solution provided by Parisse works just fine. After the definitions:

z:=x+i*y
eq:=|z|^2-200*z+500+500*i

Both solve and fsolve return the correct solution:

solve([re(eq),im(eq)],[x,y],[190,1]) -> [197.43587635 2.5]

fsolve([re(eq),im(eq)],[x,y],[190,1]) -> [197.43587635 2.5]
Reference URL's