# How to find frequency & period of pendulum in C

1. Dec 12, 2012

### E=F_flat

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:

$\frac{d^{2}θ}{dt^{2}}$ = -$\frac{g}{l}$sinθ

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

$\frac{dθ}{dt}$ = ω

$\frac{dω}{dt}$ = -$\frac{g}{l}$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. Dec 12, 2012

### SteamKing

Staff Emeritus
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.

3. Dec 12, 2012

### E=F_flat

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.

4. Dec 12, 2012

### SteamKing

Staff Emeritus
Your initial value of theta is about 5.7 degrees, which should simulate a pendulum for small amplitudes.

5. Dec 12, 2012

### Staff: Mentor

And when θ is "small", sin(θ) ≈ θ. That approximation will turn your nonlinear system into a linear one.

6. Dec 13, 2012

### E=F_flat

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:
http://webphysics.davidson.edu/alumni/BeKinneman/pendulum/report.htm

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

T = 4$\sqrt{\frac{l}{g}}$$\int^{1}_{0}\frac{1}{\sqrt{ { <1-z^{2}> . [ 1 - (k)^{2}z^{2}] }}}$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?