Rates of Change¶
[1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Slope and Rate of Change¶
| t | speed |
|---|---|
| 1 | 4 |
| 4 . | 10 |
| 8 | 12 |
[2]:
#rate of change from 1 to 4?
[3]:
#rate of change from 4 to 8?
Secant¶
[15]:
def f(x): return x**2
x = np.linspace(0, 3, 100)
plt.figure(figsize = (15, 5))
plt.plot(x, f(x))
plt.plot([1, 3], [f(1), f(3)], '-o', label = '(0, 3)')
plt.plot([1, 2], [f(1), f(2)], '-o', label = '(0, 2)')
plt.plot([1, 1.1], [f(1), f(1.1)], '-o', label = '(0, 1)')
plt.legend()
[15]:
<matplotlib.legend.Legend at 0x122a25190>
Definition of Derivative¶
Use this definition (and show work) to determine the derivative of:
- \(f(x) = 7x + 6\)
- \(f(x) = 4x^2 - 3x + 8\)
[ ]:
[ ]:
[ ]:
[ ]:
Writing a Derivative Function¶
The function below will compute the derivative of a function f at some point x. We are really approximating by letting h be a very small value.
[9]:
def ddf(f, x, h = 0.0000001):
derivative = (f(x + h) - f(x))/h
return np.round(derivative, 4)
[10]:
#example functions
def f(x):
return x**2
[23]:
#value of f at x=3
f(3)
[23]:
9
[24]:
#derivative of f at x=3
ddf(f, 3)
[24]:
6.0
[26]:
a = 3
print(f'The slope of the tangent line to f at x = {a} is {ddf(f, a)}')
The slope of the tangent line to f at x = 3 is 6.0
[12]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
[31]:
#plot the function and derivative together
x = np.linspace(-4, 4, 1000)
plt.plot(x, f(x), label = '$f$')
plt.plot(3, f(3), 'o',label = "$f(3)$")
plt.legend(fontsize = 20)
plt.title('Write an equation for the line through the point (3, 3)\ntangent to $f$.');
[ ]:
[ ]:
[ ]:
[ ]:
[30]:
#problem 2
def f(x): return -x**2 + 1
x = np.linspace(-4, 4, 1000)
plt.plot(x, f(x), label = '$f$')
plt.plot(-1, f(-1), 'o',label = "$f(3)$")
plt.legend(fontsize = 20)
plt.title('Write an equation for the line through the point (-1, -1)\ntangent to $f$.');
[ ]:
[ ]:
[ ]:
[ ]:
Describe a general procedure for writing an equation for the line tangent to the graph of \(f\) at some point \(x = a\). This should culminate in an expression for the line in terms of \(f\) and \(f'\).
[ ]:
[ ]:
[ ]:
[ ]:
[ ]:
[ ]:
Power Rule¶
In general, we can compute the derivative of a given polynomial function using the power rule that states:
Use the power rule to evaluate the derivative of the following functions:
- \(f(t) = 2t^5 - 7t^3 + 4t^2 - 6t + 1\)
- \(g(t) = 3t^4 - t^3 + 7t^2 - t + 17\)
[ ]:
[ ]:
[ ]:
[ ]:
Problem: Sequences¶
In derivatives, we find the following two patterns:
- \(f(x) = mx + b \rightarrow \quad f'(x) = m\)
- \(f(x) = ax^2 + bx + c \rightarrow \quad f'(x) = 2ax + b\)
Rephrase these symbolic statements in your own words. Should we have expected these results? What do they have to do with the sequences:
- 1, 3, 5, 7, 9, 11
- 1, 4, 9, 16, 25, 36
[ ]:
[ ]:
[ ]:
[ ]:
[ ]: