*Please read all of the instructions before getting started.*

## Goal

Use Sage to explore differentiation.

## Instructions

This lab should be completed in groups of 2-4. No one should work alone. I recommend keeping this window open as a tab in your browser, so that you can refer back to these instructions as you are working on the lab.

First, one member of your group will need to log into the Sage Notebook server. Go to http://prep.sagenb.org (Sage recommends that you use Firefox). Once you are logged into the Sage Notebook server, you will be in your "`Home`" directory. Click on "`New Worksheet`" towards the top left. A small window will pop up asking you what you want to call the worksheet. Name your worksheet

`MA2550 Lab 2 (name-1, name-2, etc.)`

where you should replace

`name-1`,

`name-2`, etc. with the appropriate first names of your group members separated by commas. You will be presented with a blank Sage worksheet.

Before you actually do anything with this worksheet, I want you to share it with me and the other members of your group. Click "`Share`" in the third row of menus that appear in the upper right hand corner of your worksheet. As you did on Lab 1, type in the Sage usernames of the members of your group (separated by commas). You should also share the worksheet with me (my Sage username is `dcernst`). Once you have typed in the appropriate usernames, click "`Invite Collaborators`". This should return you to your blank worksheet.

We are going to use Sage to explore two different functions. For the first function, I will describe exactly what to do. For the second function, you should mimic the techniques of that I describe for the first function.

Follow the steps below:

1. Place your cursor above the single Sage cell until a blue horizontal line appears and then "`shift+click`" to open the text editor for an HTML block.

2. Center and **bold** the title "Lab 2 for Calculus I (Fall 2010)" and then click "`Save changes`".

3. In the first Sage cell, define the function $f(x)=3x^2-2x^3$ by typing the following and then clicking "`evaluate`" (or typing "`shift+enter`"):

f(x)=3*x^2-2*x^3

4. It looks like nothing happened, but what we did was tell Sage to define a function. To see what Sage thinks $f$ is, use the `show()` command by typing:

show(f(x))

5. In the next Sage cell, graph $f$ on the interval $(-1,2)$ using the `plot` function by typing:

plot(f(x),(-1,2))

6. Next, have Sage compute the derivative of $f$ using the `diff()` command:

fprime(x)=diff(f(x))

*Note:* I made up the name "fprime" to refer to the derivative of $f$.

7. Use the `show()` command to see what the derivative of $f$ actually is:

show(fprime(x))

8. Next, have Sage plot the graph of $f$ and $f'$ on the same set of axes over the interval $(-1,2)$ so that the graph of the derivative is red:

plot(f(x),(-1,2))+plot(fprime(x),(-1,2),color='red')

9. "`shift+click`" on a blue line to open up an HTML block and type in a response to the following just below the graph from 8. Explain the connection between the $x$-intercepts of the graph of $f'$ and the places where the graph of $f$ has horizontal tangent lines.

10. Use Sage to compute the slope of the tangent line to the graph of $f$ at $x=.5$:

fprime(.5)

11. Recall that the equation of a line with slope $m$ passing through $(x_0,y_0)$ is given by $y-y_0=m(x-x_0)$. If $(x_0,y_0)$ lies on the graph of $f$, then $y_0=f(x_0)$ and $m=f'(x_0)$. If we solve for $y$ and do some substitution, we see that the equation of the tangent line to the graph of $f$ at $x_0$ is given by $y=f'(x_0)(x-x_0)+f(x_0)$. Use Sage to define the equation of the tangent line to $f$ at $x=.5$:

ftline(x)=fprime(.5)*(x-.5)+f(.5)

*Note:* I made up "`ftline`" as an abbreviation for the tangent line of $f$.

12. Use the `show()` command to see what the equation of the tangent line to the graph of $f$ is.

show(ftline(x))

13. Plot the graph of $f$ and the tangent line from 11 on the same set of axes over the interval $(-1,2)$ so that the graph of the tangent line is red:

plot(f(x),(-1,2))+plot(ftline(x),(-1,2),color='red')

14. Next, define the function

(1)Certainly, no one wants to take the derivative of this function by hand.

*Note:* To type this function into Sage, you need to remember to use `*` for multiplication. Also, use `sqrt()` to obtain a square root.

15. Use the `show()` command to verify that you typed everything in correctly.

16. Mimic steps 5-8 and 10-13 above, except use the function $g$, the interval $(1.5,2.5)$, and $x=2$ instead of $f$, $(-1,2)$, and $x=.5$.

## Getting Help

If you need help, you can always contact me, or even better, post a question in the course forum. In addition, there are some useful links on the Sage help page.

## Due Date

This lab is due by **5PM on Friday, October 8**.