This material was developed by Aaron Tresham at the University of Hawaii at Hilo and is

licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

- Intro to Sage
- Graphing and Solving Equations
- Tangent Lines

Last time we saw that the slope of the line tangent to a function at the point is equal to .

Since every point on the graph of has a different tangent line, the slope of the tangent line may change. To keep track of these slopes, we define a new function, called the "derivative" of .

In other words, the derivative of the function , denoted or , gives the slope of the line tangent to at . Replacing with in the above limit results in the following formula for the derivative:

**Note:** The slope of the tangent line is also the (instantaneous) rate of change of the function. So you can think of the derivative as giving the rate of change of .

In this lab, we will learn how to use Sage to calculate derivatives (called "differentiation"), and we will look at graphs of the derivative function.

To calculate the derivative of a function in Sage, we use the derivative command. This command requires two arguments: (1) a function name or an expression and (2) the variable with respect to which the derivative is to be calculated.

Find the derivative of .

We could do this using limits:

2*x

However, instead of using limits it will be easier to use the derivative command:

2*x

You can also define a function first, and use the function name in the derivative command.

2*x

Whichever way we do it, we see that .

Find the derivative of .

-2*x^4*e^(-x^2) + 3*x^2*e^(-x^2)

We see .

There are two ways to calculate the value of the derivative at a particular point.

Give the derivative function a name, and then use it to calculate the particular value.

Add the particular value in parentheses

*after*the derivative command.

Note: Sage may give you a warning message if you use the second method (this method may be disallowed in a future version of Sage).

Suppose we want to calculate when .

Method 1: Name the derivative function. Sage does not allow the name , so I like to use df(x) [d for derivative].

Now that I have defined my derivative function df(x), I can use it to evaluate .

6

Sage tells me that .

Method 2: Add (3) after the derivative command:

6

Notice that we get the same answer: .

Caution: The (3) must come *after* the closing parenthesis of the derivative command. There is no place for the 3 within the derivative command. You must substitute 3 after finding the derivative, either by naming the derivative function or by putting (3) afterwards.

Find (using the same from above).

Method 1: Give the derivative a name, such as dg. Then we simply compute dg(5).

-1175*e^(-25)

Use the N() command if you want a numerical approximation:

-1.63183340413327e-8

So (notice the scientific notation).

Method 2: Add the particular value after the derivative command:

-1175*e^(-25)

Of course, we get the same answer as we got from method 1.

Find .

If you already have a dg function (method 1), then just compute dg(-3).

-135*e^(-9)
-0.0166603235517017

Thus, .

If you are using method 2, then compute the derivative again:

-135*e^(-9)

If you have many particular values to calculate, method 1 is more efficient. If you need only one particular value, then method 2 involves less typing.

Personally, I prefer method 1. I think method 1 more clearly shows what you are doing.

Sage is able to handle derivative when other variables are involved. All variables other than the variable of differentiation (the variable after the comma in the derivative command) are treated as constants (unspecified numbers).

Find the derivative of . [It's implied that the derivative is with respect to , since the function is defined as a function of .]

So .

Of course, if we take the derivative with respect to , , or we will get a different answer. [This is awkward, since F is written as a function of . This is not a normal Calculus 1 question, but Sage is able to deal with it.]

The rate of change of position with respect to time (called velocity) is the derivative of the position function.

The position (in feet) of an object moving in a straight line after minutes is given by the function .

How fast is the object travelling at minutes?

-20

The objects's velocity is ft/min.

You could also use method 2:

-20

The second derivative of , denoted or , is the derivative of . In other words, or .

Similarly, the third derivative of , denoted or, is the derivative of .

After the third derivative, we stop using primes. For example, the fourth derivative is denoted and the tenth derivative is denoted .

If you want the second, third, etc. derivative in Sage, you need to add one more argument to the derivative command.

Here are some second derivatives (using the same , , and from above):

2

Here are some higher-order derivatives (same , , and ):

0

0

Find .

Method 1:

41459781162688*e^(-49)
2.17368892264044e-8

Notice the scientific notation again:

Method 2:

41459781162688*e^(-49)

Acceleration is the rate of change of velocity. In other words, acceleration is the second derivative of the position function.

The position (in feet) of an object moving in a straight line after minutes is given by the function .

What is the object's acceleration at minutes?

-6

The acceleration is ft/min/min = ft/min.

We are going to graph a function and its derivative and compare.

Let's start with a simple example and look at the graphs of and its derivative.

Notice:

- When the original function is increasing, the derivative is positive.
- When is decreasing, is negative.
- has a local minimum at , and .

Caution: There is no relationship between the direction (increasing/decreasing) of and the direction of . The relationship is between the direction of and the sign (positive/negative) of .

Now let's look at and its derivative.

Again we observe the same relationship:

- When the original function is increasing, the derivative is positive.
- When is decreasing, is negative.
- When has a local minimum or maximum, is .

Also observe the following:

- When is concave up, is increasing.
- When is concave down, is decreasing.
- When has an inflection point, has a local minimum or maximum.

Last time we used limits to find the slopes of tangent lines. Now we can use the derivative to find the slope.

In general, the tangent line to at has equation .

Suppose we want the tangent line to the function when .

An equation for the line is .