Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am new to using Mathematica and have a problem at hand: I need to solve $y''(x)+ a \sin(y(x)) = 0$ and plot the output, I need a "manipulate" thingy for the two initial conditions. Help needed.

share|improve this question
    
Have a look at NDSolve in the documentation. –  b.gatessucks Oct 10 '12 at 8:52
    
You wrote the question so fast that seems some dishonest educator is going to catch you. Please take your time and show your effort. –  belisarius Oct 10 '12 at 8:55
    
@belisarius actually yes, my "educator" wants to see the solution in 20 minutes :P –  kernel_panic Oct 10 '12 at 9:05
1  
have you tried anything? eg, asking google? –  acl Oct 10 '12 at 12:21
1  
This equation is easily solved analytically by using y[x] as an independent variable, which reduces it to a first-order equation. By calling y'[x] == f[y], you get y''[x] == 1/2 (d/dy)(f[y]^2),so this becomes a first order in y equation. Once you solve it, you recall what f is and solve for x = x(y), then invert. –  Leonid Shifrin Oct 10 '12 at 13:17
show 2 more comments

closed as too localized by acl, belisarius, cormullion, Leonid Shifrin, rm -rf Oct 10 '12 at 14:55

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

The function you are looking for is NDSolve. I don't think DSolve gives a working answer with the y[x] wrapped inside in the Sin function

For one-off execution, you can use this kind of expression:

finish = 10;
ic1 = 1;
ic2 = 1;
a = 2;
sol = NDSolve[{y''[x] + a Sin[y[x]] == 0, y[0] == ic1, y'[0] == ic2}, y[x], {x, 0, finish}];
Plot[y[x] /. sol, {x, 0, finish}]

plot of differential equation solution

And for a Manipulate type set up hopefully this will help you

a = 3; Manipulate[{sol = 
NDSolve[{y''[x] + a Sin[y[x]] == 0, y[0] == ic1, y'[0] == ic2}, 
 y[x], {x, 0, finish}]; Plot[y[x] /. sol, {x, 0, finish}]}[[1]], {ic1, 1, 3, 0.1}, {ic2, 2, 4, 0.1}]

Manipulate[] interface

share|improve this answer
    
DSolve may not return closed form expressions, but this ODE is the equation of motion for a nonlinear pendulum; the solution involves elliptic functions (Jacobi I think). However, I suspect that if the OP used them, their "educator" might work out that they've had help. –  acl Oct 10 '12 at 12:05
    
@acl, it does require Jacobian elliptic functions to solve the pendulum's DE, but I am told most of the kids these days have absolutely no clue about them... –  J. M. Oct 10 '12 at 12:50
    
@J.M. You know, Sin[t] == t ... or else –  belisarius Oct 10 '12 at 12:58
    
@bel, I guess that's why most people don't want their pendulums to be swinging at too wide an angle... ;P –  J. M. Oct 10 '12 at 13:00
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.