Implicit Plots and Derivatives

Copyright 1999
Department of Mathematics
University of Georgia
Athens, Georgia

John Gosselin

In this project you will learn how to use some powerful graphing tools of Maple that allow one to visualize curves in the plane that are defined as solution sets of equations of the form   F(x,y) = 0 .  Here F(x,y)   is an expression that depends on the two variables  x  and  y.  Perhaps the most common example is the case of a circle   x^2+y^2 = 1  ; that is,   x^2+y^2-1 = 0 .  The circle of radius  1  centered at the origin is the solution set of the equation   F(x,y) = 0   where   F(x,y) = x^2+y^2-1 .

Implicit Plots

To plot the solution set of an equation, you must first load the plots  package:

>    restart:with(plots):

You then use the  implicitplot  command:

>    implicitplot(x^2+y^2=1,x=-2..2,y=-2..2);

Notice that the graph does not look like a circle. This is because the scales are different on the vertical and horizontal axes. To deal with this issue, you can add the option scaling=constrained:

>    implicitplot(x^2+y^2=1,x=-2..2,y=-2..2,scaling=constrained);

Also notice that even though we specified our window as -2<x<2 and -2<y<2, Maple  automatically cut down the window to a smaller window containing the curve being plotted.

To plot more than one curve, simply enter the equations as a set within braces in the implicitplot command:

>    implicitplot({x^2+y^2=1,x^2-y^2=1/4},x=-2..2,y=-2..2,color=blue,scaling=constrained);

You can easily plot a family of curves with the help of the sequence command:

>    implicitplot({x^2+y^2=1,seq(x^2-y^2=2/c,c=1..6)},x=-2..2,y=-2..2,color=green,scaling=constrained);

To find points of intersection of two curves in the plane, we use the solve  command for a system  of equations.  In order to solve the equations numerically, we enter at least one number with a decimal.  For example to find the points of intersection of the curves x^2+y^2 = 1  and x^2-y^2 = 1/4 , we type

>    solve({x^2+y^2=1.0,x^2-y^2=1/4},{x,y});

We could plot these two curves and display the first-quadrant  point of intersection:

>    with(plottools):pt:=point([.7905694151,.6123724357],color=navy,symbol=circle):
curves:=implicitplot({x^2+y^2=1.0,x^2-y^2=1/4},x=-1.5..1.5,y=-1.5..1.5,color=red):
display(curves,pt);

If an implicit plot looks jagged, sometimes it can be improved by changing the grid  option.  This option specifies how many points along the x and y axes are used to generate a grid in the plot window.  The default value is 25 points in each direction.

>    implicitplot(x^3-6*x*y+y^3,x=-2..6,y=-2..6);

You should compare this plot with the following:

>    implicitplot(x^3-6*x*y+y^3,x=-2..6,y=-2..6,grid=[75,75]);

>   

Implicit Differentiation

Many curves that arise as the solution set of an equation   F(x,y) = 0   have tangent lines at most points.  To find the slope of such a tangent line, you must differentiate the expression   F(x,y)    implicitly.   Normally we want to differentiate  y  with respect to  x,  but we could also differentiate  x  with respect to  y.  To find the implicit derivative of  y  with respect to  x  for the circle   x^2+y^2 = 1 , use the command  implicitdiff .

>    restart:with(plots):

>    implicitdiff(x^2+y^2-1,y,x);

To find the implicit derivative of  x  with respect to  y  for the circle   x^2+y^2 = 1 , use the command

>    implicitdiff(x^2+y^2-1,x,y);

>   

Note the particular order of the variables after   F(x,y) .  Implicit differentiation allows us to find equations of tangent lines at particular points to curves that are defined by   F(x,y) = 0 .  Both the curve and the tangent line can be plotted together with the implicitplot  command. As an example we find the equation of  the lines tangent to the unit circle   x^2+y^2 = 1   at the points with x-coordinate   x = 1/3 .  It is clear that there are two such tangent lines.  One has its point of tangency in the first quadrant while the other has its point of tangency in the fourth quadrant.  We first determine these points by substituting   x = 1/3   in the equation   x^2+y^2 = 1   and solving for  y.

>    subs(x=1/3,x^2+y^2=1);

>    solve(1/9+y^2 = 1,y);

Thus the two points of tangency are  ( 1/3 , 2*sqrt(2)/3 )  and  ( 1/3 , -2*sqrt(2)/3 ).  We have already found   dy/dx  = -x/y   at any point  ( x, y )  on the circle   x^2+y^2 = 1   for which y is not equal to 0.

>    subs({x=1/3,y=2*sqrt(2)/3},-x/y);

>    subs({x=1/3,y=-2*sqrt(2)/3},-x/y);

Thus at  ( 1/3 , 2*sqrt(2)/3 )  we have   dy/dx  = -sqrt(2)/4   , while at  ( 1/3 , -2*sqrt(2)/3 )  we have   dy/dx  = sqrt(2)/4 .   We recall the point-slope formula   y-b = m*(x-a)   for a line passing through the point  ( a, b )  with slope   m .  Thus the equation of the tangent line at  ( 1/3 , 2*sqrt(2)/3 )  is   y-2*sqrt(2)/3 = -sqrt(2)*(x-1/3)/4   ; at ( 1/3 , -2*sqrt(2)/3 ) , the tangent line is    y+2*sqrt(2)/3 = sqrt(2)*(x-1/3)/4 .  To plot both tangent lines together with the circle we use the implicitplot  command:

>    implicitplot({x^2+y^2=1,y-2*sqrt(2)/3 = -sqrt(2)*(x-1/3)/4,y+2*sqrt(2)/3 = sqrt(2)*(x-1/3)/4},x=-2..2,y=-2..2,color=red,scaling=constrained);

It is very easy to compute higher order derivatives with the implicitdiff  command. To compute the second derivative of  y  with respect to x, d^2*y/(dx^2) , at a point on the unit circle   x^2+y^2 = 1   we enter the following command

>    implicitdiff(x^2+y^2-1,y,x,x);

The second derivative can then be calculated by substituting the coordinates of a point on the unit circle.  For example, at the point  ( 1/3 , 2*sqrt(2)/3 )  we have   d^2*y/(dx^2) = -27*sqrt(2)/32 .  Note that the fact that this second derivative is negative at this point indicates the curve is concave down near the point  ( 1/3 , 2*sqrt(2)/3 ).

>    subs({x=1/3,y=2*sqrt(2)/3},-(x^2+y^2)/(y^3));

The decimal approximation of this number is

>    evalf(subs({x=1/3,y=2*sqrt(2)/3},-(x^2+y^2)/(y^3)));

Numerically we have d^2*y/(dx^2) = -1.193242693 . To compute the third derivative of   y   with respect to x ,   d^3*y/(dx^3)  , we use the command

>    implicitdiff(x^2+y^2-1,y,x,x,x);

>    F1:=(x,y)->x^2+y^2;

>    a:=1/3;

>    eq1:=subs(x=a,F1(x,y)=1);

>    solve(eq1,y);

>    b:=2/3*sqrt(2);

>    implicitdiff(F1(x,y),y,x);

>    F2:=(x,y)->-x/y;

>    F2(a,b);

>    implicitplot({F1(x,y)=1,y-b=F2(a,b)*(x-a)},x=-2..2,y=-2..2,scaling=constrained);

>    b:=-2/3*sqrt(2);

>    implicitplot({F1(x,y)=1,y-b=F2(a,b)*(x-a)},x=-2..2,y=-2..2,scaling=constrained);

>    implicitdiff(F1(x,y),y,x,x);

>    subs({x=a,y=b},-(x^2+y^2)/(y^3));

WARNING:  If you are going to make a function of the derivative you obtain from the implicitdiff command, first let implicitdiff produce the expression and then make the assignment. If you make the assignment F2:=(x,y)->implicitdiff(F1(x,y),y,x); you will run into problems. When working with lots of variables you will need to make frequent use of the restart command.

Tip: The above example was fairly simple. When we solved for the y-values at 1/3, we were solving a quadratic and we were able to do so algebraically with the solve command. This may not always be possible and you may need to solve the equation numerically with the fsolve command. Also even if an equation can be solved exactly, the solutions may be so complicated that they are almost useless for the work you are doing. It may be advantageous to convert the solutions to decimals with the aid of the evalf command.

Project

1.   Plot the curve   x^3-4*x*y+2*y^3 = 0  as x  varies between -3 and 3  with the aid of the implicitplot  command. You may wish to set the grid to [50,50].

>    restart:with(plots):

>   

>   

>   

2.Find   dy/dx   at all points  ( x, y )  on the curve for which  

x = 1.

3. Find the equations of the lines tangent to the curve at the points you found in part 2.

4. Find   d^2*y/(dx^2)   at the same points of tangency. Explain what the values of d^2*y/(dx^2)  indicate about the graph of this curve at these points.

5. Plot the curve and the tangent lines on the same set of axes.

6. Find the coordinates of all points (if any) on the curve where the tangent line is horizontal.

7. Find the coordinates of all points (if any) on the curve where the tangent line is vertical.

Extra Credit - Contour Plots and Orthogonal Trajectories

Another tool of Maple that is closely related to the implicitplot  command is the contourplot  command.  This command generates a family of curves that are solution curves of the equation F(x,y) = c   for various values of c.  Here we consider equations of the form x^2-y^2 = c .

>    restart:with(plots):

>    contourplot(x^2-y^2,x=-5..5,y=-5..5,scaling=constrained);

Sometimes we want to explicitly give the values of c  to be used.  This is accomplished with the aid of the contours  option.

>    contourplot({x^2-y^2},x=-5..5,y=-5..5,scaling=constrained,contours=[1,4,8,12,15]);

Two families of curves   F[1]   and   F[2]   in the plane are said to be orthogonal trajectories  if whenever a curve from   F[1]   and a curve from   F[2]   intersect, they intersect at right angles--two curves intersect at right angles if their tangent lines are perpendicular at the point of intersection.  A simple example of families of  orthogonal trajectories  are circles centered at the origin and straight lines passing through the origin.

>    p:=contourplot({x^2+y^2},x=-5..5,y=-5..5,scaling=constrained):
q:=plot([seq(c*x,c=-5..5)],x=-5..5,y=-5..5,color=blue,scaling=constrained):
display({p,q});

Another example of orthogonal trajectories  is the family of curves   x^2-y^2 = c   and the family of curves   x*y = d .

>    contourplot({x^2-y^2,x*y},x=-5..5,y=-5..5,scaling=constrained,
contours=[-3,-2,-1,1,2,3],grid=[50,50]);

1. State a condition in terms of the derivatives   dy/dx   that will ensure that two families   F[1]   and   F[2]   of curves are orthogonal trajectories of each other.  Use the implicit differentiation tool to verify that the family of curves   x^2-y^2 = c   and   x*y = d , where c  and d  are constants, are orthogonal trajectories of each other.

2. Use your condition to verify that the family of curves x^3+y^3 = c  and 1/x-1/y = d  ,where c  and d  are constants, are orthogonal trajectories of each other.

3. Use the contour plot command to graph some of the curves from each of the above families on the same coordinate axes.

It is important to set the option scaling = constrained  in the contourplot  command in order to see the curves intersecting at right angles. If the contours look jagged, somethimes the plot can be improved by adding the option grid=[a,a] where a is an integer between 1 and 100. The choice a = 50 is moderate. Setting the grid to a higher value will make the computer take a little longer to generate the plot.

The Most Common Maple Commands

Academic Honesty Statement:

Place the following statement (by copying and pasting) at the end of your report and sign it in ink.  Your instructor will not grade your report unless this signed statement appears at the end of your report.

I understand that I may work with others if I give them credit in this statement.  I also understand that I am required to write my report--that to copy all or part of someone else's report or to allow someone else to copy all or part of my report constitutes plagiarism, which is a serious violation of academic honesty.

I worked with (replace this parenthetical remark with first and last names of those with whom you worked)  on this project.  I wrote my own report.  I did not copy any of this report from anyone else and I did not allow anyone else to copy any of this report.

Signed: