The Maple notebook is chapt2_5_2.mw but you are warned that it may download as a text file.

Explorations of Lagrange's Remainder

The command LagrangeRem(f,n,a,x) returns the difference between f(x) and the (n-1) degree Taylor polynomial of f expanded about a.

 > LagrangeRem := (f,n,a,x) -> evalf(eval(f(t) - convert(taylor(f(t),t=a,n),polynom),t=x),20);

 > LagrangeRem(sin,10,0,x);

 > LagrangeRem(sin,10,0,0.5);

 > plot(LagrangeRem(sin,10,0,x),x=-2..2);

The problem with investigating Lagrange's remainder theorem is that the Lagrange remainder is so extremely small near x=a. Rather than comparing this remainder with the nth derivative times (x-a)^n divided by n!, it makes more sense to divide the remainder by (x-a)^n, multiply it by n!, and then compare the resulting function to the nth derivative of f.

 > ModifiedLagrangeRem := (f,n,a,x) -> LagrangeRem(f,n,a,x)*n!/(x-a)^n;

We now compare the plot of the constant function y = ModifiedLagrangeRem with the nth derivative of f over the interval [a,x]. Lagrange's Remainder theorem is simply the statement that the graphs of these two functions interesect.

 > ModifiedLagrangeRem(cosh,10,0,0.5);

 > plot([ModifiedLagrangeRem(cosh,10,0,0.5),eval(diff(cosh(x),x\$10),x=t)],t=0..0.5);