Problem 4: Taylor polynomials and errors.
> f := x -> exp(x^2 - 1) - 1;
a )
> taylor(f(x),x=1,3);
Hence
> P := x -> 3*(x-1)^2 + 2*(x-1) + 0;
It is not necessary to simplify this, but in case you wish to:
> simplify(P(x));
Just for fun, let's compare:
> plot([f(x),P(x)], x=-1..1);
Notice that the approximation is good near +1, but not so good near -1. Part c) uses Lagrange's formula:
c )
> diff(f(x), x$3)/3!;
In Lagrange's formula, the x here is replaced by c, and the whole thing is multiplied by (-1-(1))^3.
The e-factors are never bigger than 1, so the magnitude of this error is smaller than
max |2 c + 4 c^3/3| for c between -1 and 1. Kindergarten calculus tells us this value will occur when c=+1 or c = -1 (end points ), because the derivative of this expression is not 0 for -1 < c < 1. Therefore the error is less in magnitude than
> (2 + 4/3)*2^3;
Evidently, the Lagrange form of the error is more than 20 . WIth more work, we could do a little better, but this is not required on the test