Assignment instructions

Using R, provide the solution for any exercise in eitehr Chapter 4 or Chapter 7 of the calculus textbook. If you are unsure of your solution, post your concernts.



Selected Problem

Exercises 4.2 Problem 4 page 179

  1. A circular balloon is inflated with air flowing at a rate of 10cm^3/s. How fast is the radius of the balloon increasing when the radius is:
  1. 1 cm?
  2. 10 cm?
  3. 100 cm?


Introduction of Concepts

In a Related Rate problem we know one rate and have to determine a second rate at a given moment. First we need to find how the two rates are related and take the derivative of each side to solve for the second, related rate at the given moments.

In this case we have a volume of air coming into a balloon and we need to know how fast the radius of the balloon is expanding. The relationship between volume and radius for a sphere is:

V = 4/3*pi*r^3



Solving in R

# Set the formula for Volume
V = expression(4/3*pi*r^3)
# Find the derivative of V with respect to r
D(V,'r')
## 4/3 * pi * (3 * r^2)
# Set the formula for dr/dt equal to dV/dt divided by D(V,'r')
dr = expression(10/4/pi/r^2)
# dr/dt evaluated at r = 1cm is:
r = 1
eval(dr,r)
## [1] 0.7957747
# dr/dt evaluated at r = 0cm is infinity!
r = 0
eval(dr,r)
## [1] Inf
# When I try to evaluate at r = 10 or 100 I get the following error message:

#Error in eval(dr, r) : not that many frames on the stack

# it doesn't need the supplied r for some reason

r = 10
eval(dr)
## [1] 0.007957747
# strange, but it works without needing the r specified.
r = 100
eval(dr)
## [1] 7.957747e-05
# From the generosity of classmate Karma Gyatso
dr <- expression(10 / (4 * pi * r^2))

r_values <- c(1, 10, 100)
for (r in r_values) {
  dR_dt <- eval(dr)
  cat("When the radius is ", r, " cm, the rate of change of the radius is ", dR_dt, " cm/s\n")
}
## When the radius is  1  cm, the rate of change of the radius is  0.7957747  cm/s
## When the radius is  10  cm, the rate of change of the radius is  0.007957747  cm/s
## When the radius is  100  cm, the rate of change of the radius is  7.957747e-05  cm/s


Conclusion

Using R I wasn’t able to capture the units and rates expressed as dV/dt and dr/dt. R was helpful in confirming my calculation of the derivative, but with the written out math it’s much more elegant to track the rates as rates and use units to check that everything ties together.

I also wasn’t able to evaluate the related rate function at values of r other than 0 or 1, initially. For some reason I didn’t need to specify that we were evaluating with r for r = 10 or 100, but I was able to specify with r for r = 0 or 1.

Classmate Karma Gyatso provided a solution where we pass a list of r values to be solved, which I’ve included. Very elegant.



Bonus

We’re attempting a second problem, #7

An F-22 aircraft is flying at 500mph with an elevation of 10,000ft on a straight-line path that will take it directly over an anti-aircraft gun. How fast must the gun be able to turn to accurately track the aircraft when the plane is:
(a) 1 mile away?
(b) 1/5 miles away?
(c) Directly overhead?

Here we have a right triangle where the bottom corner is the gun, the adjacent, straight vertical is about 2 miles, the opposite is D, the distance between the gun and the airplane, 0, .2 miles or 1 mile and we don’t need the hypotenuse. We can calculate the angle of the bottom corner of the gun pointing to the air craft as

theta = arctan(distance/2mi)

which when both sides have their derivatives taken is:

dtheta_dt = 1/(2(1+D^2/4))dD_dt

Where 2 is really 10,000 feet/5280 feet/mi, or about 1.89 dD_dt is 500mph

# To adopt Karma Gyatso's solution for the first problem to this one:

h <- 10000/5280 #10,000ft/(5280ft/mi)

dtheta_dt <- expression(500*(h*(1+D^2/h^2))^-1)

D_values <- c(1, .2, 0)
for (D in D_values) {
  RadiansPerSecond <- eval(dtheta_dt)/360
  cat("When the distance is ", D, " miles, the rate of change of the gun's angle is ", RadiansPerSecond, " radians/second\n")
}
## When the distance is  1  miles, the rate of change of the gun's angle is  0.5734615  radians/second
## When the distance is  0.2  miles, the rate of change of the gun's angle is  0.7252459  radians/second
## When the distance is  0  miles, the rate of change of the gun's angle is  0.7333333  radians/second
# And here in degrees per second for a better visualization
h <- 10000/5280

dtheta_dt <- expression(500*(h*(1+D^2/h^2))^-1)

D_values <- c(1, .2, 0)
for (D in D_values) {
  DegreesPerSecond <- eval(dtheta_dt)/360*180/pi
  cat("When the distance is ", D, " miles, the rate of change of the gun's angle is ", DegreesPerSecond, " degrees/second\n")
}
## When the distance is  1  miles, the rate of change of the gun's angle is  32.85692  degrees/second
## When the distance is  0.2  miles, the rate of change of the gun's angle is  41.55353  degrees/second
## When the distance is  0  miles, the rate of change of the gun's angle is  42.0169  degrees/second