Use the composite trapezoidal rule to find approximations to πΌ = β« π¬π’π§π π π π
π
with n = 1, 2, 4, and 8. Then perform Romberg extrapolation on the results.
"f(x)=xsinx"
for n = 1:
"I=\\pi(\\frac{f(0)+f(\\pi)}{2})=0"
for n = 2:
"I=\\frac{\\pi}{2}(\\frac{f(0)+f(\\pi\/2)}{2}+\\frac{f(\\pi\/2)+f(\\pi)}{2})=\\frac{\\pi^2}{4}=2.465"
for n = 4:
"I=\\frac{\\pi}{4}(\\frac{f(0)+f(\\pi\/4)}{2}+\\frac{f(\\pi\/4)+f(\\pi\/2)}{2}+\\frac{f(\\pi\/2)+f(3\\pi\/4)}{2}+\\frac{f(3\\pi\/4)+f(\\pi)}{2})="
"=\\frac{\\pi}{4}(\\pi sin(\\pi\/4)\/4+\\pi \/2+3\\pi sin(3\\pi\/4)\/4)=2.975"
for n = 8:
"I=\\frac{\\pi}{8}(f(\\pi\/8)+f(\\pi\/4)+f(3\\pi\/8)+f(\\pi\/2)+f(5\\pi\/8)+f(3\\pi\/4)+f(7\\pi\/8))="
"=1.232(0.048+0.177+0.346+0.5+0.578+0.530+0.336)=3.098"
Romberg extrapolation:
"R_{j,k}=R_{j,k-1}+\\frac{R_{j,k-1}-R_{j-1,k-1}}{4^{k-1}-1}"
for n = 1:
"R_{1,1}=\\pi(\\frac{f(0)+f(\\pi)}{2})=0"
for n = 2:
"R_{2,1}=\\frac{\\pi}{2}(\\frac{f(0)+f(\\pi\/2)}{2}+\\frac{f(\\pi\/2)+f(\\pi)}{2})=2.465"
"R_{2,2}=R_{2,1}+\\frac{R_{2,1}-R_{1,1}}{3}=3.287"
for n = 4:
"R_{3,1}=\\frac{\\pi}{4}(\\frac{f(0)+f(\\pi\/4)}{2}+\\frac{f(\\pi\/4)+f(\\pi\/2)}{2}+\\frac{f(\\pi\/2)+f(3\\pi\/4)}{2}+\\frac{f(3\\pi\/4)+f(\\pi)}{2})=2.975"
"R_{3,2}=R_{3,1}+\\frac{R_{3,1}-R_{2,1}}{3}=3.145"
"R_{3,3}=R_{3,2}+\\frac{R_{3,2}-R_{2,2}}{15}=3.136"
for n = 8:
"R_{4,1}=\\frac{\\pi}{8}(f(\\pi\/8)+f(\\pi\/4)+f(3\\pi\/8)+f(\\pi\/2)+f(5\\pi\/8)+f(3\\pi\/4)+"
"+f(7\\pi\/8))=3.098"
"R_{4,2}=R_{4,1}+\\frac{R_{4,1}-R_{3,1}}{3}=3.139"
"R_{4,3}=R_{4,2}+\\frac{R_{4,2}-R_{3,2}}{15}=3.139"
"I=R_{4,4}=R_{4,3}+\\frac{R_{4,3}-R_{3,3}}{63}=3.139"
Comments
Leave a comment