Lab 4: Functions and Their Derivatives



In this lab you will practice distinguishing between applications of the function and applications of the derivative. Some questions will require you to know a little more about SageMath.

Using SageMath to Calculate Derivatives and to Solve Equations

SageMath can evaluate functions by entering two lines of code. The first line defines the function and the second line specifies the output to evaluate. For example, to evaluate \(f(3)\) when \(f(x)=4x^2\) enter: f(x)= 4*x^2
f(3)
Try this in the SageMath evaluation cell below.

SageMath can also compute derivatives and evaluate these derivatives. For example, to determine the function rule for \(f’\) when \(f(x) = 4x^2\) you may enter the following:
f(x)= 4*x^2
df(x)=diff(f,x)
df(x)
And a slight modification of the last SageMath code gives the value of the derivative at \( x=3 \):
f(x)= 4*x^2
df(x)=diff(f,x)
df(3)
Try these in the SageMath cell below.

Finally, you can use SageMath to solve equations. In SageMath (and many other software packages), definitions are often made with an equal sign (‘=’). For example, when you type z(x) = x^2 + 1 into SageMath, this assigns z to be a function of x after that line.

In an equation, the equal sign has a different meaning; you are not assigning the left-hand side to be the right-hand side for future reference, but are interested in which values of variables make the sides equal. For this reason, SageMath needs to use something besides ‘=’. The developers of SageMath have chosen the double equal sign ‘==’ to denote an equation. Use the SageMath equation solver cell below Exercise 1 to get the two solutions to \(4x^2 = 2\). (You need to replace the default equation \(2x = 7\) with \(4x^2 = 2\)—and remember to use ‘==’!)


1. In a medical experiment, the body weight in grams of a baby rat after \(t\) days was \(f(t)=4.96+4.8t+0.17t^2-0.0048t^3\). Use the SageMath computation cells below to answer the following questions. Only use solutions that make sense in the context of the experiment and include brief explanations with your answers. Attach a printout of your work to your lab report—use SageMath‘s print() command to fit the work for all three parts on the same page.

(a) Approximately how much did the rat weigh after the number of days specified in your lab report?
(b) Approximately when did the rat’s weight reach the number of grams specified in your lab report?
(c) Approximately how fast was the rat gaining weight after the number of days specified in your lab report?

Name:

Skip to toolbar