next up previous
Next: About this document ... Up: lab_template Previous: lab_template

Subsections


Implicit Differentiation

Purpose

The purpose of this lab is to give you experience using Maple to compute derivatives of functions defined implicitly.

Background

Implicit Differentiation

The implicitdiff command can be used to find derivatives of implicitly defined functions. Suppose we wanted to use implicit differentiation to find $\displaystyle \frac{dy}{dx}$ for the relation

\begin{displaymath}x^2y^2+y^3=0 \end{displaymath}

Then we first define our relation and give it a label for later use.
> f:=x^2*y^2+y^3=0;
The syntax of the implicitdiff command is shown by the following example.
> implicitdiff(f,y,x);

The result of the command is the implicit derivative, $\displaystyle \frac{dy}{dx}$. The syntax of this command is very similar to that of the diff command. The first argument is always the relation that you want to differentiate implicitly. We were careful to use an equation for this argument, but if you just give an expression for this argument, Maple assumes you want to set this expression equal to zero before differentiating. The second argument to the implicitdiff command is where you tell Maple what the dependent variable is. That is, by putting y here, we were saying that we were thinking of this relation as defining $y(x)$ and not $x(y)$. The remaining arguments to implicitdiff are for specifying the order of the derivative you want.

Second derivatives can also be computed with implicitdiff. The following command computes $\displaystyle\frac{d^2y}{dx^2}$.

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

To compute numerical values of derivatives obtained by implicit differentiation, you have to use the subs command. For example, to find the value of $\displaystyle \frac{dy}{dx}$ at the point $(1,-1)$ you could use the following command.

> subs({x=1,y=-1},implicitdiff(f,y,x));

Suppose you wanted to find the equation of the tangent line to the graph of $f$ at the point $(1,-1)$. You may want to label the output to $\displaystyle \frac{dy}{dx}$ at the point $(1,-1)$ as $m$ for slope and then you can use the point-slope form of a line to get the equation of the tangent line. The Maple commands below show how this can be done.

> m:=subs({x=1,y=-1},implicitdiff(f,y,x));
> tanline := y-(-1)=m*(x-1);
> implicitplot({f,tanline},x=0..2,y=-2..0);

Now suppose, using the same relation $f$, you want to find the $(x,y)$ location of horizontal tangents. The implicit derivative involves both variables $x$ and $y$, so you would need to solve for them simultaneously. When solving for two variables, two equations are needed. The two equations would be where the derivative is zero and the original relation. You would need to have a rough estimate as to where the horizontal tangents occur so that you can use fsolve in a range of $x$ and $y$ values. Maple will give you an $x$ and a $y$ solution, but a horizontal line is of the form $y=c$, so only the $y$ solution is needed. This can be done in Maple as follows:

> der:=implicitdiff(f,y,x);
> a:=fsolve({f,der=0},{x=-1..1,y=-1..1});
> implicitplot({f,y=a[2]},x=-1..1,y=-1..1);

Sometimes you want the value of a derivative, but first have to find the coordinates of the point. More than likely, you will have to use the fsolve command for this. However, to get the fsolve command to give you the solution you want, you often have to specify a range for the variable. Being able to plot the graph of a relation can be a big help in this task, so we now describe the implicitplot command. This Maple command for plotting implicitly defined functions is in the plots package which must be loaded before using the command.

> with(plots):
Here is an example of using this command to plot the hyperbola $x^2-y^2=1$. Note that you have to specify both an $x$ range and a $y$ range. This is because the implicitplot command works by setting up a grid inside the ranges you specify and then using the grid points as starting values in solving the relation numerically.
> implicitplot(x^2-y^2=1,x=-3..3,y=-3..3);
To get a good graph with this command, you usually have to experiment with the ranges. For example the following command
> implicitplot(f,x=-1..1,y=1..2);
produces an empty plot. The reason is simply that there are no solutions to $x^2y^2+y^3 = 0$ with $y > 0$. This is easy to see if you rewrite the equation as $x^2y^2= -y^3$ and recognize that both sides of the equation must be nonnegative. Usually a good strategy to follow is to start with fairly large ranges, for example $-10$ to $10$ for both variables, and then refine them based on what you see.

This command can also have problems if the relation in question has solution branches that cross or are too close together. For example, try the following command.

> implicitplot(f,x=-1..1,y=-1..0);
For $y$ less than about $-0.2$, you should see the two smooth curves. However, for values of $y$ closer to zero the two curves become jagged. To understand this, we need to take a closer look at the relation we tried to plot. The key is to notice that we can factor out $y^2$ and write our relation as follows.

\begin{displaymath}y^2 (x^2+y) \end{displaymath}

This makes it clear that the graph of the relation really has two pieces: $y=0$ and $y=-x^2$. These two curves intersect at the origin, which explains why implicitplot has problems there.

As our last example, consider the relation $x^2 \sin(y)=1$. Try the following commands to see what a part of the graph of this relation looks like.

> g := x^2*sin(y)=1;
> implicitplot(g,x=-4..4,y=-10..10);
Suppose you were asked to find the slope of the graph of this relation at $x=2$, but you were only given that the value of $y$ was about 9. Using the plot, it is relatively easy to find this derivative by first using fsolve to find the $y$ value and then substituting into the formula for the derivative. Note the use of a label so we can use the value of $y$ in the next command.
> y_sol := fsolve(subs(x=2,g),y=8..10);
> evalf(subs({x=2,y=y_sol},implicitdiff(g,y,x)));

Exercises

  1. Plot the graph of the relation $\displaystyle 2x^2y^2-xy^2+\frac{x^3}{3}=1$ over the interval $-5 \leq x \leq 5$ and $-5 \leq y \leq 5$. Find all $y$ values when $x=-1$. Find the slope of the relation when $x=-1$ and $y$ is positive.

  2. Given the relation $\displaystyle x^2y-\frac{xy^2}{2}-x=1$,
    1. Plot the graph of the relation over the interval $-5 \leq x \leq 5$ and $-5 \leq y \leq 5$. Find the $y$ values when $x=-1$?
    2. Find the slope of the graph at all points where $x=-1$ and label each slope a different variable name (ie. $m1$, $m2$,...)
    3. Find the equation of all lines tangent to the graph at $x=-1$. Be sure to label each tangent line as an implicit relation using the point-slope form of a line. Supply a plot of the relation and the tangent lines over the interval $-5 \leq x \leq 0$ and $-5 \leq y \leq 5$.

  3. For the ellipse $\displaystyle x^2-xy+y^2=9$, find the location of all horizontal tangent lines and plot them implicitly on the same graph as the relation over the interval $-5 \leq x \leq 5$ and $-5 \leq y \leq 5$. (Hint: Remember that a horizontal line is of the form $y=c$, where $c$ is some constant value.)


next up previous
Next: About this document ... Up: lab_template Previous: lab_template
Dina J. Solitro-Rassias
2010-09-23