Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
179 views
ubuntu2004
Kernel: SageMath 9.3

MAT 150, Spring Quarter 2023

Name: (type your name here)



Lab 1: Slopes and Difference Quotients

Instructions: Follow the prompts and respond to all questions. Be sure to use clear and logical explanations with good grammar and punctuation. Refer to the "15X Lab Guidelines" handout for tips and to see what's expected for the lab report. Collaboration with your classmates is encouraged, but you must do your own lab report in your own words.

In this lab, we are going to look at secant lines and tangent lines related to certain functions ff. To be more specific, suppose hh is some small number (positive or negative, but not zero). We'll find the equation for the secant line that passes through a fixed point P=(a,f(a))P=(a,f(a)) and a nearby point Q=(a+h,f(a+h))Q=(a+h, f(a+h)). The slope of this secant line is

m=ΔyΔx=f(a+h)f(a)a+ha=f(a+h)f(a)hm= \frac{\Delta y}{\Delta x} = \frac{f(a+h)-f(a)}{a+h-a} = \frac{ f(a+h)-f(a)}{h}

and the equation of the secant line is

y=m(xa)+f(a)y=m(x-a)+f(a)

Note that the slope mm, and hence the equation of the secant line, depends on the choice of the (small) number hh! To find a tangent line, we take a limit as h0h\to 0. With the computer we won't be computing this limit exactly, but we can investigate it by examining smaller and smaller hh values, like h=±0.1,±0.01,±0.001,h=\pm 0.1, \pm 0.01, \pm 0.001, and so on.


Core code: Run the following cell each time you open this lab to work on it.

f(x) = 3*(x-1)^2-x+3 def Qpt(h): return point((1+h,f(1+h)),size=20,color='red') m(h)=(f(1+h)-f(1))/h secline(h)=m(h)*(x-1)+f(1) def Niceplot(h): return P + Qpt(h) + plot([f(x),secline(h)],0,2.3, legend_label='automatic') P2=point((0,1),size=20,color='black') def Qpt2(h): return point((0+h,cos(0+h)),size=20,color='red') m2(h)=(cos(0+h)-cos(0))/h secline2(h)=m2(h)*(x-0)+cos(0) def Niceplot2(h): return P2 + Qpt2(h) + plot([cos(x),secline2(h)],-pi/2,pi/2, ymax=1, legend_label='automatic') P3=point((0,1),size=20,color='black') def Qpt3(h): return point((0+h,2^(0+h)),size=20,color='red') m3(h)=(2^(0+h)-2^(0))/h secline3(h)=m3(h)*(x-0)+2^(0) def Niceplot3(h): return P3 + Qpt3(h) + plot([2^x,secline3(h)],-1,2, ymin=0, ymax=3, legend_label='automatic') P4=point((0,1),size=20,color='black') def Qpt4(h): return point((0+h,3^(0+h)),size=20,color='red') m4(h)=(3^(0+h)-3^(0))/h secline4(h)=m4(h)*(x-0)+3^(0) def Niceplot4(h): return P4 + Qpt4(h) + plot([3^x,secline4(h)],-1,2, ymin=0, ymax=3, legend_label='automatic') def Explot(b): tanline=diff(b^x,x)(x=0)*x+1 return plot([x+1,tanline,b^x], -1,2, ymin=0, ymax=3, legend_label='automatic',color=['red','green','blue'])

Problem 1

This problem will investigate the slope of the tangent line to f(x)=3(x1)5x+3f(x)=3(x-1)^5-x+3 at x=1x=1.

(a) The following code cell defines the function ff. Run it, and then run the next two cells to verify that f(1)=2f(1)=2 and f(2)=4f(2)=4.

f(x) = 3*(x-1)^2-x+3
f(1)
2
f(2)
4

(b) Now let P=(1,2)P=(1,2) and Q=(2,4)Q = (2,4). We just learned that both of these points are on the graph of f(x)f(x). The point PP is the one we really care about, since that's where we want the slope. Think of QQ as a "nearby point" that we're about to move around, and eventually move closer and closer to PP.

On paper, find the equation of the line between PP and QQ, and write your result in standard "y=y=\cdots" form. Your answer should agree with the function called line1\mathtt{line1} defined in the next cell, which you should now run.

line1(x) = 2*x

Use the code below to plot the curve y=3(x1)5x+3y=3(x-1)^5-x+3 and your line together, for 0x2.30\leq x\leq 2.3. Describe what you see, including what you see in the legend. Which point is P and which point is Q?

P = point((1,2),size=20,color='black') Q = point((2,4),size=20,color='red') P+Q+plot([f(x),line1(x)],0,2.3, legend_label='automatic')
Image in a Jupyter notebook

Point P is the point at the bottom of the blue curve, where x=1 and y-2. Point Q is at where x=2 and y=4 on the right of the blue curve. These two points mark where the equations intersect at two different places on the graph.

(c) The cool thing about coding with a sophisticated programming environment like this is that we can bundle up all of our commands. This next function plots everything in terms of the parameter hh only. Run the following two cells to see our curve and secant line corresponding to h=1h=1 and h=.2h=.2. Describe what you see. What's different about the two graphs? What is the effect of taking a smaller number like .2.2 for hh?

The two graphs have different slopes, but always cross the curve at the point (1,2). The smaller number of h causes the slope of the line to change, the decimal making it a negative slope over a positive one.

Niceplot(1)
Image in a Jupyter notebook
Niceplot(0.2)
Image in a Jupyter notebook

(d) Now, we can get really fancy here with just a couple of lines of code. Run the following cell and play around a little bit with the output, and describe the results.

@interact def slides(h=slider(vmin=-1, vmax=1, step_size=0.001, default=1, label='h', display_value=True)): show(Niceplot(h),xmin=0,xmax=2.5,ymin=0,ymax=6)
Interactive function <function slides at 0x7f39981b6820> with 1 widget h: TransformFloatSlider(value=1.0, de…

(e) Finally, let's sum up what is happening for the function ff near the point PP. Based on your evidence so far by playing around with the "Niceplot(h)" function when hh is very small, what do you think the equation of the tangent line at point PP ought to be?

When changing the h function, it seems that all lines on the graph with intersect with the curve at the same point, at point P. Based on my evidence thus far, I would guess that the equation for the tangent line would be y=-+3.


Problem 2

This problem will investigate the tangent line to the function cos(x)\cos(x) at the point P=(0,1)P=(0,1).

(a) First things first, let's just look at the plot of the cosine function on [π/2,π/2][-\pi/2,\pi/2]. Why do you think we've chosen such a small interval here, as opposed to graphing more of the cosine function so you can see it wave back and forth as usual?

I think you chose a small interval so we can focus on the single curve in the graph as opposed to the whole thing, and so we can see larger changes made between very small numbers.

plot(cos(x),-pi/2,pi/2)
Image in a Jupyter notebook

(b) Now we are going to mimic our investigation from Problem 1. Run the following to plot a secant line. What is the value of hh here? What is the "nearby point" that we're taking the secant line through?

Niceplot2(1.0)
Image in a Jupyter notebook

The value of h here is 1. The nearby point is the point at (1, 0.75(ish)).

(c) Use the code cell below to run "Niceplot2" a few times with various values of hh to get a feel for the situation. What is the difference between using h=1h=1 and using h=1.0h=1.0?

Niceplot2(1.2)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-3-243aec4d3eb5> in <module> ----> 1 Niceplot2(RealNumber('1.2')) NameError: name 'Niceplot2' is not defined

Using both 1 and 1.0 at h gives us the same slope, but the equation is written out in the equation for the line while using 1, and for using 1.0, cosine is used in the equations.

(d) Now for fun we can go ahead and play with the interactive cell with a slider below. Comment on what you observe here.

@interact def slides2(h=slider(vmin=-1, vmax=1, step_size=0.001, default=1, label='h', display_value=True)): show(Niceplot2(h))
Interactive function <function slides2 at 0x7f39980950d0> with 1 widget h: TransformFloatSlider(value=1.0, d…

At all values of h, the line will meet/touch the curve at only two places but never cross. When h is closer to 0, the line is horizontal at y=1, while when h is closer to 1, it is closer to x=1.

(e) What is the equation of the tangent line to cos(x)\cos(x) at the point (0,1)(0,1)?

The equation is y=1.


Problem 3

This problem is going to investigate tangent lines for exponential curves.

(a) What is the slope of the tangent line to the curve y=2xy=2^x at the point (0,1)(0,1)? Try smaller and smaller values of hh until you are confident your answer is correct to three decimal places.

Niceplot3(1.0)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-4-943e1473b1d1> in <module> ----> 1 Niceplot3(RealNumber('1.0')) NameError: name 'Niceplot3' is not defined

The slope of this line is 2?

(b) Now do the same for the curve y=3xy=3^x at the point (0,1)(0,1). What is the equation of this tangent line? Investigate as you did in part (a).

Niceplot4(1.0)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-5-aa366c9f837e> in <module> ----> 1 Niceplot4(RealNumber('1.0')) NameError: name 'Niceplot4' is not defined

The equation is y=3x+1.

(c) You should have found in Problem 3(a) a tangent line of slope less than one. In Problem 3(b) you should have found a tangent line of slope greater than one. This means the curve y=2xy=2^x is less steep than the line y=x+1y=x+1 at the point (0,1)(0,1), while the curve y=3xy=3^x is more steep.

Suppose we want to find a curve y=bxy=b^x, where bb is a number between 22 and 33, such that the slope at the point (0,1)(0,1) is exactly one. Use the code below to generate a dynamic plot that allows you to play with the parameter bb until you find a slope very close to one. Note that you vary both the curve and its tangent line with the slider, but the "target line" y=x+1y=x+1 is fixed in red.

@interact def slides3(b=slider(vmin=2, vmax=4, step_size=0.001, default=2, label='b', display_value=True)): show(Explot(b))
Interactive function <function slides3 at 0x7efc828848b0> with 1 widget b: TransformFloatSlider(value=2.0, d…

I cannot use this code, it is running with an error even though I have not changed any of the code that was given to me.

What is your best guess about the number bb such that the curve y=bxy=b^x has slope one at the point (0,1)(0,1)? Give your best answer to at least three decimal places. Use the command below to illustrate your best choice of bb.

Explot(PUT YOUR BEST CHOICE HERE)

Again, I cannot use this code, it is running with an error even though I have not changed any of the code that was given to me. I'm sorry I am unable to complete this problem.


Summary of Lab

Here is where you write a few sentences describing that touch on

  • what this lab was about

  • what you learned

  • anything that was confusing or difficult

  • anything that was surprising or interesting

If you collaborated with other students from class, be sure to acknowledge your colleagues here as well.

This lab is about understanding tangent graphs and using points to create equations for tangent graphs. I learned about the various factors that affect the graphs, and how they are used/placed in the equations and derivatives. I found the system itself, CoCalc, to be very difficult, it is not a system that runs easily and it made completely this project especially hard. Even though I tried, I could not figure out how to fix the issues I ran into and thus could not finish properly. Ruby from class helped me with some of these problems, she is very smart and knows her stuff!

I know that problem three is incomplete, I can't figure out how to fix the errors that occurred while running the graphs, so I completed the lab with the problems and words I could see.