简体   繁体   中英

Solving nonlinear differential third order equation using Python

I would like to solve a nonlinear third order differential equation using Python.

In my case it is:

d^3f/dx^3 = (1-f)/(f^3)

I wrote the following program, but I have an issue with the solver, so I don't know if the method that I used with scipy is correct.

from sympy.interactive import printing
printing.init_printing(use_latex=True)

from sympy import *
import sympy as sp

x = sp.symbols('x')
f = sp.Function('f')(x)

diffeq = Eq(f.diff(x,x,x),(1-f)/(f**3))
display(diffeq)

dsolve(diffeq,f)

I got this error:

NotImplementedError: solve: Cannot solve -(1 - f(x))/f(x)**3 + Derivative(f(x), (x, 3))

Could you help me please maybe to use a different solving strategy?

Thank you

It is what it is, there is no method implemented to treat this case. It is only a very narrow set of ODE that has a symbolic solution, even small changes in the equation can destroy that character. sympy.dsolve is in only sporadic development and will thus recognize even less cases as for instance Wolfram's Mathematica.

Largely, sympy has methods that can treat, if recognized, scalar linear DE of first order, scalar linear DE with constant coefficients, Bernoulli and Riccati, some first order linear systems (esp. with constant coefficients), even less second order linear systems (again with constant coefficients), a selection of second order linear DE that have a normal form giving special functions as solutions. And possibly some exotics. You can find these in the documentation. Then add on top of that some heuristics to reduce a given equation to one of these cases, which is an even more experimental process.

It is unlikely that you can transform your equation, even manually, into one of these forms, thus the error NotImplementedError: .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM