# Numerical Analysis# Section 1.1: Review of Calculus# Worksheet by Russell Blyth# > restart;# Extreme Value Theorem# Find the maximum value of |f(x)| for f(x) = > 2x cos(2x) - (x-2)^2# for 2 ² x ² 4 (Exercise 4(c), page 15).> with(plots):> f := 2*x*cos(2*x) - (x-2)^2;> plot(f,x=2..4);> g := diff(f,x);> m:=fsolve(g,x,3..3.5);> evalf(subs(x=m,f));> evalf(subs(x=2,f)); evalf(subs(x=4,f));# Hence the maximum value of |f(x)| occurs at the right end point, x =# 4, and is > -5.164000270;> # Intermediate Value Theorem# Show that f'(x) is 0 for at least once in the interval [1,2], where# f(x) = x sin(¹x) - (x-2)ln(x).> f1 := x*sin(Pi*x) - (x-2)*ln(x);> g1 := diff(f1,x);> evalf(subs(x=1,g1)); evalf(subs(x=2,g1));# Since f'(x) is a continuous function, and changes sign on the interval# [1,2], we conclude that it takes the value 0 at least once in the# interval [1,2].# Taylor approximation# Let f(x) = > ln(x^2 + 2)# . Find the third Taylor polynomial P3(x) for f expanded# about x = 1. (Exercise 17, page 16)> f2 := ln(x^2 + 2);> s3 := taylor(f2, x=1, 4); p3 := convert(s3, polynom);# Find the maximum error |f(x) - P3(x)| for 0 ² x ² 1> err := abs(f2 - p3);> plot(err,x=0..1);# The maximum error occurs at x = 0, and has value:> evalf(subs(x=0,err));# Now we compute the Maclaurin polynomial for f(x) , namely the Taylor# polynomial for f(x) around x = 0, and compare the maximum error it# produces on the interval [0,1] with the above.> s3m := taylor(f2, x=0, 4); p3m := convert(s3m, polynom);> errm := abs(f2 - p3m);> plot(errm,x=0..1);# The maximum error here occurs for x = 1, and is:> evalf(subs(x=1,errm));# Thus the Taylor expansion about x = 1 gives better approximations on# the interval [0,1] in this case.# # Extension: # Compare the actual maximum error found here with the bound provided by# the remainder term of Taylor's theorem. We need the fourth derivative# of f:> f2d4 := diff(f2,x,x,x,x);> plot(f2d4,x=0..1);# Thus the fourth derivative is bounded by 3 on [0,1]. Hence the# remainder term is bounded by (3/4!) times 1^4, that is, 3/24, which# is 1/8, i.e. 0.125. Thus the actual error is much less than the error# bound provided by the remainder term. Yet much of our analysis will# depend on bounds provided by such remainder terms.>