1 (b) For \(f(x)=\cos x\), the Trapezoid Rule is \(S_{[a,b]}= (b-a)(\cos a+\cos b)/2\). Begin with one interval \(S_{[0,\frac{\pi}{2}]} = 0.7854\). Checking the interval \([0,\frac{\pi}{2}]\), \[S_{[0,\frac{\pi}{4}]}\approx 0.6704,\quad S_{[\frac{\pi}{4},\frac{\pi}{2}]} \approx 0.2777, \quad |S_{[0,\frac{\pi}{2}]} -S_{[0,\frac{\pi}{4}]} -S_{[\frac{\pi}{4},\frac{\pi}{2}]}|\approx 0.1627>3\ \text{TOL}=0.15,\] therefore \(S_{[0,\frac{\pi}{2}]}\) is rejected and \([0,\frac{\pi}{4}], [\frac{\pi}{4},\frac{\pi}{2}]\) are added to the list of intervals.
Checking the interval \([0,\frac{\pi}{4}]\), \[S_{[0,\frac{\pi}{8}]}\approx 0.3778,\quad S_{[\frac{\pi}{8},\frac{\pi}{4}]} \approx 0.3202, \quad |S_{[0,\frac{\pi}{4}]} -S_{[0,\frac{\pi}{8}]} -S_{[\frac{\pi}{8},\frac{\pi}{4}]}|\approx 0.0275<\frac{3}{2}\text{TOL}=0.075,\] therefore the estimate \(S_{[0,\frac{\pi}{8}]}+ S_{[\frac{\pi}{8},\frac{\pi}{4}]}=0.6980\) is accepted for \([0,\pi/4]\).
Checking the interval \([\frac{\pi}{4},\frac{\pi}{2}]\), \[S_{[\frac{\pi}{4},\frac{3\pi}{8}]}\approx 0.2140, S_{[\frac{3\pi}{8},\frac{\pi}{2}]} \approx 0.0751, |S_{[\frac{\pi}{4},\frac{\pi}{2}]} -S_{[\frac{\pi}{4},\frac{3\pi}{8}]} -S_{[\frac{3\pi}{8},\frac{\pi}{2}]}|\approx 0.0114<\frac{3}{2}\text{TOL}=0.075,\] therefore the estimate \(S_{[\frac{\pi}{4},\frac{3\pi}{8}]}+ S_{[\frac{3\pi}{8},\frac{\pi}{2}]}=0.2891\) is accepted for \([\pi/4,\pi/2]\). Adding the accepted estimates above, the approximate integral is \(0.6980+ 0.2891 = 0.9871\). Compared to the correct value \(1\) of the integral, the error is \(0.0129<0.05\) as required.
1 (c) For \(f(x)=e^x\), the Trapezoid Rule is \(S_{[a,b]}= (b-a)(e^a+e^b)/2\). Begin with one interval \(S_{[0,1]} = (1+e)/2\approx 1.8591\). Checking the interval \([0,1]\), \[S_{[0,\frac{1}{2}]}\approx 0.6622, S_{[\frac{1}{2},1]}\approx 1.0917, |S_{[0,1]}-S_{[0,\frac{1}{2}]} -S_{[\frac{1}{2},1]}|\approx 0.1051<3\ \text{TOL}=0.15,\] therefore the estimate \[S_{[0,\frac{1}{2}]}+S_{[\frac{1}{2},1]}= 1.7539\] is accepted for the integral. The error is \(|(e-1)- 1.7539|\approx 0.0356%lt 0.05\) as required.