1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: How to find frequency & period of pendulum in C

  1. Dec 12, 2012 #1
    1. The problem statement

    Hi everyone, I'm currently working on an assignment that involves modelling a non-linear pendulum in C. I have to investigate the dynamics of a simple non-linear pendulum all the way up to a chaotic damped, driven situation. However, I'm completely baffled as to how to find the frequency of oscillation and period through my simulation (for large amplitudes). Do I simply use a counting method which involves storing the times at which the pendulum angle (or angular velocity) change sign, or is there some other more efficient method? I'm not asking for code, I just want some guidance as to what course of action to take.

    2. Relevant equations

    For the moment, I'm modelling the simple non-linear pendulum with equation:

    [itex]\frac{d^{2}θ}{dt^{2}}[/itex] = -[itex]\frac{g}{l}[/itex]sinθ

    My Runge-Kutta code is based on the following equations:

    [itex]\frac{dθ}{dt}[/itex] = ω

    [itex]\frac{dω}{dt}[/itex] = -[itex]\frac{g}{l}[/itex]sinθ

    ω = angular velocity
    g = acceleration due to gravity
    l = length of pendulum
    θ = angle of pendulum in relation to the vertical
    Last edited: Dec 12, 2012
  2. jcsd
  3. Dec 12, 2012 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    What initial conditions are you using for your RK method?

    The period of oscillation would be the interval from when the pendulum starts at its initial deflection theta and returns to the same angle.
  4. Dec 12, 2012 #3
    For my RK method I initialised the variables as follows:

    θ = 0.1
    ω = 0
    dt = 0.04 (time step)

    However, I have to investigate the dynamics of the pendulum at progressively larger amplitudes.
  5. Dec 12, 2012 #4


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    Your initial value of theta is about 5.7 degrees, which should simulate a pendulum for small amplitudes.
  6. Dec 12, 2012 #5


    Staff: Mentor

    And when θ is "small", sin(θ) ≈ θ. That approximation will turn your nonlinear system into a linear one.
  7. Dec 13, 2012 #6
    Thanks for responding. I only entered those initial values to test that my RK method was working. However, I will have to enter large values of θ, and the small amplitude approximation will no longer be accurate.

    I happened to come across the following website:

    This report derives the following equation for period of a non-linear pendulum with unrestricted amplitudes:

    T = 4[itex]\sqrt{\frac{l}{g}}[/itex][itex]\int^{1}_{0}\frac{1}{\sqrt{ { <1-z^{2}> . [ 1 - (k)^{2}z^{2}] }}}[/itex]dz

    I was thinking of adapting this formula into my C-program. You can't perform integrals on C, so I would have to perform a summation between max amplitude and zero amplitude. Am I on the right lines, or am I talking complete rubbish?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook