python - Solve differential equation with SymPy -
i have following differential equation solve sympy
this differential equation has implicit solution (with h(0) = [0,1) , t = [0, inf) )
but sympy gives
which other packages such maxima able find. sympy unable, however. there way so? code is
import sympy sp sp.init_printing(use_unicode=true) h = sp.symbols('h', function=true) t = sp.symbols('t') eq = sp.eq(sp.derivative(h(t),t), (1 - h(t))**sp.rational(4,3) / h(t)) sp.dsolve(eq)
sympy leaves integral unevaluated because unsure sign of 1-y in integral.
the differential equation has singularity @ h=1, , behavior depends on side of 1 are. there isn't way h(t) < 1, 1 can substitute h(t) = 1 - g(t) g positive function:
g = sp.symbols('g', function=true, positive=true) eq1 = eq.subs(h(t), 1 - g(t)) print(sp.dsolve(eq1))
this returns explicit solution of ode (actually 3 of them, sympy solves cubic equation). first 1 of looks reasonable.
eq(g(t), (-2*(c1 + t)/(sqrt(-8*(c1 + t)**3 + 729) + 27)**(1/3) - (sqrt(-8*(c1 + t)**3 + 729) + 27)**(1/3))**3/27)
Comments
Post a Comment