I want to perform ode with Sympy.
If I start with a simple one, such as, f''(x) = f(x), dsolve
works fine
import sympy as sym
z = sym.symbols('z', real=True)
Phi = sym.Function('Phi')(z)
Phi_ = sym.Derivative(Phi,z)
Phi__ = sym.Derivative(Phi_,z)
Eqn1 = sym.Eq(Phi__, Phi) # f'' = f
sol1 = sym.dsolve(Eqn1) # Find solution
However, I try this ode f''(x) = exp(f(x)) (The solution can be check with Wolfram Alpha.)
Eqn2 = sym.Eq(Phi__, sym.exp(Phi)) # f'' = exp (f)
sol2 = sym.dsolve(Eqn2) # ERROR
I have an error:
NotImplementedError: solve: Cannot solve -exp(Phi(z)) + Derivative(Phi(z), (z, 2))
Is this a limitation of Sympy? Should I use another function?
I don't know what version of SymPy you are using but I'm using 1.9 and I just checked all versions back to 1.2 and this ODE is always solved:
In [1]: import sympy as sym
...:
...: z = sym.symbols('z', real=True)
...: Phi = sym.Function('Phi')(z)
...: Phi_ = sym.Derivative(Phi,z)
...: Phi__ = sym.Derivative(Phi_,z)
...:
...: Eqn1 = sym.Eq(Phi__, Phi) # f'' = f
...:
...: sol1 = sym.dsolve(Eqn1) # Find solution
In [2]: sol1
Out[2]:
-z z
Φ(z) = C₁⋅ℯ + C₂⋅ℯ