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.
Exercise 1. Evaluate the cell in your turn-in sheet that contains the function weird_function()
and run the command h(x)=weird_function()
to create a random function called .
Exercise 2. 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 .
Exercise 3. Create a list of average rates of change for for values of 1, 0.1, 0.01, and 0.001. That is find the average rate of change between and . (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 ? Please make sure you get decimal answers.
The rate of change of a function at a point is called its instantaneous rate of change at that point.
Exercise 4. 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.
Exercise 5. 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.
Exercise 6. Repeat this procedure for . What is this function's rate of change at ?
Exercise 7. 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 is a built-in symbolic variable.
Exercise 8. Compute .
Exercise 9. 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.
Exercise 10. Factor .
Exercise 11. 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.
Exercise 12. 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. Execute the cell below to see the issue.
Exercise 13. Why is the horizontal line rather than some other value of ?
To fix this problem, just declare to be a symbolic variable again.