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

Subsections


Solving Equations and Differentiation

Solving a function or an expression algebraically

You can set an expression or function equal to another expression, function, or number inside a solve command.As an example, you may want to find where the following two parabolas intersect.
> g := 9*x^2-14;
> h:=-x^2;
> plot([g,h],x=-2..2);
> solve(g=h,x);
The plot shows that there are two intersection points and the solve command finds both $x$ values. It is good to get into the habit of naming your output so you can use it in a later command. Giving the $x$ values a name makes it easy to plug them into the expression to find the $y$ values.
> ip:=solve(g=h,x);
Since there are two $x$ values called $ip$, use [ ] to call up the one you want.
> subs(x=ip[1],g);
> subs(x=ip[2],h);
Therefore the two intersection points are $(\frac{\sqrt{35}}{5},\frac{-7}{5})$ and $(\frac{-\sqrt{35}}{5},\frac{-7}{5})$. This seems like the answer shown on the graph.

Solving a function or an expression numerically

If you want to find where the following function crosses the x-axis, just set it equal to zero.
> f:=theta->-1/2*theta+sin(theta);
> plot(f(theta),theta=-8*Pi..8*Pi);
> solve(f(theta)=0,theta);
Wow, what is that?!?! We know from the graph that there should be three answers and solve wasn't a great option so try fsolve.
> fsolve(f(theta)=0,theta);
Where are the other two answers!? This is actually how fsolve usually works. It shoots for one answer and only gives that one. But you can tell fsolve where to look by getting an idea from the graph and typing that domain into the fsolve command.
> a:=fsolve(f(theta)=0,theta=-5..-1);
> b:=fsolve(f(theta)=0,theta=-1..1);
> c:=fsolve(f(theta)=0,theta=1..5);
To find the $y$ values just plug in the names of the $x$ values.
> f(a);
> f(b);
> f(c);
(Of course the y-values are zero!)

The Derivative

The Limit Definition of the Derivative

The limit definition of the derivative of $f(x)$ often written as $f'(x)$ is defined as:

\begin{displaymath}f'(x)=\lim_{h \rightarrow 0} \frac{f(x+h)-f(x)}{h} \end{displaymath}

It can be interpreted geometrically as the slope of the tangent line to the graph of $f(x)$ at a point $x=a$ and functionally as the instantaneous rate of change of $f$ at $x=a$. You can use the definition and the Maple limit command to compute derivatives directly, as shown below. You can also compute derivatives using Maple's diff or D command. The following limit determines f'(x).
> limit((f(x+h)-f(x))/h,h=0);
The example below shows how to use the limit definition of derivative to find $f'(1)$ with Maple.
> f := x -> x^2+3*x+5;
> limit((f(1+h)-f(1))/h,h=0);

The Maple D and diff commands

These commands can be summarized as follows.

When you use the D operator to compute the derivative of a function, be careful with the parentheses. It is one of the only commands in Maple where the $f$ gets its own parentheses.

> f:=x->x^2;
> D(f)(x);
Finding the derivative at a specific $x$ value is easy. (Again be careful of the parentheses.)
> D(f)(2);

The D operator CANNOT be used on expressions. To differentiate expressions, you need to use the diff command. Here is an example.

> p:=3*x+2;
> diff(p,x);
Remember the diff command can also be applied to functions. However, the syntax for plugging in an $x$ value is a little longer with the diff command. To compute the value of the derivative at a specific value of $x$ requires you to use the subs command. First, give the diff command a name so you can call it up in the subs command.
> pprime:=diff(p,x);
> subs(x=2,pprime);
Another option is to embed the commands.
>subs(x=2,diff(p,x));

Exercises

  1. For the functions $\displaystyle f(x) = \ln(x)\cos(x-1)$ and $g(x) = \exp((x-2)/12)+0.1$, plot both functions on the same graph using an $x$-domain that clearly shows all the intersection points and then find the $x$ and $y$ coordinates of the intersection points using Maple's solving capabilities.

  2. Find the dervative of the function $\displaystyle f(x)=\frac{(x^2-3)^2}{x^4+x^2+1}$ using the limit definition of the derivative, the diff command and then the D command and then use all three methods to find the slope of $f$ at $x=-5$.

  3. For the function in the last exercise, find all points on the graph of $f(x)$ where the tangent line is horizontal. Remember that a point has an $x$ and a $y$ value.

next up previous
Next: About this document ... Up: lab_template Previous: lab_template
Jane E Bouchard
2011-10-19