Answers to some of the exercises in Section 2.2 in the book “A frist course in Math Modeling (5th ed)”. These are my answers and they need not be correct.
y <- c(3.5,5,6,7,8)
z <- c(3,6,9,12,15)
y
## [1] 3.5 5.0 6.0 7.0 8.0
z
## [1] 3 6 9 12 15
To check if \(y \propto \sqrt{z}\), we have to plot a graph between \(y\) and \(\sqrt{z}\).
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
ggplot(data.frame(y,sqrt_z=sqrt(z)),aes(x=sqrt_z,y=y)) +
geom_point(size=2,color='blue') +
labs(title="Plot between sqrt(z) and y")
The above plot clearly shows that the line passes through the origin, and hence \(y \propto \sqrt{z}\)
Check if \(Force \propto Strech\)
Given the following data:
Force <- seq(from=10,to=90,by=10)
Stretch <- c(19,57,94,134,173,216,256,297,343)
df <- data.frame(Force=Force,Stretch=Stretch)
ggplot(df,aes(x=Stretch,y=Force)) +
geom_point(size=2,color="red") +
labs(title="Stretch vs Force")
Hence, using the above graph, we can conclude that \(Force \propto Strech\).
Check if \(y \propto x^2\) in the following data:
y <- c(4,11,22,35,56,80,107,140,175,215)
x <- 1:10
df <- data.frame(x,y)
df$x_sq <- (df$x)^2
df
## x y x_sq
## 1 1 4 1
## 2 2 11 4
## 3 3 22 9
## 4 4 35 16
## 5 5 56 25
## 6 6 80 36
## 7 7 107 49
## 8 8 140 64
## 9 9 175 81
## 10 10 215 100
Let us plot the graph between \(y\) and \(x^2\)
ggplot(df,aes(x=x_sq,y=y)) +
geom_point(size=2,color="red") +
labs(title="square(x) and y plot")
Hence \(y \propto x^2\)
As per the vehicular stopping distance modeling, given on page 73, the stopping distance is:
\[d = 1.1 v + 0.054v^2\]
The reaction distance is: \(1.1 v\), while breaking distance is: \(0.054v^2\), \(d\) is the stopping distance in feet and \(v is the velocity in mph\).
Let us get the stopping distance, breaking distance, reaction distance for some values of mph velocity.
velocity <- seq(from=0,to=200,by=5)
reaction_dist <- 1.1 * velocity
breaking_dist <- 0.054*velocity^2
stopping_dist <- (reaction_dist + breaking_dist)
df <- data.frame(velocity = velocity, reaction_dist=reaction_dist, breaking_dist= breaking_dist, stopping_dist=stopping_dist)
df
## velocity reaction_dist breaking_dist stopping_dist
## 1 0 0.0 0.00 0.00
## 2 5 5.5 1.35 6.85
## 3 10 11.0 5.40 16.40
## 4 15 16.5 12.15 28.65
## 5 20 22.0 21.60 43.60
## 6 25 27.5 33.75 61.25
## 7 30 33.0 48.60 81.60
## 8 35 38.5 66.15 104.65
## 9 40 44.0 86.40 130.40
## 10 45 49.5 109.35 158.85
## 11 50 55.0 135.00 190.00
## 12 55 60.5 163.35 223.85
## 13 60 66.0 194.40 260.40
## 14 65 71.5 228.15 299.65
## 15 70 77.0 264.60 341.60
## 16 75 82.5 303.75 386.25
## 17 80 88.0 345.60 433.60
## 18 85 93.5 390.15 483.65
## 19 90 99.0 437.40 536.40
## 20 95 104.5 487.35 591.85
## 21 100 110.0 540.00 650.00
## 22 105 115.5 595.35 710.85
## 23 110 121.0 653.40 774.40
## 24 115 126.5 714.15 840.65
## 25 120 132.0 777.60 909.60
## 26 125 137.5 843.75 981.25
## 27 130 143.0 912.60 1055.60
## 28 135 148.5 984.15 1132.65
## 29 140 154.0 1058.40 1212.40
## 30 145 159.5 1135.35 1294.85
## 31 150 165.0 1215.00 1380.00
## 32 155 170.5 1297.35 1467.85
## 33 160 176.0 1382.40 1558.40
## 34 165 181.5 1470.15 1651.65
## 35 170 187.0 1560.60 1747.60
## 36 175 192.5 1653.75 1846.25
## 37 180 198.0 1749.60 1947.60
## 38 185 203.5 1848.15 2051.65
## 39 190 209.0 1949.40 2158.40
## 40 195 214.5 2053.35 2267.85
## 41 200 220.0 2160.00 2380.00
Let us get the average reaction and breaking distances:
mean(df$reaction_dist)
## [1] 110
mean(df$breaking_dist)
## [1] 729
mean(stopping_dist)
## [1] 839
So the mean of the breaking distance is close to the stopping distance, while the reaction distance is drastically different from the stopping distance’s mean. Let us plot the graph to chick which component is more important (reaction distance or the breaking distance)?
library(reshape)
##
## Attaching package: 'reshape'
##
## The following object is masked from 'package:dplyr':
##
## rename
df_melt <- melt(df,id("velocity"))
ggplot(df_melt,aes(x=velocity,y=value,color=variable)) +
geom_point() +
labs(x="Velocity in MPH",y= "Distance", title="Stopping distances vs Velocity plot")
Therefore to model stopping distance the breaking distance is significant when compared to the reaction distance (this is especially true for higher velocities - velocities after 20 mph).