Homework 4.2
Calculus I
Andy Long

#4,  p. 306

f[x_]:=Sin[x]
a=0
b=3Pi/2
n=6
(* Now we can do this for any function, combination of endpoints, and value of n: *)
DeltaX=(b-a)/n
right=Table[a+i*DeltaX,{i,1 ,n}];
midpoint=Table[DeltaX/2+(i-1)*DeltaX,{i,1 ,n}];
RRR=Total[f[right]]*DeltaX;
MID=Total[f[midpoint]]*DeltaX;
N[RRR]
N[MID]
(* Mathematica will integrate for us, numerically if it must: *)
Integrate[f[x],{x,a,b}]
(* But we know the answer, because we know an antiderivative: *)
N[-Cos[b]-(-Cos[a])]

#8,  p. 306

xs=Table[i,{i,3,9}]
fxs={-3.4,-2.1,-0.6,0.3,0.9,1.4,1.8}
RRR3=2*(fxs[[3]]+fxs[[5]]+fxs[[7]])
LRR3=2*(fxs[[1]]+fxs[[3]]+fxs[[5]])
midpoint=2*(fxs[[2]]+fxs[[4]]+fxs[[6]])
(* Some additional stuff, that wasn't asked for, but is interesting! *)
trapezoidal=(RRR3+LRR3)/2
simpson=(2*midpoint+trapezoidal)/3
Mean[fxs]

#9,  p. 307

Clear[x,xs,i,f,fxs]
xs=Table[i,{i,1,7,2}]
f[x_]:=Sin[Sqrt[x]]
fxs=f[xs]
N[%]
Total[fxs]*2
N[%,5]
(* What's the exact answer? *)
Integrate[f[x],{x,0,8}]
N[%]

#37,  p. 308

f[x_]:=1+Sqrt[9-x^2]
Plot[f[x],{x,-3,0},AspectRatio->2,AxesOrigin->{0,0},Filling->Axis]
Integrate[f[x],{x,-3,0}]
N[%]
(* One quarter of the area of a circle of radius 3, plus 3 units at the bottom -- Pi*9/4+3 *)
N[1/4*Pi*3^2+3]

#43, p. 308

(* you need to use what is given-- you need only that and the linearity of the integral *)

#49, p. 308

(* Ditto! *)