On 28/05/2020 22:13, Rainer Dorsch wrote:
Hello,
when solving a cubic equation
fk: 95.9271531456121*x - 1.7e-18/(x - 6.0e-7)**2
I get a strange result:
[6.10000000000001e-8 - 0.e-30*I, 3.85627081928849e-7 + 0.e-27*I,
7.53372918071151e-7 - 0.e-28*I]
What does the 0.e-30*I mean? I do not think that there should be an
imaginary
part...
Even worse, if I decleare x as real, I do get no solution at all.
In addition to Aaron's comments I would like to point out that if you
have a non-linear equation which is either intrinsically inexact because
one or more of the coefficients is a floating point number (as in this
case) or where the intention is simply to convert the answer as a
floating point number, it is far better to use nsolve in the real domain:
nsolve( 95.9271531456121*x - 1.7e-18/(x - 6.0e-7)**2,x,(-50,50))
The result is generally more accurate, spurious imaginary solutions
don't appear, and the calculation is probably more efficient (only
relevant if the intention is to do a lot of such calculations).
David
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/160545eb-3a37-0385-568b-79f1538f97b6%40dbailey.co.uk.