The implicitdiff command can be used to find derivatives of
implicitly defined functions. Suppose we wanted to use implicit
differentiation to find
for the relation
> f:=x^2*y^2+y^3=0;
> implicitdiff(f,y,x);
Second derivatives can also be taken with implicitdiff. The following command computes .
> 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 at the point you could use the following command.
> subs({x=1,y=-1},implicitdiff(f,y,x));
> with(plots):Here is an example of using this command to plot the hyperbola . Note that you have to specify both an range and a 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 with . This is easy to see if you rewrite the equation as 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 to for both variables, and then refine them based on what you see.
Here is an example of finding the two points on the graph of the relation where the tangent line is horizontal. The first step is to plot the graph using implicitdiff so that you can approximately the locations of the points where the tangent line is horizontal. Then you use the fsolve command to find the points in question.
> g := x^2+y^2-y+x/2=2;
> implicitplot(g, x=-2..2,y=-2..2.5);Looking at the plot, the horizontal tangents occur approximately at the two points and . To find them more exactly, we can use the fsolve command. Such points have to satisfy two conditions. The have to be on the graph and the slope has to be zero there. The following commands first compute the derivative implicitly and then find the two points using fsolve. The exact ranges you use for the fsolve command are not crucial, but you should choose them so that each includes exactly one of the solution points. If you don't do this, the fsolve command may fail to find a solution or may only find one solution.
> dg := implicitdiff(g,y,x);
> fsolve({g,dg=0},{x,y},x=-1..0,y=1.5..2.5);
> fsolve({g,dg=0},{x,y},x=-1..0,y=-1.5..-0.5);
The implictiplot 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 less than about , you should see the two smooth curves. However, for values of 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 and write our relation as follows.
As our last example, consider the relation . 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 , but you were only given that the value of was about 9. Using the plot, it is relatively easy to find this derivative by first using fsolve to find the value and then substituting to into the formula for the derivative. Note the use of a label so we can use the value of in the next command.
> y_sol := fsolve(subs(x=2,g),y,y=8..10);
> evalf(subs({x=2,y=y_sol},implicitdiff(g,y,x )));