The Derivative f'(a) as Slope of Tangent Line to f(x) at x=a

Here we plot the function f(x)=x^2-x-4 and the tangent line we worked out in class.

f[x_]=x^2-x-4

m[a_]=2 a-1

tangent[x_,a_]=m[a] (x-a)+f[a]

Manipulate[Plot[{f[x],tangent[x,a]},{x,-5,5},PlotRange->{-20,20},PlotStyle->{{Blue,Thick},{Orange,Thick}}],{a,-3,3}]

Use the slider to vary the value of a in the sketch. The orange line is the tangent line, and it has a slope at x=a given by f'(a).

Notice the value of m (the slope) depends on the point a you are working at.

Mathematica Note: When using Manipulate, when you do another Manipulate command later on, the image in earlier Manipulate commands may change since the definition of the functions you are plotting will be different!

The Derivative f'(x) as a Function, and how it relates to the orginal function f(x)

This section we will cheat, and let Mathematica compute derivatives for us. We are trying to gain experience with how functions and their derivatives are related, and computing everything by hand would be tedius (and for some of the functions later on in this document, we don't know how to compute the derivative using the definition of derivative yet!).

The important thing here is that we could think of the derivative as a new function of x, using a slightly modified definition of derivative:

f'(a)=(Subscript[Lim, h-> 0])((f(a+h)-f(a))/h)
becomes
f'(x)=(Subscript[Lim, h-> 0])((f(x+h)-f(x))/h)

Let's investigate what this means by plotting the functions f(x) and f'(x).

Example

Here we plot the function f(x)=(x^3)-3(x^2)+2x and its derivative f'(x).

f[x_]=x^3-3x^2+2x
f'[x]
Plot[{f[x],f'[x]},{x,-1,3},PlotStyle->{{Blue,Thick},{Red,Thick}}]

Animation of how the above graph is being created

I don't expect you to be able to create the Mathematica used here by yourself, but you should be able to look at it and make some sense of it. What's important is that it helps us see the relationship between f(x) and f'(x).

f[x_]=x^3-3x^2+2x

plottangent[a_]:=Plot[f'[a](x-a)+f[a],{x,a-0.5,a+0.5},PlotStyle->{Thick,Orange}];

plotf = Plot[{f[x]},{x,-1,3},PlotStyle->{Thick,Blue},PlotRange->{All,All}];

plotderivative[a_] := Plot[{f'[x]},{x,-1,a},PlotStyle->{Thick,Red}]
plotpoint[a_]:=Show[Graphics[{Red,Disk[{a,f'[a]},{0.05,15/4*0.05}]}]];

Manipulate[Show[plotf,plotderivative[a],plottangent[a],plotpoint[a],PlotRange->{{-1,3},{-5,10}},AspectRatio->1,AxesOrigin->{0,0}],{a,-0.9,3}]

Use the slider above to vary a, and you can see how the slope of the function f(x) (the blue line, with slope given by orange line) is used to create the sketch of the derivative f'(x). When doing this by hand it is usually best to identify places where the derivative is zero, then look for negative or positive slope. In this case, the derivative f'(x) is zero (slope of tangent line to f(x) is horizontal) near x~0.4 and x~1.6.

Another Example of How the Derivative is Related to Function

Notice that this function has a vertical asymptote at x=1/2, which is where the slope of the tangent line becomes infinite.

f[x_]=((x^2-1)/(x-1/2))

plottangent[a_]:=Plot[f'[a](x-a)+f[a],{x,a-0.5,a+0.5},PlotStyle->{Thick,Orange}];

plotf = Plot[{f[x]},{x,-1,3},PlotStyle->{Thick,Blue},PlotRange->{All,All}];

plotderivative[a_] := Plot[{f'[x]},{x,-1,a},PlotStyle->{Thick,Red}]
plotpoint[a_]:=Show[Graphics[{Red,Disk[{a,f'[a]},{0.05,15/4*0.05}]}]];

Manipulate[Show[plotf,plotderivative[a],plottangent[a],plotpoint[a],PlotRange->{{-1,3},{-5,10}},AspectRatio->1,AxesOrigin->{0,0}],{a,-0.9,3}]

Notice that in this example, the orginal function has end behaviour given by f(x)~x when x is large, so the derivative function f'(x) has a horizontal asymptote at x=1.

Another Example of How the Derivative is Related to Function

f[x_]=((4x-1)/(Sqrt[x^2+1]))

plottangent[a_]:=Plot[f'[a](x-a)+f[a],{x,a-0.5,a+0.5},PlotStyle->{Thick,Orange}];

plotf = Plot[{f[x]},{x,-1,3},PlotStyle->{Thick,Blue},PlotRange->{All,All}];

plotderivative[a_] := Plot[{f'[x]},{x,-1,a},PlotStyle->{Thick,Red}]
plotpoint[a_]:=Show[Graphics[{Red,Disk[{a,f'[a]},{0.05,15/4*0.05}]}]];

Manipulate[Show[plotf,plotderivative[a],plottangent[a],plotpoint[a],PlotRange->{{-1,3},{-5,10}},AspectRatio->1,AxesOrigin->{0,0}],{a,-0.9,3}]

Notice here that the maximum slope occurs for x just a bit larger than 0.

Another Example of How the Derivative is Related to Function

The exponential function f(x)=(2^x) has a slope that is always increasing.

f[x_]=2^x

plottangent[a_]:=Plot[f'[a](x-a)+f[a],{x,a-0.5,a+0.5},PlotStyle->{Thick,Orange}];

plotf = Plot[{f[x]},{x,-1,3},PlotStyle->{Thick,Blue},PlotRange->{All,All}];

plotderivative[a_] := Plot[{f'[x]},{x,-1,a},PlotStyle->{Thick,Red}]
plotpoint[a_]:=Show[Graphics[{Red,Disk[{a,f'[a]},{0.05,15/4*0.05}]}]];

Manipulate[Show[plotf,plotderivative[a],plottangent[a],plotpoint[a],PlotRange->{{-1,3},{-5,10}},AspectRatio->1,AxesOrigin->{0,0}],{a,-0.9,3}]

Another Example of How the Derivative is Related to Function

This is what is special about the exponential function with base e. The slope of the tangent line is the same as the value of the function! How cool is that?

f[x_]=Exp[x]

plottangent[a_]:=Plot[f'[a](x-a)+f[a],{x,a-0.5,a+0.5},PlotStyle->{Thick,Orange}];

plotf = Plot[{f[x]},{x,-1,3},PlotStyle->{Thick,Blue},PlotRange->{All,All}];

plotderivative[a_] := Plot[{f'[x]},{x,-1,a},PlotStyle->{Thick,Red}]
plotpoint[a_]:=Show[Graphics[{Red,Disk[{a,f'[a]},{0.05,15/4*0.05}]}]];

Manipulate[Show[plotf,plotderivative[a],plottangent[a],plotpoint[a],PlotRange->{{-1,3},{-5,10}},AspectRatio->1,AxesOrigin->{0,0}],{a,-0.9,3}]

Example of Function Where the Derivative Does Not Exist

Our little "slider" to move the derivative around can also help us understand examples where the derivative does not exist.

Discontinuity in a Piecewise defined Function

The derivative does not exist at x=1 for this function. Why? Because the derivative from the left does not equal the derivative from the right; in other words:

(Subscript[Lim, h-> (SuperPlus[0])])((f(x+h)-f(x))/h)≠(Subscript[Lim, h-> (SuperMinus[0])])((f(x+h)-f(x))/h)
so (Subscript[Lim, h-> 0])((f(x+h)-f(x))/h) does not exist.

f[x_]=Piecewise[{{2x^2+1,x<1},{-2x+4,x≥1}}]

plottangent[a_]:=Plot[f'[a](x-a)+f[a],{x,a-0.5,a+0.5},PlotStyle->{Thick,Orange}];

plotf = Plot[{f[x]},{x,-1,3},PlotStyle->{Thick,Blue},PlotRange->{All,All}];

plotderivative[a_] := Plot[{f'[x]},{x,-1,a},PlotStyle->{Thick,Red}]
plotpoint[a_]:=Show[Graphics[{Red,Disk[{a,f'[a]},{0.05,15/4*0.05}]}]];

Manipulate[Show[plotf,plotderivative[a],plottangent[a],plotpoint[a],PlotRange->{{-1,3},{-5,10}},AspectRatio->1,AxesOrigin->{0,0}],{a,-0.9,3}]

A Function with a Sharp Point

This piecewise function is continuous, but still has a sharp point at x=1. As we can see, the derivative does not exist at x=1.

f[x_]=Piecewise[{{2x^2+1,x<1},{-2x+5,x≥1}}]

plottangent[a_]:=Plot[f'[a](x-a)+f[a],{x,a-0.5,a+0.5},PlotStyle->{Thick,Orange}];

plotf = Plot[{f[x]},{x,-1,3},PlotStyle->{Thick,Blue},PlotRange->{All,All}];

plotderivative[a_] := Plot[{f'[x]},{x,-1,a},PlotStyle->{Thick,Red}]
plotpoint[a_]:=Show[Graphics[{Red,Disk[{a,f'[a]},{0.05,15/4*0.05}]}]];

Manipulate[Show[plotf,plotderivative[a],plottangent[a],plotpoint[a],PlotRange->{{-1,3},{-5,10}},AspectRatio->1,AxesOrigin->{0,0}],{a,-0.9,3}]

A Function with a Vertical Tangent

This piecewise function is continuous, but has a horizontal tangent at x=0. As we can see, the derivative does not exist at x=0, since the derivative is infinite.

f[x_]=Piecewise[{{-(-5x)^(1/3),x<0},{5x^(1/3),x≥0}}]

plottangent[a_]:=Plot[f'[a](x-a)+f[a],{x,a-0.5,a+0.5},PlotStyle->{Thick,Orange}];

plotf = Plot[{f[x]},{x,-1,3},PlotStyle->{Thick,Blue},PlotRange->{All,All}];

plotderivative[a_] := Plot[{f'[x]},{x,-1,a},PlotStyle->{Thick,Red}]
plotpoint[a_]:=Show[Graphics[{Red,Disk[{a,f'[a]},{0.05,15/4*0.05}]}]];

Manipulate[Show[plotf,plotderivative[a],plottangent[a],plotpoint[a],PlotRange->{{-1,3},{-5,10}},AspectRatio->1,AxesOrigin->{0,0}],{a,-0.9,3}]

Mathematica actually has some trouble plotting the function and derivative near x=0 because of the horizontal tangent.

Higher derivatives: f(x), f'(x),f''(x), etc.

If f'(x)  is a function, then can we differentiate it again and get a new function? Sure! These higher derivatives are just rates of changes of rates of changes. A typical example is

Position: s(t) 
Velcoity: v(t) = s'(t)
Acceleration: a(t) = v'(t) = s''(t)
Jerk: j(t) = a'(t)=v''(t)=s'''(t)

Don' t worry too much about higher derivatives at the moment. We will see them more as the semester progresses.

Example

Here we plot the function s(t)=(t^3)-3(t^2)+2t and its derivative v(t)=s'(t) (position and velocity).

s[t_]=t^3-3t^2+2t
v[t_]=s'[t]

Plot[{s[t],v[t]},{t,-1,3},PlotStyle->{{Blue,Thick},{Red,Thick}}]

Here we plot the function v(t) and a(t)=v'(t) (velocity and acceleration)

a[t_]=v'[t]

Plot[{v[t],a[t]},{t,-1,3},PlotStyle->{{Blue,Thick},{Red,Thick}}]

Here we plot the function a(t) and j(t)=a'(t) (acceleration and jerk).

j[t_]=a'[t]

Plot[{a[t],j[t]},{t,-1,3},PlotStyle->{{Blue,Thick},{Red,Thick}}]