All published worksheets from http://sagenb.org
Image: ubuntu2004
Using the Chain Rule
This section introduces you to using Sage to do implicit differentation, plotting curves implicitly, using the solver to solve for symbolic functions, take derivatives of log, exp, and trig functions, and find differentials.
Implicit Differentiation
If you do not tell Sage explicitly that y is a function of x, then it will assume y is a constant when you take derivatives. The following code shows you how to tell the computer that y is a function of x. You can then type in any equation involving x and y and then the computer will take the derivative of both sides, and then solve for dy/dx, writing it as D[0](y)(x).
Now take the derivative of both sides.
Solve for the derivative
Finally, print the solution in a nice readable way. The [0] at then end of dydx[0] tells the computer to grab the first object in the list returned by the solve function. Notice that the answer is included inside brackets [ ] which is why I have to use [0] to grab the first item in the list.
Plotting Implicit Curves and Tangent Lines
This section shows you the code needed plot curves given implicitly, as well as how to find tangent lines at any point on the curve.
This first example shows you how to use implicit plot to plot any curve given implicitly. Use the option, aspect_ratio=1 if you want the x and y scale to be the same.
In the code below, you can type in any curve and a point on the curve. This code will draw the curve, then use implicit differentation to find the derivative, find the slope at the point, create the tangent line, and then plot both the curve and tangent line on the same axes.
Derivatives of Log, Exp, and Trig Functions
Below you will find examples of the syntax needed to enter logarithmic, exponential, and trig functions.
- Remember that log(x) in Sage means log base e.
- To get a logarithm of any other base, use log(x,a).
- To type e^x, use exp(x).
- For arcsin, arccos, and arctan, Sage simplifies the derivative to something you recognize. For the other three, it leaves the derivative in symbolic form.
Sage will perform logarithmic differentiation automatically when needed.
Related Rates
It is not possible to create a computer program to solve every related rates problem. Instead, you have to type in the equations you know and then ask Sage to take derivatives and solve for the variables you need in each problem. Let's use differentials to solve a problem involving a sliding ladder. Suppose a 10 m ladder is slipping away from a building. The base is moving at a rate of 2 m per second. When the base of the ladder is 6 meters from the base of the building, how fast is the top of the ladder sliding down the edge of the building?
If we let our variables be for the distance from the base of the building to the base of the ladder, be the length of the ladder, and be the height from the base of the building to the tip of the ladder, then we know and we also know m/s. We need to find . Notice that is always 10 meters long. Let's now code this into Sage.
Let's take the derivative of both sides with respect to .
Now I need to solve for .
We have the solution . We still need to solve for , and then plug in these values into the formula we obtained for .
Differentials
The derivative gives us the slope of a tangent line. If you increase the value of a function from to , then how much does the value increase? The notation suggests that we can find a small change in by multiplying both sides by to obtain the differential Think of as a small change in . Think of as a small change in . The quantities and are called differentials. You can use differentials to estimate how much will change if changes by . The example below illustates how to do this. In high dimensional calculus, the differentials become vectors and the derivative becomes a matrix. This differential equation is the key equation needed to extend calculus to higher dimensions.
The actual vertical change in from to is the height of the green triangle. The approximate change in from to is the height of the purple triangle. They are not the same, but are very close when is small.