# Write a 2ndOrderODEProblem

Hi, I am trying to solve the following problem with DifferentialEquations, but when I run my code it does not come out. I don’t know what is wrong, I hope you can help me.

f(x,t)=-2 \ddot{x} + 0.2\dot{x} - 2x + 4

	f(ddx,dx,x,p,t) = 2 * ddx + 0.2 * dx - 2 * x
x_0 = 1
dx_0= 2
time= (0,1)
prob=SecondOrderODEProblem(f,x_0,dx_0,time, 4)
solve(prob, DPRKN6())

You have to use the out-of-place form with scalars:

using OrdinaryDiffEq
f(dx,x,p,t) = (0.2 * dx - 2 * x)/2
x_0 = 1
dx_0= 2
time= (0,1)
prob=SecondOrderODEProblem(f,x_0,dx_0,time, 4)
solve(prob, DPRKN6())

1 Like