Derivatives

Straight lines

Formatting

DarkGreen:=Green//Darker//Darker

labelst[str_]:=Style[str,12,FontFamily->"Arial",Background->White]

myn[n_]:=labelst[If[Abs[n]<.0001,NumberForm[0.0,4],NumberForm[n,4]]]

myn[8.0^-5]

Head[myn[8.9]]

labelst[cu["a"]//TraditionalForm]

Remove[fsty]

fsty[f_,x_]:=Text[labelst[f[x]]//TraditionalForm]

fsty[cu,"a"]

Point-slope form

ptsl[m_,p_,x_]:=m x+ p[[2]]-m p[[1]]

ptsl[m_,p_,x_]:=m (x-p[[1]])+ p[[2]]//Simplify

ptsl[3,{1,2},x]

Two-point form

tpl[p_,q_,x_]:=(p[[2]]-q[[2]])/(p[[1]]-q[[1]])(x-p[[1]])+p[[2]]//Simplify

tpl[{1,2},{0,-1},x]

tpl[{0,-1},{1,2},x]

tpl[{1,4},{5,2},x]

Other definitions

cu[x_]:=x^3-x;cud[x_]:=cu'[x]

labelst[str_]:=Style[str,14,FontFamily->"Arial",Background->White];
tline[a_,x_]:=ptsl[cud[a],{a,cu[a]},x];
(*offs:=.3;*)
u[x_,offs_]:={x+offs,ptsl[cud[x],{x,cu[x]},x+offs]};
v[x_,offs_]:={x-offs,ptsl[cud[x],{x,cu[x]},x-offs]};
corner[x_,offs_]:={v[x,offs][[1]],u[x,offs][[2]]};
secline[a_,b_,x_]:=If[
a==b,
ptsl[cud[a],{a,cu[a]},x],
tpl[{a,cu[a]},{b,cu[b]},x]
]

u[.8,.3]

v[.8,.3]

corner[.8,.3]

corner[x,.3]

seclineslope[a_,b_]:=If[
a==b,
cud[a],
(cu[b]-cu[a])/(b-a)]

secline[.9,1.2,x]

seclineslope[.9,1.4]

(((x+h)^3-(x+h))-((x-h)^3-(x-h)))/((x+h)-(x-h))

Simplify[((-2 h-(((-h+x))^3)+(((h+x))^3))/(2 h))]

height[x_,offs_]:=(corner[x,offs]-v[x,offs])[[2]]

height[-.85,.05]

Tangent lines

tanline[f_,a_,x_]:=ptsl[f'[a],{a,f[a]},x]

sform[e_]:=e//TraditionalForm//labelst

x^2//sform

(#^3-#)&[x]//sform

(#^3-#)&'[x]//sform

Cos[#/Pi]&[x]

Demo of tangent lines

<script type=”text/javascript” src=”http://www.wolfram.com/cdf-player/plugin/v2.1/cdfplugin.js”></script>
<script type=”text/javascript”>
var cdf = new cdfplugin();
cdf.setDefaultContent(‘<a href=”http://www.wolfram.com/cdf-player/”><img  src=”Naive Tangent.png”></a>’);
cdf.embed(‘https://abstractmath.org/Mathematica/Naive Tangent.cdf’, 285, 357);
</script>

Module[{a,f},
Manipulate[Plot[
{f[x],tanline[f,a,x]},
{x,-1.7,1.7},
PlotRange->{{-1.7,1.7},{-2,2}},
PlotStyle->{Blue,Red},AspectRatio->40/34,ImageSize->200
],
{{a,-.85,Style["a",12]},-1.25,1.25},
{{f,(#^2)&,Style["function",12]},{(#^2)&->(x^2//sform),(#^3-#)&->(x^3-3x//sform),(Cos[Pi #])&->(Cos[Pi x]//sform),(Exp[#]-2)&->(e^x-2//sform)},
Background->White},
SaveDefinitions->True,Paneled->False
]
]

Circle

Module[{a},
Manipulate[
Plot[
{Sqrt[1-x^2],-Sqrt[1-x^2]},
{x,-1.7,1.7},
PlotRange->{{-1.5,1.5},{-1.5,1.5}},
PlotStyle->{Blue,Blue},AspectRatio->1,ImageSize->200
],
{{a,Pi/4,Style["a",12]},.01,.99Pi},
SaveDefinitions->True,Paneled->False
]
]

Module[{a},
Manipulate[
ParametricPlot[
{Cos[a],Sin[a]},
{a,.01,.99Pi},
PlotStyle->{Red},AspectRatio->1,PlotRange->{{-1.5,1.5},{-1.5,1.5}},ImageSize->200
],
{{a,Pi/4,Style["a",12]},.01,.99Pi},
SaveDefinitions->True,Paneled->False
]
]

Module[{a},
Manipulate[
Graphics[
{Plot[
{Sqrt[1-x^2],-Sqrt[1-x^2]},
{x,-1.7,1.7},
PlotRange->{{-1.5,1.5},{-1.5,1.5}},
PlotStyle->{Blue,Blue},AspectRatio->1,ImageSize->200
],
ParametricPlot[
{Cos[a],Sin[a]},
{a,.01,.99Pi},
PlotStyle->{Red},AspectRatio->1,PlotRange->{{-1.5,1.5},{-1.5,1.5}},ImageSize->200
],
}
],
{{a,Pi/4,Style["a",12]},.01,.99Pi},
SaveDefinitions->True,Paneled->False
]
]

Derivative' s value is slope of tangent line

More definitions

myexp[e_]:=ToString[e//labelst,TraditionalForm]

myexp["x\\mapsto x^3-x"]

myexp["x^3-x"]

x^3-x//TraditionalForm//labelst

dvdef[f_,x_,h_]:=((f[x+h]-f[x])/h)

dvdef[cu,x,h]

myn[dvdef[cu,.4,.2]]

cu'[x]//TraditionalForm

Calculations for input function, output slope

{.2,ptsl[cud[.2],{1,cu[.2]},.3]}

<script type=”text/javascript” src=”http://www.wolfram.com/cdf-player/plugin/v2.1/cdfplugin.js”></script>
<script type=”text/javascript”>
var cdf = new cdfplugin();
cdf.setDefaultContent(‘<a href=”http://www.wolfram.com/cdf-player/”><img  src=”Deriv is Slope of Tan Line.png”></a>’);
cdf.embed(‘https://abstractmath.org/Mathematica/
/Deriv is Slope of Tan Line.cdf’, 519, 359);
</script>

Module[{a,offs},
Manipulate[
Row[{Show[
{
Plot[
{cu[x],tline[a,x]
},{x,-1.7,1.7},
PlotRange->{{-1.7,1.7},{-2,2}},
PlotStyle->{Blue,Red},AspectRatio->40/34,ImageSize->200
],
Graphics[
{PointSize[.02],
Point[{a,cu[a]}],
DarkGreen,
Point[u[a,offs]],Point[v[a,offs]],Point[corner[a,offs]],
Line[{u[a,offs],corner[a,offs]}],Line[{v[a,offs],corner[a,offs]}],
Inset[labelst["w"],.5(u[a,offs]+corner[a,offs])],Inset[labelst["ht"],.5(v[a,offs]+corner[a,offs])]
}]
}
],
"    ",
Column[{"          ",
Grid[{{labelst["x"],"=",myn[a]}}],
Grid[{{labelst["ht"],"=",myn[height[a, offs]]}}],
Grid[{{labelst["w"],"=",myn[2 offs]}}],Grid[{{labelst["function value"],"=",myexp[x^3-x],"=",myn[cu[a]]}}],Grid[{{labelst["slope of tangent line"],"=",myexp[ht/w],"=",myn[height[a, offs]/(2 offs)]}}],Grid[{{labelst["derivative value"],"=",myexp[3x^2-1],"=",myn[cu'[a]]}}]}
]}],
{{a,-.85,"x"},-1.25,1.25},{{offs,.35,"width"},.01,.7},
SaveDefinitions->True,Paneled->False]
]

Notes

The width is always nonnegative.  The height is measured from the tangent line and so may be negative or positive.

Visual calculation of value of derivative

tests

labelst[cu["a"]//TraditionalForm]

Grid[{{fsty[cu,"a"],"=",myn[cu[3]]}}]

Grid[{{fsty[dvdef["cu","a","h"]],"=",dvdef[cu,.8,.1]}}]

Calculate the value of the derivative

<script type="text/javascript" src="http://www.wolfram.com/cdf-player/plugin/v2.1/cdfplugin.js"></script>
<script type="text/javascript">
var cdf = new cdfplugin();
cdf.setDefaultContent('<a href="http://www.wolfram.com/cdf-player/"><img  src="Calc Val Deriv.png"></a>');
cdf.embed('https://abstractmath.org/Mathematica/Calc Val Deriv.cdf', 571, 417);
</script>

Module[{a,h},
Manipulate[
Row[{Show[
{
Plot[
{cu[x],tline[a,x],secline[a-h,a+h,x]
},{x,-1.7,1.7},
PlotRange->{{-1.7,1.7},{-2,2}},
PlotStyle->{Blue,Red,Brown},AspectRatio->40/34,ImageSize->250
],
Graphics[
{PointSize[.02],
Point[{a,cu[a]}],
Point[{a-h,cu[a-h]}],
Point[{a+h,cu[a+h]}]
}]
}
],
"    ",
Column[{"          ",
Grid[{{labelst["x"],"=",myn[a]}}],
Grid[{{labelst["f(x)"],"=",myn[cu[a]]}}],
Grid[{{labelst["dist. between secant points"],"=",myn[EuclideanDistance[{a-h,cu[a-h]},{a+h,cu[a+h]}]]}}],
Grid[{{labelst["slope of secant line"],"=",myn[seclineslope[a-h,a+h]]}}],Grid[{{labelst["slope of tangent line"],"=",myn[cud[a]]}}],
}]}],
{{a,-.85,"x"},-1.25,1.25},{{h,.5,"width"},.01,.7},
SaveDefinitions->True,Paneled->False]
]

Example conceptual problems

prob[f_]:=Plot[
{f[x],f'[x]
},{x,-1.7,1.7},
PlotRange->{{-1.7,1.7},{-2,2}},
PlotStyle->{Green,Blue},AspectRatio->40/34,ImageSize->200
]

prob[Sin]

prob[2 Exp[-#^2]&]