Lab 3: Secant and Tangent Lines



SageMath has the ability to compute the limits of certain functions. For example, to compute \( \lim\limits_{x \to 1} \dfrac{x^2-2x+1}{x-1} \) you would type:

f(x)=(x^2-2*x+1)/(x-1)
limit(f(x), x=1)

Try this in the SageMath cell below.  


3a. We can use the limit command in SageMath to verify our answer to Question 2b. Recall that the slope of the secant line of \( f(x) \) from \( x = a \) to \( x = b \) is given by \[ m_{\mathrm{sec}} = \frac{f(b) – f(a)}{b – a} \] If we fix a particular value of \( a \), say \( a = 1 \), this becomes a function of \( b \). In this case, we can define the function m(b)=(f(b)-f(1))/(b-1) and take the limit as \( b \) approaches \( a \). Use the SageMath cell below to compute this limit for the function \( f(x) \) assigned in your lab report. Don’t forget to define \(f(x)\) before defining \( m(b) \).


Name:

3b. The computation you did in the previous question was computing the derivative of \( f(x) \) at \( x = 1 \) using the limit definition of the derivative. SageMath can compute derivatives directly. For example, to compute \( f'(3) \), we define \( f(x) \), then write

df(x)=diff(f,x)
df(3)

Use the SageMath cell below to compute \( f'(1) \) for the function \( f(x) \) assigned in your lab report.


Name:

3c. Find the equation, in point-slope form, of the line passing through \( (1, f(1)) \) with slope equal to the result from Question 3b. Record your answer in your lab report.


3d. Define a function \( g(x) \) to be the line from Question 3c (that is, solve for \( y \), then replace \( y \) with \( g(x) \)). Plot \( f(x) \) and \( g(x) \) together on the interval \( 0 \le x \le 5 \).


Name:
Skip to toolbar