fsolve accuracy with complex variables [SOLVED]
|
02-07-2016, 11:25 AM
(This post was last modified: 02-04-2018 10:10 AM by JMB.)
Post: #1
|
|||
|
|||
fsolve accuracy with complex variables [SOLVED]
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? |
|||
02-07-2016, 02:12 PM
(This post was last modified: 02-07-2016 03:27 PM by DrD.)
Post: #2
|
|||
|
|||
RE: fsolve accuracy with complex variables
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- |
|||
02-07-2016, 02:42 PM
Post: #3
|
|||
|
|||
RE: fsolve accuracy with complex variables
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. |
|||
02-07-2016, 03:28 PM
(This post was last modified: 02-07-2016 06:59 PM by JMB.)
Post: #4
|
|||
|
|||
RE: fsolve accuracy with complex variables
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] |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)