%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
In an action movie, the hero throws a wrench at the bad guy's helicopter hovering 400m above the ground, causing the helicopter to start losing power. The lift force provided by the helicopter blades now decays with time and is given in newtons by $H(t)= 15 000 exp( -t /100)$, with $t$ in seconds after the wrench hits. The air provides a drag force proportional to velocity of magnitude $Fd = k v$ , where $k$ [in units of kg/s] varies with height above the ground as $197.5 -0.1 y$, where $y$ is the height in m. The mass of the helicopter is 1600 kg, and $g$ = 9.8 m/s$^2$ as usual.
i) Make plots of position vs time and velocity vs time for the helicopter.
ii) How fast is the helicopter falling when it crashes?
To answer this question, implement the 4th Order Runge-Kutta scheme presented in class to solve the ODE resulting from the application of Newton's Second Law. Use a time step of $\Delta t$=0.05 s.
Use the fourth-order Runge-Kutta scheme to solve the following set of coupled ODE's:
$$ \frac{dy}{dt} + 3x = \cos(t) + 5$$$$ \frac{dx}{dt} - 3y = \sin(2t)$$with
$$ y(0) = 3, x(0) = 1 $$from t = 0 to t = 10 using a timestep of 0.1. Plot your solutions for x(t) and y(t).
The exact solution to this first-order system of linear differential equations is given by
\begin{align} x(t) &= 3 \sin(3 t)+3/8 \cos(t)+2/5 \cos(2 t)-173/120 \cos(3 t)+5/3 \\ y(t) &= -1/8\sin(t)-3/5 \sin(2 t)+173/120 \sin(3 t)+3 \cos(3 t) \end{align}Define a Python function for each of these exact solutions.
Repeat the necessary steps from part a) in order to plot the difference between your numerical solution and the exact solution for y(t) when the timestep is decreased by a factor of 10 to $\Delta t=0.01$. Comment on the outcome.