Mathematica Labs | Denis Shubleka

Subject: Calculus

Topic: The Derivative

Goal: Compute the derivative as a function and as a number

Task 1

Below we define a function f(x) and ask Mathematica to compute its derivative:

f[x_]:=Log[x]+Tan[x];
f'[x]

Now we evaluate the derivative at x = π by executing the following:

f'[π]

To verify that the derivative is in fact the slope of the tangent line
at x = π, we plot the original function and the equation of the tangent line
in the same plot.

Plot[{f[x],f[π]+f'[π]*(x-π)},{x,1,5}]

We can also plot the derivative f'(x)(in green) and the original function f(x) 
(blue) in the same window, to verify the connection between the two:

Plot[{f[x],f'[x]},{x,0,2*Pi},PlotStyle->{Blue,Green}]

As always, feel free to experiment with a function of your own.

Here are two additional ways Mathematica can be used to evaluate derivatives:

D[Tan[x],x]

takes the first derivative of tan(x) with respect to x.

And, from the Basic Math Assistant palette, in the Advanced tab, find the '∂'
operation as use it as follows:

(∂_x)Log[x]+Tan[x]

Finally, we conclude this task by asking Mathematica to remind us about the 
Quotient Rule:

D[h[x]/g[x],x]

And then simplify the output using:

Simplify[%]

Try the following: product rule for two or three functions. Note that if using
pre-defined functions such as f(x), you may need to clear its definition first, 
using the command:

Clear[f,g,h,x]

Related Exercises/Notes:

ap-calc.github.io