From the textbook:
12.1, 12.2, 12.4, 12.7
Computational exercises. Turn in a copy of your code for all questions along with their output.
1: The initial value problem has solution , so . Write a code in Python
to determine how many steps (with stepsize ) are required to recover Euler's number
accurate to at least five decimal places using the Forward Euler method.
2: Answer the question above using the improved Euler method.
3: Answer the question above using the fourth-order Runge-Kutta method (RK4).
4. A soccer ball has a radius of about . Imagine that the ball is kicked with initial
angle from the ground with initial speed (a reasonable speed for a kicked soccer ball).
The equations of motion for the ball's position, and velocity
(assuming a somewhat simplistic model of the fluid mechanics) are:
where . Here is the gravitational acceleration constant, and
is a constant which involves the drag coefficient for a sphere, the density of air, the ball's radius, and the
ball's mass.
Compute an approximate solution to this system using RK4. Writing the system as
where , you can use the same code as in question (3) above.
(a) As a check on your code, carry out simulations to and compute the ratio: , where
is , computed using steps. (What do you expect to find for this ratio?)
(b) Enter a line into your code that ends the simulation if y(t)<0. Use the 'break' command to exit a loop.
(c) Plot the trajectory of the ball using timesteps of size .
(d) Plot the trajectory of the ball again on the same graph as in (c), but now with no air drag ( ). This time
use a dashed line.
(e) For both (c) and (d) report the maximum value of height attained in the simulation, and the total horizontal
distance travelled before the ball hits the ground (include units and make sure your answer is physically
realistic).
(f) We didn't include the lift force ("Magnus force") associated with rotation. Check these out