Project 6 PDF

Title Project 6
Course Calculus Computer Laboratory
Institution College of Staten Island CUNY
Pages 7
File Size 259.4 KB
File Type PDF
Total Downloads 61
Total Views 130

Summary

Project 6 using matlab...


Description

Display grades

4/25/18, 9*48 PM

Figure 1 shows that graph of f(x)=xx over the interval [0,2] along with three lines which go through the point (0.6,f(0..6)). The tangent line is drawn to have slope given by f¢(x) evaluated at 0.6. The secant lines are drawn to have slope which depends on a specified value of h. For instance, when h=1 the slope is f(0.6 + 1) - f(0.6)

2.1213-0.7360 =

= 1.3852.

1

1

Clearly this is not close to the derivative, since the slope of this secant line is not close to the slope of the tangent line. We don't expect it to be, as h is not close to 0. Taking values of h getting closer to 0 allows us to approximate the derivative at 0.6: >> c = 0.6; h = [1.0 0.1 0.01 0.001 0.0001]; >> y = ( (c+h).^(c+h) - c^c ) ./h; >> [h; y]' ans = 1.0000 1.3852 0.1000 0.4303 0.0100 0.3671 0.0010 0.3607 0.0001 0.3601 We'll take the value f¢(0.6) = 0.3601 as the approximate derivative. This is about as good as we can get before learning how to find the actual derivative algebraically. The same approach to finding limits can be done for many x values at once. This allows us to graph an approximation to the actual derivative of a function f. As well, we'll see how to plot an approximate second derivative. We emphasize that these are approximate, as we will use a fixed value of h, which although small, is still not "going to" 0. 2 The derivative at a point Exercise 1: Let f(x) = sin(x2). We wish to find the derivative of f when x = p/4. 1. Make a function m-file storing the function f(x)=sin(x2) with name f.m. What are the contents of the file: You function y=f(x) received y= sin(x.^2); 100% of 10 points.

2. Take h=0.1 and find the slope of the secant line at (x,f(x)): p p f( + h) - f( ) 4 4 . h Enter a number

file:///Users/shawnabraham/Downloads/ALL%20CALC%20MATLABS/Calc%201%20Matlab/matlab%20project%206.htm

Page 2 of 8

Display grades

4/25/18, 9*48 PM

You received 1.2760 100% of 10 points.

3. Take smaller values of h to find a better approximation to f¢(p/4) (Four decimal points of accuracy is good.) Enter a number You received 1.2813 100% of 10 points.

Exercise 2: We will see how the secant line approaches the tangent line for the function f(x) = sin(x) at the point x1=p/4. Do this by following this sequence of steps. When you are done you will upload your graph to show your work. A secant line is just a line drawn between two points on the graph of f(x), where one of the points is the point of interest like x1=p/4 in this example. The second point can be called x2, but we prefer to emphasize its relationship to x by writing x2 = x+h where h then is the distance between the two points. 1. Make a function m-file storing the function f(x)=sin(x) with name f.m. What are the contents of the file: You function y=f(x) received y=sin(x); 100% of 10 points.

2. Graph f(x) over the interval [0,p]. 3. Let h=p/2. On your graph, add the secant line connecting the points x1=p/4 and x2 = x1+h = 3p/4. The following commands will help you plot such a line. >> >> >> >>

x1=pi/4; h = pi/2; x2 = x1+h; m = (f(x1+h)-f(x1)) / h ; plot(x, f(x1) + m*(x-x1)) % point-slope form of line plot(x2,f(x2),'*') % mark the point

What is the slope of this secant line? Enter a number

file:///Users/shawnabraham/Downloads/ALL%20CALC%20MATLABS/Calc%201%20Matlab/matlab%20project%206.htm

Page 3 of 8

Display grades

4/25/18, 9*48 PM

You received 7.0679e-017 100% of 10 points.

4. For h=0.1, and h=0.001 draw the secant line as above. Label the different secant lines with the value of h. 5. The tangent line at x1 = p/4 has slope Ö2/2. Plot the tangent line on the same graph in a different color and label it. 6. Submit the graph of Example 1. Upload your image file here. Consult the manual for more information. You received Choose File no file selected 100% of 10 points.

UPLOAD YOUR FIGURE

An upload file has been saved. Click here to see it.

7. Explain carefully the relationship between h and slope of the secant lines for h. In particular, what is the limit of these slopes as h gets closer to 0? You The relationship between h and the slope of the seacant lines for h is received directly related. The slope of the seacant line approaches the slope of the tangent line as h gets closer to zero. 100% of 10 points.

3 Derivative of a Function We've seen that the derivative of f(x) at c is approximately given by (f(c+h) -f(c))/h for small values of h. To find the derivative of a function for many x values at once, we simply fix a single small value of h, and use many values for c. We call this approximate derivative the difference quotient: f(x+h)-f(x) difference quotient =

small h. h

Example 1: (Graphing the difference quotient) Let us create a plot of the derivative of f(x)=cosx over the interval [0,2p] based on the numerical evaluation of its difference quotient. We shall use h=0.01 in evaluating the difference quotient. The following MATLAB commands will plot both the function and its approximate derivative together over the file:///Users/shawnabraham/Downloads/ALL%20CALC%20MATLABS/Calc%201%20Matlab/matlab%20project%206.htm

Page 4 of 8

Display grades

4/25/18, 9*48 PM

interval [0,2p]. >> >> >> >>

h=0.01; % a small value for h x=linspace(0,2*pi); % lots of x values difquo=(cos(x+h)-cos(x))./h; % difference quotient. Or use an m-file plot(x,cos(x),'r',x,difquo,'b'),grid % plot cos in red and difquo in blue

Exercise 3: Have a close look at the resulting graphs of Example 2. Identify which is the graph for cos(x) and which is the graph for difquo. 1. Does the graph of difquo resemble the graph of a function that you are familiar with? Select exactly one of the choices. You received 100% of 10 points.

sinx

-sinx

cosx

-cosx

2. Based on your answer to part 1, what do you think is the derivative of y=cosx? Select exactly one of the choices. You received 100% of 10 points.

sinx

cosx

-cosx

-sinx

Exercise 4: It is known that the derivative of the function f(x)=x3/2+5 is given by f¢(x)=3/2Öx. We will verify that the difference quotient converges to this function as h goes to 0 over the interval [0,2] 1. Write an m-file storing the definition of f(x). List its contents here: You function y=f(x) received y=x.^(3/2)+5; 100% of 10 points.

2. For h=0.1 make a graph of the difference quotient and the derivative. What is the largest difference between the two functions? Enter a number

file:///Users/shawnabraham/Downloads/ALL%20CALC%20MATLABS/Calc%201%20Matlab/matlab%20project%206.htm

Page 5 of 8

Display grades

4/25/18, 9*48 PM

You received 0.3162 100% of 10 points.

3. On the same graph, plot the difference quotient for h=0.001. What is the maximum difference now between the difference quotient and the derivative function? Enter a number You received 0.0316 100% of 10 points.

Exercise 5: Numerical differentiation of exponential function You may not know the derivative of f(x) = ex and g(x) = ln(x) at this point. Let's use the difference quotient to figure out the derivative of ex. 1. Use MATLAB to create a continuous plot of f(x)=ex over the interval -2 £ x £ 2. Based on this graph, which of the following should be true about the derivative. Select one or more of the choices. You received 100% of 10 points.

f(x) is always increasing so f¢(x) > 0. Tangent lines for f(x) are never 'flat' so there are no critical points. f(x) increases faster and so f¢(x) should be increasing

2. On top of the graph of f(x), create a plot of the difference quotient of f(x) using h=0.01 over the same interval [-2,2] in a different color. Turn in your graph. Upload your image file here. Consult the manual for more information. You received Choose File no file selected 100% of 10 points. An upload file has been saved. Click here to see it.

3. Based on the two plots, what do you think the derivative of f(x)=ex is. file:///Users/shawnabraham/Downloads/ALL%20CALC%20MATLABS/Calc%201%20Matlab/matlab%20project%206.htm

Page 6 of 8

Display grades

4/25/18, 9*48 PM

Select exactly one of the choices. You received 100% of 10 points.

xe

logx

x2

ex

4 The approximate second derivative The second derivative is approximated in a similar way as the first derivative is approximated. A common approximation is given by f(x+h) - 2f(x) + f(x-h) .

difdifquo = h2

It can be checked that as h approaches 0, the difdifquo (for lack of a better name) converges to f"(x). Using an m-file makes it easier to find the approximate second derivative. For instance, the following example will plot a function f(x) and its approximate second derivative over the interval [0,1]. It just needs an m-file defining the function f. >> x = linspace(0,1); % adjust for your problem >> h = 0.01; % a small enough number? >> plot(x,f(x),x,(f(x+h) - 2*f(x) + f(x-h))/h^2,'g'),grid That's it. Exercise 6: We wish to graph the function f(x) = ex/3 sin(px). 1. Write an m-file that evaluates this function. Call your m-file f.m. You function y=f(x) received y=exp(x./3).*sin(pi*x); 100% of 10 points.

2. Make a plot of f(x) over the interval [0,3]. 3. Using h=0.01 compute the difference quotient for x in the interval [0,3]. Write down the commands to find the difference quotient and add its graph to the graph of f(x). You x=linspace(0,3); received h=0.01; 100% difquo=(f(x+h)-f(x))./h; of 10 points.

file:///Users/shawnabraham/Downloads/ALL%20CALC%20MATLABS/Calc%201%20Matlab/matlab%20project%206.htm

Page 7 of 8

Display grades

4/25/18, 9*48 PM

4. Again using h=0.01, find the approximate second derivative (difdifquo) and add its plot to your plot of the function. What are the commands you used to find difdifquo? You difdifquo=(f(x+h)-2*f(x)+f(x-h))/(h^2); received 100% of 10 points.

5. Use an arrow to label any zeroes of the approximate first derivative on your graph. What can you say about the graph of f(x) near these x values? You The graph of f(x) shows a relative minimum or maximum near the zeros of the first received derivative. 100% of 10 points.

6. Submit your three graphs in one figure with the requested annotations. Upload your image file here. Consult the manual for more information. You received Choose File no file selected 100% of 10 points. An upload file has been saved. Click here to see it.

Powered by e-Pupils. Copyright © 1998-2001. All rights reserved.

file:///Users/shawnabraham/Downloads/ALL%20CALC%20MATLABS/Calc%201%20Matlab/matlab%20project%206.htm

Page 8 of 8...


Similar Free PDFs