Chapter 4

Water flows onto a flat surface at a rate of 5cm3 /s forming a circular puddle 10mm deep. How fast is the radius growing when the radius is: (a) 1 cm? (b) 10 cm? (c) 100 cm?

#Relevant data
Q <- 5  # Flow rate in cm^3/s
h <- 10  # Depth of the puddle in mm, converted to cm
dV_dt <- Q  # Rate of change of volume, given by the flow rate

#A function to calculate the rate of change of the radius
rate_of_change_radius <- function(r) {
  # Convert depth to cm
  h_cm <- h / 10
  
  #Calculating the volume of the puddle using the formula V = pi * r^2 * h
  V <- pi * r^2 * h_cm
  
  #Using the formula for the volume of a cylinder to find the rate of change of the radius
  dV_dr <- 2 * pi * r * h_cm
  
  #Calculating the rate of change of the radius using dV/dt = dV/dr * dr/dt
  dR_dt <- dV_dt / dV_dr
  
  return(dR_dt)
}

#Calculating the rate of change of the radius for each given radius value
radius_values <- c(1, 10, 100)  # in cm
for (r in radius_values) {
  rate <- rate_of_change_radius(r)
  cat("When the radius is", r, "cm, the rate of change of the radius is", rate, "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.07957747 cm/s
## When the radius is 100 cm, the rate of change of the radius is 0.007957747 cm/s
LS0tDQp0aXRsZTogImRhdGEgNjA1IERpc2N1c3Npb24gMTMiDQphdXRob3I6ICJMYXVyYSBCIg0KZGF0ZTogImByIFN5cy5EYXRlKClgIg0Kb3V0cHV0OiBvcGVuaW50cm86OmxhYl9yZXBvcnQNCi0tLQ0KDQpDaGFwdGVyIDQNCg0KV2F0ZXIgZmxvd3Mgb250byBhIGZsYXQgc3VyZmFjZSBhdCBhIHJhdGUgb2YgNWNtMw0KL3MgZm9ybWluZyBhDQpjaXJjdWxhciBwdWRkbGUgMTBtbSBkZWVwLiBIb3cgZmFzdCBpcyB0aGUgcmFkaXVzIGdyb3dpbmcNCndoZW4gdGhlIHJhZGl1cyBpczoNCihhKSAxIGNtPw0KKGIpIDEwIGNtPw0KKGMpIDEwMCBjbT8NCg0KYGBge3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