Solve differential equation to describe the motion of simple pendulum

Differential equation is given by

y''[t]==-(g/L)*Sin[y[t]]

where y is the offset angle and t is time. I used the following mathematica code to solve for y

DSolve[{y''[t] ==-(g/L)*Sin[y[t]], y[0]==Pi/2,y'[0]==0},y,t]

and get the following errors

Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. >>
DSolve::bvfail: For some branches of the general solution, unable to solve the conditions. >>

The problem seems to be Sin[y], but I don’t know how to work around this. Thanks for any help.

To my knowledge there is no closed analytical solution to the pendulum problem.
You could try to do it numerically though:

g=9.81
L=0.5
y=.
y=First[y/.NDSolve[{y''[t]==-(g/L)*Sin[y[t]],y[0]==Pi/2,y'[0]==0},y,{t,0,10}]]
Plot[y[t],{t,0,10}]


This does look like a sine function but it isn’t, it becomes especially clear for large exitations:

g=9.81
L=0.5
y=.
y=First[y/.NDSolve[{y''[t]==-(g/L)*Sin[y[t]],y[0]==Pi/2,y'[0]==6.25},y,{t,0,10}]]
Plot[y[t],{t,0,10}]


Hope this helps.

Sander is right, it’s better to go with numerical solution here. Closed analytic form exist in terms of elliptic functions, but the problem is finding constants of integration from initial conditions. This needs solution of a system of nonlinear equations, which is not always possible.

sol = DSolve[y''[t] == -(g/l) Sin[y[t]], y, t];
y /. sol // Column // TraditionalForm

Untitled-5.png

@Julian, if what you need is just a case with small excitation at the equilibrium, you can simply use the y instead of Sin[y]. For small y, the Taylor expansion gives you an approximation at the first order in a small neighbourhood of x=0:

Series[Sin[x], {x, 0, 1}]

Differential equation is given by

y''[t]==-(g/L)*Sin[y[t]]

where y is the offset angle and t is time. I used the following mathematica code to solve for y

DSolve[{y''[t] ==-(g/L)*Sin[y[t]], y[0]==Pi/2,y'[0]==0},y,t]

and get the following errors

Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. >>
DSolve::bvfail: For some branches of the general solution, unable to solve the conditions. >>

The problem seems to be Sin[y], but I don’t know how to work around this. Thanks for any help.

Differential equation is given by

y''[t]==-(g/L)*Sin[y[t]]

where y is the offset angle and t is time. I used the following mathematica code to solve for y

DSolve[{y''[t] ==-(g/L)*Sin[y[t]], y[0]==Pi/2,y'[0]==0},y,t]

and get the following errors

Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. >>
DSolve::bvfail: For some branches of the general solution, unable to solve the conditions. >>

The problem seems to be Sin[y], but I don’t know how to work around this. Thanks for any help.

Thanks guys, you are awesome :slight_smile:

Sander,

I have a two questions regarding both approach and syntax. First, why can’t we obtain a numerical solution to the differential equation by using only the command, ‘NDSolve’ ? Second, what does the syntax below accomplish (i.e., y = .)?

y =.
y = First[ y /. NDSolve[{y’‘[t] == -(g/L)*Sin[y[t]], y[0] ==Pi/2, y’[0] == 0}, y, {t, 0, 10}]]

Best,

-Javier