# Question: find an approximate solution to the pendulum problem such that...

###### Question details

Find an approximate solution to the pendulum problem such that d2 theta /dt2 +g/l theta = 0. Use an approximate solver in matlab to find the solution to the exact equation d2 theta/dt2 +g/l * sin( theta) = 0. Compare the two solutions when the initial angle is 10, 30, and 90. Find a way to quantify the difference.

One approximate method for solving differential equations is Runge-Kutta, which in Matlab goes by the name ode45. I have made a template of how to solve a differential equation in matlab using ode45. Note that these are two separate files: Equations.m (the function that contains the differential equations) and Driving_Script2.m (the script that drives the solver).

Make 3 plots, with each plot showing the exact and approximate solution for each of the three angles. (The command "subplot" will make multiple plots on a single page. You will see that the exact and approximate solution are different. What I want you to do is to quantify how different the solutions are. Also, remember that matlab uses radians...(2*pi/360 * angle).

Template for solving a differential equation using ode45 in matlab:

% Driving_Script2.m (You can change the name)

clear all;

close all;

tspan = [0 10] ; Interval to be solved

y0 = [1.0 0] ; %initial condition here ...the first is angle, the second is velocity

% specify the equations to be solved using the approximate solver within the function Equations.m

[t,y] = ode45('Equations',tspan,y0)

figure(100)

h1=plot(t, y(:,1))

% Equations.m

function dy = Equations(t,y)

g= 9.81, l=2; % Constants here

%

dy = zeros(2,1);

dy(1) = y(2);

dy(2) = -g/l*sin(y(1));

%