- #1
Volant
- 2
- 0
Write a program in Mathematica that makes a plot of the period of a simple pendulum vs. its amplitude, as the amplitude (the initial angle from which the pendulum is released from rest) ranges from theta = 0 to theta = Pi/2. Use the built-in function NDSolve to solve the exact differential equation of the pendulum, which is theta''=-w^2*Sin(theta) where w=Sqrt(g/L) . Take the acceleration due to gravity g to be 9.80 m/s2 and the pendulum's length L to be 1.00 m. One way to find the period is to locate two successive times when theta(t) = 0 and subtract; the built-in function FindRoot is helpful for finding the zeros of a function.
Next, repeat the calculation without using the built-in function NDSolve, but instead solve the differential equation of the pendulum using Euler's method. In this case you won't even need to use FindRoot to identify the times when theta(t) = 0 since you will be stepping theta(t) along with small time increments (so it will be easy to note when theta(t) is near zero). Make the calculation of period vs. amplitude at 20 or so different amplitudes between theta = 0 to theta = Pi/2 and store the results as a list of points to plot {{theta1, T1}, {theta2, T2}, ...} – you can plot your list of points using the ListPlot function.
Then make one final plot showing the two plots you have made together, so you can see if they agree. The code I used for this is:
Show[plot1, ListPlot[plotlist, PlotMarkers->{Automatic,10}]]
where the instruction about the PlotMarkers makes the points on the ListPlot easy to see.
Next, repeat the calculation without using the built-in function NDSolve, but instead solve the differential equation of the pendulum using Euler's method. In this case you won't even need to use FindRoot to identify the times when theta(t) = 0 since you will be stepping theta(t) along with small time increments (so it will be easy to note when theta(t) is near zero). Make the calculation of period vs. amplitude at 20 or so different amplitudes between theta = 0 to theta = Pi/2 and store the results as a list of points to plot {{theta1, T1}, {theta2, T2}, ...} – you can plot your list of points using the ListPlot function.
Then make one final plot showing the two plots you have made together, so you can see if they agree. The code I used for this is:
Show[plot1, ListPlot[plotlist, PlotMarkers->{Automatic,10}]]
where the instruction about the PlotMarkers makes the points on the ListPlot easy to see.