Homework (due 4/21):

    p. 264, #1, 3
    p. 281, #1, but do it for all three methods; 2, 15
    p. 293, #1, 4a (I’m not sure about b!), 5

p. 264, #1,3

Clear[x,a,f,g,h]
g[x_]=Normal[Series[f[x],{x,a,6}]]
g[a+h]
g[a-h]
Simplify[(g[a+h]-2g[a]+g[a-h])/h^2]

dividedDifference[list_]:=
Module[
{n=Length[list]}, 
If[n==1,
b=list[[1]][[2]],
b=(dividedDifference[list[[2;;n]]]-dividedDifference[list[[1;;n-1]]])/
(list[[n]][[1]]-list[[1]][[1]])];
b
]

xs={0,1,2,3}
ys={0,1,5,13}
xs[[2]]
p[x_]:=xs[[1]]+(x-xs[[1]])*(dividedDifference[{{xs[[1]],ys[[1]]},{xs[[2]],ys[[2]]}}] +
(x-xs[[2]])*(dividedDifference[{{xs[[1]],ys[[1]]},{xs[[2]],ys[[2]]},{xs[[3]],ys[[3]]}}] +
(x-xs[[3]])*(dividedDifference[{{xs[[1]],ys[[1]]},{xs[[2]],ys[[2]]},{xs[[3]],ys[[3]]},{xs[[4]],ys[[4]]}}])))
p[xs]
p''[0]
(* the third derivative is constant, and would be the same for all values of x: *)
p'''[x]
6*dividedDifference[{{xs[[1]],ys[[1]]},{xs[[2]],ys[[2]]},{xs[[3]],ys[[3]]},{xs[[4]],ys[[4]]}}]

Series[f[x],{x,a,4}]+(-f[a]+f'[a] (x-a)+(1/2) f''[a] (((x-a))^2)+(1/6) Derivative[3][f][a] (((x-a))^3)+(1/24) Derivative[4][f][a] (((x-a))^4)+((O[x-a])^5))

p. 281, #1

f[x_]:=1/x
a=1
b=2.6
Integrate[f[x],{x,a,b}]
h=(b-a)/2
Trap=.5*h*(f[a]+2f[a+h]+f[b])
Mid=h*(f[a+h/2]+f[b-h/2])
Simp=(2Mid+Trap)/3

p. 281, #2

H[n_]:=Sum[1/k,{k,1,n}]
n=100
H[n]
N[%]
N[Log[2n+1]]

p. 281, #15

eh=0.034518
ehover2=0.013243
p=Log[eh/ehover2]/Log[2]

p. 293, #1, 4a (I’m not sure about b!), 5 

#1: If it’s a quadratic, it’s exact.
#4a: the xi’s aren’t (necessarily) the same. 
#5:

f[x_]:=1/(1+x^2)
a=0
b=1
h=(b-a)/2
h^4/2880(b-a)*24