Derivatives Leftovers

This Mathematica notebook is licensed under a MouseOver .

The  notebook contains the code not included in the Derivatives Books:

It is raw code and contains a few errors.  Some of the graphs differ from the graphs on the website.  I have no present intention to turn this into an easy-to-use package, but everyone should feel free to use and and adapt it under the CC Share-Alike license.

GT := 3

Definition of Derivative

A real valued function f may have a derivative, which is another real valued function denoted by f'.  At a point a, f'[a] is the slope of the tangent line to the curve y = f[x] at the point (a, f[x]).

Functions used in creating the examples

ShowDerivatives[f_,n_,a_,b_] :=Plot[Take[{f[x],f'[x],f''[x],f'''[x],f''''[x]}, n] // Evaluate,{x,a,b}, Prolog->AbsoluteThickness[GT],PlotRange->{a,b}, AspectRatio->1, ImageSize -> {200,200},PlotStyle->{{RGBColor[0,0,1]}, {RGBColor[1,0,0]},{RGBColor[0,1,0]}, RGBColor[.7,.7,0],RGBColor[.7,0,.7]}]

TO DO : Make SD print each line in the appropriate color.

TO DO : Increase the type size in the SD printout.  It is not obvious how to do this.

TO DO : Bring the graph of the function to the front so that the derivatives all pass underneath it.

SD[f_,n_,a_,b_, c_, d_, s_] := ((r := (d-c)/(b-a)); Plot[Take[{f[x],f'[x],f''[x],f'''[x],f''''[x],f'''''[x]}, n] // Evaluate,{x,a,b}, PlotRange->{c,d},Prolog->AbsoluteThickness[GT], AspectRatio->r, ImageSize -> { s,r s},PlotStyle->{{RGBColor[0,0,1]}, {RGBColor[1,0,0]},{RGBColor[0,1,0]}, RGBColor[.7,.7,0],RGBColor[.7,0,.7],RGBColor[0,.7,.7]}])

The derivatives are shown in each graph by color.  
function: blue
first derivative : red
second : green
third : gold
fourth : purple
fifth: light blue

DF prints out the formulas for the derivatives

DF[f_,n_]:=
TraditionalForm[
TableForm[
Take[{{"function",f[x]},{"1st deriv",f'[x]},{"2nd deriv",f''[x]},{"3rd deriv",f'''[x]},{"4th deriv",f''''[x]},{"5th deriv",f'''''[x]},{"6th deriv",f''''''[x]}}, n]]]

A function that is its own third derivative

TO DO : This function has very complicated behavior left of 0 that I don' t understand because it takes on extreme values that I cannot plot.

DSolve[u'''[x]==u[x],u[x],x]

owntd[x_]:=(E^x) +(E^(-x/2))  Cos[(((Sqrt[3]) x)/2)]

Manipulate[owntd[x],{x,-50,2,Appearance->"Open"}]//N

DF[owntd,4]

SD[owntd,3,-6.4,4,-7.5,13.2,200]

SD[owntd,3,-50,50,-70,50,300]

A function that is its own third derivative

TO DO : This function has very complicated behavior left of 0 that I don' t understand because it takes on extreme values that I cannot plot.

DSolve[u'''[x]==u[x],u[x],x]

owntd[x_]:=(E^x) +(E^(-x/2))  Cos[(((Sqrt[3]) x)/2)]

Manipulate[owntd[x],{x,-50,2,Appearance->"Open"}]//N

DF[owntd,4]

SD[owntd,3,-6.4,4,-7.5,13.2,200]

SD[owntd,3,-50,50,-70,50,300]

A function that is its own fifth derivative

I have not been able to make these work.  TO DO : Try later.

Sine and Cosine are functions that are their own fourth derivatives

DSolve[u'''''[x]==u[x],u[x],x]

ownfd[x_]:=%

ownfd[x_]:=(E^((-(1/4)-((Sqrt[5])/4)) ))  Cos[(Sqrt[(5/8)-((Sqrt[5])/8)]) x]+(E^((-(1/4)+((Sqrt[5])/4)) ))  Cos[(Sqrt[(5/8)+((Sqrt[5])/8)]) x]

DF[ownfd,6]

ownfd[-20]//N

SD[ownfd,4,-7,7,-3,15,200]

SD[ownfd,4,-40,3,-3,15,500]

Remove[ownfd]

A function that is its own fifth derivative second try

Sine and Cosine are functions that are their own fourth derivatives

DSolve[u'''''[x]==u[x],u[x],x]//InputForm

ownfd[x_]:=.2 E^x+E^((-1/4-Sqrt[5]/4)*x)*Cos[Sqrt[5/8-Sqrt[5]/8]*x]+E^((-1/4+Sqrt[5]/4)*x)*Cos[Sqrt[5/8+Sqrt[5]/8]*x]+E^((-1/4-Sqrt[5]/4)*x)*Sin[Sqrt[5/8-Sqrt[5]/8]*x]+E^((-1/4+Sqrt[5]/4)*x)*Sin[Sqrt[5/8+Sqrt[5]/8]*x]

ownfd[x]

ownfd[-20]//N

DF[ownfd,6]

SD[ownfd,5,-5,3,-15,7,200]

]

Beta

f[x_] := BetaRegularized[x,2,2]

ShowDerivatives[f,2,-1,2]

f[x_] := BetaRegularized[x,.5,2]

ShowDerivatives[f,3,-1,3]

f[x_] := Beta[x,1,.5,2]

f[x]

ShowDerivatives[f,5,-2,4]

LogGamma

f[x_] := LogGamma[x]

ShowDerivatives[f,3,-10, 10]

Erf

f[x_] := Erf[x]

ShowDerivatives[f,4,-3, 3]

Fresnel

g[x_] := Integrate[f[x],x]

g[x]

g[1]

C[x]

S[x]

g[x] // FullSimplify

g[2]

S[Sqrt[(2/Pi)  x]]

S[Sqrt[(2/Pi)  2]]

ShowDerivatives[g,2,-5, 5]

ShowDerivatives[g,3,-5, 5]

h[t_] := Integrate[f[x],{x,0,t}]

h[t]

h[3]

% // N

h[t] // N

More Fresnel

Integrate[Sin[t^2], {t,0,x}]

g[x_] := Integrate[Sin[t^2], {t,0,x}]
h[x_] := Sin[x^2]

ShowDerivatives[g,2,-6,6]

More exp

Integrate[Exp[t^2], {t,0,x}]

g[x_] := Integrate[Exp[t^2], {t,0,x}]
h[x_] := Exp[x^2]

ShowDerivatives[g,3,-3,3]

Remove[f]

Elliptic

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

ShowDerivatives[f,3,-3,3]

Remove[f]

More exp

f[x_] := x Exp[x] - x^2

ShowDerivatives[f,5,-4,4]

SinCos

f[x_] := Sin[x] Cos[x]

DF[f,3] //TraditionalForm

ShowDerivatives[f,3,-4,4]

SD[f,4,-4,4,-4,4,400]

ExpSin

f[x_] := Exp[x] Sin[x]/2

ShowDerivatives[f,3,-4,4]

SinExp

f[x_] := Sin[Exp[x]]

ShowDerivatives[f,2,-4,4]

SinSIn

f[x_] := 3 Sin[Sin[x]]

ShowDerivatives[f,3,-10,10]

expSin again

f[x_] := Exp[Sin[x]]

ShowDerivatives[f,4,-12,12]

More sin

f[x_] := Sin[(x^2)/3]

ShowDerivatives[f,2,-10,10]

More exp sin

f[x_] := Exp[-x/2]  Sin[Sqrt[3] x / 2]
ShowDerivatives[f,3,-4,4]

f[x_] :=1/2  Exp[-x/2]  Sin[Sqrt[3] x / 2]

{f[x], f'[x], f''[x]}

ShowDerivatives[f,3,-6,6]

f[x_] :=1/5  Exp[-x/2]  Sin[Sqrt[3] x / 2]

{f[x], f'[x], f''[x], f'''[x]}

Plot[{f[x],f'[x], f''[x]}, {x,-8,2}, PlotRange->{-7,7}, AspectRatio->7/5, Prolog->AbsoluteThickness[GT],PlotStyle->{{RGBColor[0,0,1]}, {RGBColor[1,0,0]},{RGBColor[0,1,0]}, RGBColor[.7,.7,0],RGBColor[0,.7,.6]}, ImageSize -> {300,600}]

f[x_] :=1/5  Exp[x/2]  Cos[Sqrt[3](- x )/ 2]

{f[x], f'[x], f''[x], f'''[x]}

Plot[{f[x],f'[x], f''[x], f'''[x]}, {x,-2,8}, PlotRange->{-7,7}, AspectRatio->7/5, Prolog->AbsoluteThickness[GT],PlotStyle->{{RGBColor[0,0,1]}, {RGBColor[1,0,0]},{RGBColor[0,1,0]}, RGBColor[.7,.7,0],RGBColor[0,.7,.6]}, ImageSize -> {300,600}]

f[x_] :=1/5  Exp[x/2]  Sin[Sqrt[3](-x )/ 2]

{f[x], f'[x], f''[x], f'''[x]}

f[x_] :=1/5  Exp[x/2]  Sin[Sqrt[3](x )/ 2]

{f[x], f'[x], f''[x], f'''[x]}

f[x_] :=1/5  Exp[-x/2]  Sin[Sqrt[3](x )/ 2]

{f[x], f'[x], f''[x], f'''[x]}

f[x_] :=-1/5  Exp[x/2]  Sin[Sqrt[3](-x )/ 2]

{f[x], f'[x], f''[x], f'''[x]}

ShowDerivatives[f,4,-6,6]

f[x_] :=1/5  Exp[-x/2]  Sin[Sqrt[3](x )/ 2]

ShowDerivatives[f,4,-6,6]

ShowDerivatives[f,3,-6,6]

f[x_] :=1/5  Exp[-x/2]  Sin[Sqrt[3](x )/ 2]Exp[x]

ShowDerivatives[f,4,-6,6]

f[x_] :=1/5  Exp[-x/2]  Sin[Sqrt[3](x )/ 2]+ Exp[x]

ShowDerivatives[f,3,-6,6]

f[x_] :=1/5  Exp[x/2]  Cos[Sqrt[3](- x )/ 2]

ShowDerivatives[f,4,-6,6]

f[x_] :=1/2  Exp[-x/2]  Sin[a x]

{f[x], f'[x], f''[x], f'''[x]}

f[x_] := Exp[-x/2]  Sin[1.1 Sqrt[3] x / 2]

DF[f,5]

ShowDerivatives[f,4,-6,6]

SD[f,5,-6,6,-10,6,400]

Plot[{f[x],f'[x], f''[x], f'''[x]}, {x,-6,6}, PlotRange->{-9,9}, AspectRatio->3/2, Prolog->AbsoluteThickness[GT],PlotStyle->{{RGBColor[0,0,1]}, {RGBColor[1,0,0]},{RGBColor[0,1,0]}, RGBColor[.7,.7,0],RGBColor[0,.7,.6]}, ImageSize -> {600,400}]

f[x_] := Exp[-x/2]  Sin[ x / 2]

DF[f,5]

SD[f,5,-8,6,-10,5,400]

Remove[f]

f[x_] := Sin[1.1 x]

More exp

f[x_] := Exp[-x]

Plot[{f[x],f'[x]}, {x,-2,2}, PlotRange->{-4,4}, AspectRatio->2, Prolog->AbsoluteThickness[GT],PlotStyle->{{RGBColor[0,0,1]}, {RGBColor[1,0,0]},{RGBColor[0,1,0]}, RGBColor[.7,.7,0],RGBColor[0,.7,.6]}, ImageSize -> {400,400}]

Log times exponential

f[x_] := .05 Log[x] Exp[x]

Plot[{f[x],f'[x], f''[x], f'''[x], f''''[x]}, {x,.01,3}, PlotRange->{-1,5}, AspectRatio->3/2, Prolog->AbsoluteThickness[GT],PlotStyle->{{RGBColor[0,0,1]}, {RGBColor[1,0,0]},{RGBColor[0,1,0]}, RGBColor[.7,.7,0],RGBColor[0=.7,0,.7]}, ImageSize -> {300,450}]

SD[f,5,0.01,3,-1,2,300]

exp and arctan

f[x_] := Exp[ArcTan[x]]

ShowDerivatives[f,4,-4,4]

f[x_] := ArcTan[Exp[x]]

ShowDerivatives[f,4,-3,3]

tan and sin

f[x_] :=.4  Tan[Sin[x]]

ShowDerivatives[f,4,-3,3]

f[x_] := Sin[Tan[x/3]]

ShowDerivatives[f,4,-Pi,Pi]

ShowDerivatives[f,4,-4.2,4.2]

Exponential times Sine

Remove[f]

DSolve[y'''[x] == y[x], y, x]

f[x_] := Exp[-x/2] Sin[(Sqrt[3]/2) x]

SD[f,3,-4,4,-4,3,300]

Sine of a quadratic

squad[x_] := Sin[(x^2)-1]

DF[squad,5]

Note that SD prints the graph of the derivative after the graph of the function so that the blue seems to disappear toward the left and the right.  This is an artefact and needs to be fixed.

SD[squad,2,-12,12,-12,12,300]