Elementary Numerical Methods and Programming
This project involes determining the dynamics of the double pendulum with a sliding base (see figure above). Each link is assumed to be of square cross section.
Write a MATLAB program that solves for y¯ over the interval t = 0 s to t = 4 s using three different methods: the Euler method, the mid-point method (2nd Order Runge- Kutta), and the classical 4th Order Runge-Kutta method.
To evaluate the effect of your step size (h) on the results for each of the three methods, use the following six values of h (units of seconds): 0.02, 0.01, 0.005, 0.0025, 0.00125, and 0.000625. For step sizes 0.01s and smaller, calculate the approximate percent relative error in θ1 at t = 4s between the current step size and the next largest step size.
Turn in a report that contains the following:
1. Title page, including the title of the project and your name
2. Introduction and objectives section:
- Summarize the problem and state the goals, including what you are trying to find, the ranges of values of t and h to be used, etc.
3. Program design section
- Describe the overall structure of your program
- If you used any portions of code from another source (for example, a textbook), cite the source and describe any modifications you made to the code.
- Describe how you solved for
θ¨1
and
θ¨2
in the system of equations
(backslash operator, inv(A), or others)
- Describe how you solved for y using the specified values of h
4. Plots. Your report must contain the following five figures with titles, properly labeled axes, and legends where appropriate:
- Figure 1: On a single graph, plot the approximate percent relative error in
θ1 at t = 4 s vs. step size h for the three different methods.
- Figure 2: θ1 vs. t using the largest value of h (0.02 s)
- Figure 3: θ2 vs. t using the largest value of h (0.02 s)
- Figure 4: θ1 vs. t using the smallest value of h (0.000625 s)
- Figure 5: θ2 vs. t using the smallest value of h (0.000625 s)
5. Discussion and Conclusions
- Based on Figure 1, what can you learn about the effects of h on the results obtained with the three different methods?
- What can you learn by comparing Figure 2 to Figure 4?
- What can you learn by comparing Figure 3 to Figure 5?
- If you had to design this system, which differential equation solution method would you use and why?
6. A printout of your code