---
title: "Chapter 1: Why study differential equations? Section 1.1: The 2008 Olympic 100 meter dash"
author: "Dr. Paul Pearson"
date: "Fall 2024"
#output: html_document
output: slidy_presentation
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, comment = "")
library(ggplot2)
library(BrailleR)
```

# Section 1.1: The 2008 Olympic 100-Meter Dash

## Usain Bolt's record setting 100 meter dash

[Watch this Usain Bolt video](https://www.youtube.com/watch?v=F14EaVEDyUs)

Here are Usain Bolt's split times for the 2008 Olympic finals in the 100 meter dash:

```{r, echo=FALSE}
usain <- data.frame(
  position_meters = seq(from = 0, to = 100, by = 10),
  time_seconds = c(0.165, 1.85, 2.87, 3.78, 4.65, 5.50, 6.32, 7.14, 7.96, 8.79, 9.69)
)
print(usain, row.names = FALSE)
```

```{r, include=FALSE}
# Write the data to a text file for students to plug into the applets
write.table(usain, 
            "1-1-Usain-Bolt-2008-Olympics-100m-final-data.txt", 
            col.names = c("position_meters","time_seconds"), 
            sep = "\n", 
            dec = ".", 
            row.names = FALSE, 
            append = FALSE
            )
```



## Modeling

Our goals:

1. Develop a mathematical model for sprinting:
    - a quantitative description that explains the data
    - based on accepted physics, mathematics, and reasonable assumptions
2. Test or validate this model:
    - use the model to make predictions
    - determine conditions for which the model is accurate
    
## Explore the data

1. Does the graph below go through $(0,0)$? Should it go through $(0,0)$? Why or why not? What is Usain Bolt's position between time $0$ and time $0.165$ seconds?
2. Over what time intervals is Usain Bolt accelerating? Decelerating? Neither of these?

```{r, echo=FALSE, fig.cap="This line chart has title 'Usain Bolt Split Times'.  Line 1 is increasing. Split times are marked by dots on the line."}
# time series plot
ts <- ggplot(usain, aes(time_seconds, position_meters)) +
  geom_point(size = 4) + geom_line(linewidth = 2) +
  ggtitle("Usain Bolt Split Times") +
  xlab("Time in seconds") + ylab("Position in meters") +
  theme_bw(base_size = 18)

ts # generates both graph and VI(ts) automatically
```

```{r, include=FALSE, fig.cap="Chart of Super Bowl National Anthem Length with x-axis year and y-axis song length in seconds"}
MakeAccessibleSVG.ggplot(ts,
                         file = "1-1-Usain-Bolt-split-times-time-series")
```

[Link to a screen reader accessible plot of Super Bowl Song Length Time Series](1-1-Usain-Bolt-split-times-time-series.html)

## Develop a model

1. Use calculus to express the sprinter's acceleration $a(t)$ in terms of velocity $v(t)$.
2. List in plain English all of the horizontal forces you can think of that might be relevant to the sprinter's progress down the track. Which forces help progress down the track? Which forces impede progress?

## Develop a model

Let's suppose:
    - That the net force $F$ on the runner is the sum of a propulsive force $F_p$ that helps the runner and a resistive force $F_r$ that impedes the runner.  
    - That $F_p$ depends on the runner's level of exertion and is at a constant and maximum value throughout the race.
    - That this maximum propulsive force is proportional to the mass of the runner (so, for example, a runner who is twice as massive can exert twice the propulsive force).

Under these assumptions, $F_p = m P$, where $P$ is some constant that depends on the runner's maximum propulsive effort.

3.1. Given that $F_p$ is a force and $m$ is a mass, argue that $P$ should have units of acceleration.

3.2. Suppose the runner is standing still, with no forces acting on the runner, who suddenly applies maximum propulsive effort according to $F_p = mP$.  Given that also $F = ma$, what physical interpretation can you give to $P$ at this instant?

The quantity $P$ for world class sprinters like Usain Bolt is approximately $11.0$ meters per second squared.

## Develop a model

The resistive force $F_r$ opposes the runner's motion. In our model, we will assume:
    - That the internal "friction" of joints and muscles that impedes rapid motion is predominant, and external forces such as wind resistance are not predominant.
    - That the resistive force is proportional to both the runner's velocity $v$ and mass $m$.

4.1. Explain why $F_r = -k m v(t)$ is a simple model that captures all of these assumptions, where $k > 0$.

4.2. The total force on the runner is $F = F_p + F_r$. Combine equations $F_p = mP$ and $F_r = -kmv(t)$ and $F = ma$ with the result $a(t) = v'(t)$ to show that the function $v(t)$ must satisfy $$v'(t) = P - kv(t).$$  Explain why $m$ can be canceled.

This is an example of an ordinary differential equation.

## Solutions to the ODE

5. Based on your intuition, sketch a graph of what $v(t)$ would look like over the course of a race that lasts about $10$ seconds. Hint: Be careful at the start.
6. Verify that each of the following choices for $v(t)$ is a solution to $v'(t) = P - kv(t)$.
    1. $v(t) = P/k$
    2. $v(t) = P/k - Pe^{-kt}/k$
    3. $v(t) = P/k - Ce^{-kt}$, where $C$ is any constant.
    
Note: 6.3 is called the general solution to the ODE.

## Solutions to the IVP

7. What piece of information is missing in the original data table (given below)?  What is $v(0.165)$?
8. You might be tempted to write $v(0)=0$ for the initial condition. Is the equation $v'(t) = P - kv(t)$ equation valid for all $t \geq 0$? Hint: What is the value of $P$ in $F_p = mP$ for $0 \leq t \leq 0.165$ seconds?

```{r}
print(usain, row.names = FALSE)
```

## Reflections

9. List all of the assumptions that we made when we developed our model $v'(t) = P - kv(t)$. Are these assumptions grounded in physics and are they reasonable?