Sei sulla pagina 1di 4

Math 175 Matlab Worksheet 7: Functions Defined Implicitly

Introduction:
Background: (Refer to the text, Section 3.6)
dy
You have discussed a process, called implicit differentiation, to find the derivative for a function y = f (x)
dx
defined implicitly by an equation F(x, y) = 0 . In this worksheet, you will use Matlab to examine graphs and
tangent lines for the functions defined implicitly by F(x, y) = 0 .

Matlab Hints:
You cannot use the “plot” command unless a function is defined explicitly as y = f (x) . You will need two new
commands: meshgrid and contour.
• The meshgrid command sets up an array of pairs of x and y values.
• Then the contour plot command sketches a graph through all of the points (x,y) that satisfy the equation
F( x , y) = 0 . Contained in this graph are the graphs of the functions defined implicitly by F( x , y) = 0 .
Note: Creating contour plots in general will be discussed in a multivariable calculus course.
Because the meshgrid command creates a very large number of values, you need to copy the commands given
in the problems carefully. You could have memory problems if you use a step size that is too small. Also,
remember to use a semicolon at the end to suppress the output.

Instructions:
You may bring your printed Word document to the Emporium class to be used during the quiz. Therefore it is
recommended that you:
• Number each question clearly and circle answers.
• Use Matlab-generated graphs pasted into the document.
• Show the correct Matlab input and corresponding output for each part of each problem.
• Answer all questions completely.

Use the following example to help you complete Problems 1 and 2.

(a) Graph the curve defined by 2y 3 + y 2 − y 5 = x 4 − 2x 3 + x 2 .


• First we convert the equation to the form F(x, y) = 0 . In this case, 2y 3 + y 2 − y 5 − (x 4 − 2x 3 + x 2 ) = 0
• The commands below will first create an array of (x,y) pairs for −1 ≤ x ≤ 2 and − 2 ≤ y ≤ 2 .
• Then F(x, y) = 2y 3 + y 2 − y 5 − x 4 + 2x 3 − x 2 is defined. (The array [0,0] in the contour command tells
Matlab to sketch a graph through all of the points (x,y) that satisfy the equation F(x, y) = 0 .

The default colors for contour plotting are very


light, so we added the color black ('k') to the contour
command.

>> x=-1:.1:2;
>> y=-2:.1:2;
>> [x,y]=meshgrid(x,y);
>> F=2*y.^3+y.^2-y.^5-x.^4+2*x.^3-x.^2;
>> contour(x,y,F,[0,0],'k')

Your graph should look like this:


• This graph is clearly not the graph of a function.
• There are at least two y values for each x value.
1
(b) Find to four decimal places the y-coordinates of the points on the graph that have x-coordinate x = −0.5 .
• You will need to use the fzero command.
• We can have MatLab do the work for us but it is messy.
Substitute x = −0.5 for x ; x for y and −1.3 (read from the graph) for our first estimate.
>> y1=fzero('2*x.^3+x.^2-x.^5-(-0.5)^4+2*(-0.5)^3-(-0.5)^2',-1.3)
y1 = -1.2207

So the point (−0.5, −1.2207) is on the graph of this implicit function.

Continue with 0.5 for our second estimate: Continue with 1.5 for our third estimate:

>> y2=fzero('2*x.^3+x.^2-x.^5-(- >> y3=fzero('2*x.^3+x.^2-x.^5-(-0.5)^4+2*(-


0.5)^4+2*(-0.5)^3-(-0.5)^2',0.5) 0.5)^3-(-0.5)^2',1.5)

y2 = 0.5408 y3 = 1.5781

So the point (−0.5, 0.5408) is also on the So the point (−0.5,1.5781) is also on the graph of
graph of this implicit function. this implicit function.

dy
(c) Use implicit differentiation (by hand) to calculate = y ′ . Show your work.
dx
dy 4 x 3 − 6x 2 + 2x
=
dx 6y 2 + 2y − 5y 4

(d) Write the equation of the tangent line to the graph at each of the points found in (b)

We have the points; we need the slope at these points. We KNOW the slope is the derivative so we can have
MatLab evaluate the slope for us.
>> m1 = (4*(-0.5)^3-6*(-0.5)^2+2*(-0.5))./(6*y1.^2+2*y1-5*y1.^4)
m1 = 0.6519

>> m2 = (4*(-0.5)^3-6*(-0.5)^2+2*(-0.5))./(6*y2.^2+2*y2-5*y2.^4)
m2 = -1.2455

>> m3 = (4*(-0.5)^3-6*(-0.5)^2+2*(-0.5))./(6*y3.^2+2*y3-5*y3.^4)
m3 = 0.2323

We now have the slopes. The lines are:


line1 = m1* (x − (0.5)) + y1
line2 = m2 * (x − (0.5)) + y2
line 3 = m3* (x − (0.5)) + y 3

(e) Graph the curve together with each of the tangent lines found in (d). Be sure to include your Matlab
commands. (Caution: If your tangent lines do not touch the graph at the point of tangency then the line is not the
correct tangent line.)

2
When adding the tangent lines to your graph, use the plot command and redefine an x-variable because we need
more values for the lines than the command x=-1:.1:2; gives us.

>> xc=-1:.01:2;
>> line1=m1.*(xc-(-0.5))+y1;
>> line2=m2.*(xc-(-0.5))+y2;
>> line3=m3.*(xc-(-0.5))+y3;
>> hold on
>> plot(xc,line1,xc,line2,xc,line3)

Your graph should now look like this:

We can "see" that our lines are all tangent at


x = −0.5

Problem 1:

(a) Graph the curve defined by x 2 y 2 + y 2 cos x = 3 .


• First we convert the equation to the form F(x, y) = 0 . In this case, x 2 y 2 + y 2 cos x − 3 = 0
• The commands below will first create an array of (x,y) pairs for −2 ≤ x ≤ 2 and −2 ≤ y ≤ 2 .
• Then F(x, y) = x 2 y 2 + y 2 cos x − 3 is defined. (The array [0,0] in the contour command tells Matlab to
sketch a graph through all of the points (x,y) that satisfy the equation F(x, y) = 0 .

Be careful to use the colons, semicolons, and commas exactly as you see here.

»x=-2:.1:2;
»y=-2:.1:2;
»[x,y]=meshgrid(x,y);

»F=x.^2.*y.^2+y.^2.*cos(x)-3;
»contour(x,y,F,[0,0],'k')

ƒ Is the graph you get the graph of a single function y = f (x) ? Explain.

(b) Find to four decimal places the y-coordinates of the points on the graph that have x-coordinate x = −1.

dy
(c) Use implicit differentiation (by hand) to calculate = y ′ . Show your work. Before you go on, show your
dx
derivative to the instructor to be sure that it is correct.

(d) Write the equation of the tangent line to the graph at each of the points found in (b).

(e) Graph the curve together with each of the tangent lines found in (d). Be sure to include your Matlab
commands. (Caution: If your tangent lines do not touch the graph at the point of tangency then the line is not the
correct tangent line.)

When adding the tangent lines to your graph, use the plot command.
3
Problem 2:

(a) Graph the curve defined by e x y = x 2 + y 2 .


Use the array: −3 ≤ x ≤ 3 and − 3 ≤ y ≤ 3
Note: e variable in MatLab is: exp(variable)
Be careful to use the colons, semicolons, and commas exactly as you see here.
»x=-3:.1:3;
»y=-3:.1:3;
»[x,y]=meshgrid(x,y);
»G=exp(x.*y)-x.^2-y.^2;
»contour(x,y,G,[0,0],'k')
ƒ Is the graph you get the graph of a single function y = f (x) ? Explain.

(b) Find to four decimal places the y-coordinates of the points on the graph that have x-coordinate x = 0.5.

dy
(c) Use implicit differentiation (by hand) to calculate = y ′ . Show your work. Before you go on, show your
dx
derivative to the instructor to be sure that it is correct.

(d) Write the equation of the NORMAL line to the graph at each of the points found in (b).

(e) Graph the curve together with each of the normal lines found in (d).

Potrebbero piacerti anche