0

I have this ordinary differential equation that I need to solve using SymPy.

The equation: (m, g, C, rho, A are arbitrary constants)

I already managed to get a solution out of it using the code below, but the computation takes more than 2 minutes which is too long.

m, x, t, g, C, ρ, A = sp.symbols('m, x, t, g, C, ρ, A', real=True)

x = sp.Function("x")(t)

equation_of_motion = sp.Eq(m*x.diff(t, t), -m*g + (C*ρ*A/2)*(x.diff(t))**2)

sol = sp.dsolve(equation_of_motion, x)
print(sol)

I found that you can give a hint to the function dsolve, telling which solution method you want it to use. But to reduce the computation time, I was wondering if you have a feature that can tell you which hint you should give to the function.

If you want the function to use the 'factorable' method, the last line would look like this.

sol=sp.dsolve(equation_of_motion, x, hint='factorable')

0 Answers0