How to Find the Period of Oscillation

Using the FindRoot command to find the period of oscillation of a pendulum.

Consider the linearized pendulum equation:

linPendulumEquation = {θ''[
                t] + (g/l) θ[t] == 
            0, θ'[0] == 
            0, θ[0] == θR};

Parameters = {g -> 9.81, 
          l -> 10.0, θR -> 20.0 Degree};

linSolution = 
      NDSolve[linPendulumEquation /. Parameters, θ, {t, 0, 
          10}]

Plot[Evaluate[θ[t] /. linSolution], {t, 0, 10}]

The period of oscillation is the time separating two "identical" events. For example, it is the time separating the points at which the solution crosses the x-axis with equal slope. By observation we see that this happens close to t = 1.5 and t = 7.9 seconds. What we need to do is to find the precise t-coordinate of these events. We accomplish this using the FindRoot command:

?FindRoot

You could also use the Help Browser to obtain details on this command.

root1 = 
      FindRoot[Evaluate[θ[t] == 0 /. linSolution], {t, 
          1.5}]

root2 = 
      FindRoot[Evaluate[θ[t] == 0 /. linSolution], {t, 
          7.9}]

period = (t /. root2) - (t /. root1)