Section 4.2
Calculus I
Andy Long

(* #7, p. 306 *)
Minutes={10, 14,18,22,26,30}
Speeds={-12, -6, -2,1,3,8}
Data=Transpose[{Minutes,Speeds}];
ListPlot[Data,Filling->Axis,PlotStyle->{Thick,PointSize[Large]}]
n=Length[Speeds] ;
DeltaX=4;
RRR=N[Sum[Speeds[[i]],{i,2,n}]]*DeltaX
LRR=N[Sum[Speeds[[i]],{i,1,n-1}]]*DeltaX
TRAP=(RRR+LRR)/2

p1=ListPlot[Data,Filling->Axis,PlotStyle->{Thick,PointSize[Large]}]
times=Flatten[Table[{Minutes[[i]],Minutes[[i]]},{i,2,n-1}]]
times=Flatten[{Minutes[[1]],times,Minutes[[n]]}]
rights=Flatten[Table[{Speeds[[i]],Speeds[[i]]},{i,2,n}]]
lefts=Flatten[Table[{Speeds[[i]],Speeds[[i]]},{i,1,n-1}]]
Data=Transpose[{times,lefts}];
p2=ListLinePlot[Data,Filling->Axis,FillingStyle->Orange,PlotStyle->{Thick,PointSize[Large]}]
Data=Transpose[{times,rights}];
p3=ListLinePlot[Data,Filling->Axis,PlotStyle->{Thick,PointSize[Large]}]
Show[p2,p3,p1]

#10, p. 307

f[x_]:=Cos[x]^4
a=0;
b=Pi/2;
n=4;

Clear[MID]
MID[a0_,b0_,m0_]:=
Module[{a=N[a0],b=N[b0],m=m0,k},
h = (b-a)/m; 
start=a+h/2; 
Print[{"x_i","f(x_i)" }];
sum=0;
For[ k=0, k≤m-1, k++, 
sum=sum+f[start+k*h ];
Print[{start+k*h,f[start+k*h ]}]
 ];  
Return[ h*sum ];
 ];

MID[a,b,n]

#21, p. 307: here we need to set up a Riemann sum, but this gives us a check on our answer:

Integrate[4-2x,{x,2,5}]

#33, p. 307: you need to actually compute some areas!