5

I'm new to Julia programming I managed to solve some 1st order ODE, but when I thought to move to the second order I don't know how to use the solver to implement to the required equation.

I want to solve this equation

y" + y = 0

with initial conditions

y(0) = 3
y'(0) = -0.5

How can I do this?

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

4

change it to y'' = -y and then use SecondOrderODEProblem, i.e. https://diffeq.sciml.ai/stable/types/dynamical_types/, via:

SecondOrderODEProblem((v,u,p,t)->-u,-0.5,3.0,(0.0,1.0))

For more examples of this, see the Classical Physics Problems tutorial:

https://tutorials.sciml.ai/html/models/01-classical_physics.html

Chris Rackauckas
  • 18,645
  • 3
  • 50
  • 81