Rates of Change
The average speed of a moving object over some time interval is the distance between positions divided by the time it took to get from one position to the next. More generally, the average rate of change of a function of time is the change in the value of the function divided by the length of the time interval.
Evaluate the cell in your turn-in sheet that contains the function and run the command to create a random function called .
Compute the average rate of change of between and
We know the average rate of change of the function between and . Now, we want its rate of change at .
Create a list of average rates of change for for values of 1, 0.1, 0.01, and 0.001. (You can do this by hand or use a loop.) Use the result to estimate the function’s rate of change at . Why do you think the number you gave is the rate of change at that value of ?
The rate of change of a function at a point is called its instantaneous rate of change at that point.
Estimate the instantaneous rate of change at another point (as you did in Exercise 3).
At this point, you might be wondering why we bother with different values of at all. Why not just pick a small value of and always use that to compute rates of change? The answer won’t be mathematically precise, but real-world measurements always have some error anyway. The following series of exercises will explore this question.
Find the average rates of change for the function at using 1, 0.1, 0.01, and 0.001 as your values of . Then, estimate the function’s rate of change at . Feel free to use more values if you want.
Repeat this procedure for . What is this function’s rate of change at ?
Drawing on your results, briefly explain why limits are necessary when computing derivatives. Why don’t we just pick a small value of and always use that?
Symbolic Calculations in Sage
One of Sage’s most powerful features is its ability to do symbolic computations – calculations with variables rather than numbers. Such calculations require you to use a particular kind of variable called a symbolic variable. Symbolic variables can be manipulated algebraically without having numerical values. The variable x is a built-in symbolic variable.
Compute .
Find the type of .
The variable is a built-in symbolic variable. To use other symbolic variables, like or , you’ll need to create them. This is called declaring the variables and is done using the var function. This function takes a string of variable names, separated by commas, as input and generates the appropriate symbolic variables.
Note that Sage assumes that . Symbolic variables don’t have to be single letters.
Once a symbolic variable has been declared, you can use it in subsequent calculations without re-declaring it until you close your worksheet.
The command factor allows you to factor polynomials.
Factor .
Factor
Plotting uses symbolic variables, so if you want to plot a function of a variable other than , you have to declare it before using it.
Plot the function using as the independent variable, for values of between -30 and 30. You don’t need to define the function before plotting it.
Once you assign a numeric value to a symbolic variable, it’s no longer a symbolic variable. Instead, it’s now a number. A common plotting error results from assigning a value to some variable, usually , and later using that variable in a plot. The tell-tale symptom of this problem is a graph consisting of one or more horizontal lines.
Why is the horizontal line y=8 rather than some other value of y?
To fix this problem, just declare to be a symbolic variable again.
-------------------Second Half of Lab 4--------------------------.
Curves and Lines
The rate of change of a function at a point has an important geometric meaning that you will explore in this section. To do this, you’ll need to be able to plot points, which is done with the command point.
To plot a point at the coordinates (1,2), use the command point([1,2]). Notice that the coordinates are given as a list.
To plot a larger red point at the coordinates (-3,5), use the command point([-3,5], color="red", size=40).
Plot the function for values of x between 0 and 5. Overlay the point (1,16) on the graph and make sure the point is visible.
Create an animation that zooms in on this point by reducing the range of . Use at least five different zoom levels. What do you observe?
You should have noticed that as you zoom in on the curve, it starts to look like a straight line. (Some points on certain curves will not do this, which is an important observation but not very common in mathematical biology.) The question is what straight line it is.
To answer this question, we want to plot lines with slopes corresponding to the average rates of change we computed earlier. Since we have a point and a slope, this is most easily done using the point-slope equation for a line passing through the point . This equation is . However, since Sage’s plot command requires everything other than y to be on the right-hand side of the equation, we have to rearrange it into .
Create an interactive that plots the function f(x) = and a line that passes through the point (1,16) and a second point on the function whose -coordinate is set by the slider. Describe what happens as the movable point approaches the fixed one.
You can display a number on a plot using the text function. The syntax to display the value val at point pt on a plot is text(val, pt). (As in other cases, you can give the coordinates of pt as a list.) Modify your interactive so it computes and displays the slope of the line being plotted. HINT: Use + to overlay text on a plot.
Modify your interactive to also compute and display the derivative of the function at the point (1,16) (NOT the point moved by the slider). What do you notice about the derivative of the function and the slope of the plotted line?
So far, we’ve been working with derivatives at single points. However, we can compute the derivative of a function at all points on the function. We then obtain a new function, . Just like the number that gives the rate of change of a function at a single point, is termed the derivative of .
In Sagemath, derivatives are computed using the function diff. For example, to find the derivative of with respect to , enter diff(e^(3*x),x). The diff function outputs a symbolic expression into which you can substitute numbers. If you would prefer to have a function as the answer, use fp(x)=diff(e^(3*x),x).
What is the derivative of at ?
Use diff to create an animation showing the tangent line to a function at different points, like the one at http://en.wikipedia.org/wiki/File:Graph_of_sliding_derivative_line.gif. (You don’t need to make the line change color.)