circular puddle 10mm deep. How fast is the radius growing when the radius is: ### (a) 1 cm? ### (b) 10 cm? ### (c) 100 cm?
flow_rate_cm3_per_s <- 5
depth_mm <- 10
# I'm converting the depth from mm to cm
depth_cm <- depth_mm / 10
rate_of_change_radius <- function(radius_cm) {
volume_cm3 <- pi * radius_cm^2 * depth_cm
dV_dr <- 2 * pi * radius_cm * depth_cm
dr_dt <- flow_rate_cm3_per_s / dV_dr
return(dr_dt)
}
radius_values <- c(1, 10, 100)
for (radius_cm in radius_values) {
rate <- rate_of_change_radius(radius_cm)
cat("When the radius is", radius_cm, "cm, the rate of change of the radius is", round(rate, 2), "cm/s.\n")
}
## When the radius is 1 cm, the rate of change of the radius is 0.8 cm/s.
## When the radius is 10 cm, the rate of change of the radius is 0.08 cm/s.
## When the radius is 100 cm, the rate of change of the radius is 0.01 cm/s.