Implement a fourth-order Runge-Kutta method that integrates the system
y^(˙)=f(y)from
t=0to
t=100with stepsize
h=0.05. Use the four initial conditions described in the table below. You can use the pendplot function to animate the motion of the pendulum, which might be fun and might help you debug your code. But you do not need to include these plots in your report. For each case, plot the function
\theta _(2)(t)versus time. Cases 3 and 4 demonstrate the initial value sensitivity of the system, namely, that a small perturbation can lead to drastically different solutions. Your report should contain the MATLAB commands required to produce the results, and the four plots of
\theta _(2)(t). Run Case 1 in problem
,with the five stepsizes
h=(0.05)/(2^((k-1))),k=1,2,3,4, and
h=0.001. Compute the value of
\theta _(2)(t=100)for each stepsize. Consider the last result the exact solution, and plot the four errors as a function of
hin a loglog-plot. Estimate the order of convergence from the slope. Your report should contain the MATLAB commands used, the five values of
\theta _(2)(t=100), the loglog-plot, and the estimated slope.