Exam 2, MAT360
Spring, 2017
Andy Long

Problem 1: Preamble: I used dividedDifferences to interpolate to get the type of quartic I wanted to show you:

dividedDifference[list_]:=
Module[
{n=Length[list],b},
If[n==1,
b=list[[1]][[2]],
b=(dividedDifference[list[[2;;n]]]-dividedDifference[list[[1;;n-1]]])/
(list[[n]][[1]]-list[[1]][[1]])];
b
]
{x0,x1,x2,x3,x4}={-8,-4,-2,2,0}
{y0,y1,y2,y3,y4}={3,3,0,0,-1}

a=dividedDifference[{{x0,y0}}];
b=dividedDifference[{{x0,y0},{x1,y1}}];
c=dividedDifference[{{x0,y0},{x1,y1},{x2,y2}}];
d=dividedDifference[{{x0,y0},{x1,y1},{x2,y2},{x3,y3}}];
e=dividedDifference[{{x0,y0},{x1,y1},{x2,y2},{x3,y3},{x4,y4}}];
p[x_]=a+(x-x0)*(b+(x-x1)*(c+(x-x2)*(d+(x-x3)e)))
Plot[p[x],{x,-9,6}]
Expand[p[x]]

Having got the polynomial, here are a couple of important numbers for Newton’s, and for Newton’s quadratic:

p[0.5]
p'[0.5]
p''[0.5]

Horner’s form is much better for computation, of course:

HornerForm[p[x],{x}]

Problem 2: linear splines

f[x_]:=Sin[x]
true=f[.55]

l[x_]:=f[.5](x-.6)/(.5-.6)+f[.6](x-.5)/(.6-.5)
l[x]
Simplify[l[x]]
estimate=l[.55]
error=estimate-true

upperbound=Abs[f''[.6]/2*.05^2]
lowerbound=Abs[f''[.5]/2*.05^2]

Problem 6: relative error in cos(x)-1

Plot[(-x^2/2 - (Cos[x]-1))/ (Cos[x]-1),{x,-.1,.1}]