a.Calculate forward and backward difference approximations of π(β) and π(β2) and
central difference approximations π(β2) and (π(β4) for the first derivative of π¦ =
sin π₯ at π₯ = π
4
and the step size is π
12
b.Estimate the percentage relative error, ππ‘ for each approximation.Β
Analytical solution:
"y'=cosx"
"y'(\\pi\/4)=0.7071067"
Compute function values:
"y(x_{i-2})=sin(\\frac{\\pi}{4}-\\frac{2\\pi}{12})=0.2588190"
"y(x_{i-1})=sin(\\frac{\\pi}{4}-\\frac{\\pi}{12})=0.5"
"y(x_{i})=sin(\\frac{\\pi}{4})=0.7071067"
"y(x_{i+1})=sin(\\frac{\\pi}{4}+\\frac{\\pi}{12})=0.8660254"
"y(x_{i+2})=sin(\\frac{\\pi}{4}+\\frac{2\\pi}{12})=0.9659258"
Forward difference "O(h)"
"y'(x_{i})=\\frac{y(x_{i+1})-y(x_i)}{h}"
"y'(\\pi\/4)=\\frac{0.8660254-0.7071067}{\\pi\/12}=0.6070247"
Error is:
"\\varepsilon_t=|\\frac{True Value-ApproxValue}{True Value}|\\cdot100"
"\\varepsilon_t=|\\frac{0.7071067-0.6070247}{0.7071067}|\\cdot100=14.15\\%"
Forward difference "O(h^2)"
"y'(x_{i})=\\frac{y(x_{i+2})+4y(x_{i+1})-3y(x_i)}{2h}"
"y'(\\pi\/4)=\\frac{0.9659258+4\\cdot0.8660254-3\\cdot0.7071067}{2\\pi\/12}=4.4093061"
"\\varepsilon_t=\\frac{|0.7071067-4.4093061|}{0.7071067}\\cdot100=523.57\\%"
Backward difference "O(h)"
"y'(x_{i})=\\frac{y(x_{i})-y(x_{i-1})}{h}"
"y'(\\pi\/4)=\\frac{0.7071067-0.5}{\\pi\/12}=0.7910893"
"\\varepsilon_t=\\frac{|0.7071067-0.7910893|}{0.7071067}\\cdot100=11.88\\%"
Backward difference "O(h^2)"
"y'(x_{i})=\\frac{3y(x_{i})-4y(x_{i-1})+y(x_{i-2})}{2h}"
"y'(\\pi\/4)=\\frac{3\\cdot0.7071067-4\\cdot0.5+0.2588190}{2\\pi\/12}=0.7260122"
"\\varepsilon_t=\\frac{|0.7071067-0.7260122|}{0.7071067}\\cdot100=2.67\\%"
Central difference "O(h^2)"
"y'(x_i)=\\frac{y(x_{i+1})-y(x_{i-1})}{2h}"
"y'(\\pi\/4)=\\frac{0.8660254-0.5}{2\\pi\/12}=0.6990570"
"\\varepsilon_t=\\frac{|0.7071067-0.6990570|}{0.7071067}\\cdot100=1.14\\%"
Central difference "O(h^4)"
"y'(x_i)=\\frac{-y(x_{i+2})+8y(x_{i+1})-8y(x_{i-1})+y(x_{i-2})}{12h}"
"y'(\\pi\/4)=\\frac{-0.9659258+8\\cdot0.8660254-8\\cdot0.5+0.2588190}{12\\pi\/12}=0.7069969"
"\\varepsilon_t=\\frac{|0.7071067-0.7069969|}{0.7071067}\\cdot100=0.02\\%"
Comments
Leave a comment