Ask Your Question

F. Semih Dündar's profile - activity

2023-05-27 03:30:21 +0200 received badge  Notable Question (source)
2022-05-03 12:18:51 +0200 received badge  Popular Question (source)
2020-06-02 07:51:44 +0200 commented answer Solving 2nd order ode with desolve_system_rk4

Thanks for your help and time. It really helped me.

2020-06-02 07:50:40 +0200 received badge  Scholar (source)
2020-06-01 14:51:17 +0200 asked a question Solving 2nd order ode with desolve_system_rk4

Dear All,

I have the following nonlinear ode to solve numerically:

$$\ddot q(t) = -\dot q(t)^2 - q(t)$$.

Since desolve_system_rk4 cannot solve 2nd order ode I make this ode a system of two 1st order odes in the following way:

$$q'(t) = qdot(t)$$ $$qdot'(t) = -qdot(t)^2 - q(t)$$

However desolve_system_rk4 cannot still solve this 2 odes numerically. It raises an error. Any help is appreciated.

Here is the code I wrote:

t = var('t')
q = function('q')(t)
qdot = function('qdot')(t)
# Equations of motion
eom1 = q.diff(t) == qdot(t)
eom2 = qdot.diff(t) == -(qdot(t))^2 - q(t)
# Initial conditions
q0 = 0
qdot0 = 1
sol = desolve_system_rk4([eom1, eom2], [q, qdot], ivar = t , ics = [q0, qdot0])