Tata
Tata

Reputation: 1

How to solve an equation in Python? Which is the equivalent to ode45 for Matlab?

I'm trying to solve an equation in Python. This is an implicit equation and this is not easy to solve. I think that the Matlab command is ode45, but what is the equivalent for Python? Is there a function that solve easily any kind of equation?

Thank you!!

Upvotes: 0

Views: 451

Answers (1)

David Contreras
David Contreras

Reputation: 236

This is the equivalent to ode45:

scipy.integrate.solve_ivp

The way to use it is almost identical:

from scipy.integrate import solve_ivp
    
vdp1 = lambda T,Y : [Y[1], (1 - Y[0]**2) * Y[1] - Y[0]]

sol = solve_ivp (vdp1, [0, 20], [2, 0])
T = sol.t
Y = sol.y

Upvotes: 2

Related Questions