CoCalc Public Files08 - Related Rates Assignment / Related Rates Notes.sagewsOpen with one click!
Author: Aaron Tresham
Views : 92
License: Other -- explicitly state in your code
Compute Environment: Ubuntu 20.04 (Default)
This material was developed by Aaron Tresham at the University of Hawaii at Hilo and is Creative Commons License
licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.


  • Intro to Sage
  • Differentiation
  • Implicit Differentiation

Related Rates

Related rates problems involve two or more changing quantities. The quantities are related to each other, and you know the rate of change of all but one quantity. The goal is to find the rate of change of the last quantity.

The computations are similar to implicit differentiation.

Example 1

The length of a rectangle is increasing at a rate of 8 cm/s and its width is increasing at a rate of 3 cm/s. At what rate is the area of the rectangle increasing when the length is 20 cm and the width is 10 cm?


This example involves three quantities: length, width, and area of a rectangle. Let's call these ll, ww, and AA.

We know from geometry that these three quantities are related: A=lwA=l\cdot w.

We know the rate of change of two of the three quantities with respect to time (tt):

dldt=8\displaystyle\frac{dl}{dt}=8 cm/s

dwdt=3\displaystyle\frac{dw}{dt}=3 cm/s

The question asks us about the third rate of change, dAdt\displaystyle\frac{dA}{dt}.

The idea is to take the derivative of the equation A=lwA=l\cdot w with respect to tt (all three quantities are functions of time).

Similar to what we did with implicit differentiation, we must tell Sage that ll, ww, and AA are functions of tt, and then we can take the derivative.

Caution: Always take the derivative before plugging in values for any variables.

%var t l=function('l')(t) #l is a function of t w=function('w')(t) #w is a function of t A=function('A')(t) #A is a function of t derivative(A==l*w,t) #don't forget the double equal sign == show(_)
diff(A(t), t) == w(t)*diff(l(t), t) + l(t)*diff(w(t), t)
tA(t)=w(t)tl(t)+l(t)tw(t)\displaystyle \frac{\partial}{\partial t}A\left(t\right) = w\left(t\right) \frac{\partial}{\partial t}l\left(t\right) + l\left(t\right) \frac{\partial}{\partial t}w\left(t\right)

Notice that Sage writes ll, ww, and AA as functions of tt.

Usually we don't write all of these as functions of tt, but we will use Liebniz's notation to make it clear that the derivatives are with respect to time:


Notice that this equation gives us a formula for the rate of change of area (what the question asks for) in terms of things we know (length, width, and their rates of change).

Although the rates of change of both length and width are constants, notice that the rate of change of area is not a constant.

Now that we have the derivative, we can start plugging in values. The question asks for dAdt\displaystyle\frac{dA}{dt} when l=20l=20 and w=10w=10.


So at the time specified, the area is changing at a rate of 140 cm2/s140\ \textrm{cm}^2/\textrm{s}.


Example 2

A 12 m ladder rests on horizontal ground and leans against a vertical wall. The foot of the ladder is pulled away from the wall at the rate of 110\frac{1}{10} m/s. How fast is the top sliding down the wall when the foot of the ladder is 4 m from the wall?


Let yy be the vertical distance from the top of the ladder to the ground, and let xx be the horizontal distance from the wall to the foot of the ladder.

We are told dxdt=110\frac{dx}{dt}=\frac{1}{10}, and we are asked to find dydt\frac{dy}{dt} when x=4x=4.

Since the ladder, wall, and ground form a right triangle, the Pythagorean Theorem relates xx and yy:


We now take the derivative of this equation with respect to time.

[Note: 12 is a constant, so we can plug it in now. But xx and yy are changing, so do not plug in values for these until after you have found the derivative.]

%var t x=function('x')(t) y=function('y')(t) derivative(x^2+y^2==12^2,t) #don't forget == show(_)
2*x(t)*diff(x(t), t) + 2*y(t)*diff(y(t), t) == 0
2x(t)tx(t)+2y(t)ty(t)=0\displaystyle 2 \, x\left(t\right) \frac{\partial}{\partial t}x\left(t\right) + 2 \, y\left(t\right) \frac{\partial}{\partial t}y\left(t\right) = 0

Let's rewrite this:


We want dydt\frac{dy}{dt}, so let's have Sage solve for this:

solve(derivative(x^2+y^2==12^2,t),derivative(y,t)) show(_)
[diff(y(t), t) == -x(t)*diff(x(t), t)/y(t)]
[ty(t)=x(t)tx(t)y(t)\displaystyle \frac{\partial}{\partial t}y\left(t\right) = -\frac{x\left(t\right) \frac{\partial}{\partial t}x\left(t\right)}{y\left(t\right)}]


We are given dxdt\frac{dx}{dt} and xx, but we also need to know yy.

When x=4x=4, what is yy?

solve(4^2+y^2==12^2,y) show(_)
[y(t) == -8*sqrt(2), y(t) == 8*sqrt(2)]
[y(t)=82\displaystyle y\left(t\right) = -8 \, \sqrt{2}, y(t)=82\displaystyle y\left(t\right) = 8 \, \sqrt{2}]

We don't care about the negative solution (y>0y>0 since it is a distance). So when x=4x=4 we have y=82y=8\sqrt{2}.

Now let's plug in all the given information:

dydt=482110=2400.0354\frac{dy}{dt}=-\frac{4}{8\sqrt{2}}\cdot \frac{1}{10}=-\frac{\sqrt{2}}{40}\approx-0.0354

Notice that the derivative is negative, since the distance is decreasing (top of ladder sliding down the wall).

The top of the ladder is sliding down the wall at a rate of about 0.0354 m/s.

-4/(8*sqrt(2))*1/10 N(_)
-1/40*sqrt(2) -0.0353553390593274

Example 3

A cylindrical tank standing upright (with one circular base on the ground) has radius 20 cm. How fast does the water level in the tank drop when the water is being drained at a rate of 25 cm3^3/s?


Let rr be the radius of the tank, hh be the water level, and VV the volume of the water. We are given that r=20r=20 and dVdt=25\frac{dV}{dt}=-25 [the derivative must be negative, since VV is decreasing].

The relationship of these three quantities is given by the volume formula for a cylinder: V=πr2hV=\pi r^2h.

In this case r=20r=20, so V=400πhV=400\pi h.

Let's take the derivative:

%var t V=function('V')(t) h=function('h')(t) derivative(V==400*pi*h,t) show(_)
diff(V(t), t) == 400*pi*diff(h(t), t)
tV(t)=400πth(t)\displaystyle \frac{\partial}{\partial t}V\left(t\right) = 400 \, \pi \frac{\partial}{\partial t}h\left(t\right)

So we see


We want to solve this for dhdt\frac{dh}{dt}, so divide both sides by 400π400\pi and plug in the given value of dVdt\frac{dV}{dt}:


Thus, the water level is falling at a rate of about 0.02 cm/s.

-25/(400*pi) N(_)
-1/16/pi -0.0198943678864869