Chapter 4 Example 4:

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

  2. 10 cm?

  3. 100 cm?

# Given rate of change of volume (dV/dt) in cm^3/s
dV_dt <- 10

# to created function to calculate the rate of change of radius (dr/dt)
calculate_radius_rate <- function(r) {
  dr_dt <- (1 / (4 * pi * r^2)) * dV_dt
  return(dr_dt)
}

# to calculate the rates for different values of r
radius_1_cm <- calculate_radius_rate(1)
radius_10_cm <- calculate_radius_rate(10)
radius_100_cm <- calculate_radius_rate(100)

# to print the results
cat("(a) When the radius is 1 cm, the rate of increase in radius is approximately", round(radius_1_cm, 2), "cm/s.\n")
## (a) When the radius is 1 cm, the rate of increase in radius is approximately 0.8 cm/s.
cat("(b) When the radius is 10 cm, the rate of increase in radius is approximately", round(radius_10_cm, 5), "cm/s.\n")
## (b) When the radius is 10 cm, the rate of increase in radius is approximately 0.00796 cm/s.
cat("(c) When the radius is 100 cm, the rate of increase in radius is approximately", round(radius_100_cm, 8), "cm/s.\n")
## (c) When the radius is 100 cm, the rate of increase in radius is approximately 7.958e-05 cm/s.