Using Mathematica to solve 2nd order system of nonlinear ODE's

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 4K views
Mugged
Messages
103
Reaction score
0
Hello, I've started learning how to numerically integrate ODE's and I've run aground when i posed a 2nd order system for mathematica.

Here is my initial code:

NDSolve = [{x'[t] == -y[t] - x[t]^2, y'[t]==x[t], x[0]==1, y[0]==0.5},{x,y},{t,0,30}]

and i get an error message saying the equation becomes stiff at a certain time t. Now I have played around with different integrating methods, switching from stiff integrators to nonstiff ones...but i can't get this to work.

The code above you can probably just cut and paste into your mathematica and see for yourself.

If you know how to fix the problem, can you post the code of how you did it?

Thank you so much
 
Physics news on Phys.org
The two ODE system can be analytically solved. The solution is obtained on a parametric form.
 

Attachments

  • Analytic solution.JPG
    Analytic solution.JPG
    30.5 KB · Views: 657
wow jjacquelin, i attempted to do this recently but couldn't figure it out. you're really good thanks. I am wasnt familiar with the method you used; what class have you taken to learn this?

Also, what do you think if the system has a forcing term? for example:

x'[t] == -y[t] - x[t]^2 + sin[w*t]
y'[t]==x[t]

where sin[w*t] is the forcing term.

Im not asking you to solve this system, but do you think this can be solved analytically?
Thanks
 
what class have you taken to learn this?
Not all is learned in classes... :smile:

x'[t] == -y[t] - x[t]^2 + sin[w*t]
y'[t]==x[t]
where sin[w*t] is the forcing term.
Im not asking you to solve this system, but do you think this can be solved analytically?
It is very doubtfull that it could be.
May be we could find approximative analytical solution in case of
x'[t] == -y[t] - x[t]^2 + a*sin[w*t]
with small coefficient a.