`f(x)=cosx` and `h = 0.05`, estimate `f^'(1.2) and f^('')(1.2)`
using Four point Forward difference, Backward difference, Central difference formula numerical differentiation
Also find exact value of f', f'' and error for each estimation
Solution:
Equation is `f(x) = cos(x)`.
`:. f^'(x) = -sin(x)`
`:. f^('')(x) = -cos(x)`
The value of table for `x` and `y`
x | 1.05 | 1.1 | 1.15 | 1.2 | 1.25 | 1.3 | 1.35 |
---|
y | 0.4976 | 0.4536 | 0.4085 | 0.3624 | 0.3153 | 0.2675 | 0.219 |
---|
Four-point CDF (Central difference formula)
`f^'(x)=1/(12h)[f(x-2h)-8f(x-h)+8f(x+h)-f(x+2h)]`
`f^'(1.2)=1/(12*0.05)[f(1.2-2*0.05)-8f(1.2-0.05)+8f(1.2+0.05)-f(1.2+2*0.05)]`
`f^'(1.2)=1/0.6[f(1.1)-8f(1.15)+8f(1.25)-f(1.3)]`
`f^'(1.2)=1/0.6[0.4536-8(0.4085)+8(0.3153)-0.2675]`
`f^'(1.2)=-0.932`
Absolute Error:`|"exact value of " f^'(1.2)-(-0.932)|=|-0.932 +0.932|=0`
Four-point FDF (Forward difference formula) for second derivatives
`f^('')(x)=(2f(x)-5f(x+h)+4f(x+2h)-f(x+3h))/(h^2)`
`f^('')(1.2)=(2f(1.2)-5f(1.2+0.05)+4f(1.2+2*0.05)-f(1.2+3*0.05))/((0.05)^2)`
`f^('')(1.2)=(2f(1.2)-5f(1.25)+4f(1.3)-f(1.35))/(0.0025)`
`f^('')(1.2)=(2(0.3624)-5(0.3153)+4(0.2675)-(0.219))/(0.0025)`
`f^('')(1.2)=-0.3631`
Absolute Error:`|"exact value of " f^('')(1.2)-(-0.3631)|=|-0.3624 +0.3631|=0.0007`
Four-point BDF (Backward difference formula) for second derivatives
`f^('')(x)=(-f(x-3h)+4f(x-2h)-5f(x-h)+2f(x))/(h^2)`
`f^('')(1.2)=(-f(1.2-3*0.05)+4f(1.2-2*0.05)-5f(1.2-0.05)+2f(1.2))/((0.05)^2)`
`f^('')(1.2)=(-f(1.05)+4f(1.1)-5f(1.15)+2f(1.2))/(0.0025)`
`f^('')(1.2)=(-0.4976+4(0.4536)-5(0.4085)+2(0.3624))/(0.0025)`
`f^('')(1.2)=-0.3633`
Absolute Error:`|"exact value of " f^('')(1.2)-(-0.3633)|=|-0.3624 +0.3633|=0.0009`
This material is intended as a summary. Use your textbook for detail explanation.
Any bug, improvement, feedback then