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.


Here is some reference code

import sympy as sp
sp.init_printing()


k,x=sp.symbols('k,x')
#k,x=sp.symbols('k,x',real=True)

f=k*x - 1.7e-18/(x - 6e-7)**2

x_test=6.1e-8
print("x_test set: ",x_test)
fx=f.subs(x,x_test)
print("fx: ",fx)
k0=sp.solvers.solve(fx,k)[0]
print("k: ",k0)

print("x_test:")
fk=sp.simplify(f.subs(k,k0))
print("fk: ",fk)

p1=sp.plotting.plot(fk,(x,0,1e-7))

x_test=sp.solvers.solve(fk,x)
print(x_test)

and the output

*** example end ***

(sympy) rd@h370-wlan:~$ python3 online2.py
x_test set:  6.1e-08
fx:  6.1e-8*k - 5.85155634188234e-6
/home/rd/virtualenv/sympy/lib/python3.7/site-packages/sympy/__init__.py:676:

SymPyDeprecationWarning:

importing sympy.solvers.solvers with 'from sympy import *' has been
deprecated since SymPy 1.6. Use import sympy.solvers.solvers instead.
See https://github.com/sympy/sympy/issues/18245 for more info.

 deprecated_since_version="1.6").warn()
k:  95.9271531456121
x_test:
fk:  95.9271531456121*x - 1.7e-18/(x - 6.0e-7)**2
2.8e-06 |                                                     ..
| ...
| ...
| ...
| ..
| ...
| ...
| ...
| ..
| ...
-9.5e-0 |-------------------------...---------------------------
| ..
| ...
| ...
| ..
| ...
| ..
| ...
| ...
| ..
-4.7e-0 |_______________________________________________________
        0                          5e-08                      1e-07
[6.10000000000001e-8 - 0.e-30*I, 3.85627081928849e-7 + 0.e-27*I,
7.53372918071151e-7 - 0.e-28*I]
(sympy) rd@h370-wlan:~$

***** Output end *****


Any hint is welcome
Thanks
Rainer

-- 
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/CAHXQ_BJj-dyPUiNZRi0bVSFPK1Cmi-VVnC5sDYc35GjwZg-q2g%40mail.gmail.com.

Reply via email to