Evaluate the following integral: π° = β« ππ¬π’π§(π)π π π /π
π
(1) analytically, (2) using single application of the trapezoidal rule, (3) using composite
trapezoidal rule with n = 2 and 4. For the numerical estimates (2) and (3), determine the true
percent relative error based on (1).
1)
"\\int^{\\pi\/4}_0 xsinx dx=-xcosx|^{\\pi\/4}_0+\\int^{\\pi\/4}_0 cosx dx="
"=-xcosx|^{\\pi\/4}_0+sinx|^{\\pi\/4}_0=-\\frac{\\pi}{4\\sqrt 2}+\\frac{1}{\\sqrt 2}=0.152"
2)
"f(x)=xsinx"
"I=(b-a)\\frac{f(a)+f(b)}{2}=\\frac{\\pi}{4}\\frac{\\pi}{2\\cdot4\\sqrt 2}=0.436"
3)
for n = 2:
"I=\\frac{\\pi}{8}(\\frac{f(0)+f(\\pi\/8)}{2}+\\frac{f(\\pi\/8)+f(\\pi\/4)}{2})=\\frac{\\pi}{8}(\\pi sin(\\pi\/8)\/8+\\pi sin(\\pi\/4)\/8)=0.021"
for n = 4:
"I=\\frac{\\pi}{16}(\\frac{f(0)+f(\\pi\/16)}{2}+\\frac{f(\\pi\/16)+f(\\pi\/8)}{2}+\\frac{f(\\pi\/8)+f(3\\pi\/16)}{2}+\\frac{f(3\\pi\/16)+f(\\pi\/4)}{2})="
"=\\frac{\\pi}{16}(\\pi sin(\\pi\/16)\/16+\\pi sin(\\pi\/8)\/8+3\\pi sin(3\\pi\/16)\/16+\\pi sin(\\pi\/4)\/8)="
"=0.616(0.012+0.048+0.104+0.88)=0.155"
relative error:
for single application:
"\\frac{0.436-0.152}{0.152}=1.87=187\\%"
for n = 2:
"\\frac{0.152-0.021}{0.152}=0.86=86\\%"
for n = 4:
"\\frac{0.155-0.152}{0.152}=0.02=2\\%"
Comments
Leave a comment