Skip to main content
Ctrl+K
An Introduction to Python Jupyter Notebooks for College Math Teachers - Home
  • An Introduction to Python Jupyter Notebooks for College Math Teachers
  • 1. PREFACE
    • 1.1. JMM 2023
    • 1.2. JNB LAB: Patterns
    • 1.3. JNB Lab Solutions
  • 2. PRE-COLLEGE - Wheaton College Team
    • 2.1. Introduction
    • 2.2. Elementary Blackboard Problems
    • 2.3. Beginning Python Programming
    • 2.4. Glimpse of Chicago
    • 2.5. Arts in STEM (STEAM)
    • 2.6. Solution to Exercises
    • 2.7. JNB LAB: After-School Program Demo
    • 2.8. JNB Lab Solutions
  • 3. PYTHON PROGRAMMING GUIDE - Thomas VanDrunen, Yiheng Liang
    • 3.1. Introduction
    • 3.2. Introduction to Python
    • 3.3. Working with Data
    • 3.4. Solution to Exercises
    • 3.5. JNB Lab: Introduction to Python
    • 3.6. JNB Lab Solutions
  • 4. EXPLORATORY DATA ANALYSIS - Jonathan Zhu
    • 4.1. Introduction to Part I
    • 4.2. Data Investigation I
    • 4.3. Plotting and Statistical Testing I
    • 4.4. Solutions to Part I Exercises
    • 4.5. Introduction to Part II
    • 4.6. Data Investigation II
    • 4.7. Plotting and Statistical Testing II
    • 4.8. Making EDA Reports
    • 4.9. Solutions to Part II Exercises
    • 4.10. JNB Lab: Housing Equity Initiative
    • 4.11. JNB Lab Solutions
  • 5. PROBABILITY - Laura Gross, Yiheng Liang
    • 5.1. Introduction
    • 5.2. Random Numbers
    • 5.3. Probability
    • 5.4. Conditional Probability
    • 5.5. Probability Distributions
    • 5.6. Random Walks
    • 5.7. Agent-based Models
    • 5.8. Mathematical Games
    • 5.9. Solution to Exercises
    • 5.10. JNB Lab: Homicides in Chicago
    • 5.11. JNB Lab Solutions
  • 6. STATISTICAL INFERENCE - Peter Jantsch, Claire Wagner
    • 6.1. Introduction
    • 6.2. Foundations of Statistical Inference
    • 6.3. Hypothesis Testing for Categorical Data
    • 6.4. Hypothesis Testing for Numerical Data
    • 6.5. Linear Regression
    • 6.6. Solutions to Exercises
    • 6.7. JNB Lab: The Framingham Heart Study
    • 6.8. JNB Lab Solutions
  • 7. APPLIED CALCULUS FOR DAILY LIFE - Wheaton College Team
    • 7.1. Introduction
    • 7.2. Linear Systems and the Two-commodity Model
    • 7.3. Marginal and Average Cost
    • 7.4. Optimization and Object Design
    • 7.5. Optimization and Cobbs-Douglas Production
    • 7.6. Related Rates and Volumes
    • 7.7. Related Rates with Trig Functions and Football
    • 7.8. Probability Distributions and Drive Thrus
    • 7.9. Normal Distribution and Process Control
    • 7.10. Partial Derivatives and OLS Regression
    • 7.11. Area Between Curves and the Gini Index
    • 7.12. Integral Test and Income Streams
    • 7.13. Ordinary Differential Equations and Exponential Growth/Decay
    • 7.14. Solutions to Exercises
    • 7.15. JNB Lab: Calculus of Entropy in Daily Life and Monte Carlo Simulations
    • 7.16. JNB Lab Solutions
  • 8. CALCULUS - Inne Singgih
    • 8.1. Introduction
    • 8.2. Functions
    • 8.3. Limits, Continuity, and Rates
    • 8.4. Derivatives
    • 8.5. Integrals
    • 8.6. Parametric Equations
    • 8.7. Sequences and Series
    • 8.8. Solution to Exercises
    • 8.9. JNB LAB: Calculus Animations
    • 8.10. JNB Lab Solutions
  • 9. LINEAR ALGEBRA - Soheil Anbouhi
    • 9.1. Introduction
    • 9.2. Linear Systems
    • 9.3. Matrices and Determinants
    • 9.4. Linear Transformations
    • 9.5. Eigenvalues and Eigenvectors
    • 9.6. Orthogonality
    • 9.7. Solutions to Exercises
    • 9.8. JNB Lab: Linear Algebra
    • 9.9. JNB Lab Solutions
  • 10. LINEAR ALGEBRA AND OPTIMIZATION FOR DATA ANALYSIS - Wheaton College Team
    • 10.1. Introduction
    • 10.2. OLS Linear Regression
    • 10.3. K-means Clustering
    • 10.4. Dimension Reduction by Principal Component Analysis
    • 10.5. Binary Classification of Labeled Data by Support Vector Machines
    • 10.6. Solution to Exercises
    • 10.7. JNB LAB: Linear Algebra for Data Analysis
    • 10.8. JNB Lab Solutions
  • 11. DIFFERENTIAL EQUATIONS - Rachel Petrik
    • 11.1. Overview of Chapter
    • 11.2. Introduction to Differential Equations
    • 11.3. First-Order Differential Equations
    • 11.4. Second-Order Differential Equations
    • 11.5. Systems of First-Order Differential Equations
    • 11.6. Laplace Transforms
    • 11.7. Solutions to Exercises
    • 11.8. JNB Lab: Differential Equations
    • 11.9. JNB Lab Solutions
  • 12. DIFFERENTIAL EQUATIONS FOR THE BENEFIT OF SOCIETY - Wheaton College Team
    • 12.1. Introduction
    • 12.2. Logistic Growth and COVID-19
    • 12.3. The Basic SIR Model
    • 12.4. Cholera in Haiti
    • 12.5. CWS Model of Alzheimer’s Disease
    • 12.6. Gravity Fed Water Delivery
    • 12.7. Earthquake Resistant Construction
    • 12.8. Solutions to Exercises
    • 12.9. JNB Lab: HIV-AIDS
    • 12.10. JNB Lab Solutions
  • 13. COMPLEX VARIABLES IN GROUNDWATER MODELING - Wheaton College Team
    • 13.1. Setting the Scene
    • 13.2. Complex Analysis Background
    • 13.3. Idealized Groundwater Flow
    • 13.4. Contaminant Extraction Modeling
    • 13.5. Solutions to Exercises
    • 13.6. JNB LAB: Complex Potentials and Contaminant Flow
    • 13.7. JNB Lab Solutions
  • 14. ADVANCED DATA ANALYSIS - Jonathan Zhu, Claire Wagner, Ying Li
    • 14.1. Introduction
    • 14.2. Preprocessing
    • 14.3. About Text Data
    • 14.4. Document Embedding
    • 14.5. Classification of Texts
    • 14.6. Evaluating Classification
    • 14.7. Applications
    • 14.8. Solutions to Exercises: Sections 1 to 4
    • 14.9. Solutions to Exercises: Sections 5 to 7
    • 14.10. JNB Lab: United States Grant Data
    • 14.11. JNB Lab Solutions
  • 15. COMPLEX SYSTEMS - Wheaton College Team
    • 15.1. Introduction
    • 15.2. Fundamental Concepts
    • 15.3. Mathematical Concepts from Equilibrium Statistical Physics
    • 15.4. Societal Applications
    • 15.5. Solution to Exercises
    • 15.6. JNB LAB: Complex Systems
    • 15.7. JNB Lab Solutions
  • Index
  • Binder logo Binder
  • Repository
  • Open issue
  • .ipynb

Related Rates with Trig Functions and Football

Contents

  • 7.7.1. Definition of Trig Functions
  • 7.7.2. Derivatives of basic trig functions
    • Example
  • 7.7.3. Radian Measure
    • Example
  • 7.7.4. Python trig functions
    • Example
    • Questions
  • 7.7.5. Exercises

7.7. Related Rates with Trig Functions and Football#

In this lab, we will solve a related rates problem which involves the use of trig functions. In particular, we will determine how fast a camera is rotating as it tracks a football player speeding along the sideline to the endzone.

../../_images/Football_Animation.gif

The following code creates the animation, Football_Animation.gif. If you execute the code, you can open and view the .gif file.

Show code cell source Hide code cell source
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.path import Path
import matplotlib.animation as animation
from matplotlib.animation import FuncAnimation
%matplotlib notebook
%matplotlib inline
from matplotlib.markers import MarkerStyle
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
from matplotlib.transforms import Affine2D
import matplotlib.patches as patches
from matplotlib.patches import Rectangle

frames=9
for n in range(frames):

#green background
    verts = [(-20, -20),  # left, bottom
         (-20, 100),  # left, top
         (100, 100),  # right, top
         (100, -20),  # right, bottom
         (0., 0.),  # ignored
        ]
    codes = [Path.MOVETO,Path.LINETO,Path.LINETO,Path.LINETO,Path.CLOSEPOLY,]

    path = Path(verts, codes)
    patch = patches.PathPatch(path, facecolor='green', lw=.1, edgecolor='w')
    fig, ax = plt.subplots()
    ax.add_patch(patch)
    ax.set_xlim(-2, 10)
    ax.set_ylim(-2, 10)
    
#endzone
    plt.gca().add_patch(Rectangle((7.88,-20),50,20.04, edgecolor='w', facecolor=(.0,.1,.4), lw=4))

#side line
    plt.gca().add_patch(Rectangle((6.8,-20),70,200, edgecolor='w', facecolor='none', lw=70))

#Yard Marks
    yards= [0,1,2,3,4,5,6,7,8,9,10]
    for i in range(len(yards)):
        plt.gca().add_patch(Rectangle((8.1,i),.5,.1, edgecolor='w', facecolor='w', lw=1))
#5 & 10
    plt.gca().add_patch(Rectangle((8.1,5),50,.1, edgecolor='w', facecolor='w', lw=1))
    plt.gca().add_patch(Rectangle((8.1,10),50,.1, edgecolor='w', facecolor='w', lw=1))

#Adjacent line to camera
    plt.gca().add_patch(Rectangle((0.3,-0.1),7.68,.1, edgecolor='none', facecolor='yellow', lw=1))

#Tracking line
    x = np.linspace(0, 8, 100)
    f = lambda x : ((8-n)/8)*x
    y=f(x)
    plt.plot(x,((8-n)/8)*x,'--y')

#Bob Hayes
    import matplotlib as mpl
    from svgpath2mpl import parse_path
    from svgpathtools import svg2paths
    player_path, attributes = svg2paths('bullet_bob.svg')
    player_marker = parse_path(attributes[0]['d'])
    player_marker.vertices -= player_marker.vertices.mean(axis=0)
    x=7.8
    y=8.8-(n)
    plt.plot(x,y, marker=player_marker, markersize=35,color= 'b')
    
#Camera
    camera_path, attributes = svg2paths('camera.svg')
    camera_marker = parse_path(attributes[0]['d'])
    camera_marker.vertices -= camera_marker.vertices.mean(axis=0)
    camera_marker = camera_marker.transformed(mpl.transforms.Affine2D().rotate_deg(45-(5*n)))
    camera_marker = camera_marker.transformed(mpl.transforms.Affine2D().scale(.1,.1))
    x = -0.01
    y = 0.15
    plt.plot(x,y,marker=camera_marker,markersize=30,color = 'k')

#Annotations
    ax.annotate('Camera',
                xy=(0, 1), xycoords='data',
                xytext=(0, -35), textcoords='offset points', color='white')
#Legend
    plt.xlabel('Distance from camera (yds)')
    plt.ylabel('Distance from endzone (yds)')
    plt.title('"Bullet" Bob Hayes Returning a Kick')

#Save each frame as a .png
    plt.savefig(str(n)+'.png')
    plt.close()

#Save as a GIF
from PIL import Image
images = []
for n in range(frames):
    exec('a'+str(n)+'=Image.open("'+str(n)+'.png")')
    images.append(eval('a'+str(n)))
images[0].save('Football_Animation.gif',
               save_all=True,
               append_images=images[1:],
               duration=400,
               loop=0)

Now the idea of the scenario is how we can use calculus to solve the problem of how fast the camera must rotate to stay pointed at the player. To begin, we need to review some basic info about trig functions.

7.7.1. Definition of Trig Functions#

The acronym SOH-CAH-TOA is helpful to remember the definitions of the three basic trig functions sine, cosine, and tangent as ratios of sides of a right triangle:

\[\sin(\theta)=\frac{opposite}{hypotenuse}\]
\[\cos(\theta)=\frac{adjacent}{hypotenuse} \]
\[\tan(\theta)= \frac{opposite}{adjacent} \]

7.7.2. Derivatives of basic trig functions#

The basic derivative formulas are

\[ \frac{d}{d\theta} \sin(\theta)=\cos(\theta) \]
\[\frac{d}{d\theta} \cos(\theta)=-\sin(\theta) \]
\[ \frac{d}{d\theta} \tan(\theta)=\sec^2(\theta)=\frac{1}{\cos^2(\theta)} \]

In our application problem, we will assume that the angle \(\theta\) is changing with time \(t\). In this case, the derivatives with respect to time \(t\) are given by

\[\frac{d}{dt}\sin(\theta(t))=\cos(\theta)\frac{d\theta}{dt}\]
\[\frac{d}{dt}\cos(\theta(t))=-\sin(\theta)\frac{d\theta}{dt}\]
\[\frac{d}{dt}\tan(\theta(t))=\sec^2(\theta)\frac{d\theta}{dt}=\frac{d\theta/dt}{\cos^2(\theta)} \]

Example#

Find \(\frac{d}{dt}\) of \(\tan\)(\(t^2\)). (Hint: In this case, \(\theta(t)=t^2\))

Answer: \(\sec^2(t^2)2t\) or \(\frac{2t}{\cos^2(t^2)}\)

Explanation:

It’s been given that the derivative \(d/dt\) of \(\tan\)(\(\theta(t)\)) is \(\sec^2(\theta)\frac{d\theta}{dt}\) . Therefore, since \(d\theta/dt\) is \(2t\), multiplying by \(\sec^2(\theta)\) gives \(\sec^2(t^2)2t\) or equivalently, \(\frac{2t}{\cos^2(t^2)}\).

7.7.3. Radian Measure#

The above formulas for the derivatives of \(\sin(\theta)\), \(\cos(\theta))\) and \(\tan(\theta)\) all assume that the angle \(\theta\) is measured in radians.

Conversion between radians and degrees is possible if we remember that \(\pi\) radians = 180 degrees or \(2\pi\) radians = 360 degrees.

Example#

Convert \(\frac{5}{6}\) radians to degrees

Answer: \(\frac{5}{6}\) \(radians\) x \(\frac{180 \, degrees}{\pi \, radians}\) = \(\frac{150}{\pi}\) degrees

Explanation:

It’s been given that \(\pi\) radians = 180 degrees so \(\frac{180 \, degrees}{\pi \, radians} = 1\). We can complete the conversion using cross cancellation method.

7.7.4. Python trig functions#

from math import pi, sin, cos, tan, asin, acos, atan, radians, degrees

You can use these imported python functions to do calculations within the notebook. For correct syntax, code as follows:

sin(pi/4)
0.7071067811865475

To convert from radians to degrees, simply type degrees(radian value). This will give you the corresponding degree value:

degrees(pi)
180.0

Furthermore, by default Python assumes the input angle measure is in radians. You can convert the final answer to degrees as such:

degrees(atan(1)) 
45.0

Note that the above example asks for the degree conversion of the radian value of the arctangent of a right triangle with congruent sides (8/8, 6/6, and so on).

Example#

Bob Hayes won the 100 meter dash at the Tokyo ‘64 Olympics equaling the world record of 10.0 seconds. Hayes went on to be a star wide receiver with the Dallas Cowboys.

Suppose a TV camera is positioned on the goal line and 8 yards from the sideline. The camera stays fixed on Hayes, who is currently on the 8 yard line and sprinting towards the end zone at 10 yards per second.

Answer the questions below to determine how fast the camera is turning (in degrees per second).

  1. From the Figure below , give an equation for \(y\) in terms of \(\theta\).

../../_images/football.png

Answer: \(y(t) = 8 \tan(\theta(t)\))

Explanation:

We know that \(\tan(\theta)= \frac{opposite}{adjacent} \).

In our case, the opposite side is \(y\) and adjacent side is 8, so \(\tan\)(\(\theta\)) = \(\frac{y}{8}\).

To convert to \(y(t)\), we multiply on both sides and get \(y(t)\) = \(8\) \(\tan\)(\(\theta\))

2a) What is the physical meaning of \(\frac{dy}{dt}\) ?

Answer: The physical meaning of \(\frac{dy}{dt}\) is the speed of Bob Hayes as he is running towards the end line from the side line measured in yds/sec. A negative value indicates he is getting closer to the goal line.

2b) What is the physical meaning of \(\frac{d\theta}{dt}\) ?

Answer: The physical meaning of \(\frac{d\theta}{/dt}\) is how fast the camera angle is turning as it keeps pointing at Hayes as he runs towards the goal line. A negative value indicates clockwise rotation.

  1. If \(\theta\) is measured in radians, then \(\frac{d}{dt} \tan(\theta(t)) = \frac{1}{\cos^2\theta} \frac{d\theta}{dt}\). Use your answer to problem 1 to find a general relationship between \(\frac{dy}{dt}\) and \(\frac{d\theta}{dt}\).

Answer: If \(y = 8\tan(\theta)\), then \(dy/dt = 8\frac{ d\theta/dt}{\cos^2(\theta)}\)

Explanation:

We learn that the derivative of \(tan(\theta) = \frac{1}{\cos^2\theta}\) .

Using chain rule, we deduce that the derivative of \(tan(\theta(t))= \frac{1}{\cos^2\theta}\frac{d\theta}{dt}\) .

Thus, \(\frac{dy}{dt}\), using the equation in question one in which \(y(t) = 8\tan(\theta(t))\), equals \(8 \frac{d(\theta)/dt} {\cos^2(\theta)}\)

  1. Find \(\frac{d\theta}{dt}\) (in radians per second) at the instant when \(y=8.\) (Hint: \(\cos(\theta)=\frac{adjacent}{hypotenuse}\)).

Answer: \(-\)\(\frac{5}{8}\)

Explanation:

\[ y(t) = 8 \tan(\theta(t)) \Rightarrow \tan(\theta(t)) = \frac{y(t)}{8}. \]

Since \(y(t) = 8\), then \(\tan(\theta(t)) = 1\), which means \(\theta(t)\) is \(\frac{\pi}{4}\) radians .

The formula

\[ \frac{dy}{dt} = \frac{\frac{d\theta}{dt}}{\cos^2(\theta)} \]

implies that

\[ \frac{d\theta}{dt} = \frac{\cos^2(\theta)\frac{dy}{dt}}{8}. \]

We can substitute \(\theta\) with \(\frac{\pi}{4}\) and \(\frac{dy}{dt}\) with -10.

Then we get:

\[ -\frac{10 \cos^2 (\frac{\pi}{4})}{8} = - \frac{5}{4}\cos^2(\frac{\pi}{4}) = - \frac{5}{4} (\frac{\sqrt 2}{2})^2 = - \frac{5}{4} * \frac{1}{2} = -\frac{5}{8}. \]
  1. Use the fact that 1 radian = \((\frac{180}{\pi})^o\) to express your answer to problem 4 in degrees per second.

Answer: \(-\)\(\frac{225}{2\pi}\) degrees per second or around 35.8 degrees per second.

Explanation:

Multiply \(-\frac{5}{8}\frac{ radians}{ second}\) by \(\frac{180 \, degrees}{\pi \, radians} = \frac{225 \, degrees}{2\pi \, seconds}\) = \(-35.8\) degrees per second.

  1. Let \(R\) be your answer to problem 5. If the camera revolves at the constant rate of \(R\) degrees per second, how many seconds would it take to make one \(360^o\) revolution?

Answer: It will take the camera approximately 10 seconds to make a full revolution.

Explanation:

Using the cross-canceling unit method, \((360 degrees) \, {\frac{1\ second}{R\ degrees}},\) we cancel the degrees and we are given seconds: \(360/35.8 = 10.04\) seconds.

Questions#

  1. Find \(\theta\) in degrees if the camera was 3.5 yds from the sidelines.

  1. If the camera is rotated .5 radians away from the endzone towards Bob Hayes, what yard line must he be on? (Given he is running at velocity of 10yds/sec again).

  1. Find \(\theta\) in radians when t = 0.4 seconds.

  1. Find \(\frac{d\theta}{dt}\) in degrees/sec if Bob Hayes had pulled his hamstring and could only run 6 yds/sec at the instant when y=5.

  1. Find \(\frac{d\theta}{dt}\) in radians/sec of the angle relative from Bob to the camera when y=4 and he was going 9 yds/sec.

7.7.5. Exercises#

Hint: draw pictures to assist you in visualizing the problem and marking necessary measurements.

Exercises

  1. A baseball diamond is a square with side length of 90ft. A batter hits the ball and runs toward first base with a speed of 20ft/s. At what rate is his distance from second base decreasing when he is halfway to the first base? At what rate is his angle to second base changing?

  2. At 1:00 PM, Jet-ski A is 7 miles east of Jet-ski B. Jet-ski A is moving north at 20 miles/hr while Jet-ski B is moving south 30 miles/h. How fast is the distance between the Jet-skis changing at 3:00 PM?

previous

7.6. Related Rates and Volumes

next

7.8. Probability Distributions and Drive Thrus

Contents
  • 7.7.1. Definition of Trig Functions
  • 7.7.2. Derivatives of basic trig functions
    • Example
  • 7.7.3. Radian Measure
    • Example
  • 7.7.4. Python trig functions
    • Example
    • Questions
  • 7.7.5. Exercises

By Paul Isihara, Claire Wagner, Peter Jantsch, and Thomas VanDrunen, Editors

© Copyright 2024.

Creative Commons License Except where otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License.