`f(x)=cosx` and `h = 0.05`, estimate `f^'(1.2) and f^('')(1.2)`
using Two 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.15 | 1.2 | 1.25 |
---|
y | 0.4085 | 0.3624 | 0.3153 |
---|
Two-point FDF (Forward difference formula)
`f^'(x)=(f(x+h)-f(x))/h`
`f^'(1.2)=(f(1.2+0.05)-f(1.2))/0.05`
`f^'(1.2)=(f(1.25)-f(1.2))/0.05`
`f^'(1.2)=(0.3153-0.3624)/0.05`
`f^'(1.2)=-0.9407`
Absolute Error:`|"exact value of " f^'(1.2)-(-0.9407)|=|-0.932 +0.9407|=0.0087`
Two-point BDF (Backward difference formula)
`f^'(x)=(f(x)-f(x-h))/h`
`f^'(1.2)=(f(1.2)-f(1.2-0.05))/0.05`
`f^'(1.2)=(f(1.2)-f(1.15))/0.05`
`f^'(1.2)=(0.3624-0.4085)/0.05`
`f^'(1.2)=-0.9226`
Absolute Error:`|"exact value of " f^'(1.2)-(-0.9226)|=|-0.932 +0.9226|=0.0094`
Two-point CDF (Central difference formula)
`f^'(x)=(f(x+h)-f(x-h))/(2h)`
`f^'(1.2)=(f(1.2+0.05)-f(1.2-0.05))/(2*0.05)`
`f^'(1.2)=(f(1.25)-f(1.15))/0.1`
`f^'(1.2)=(0.3153-0.4085)/0.1`
`f^'(1.2)=-0.9317`
Absolute Error:`|"exact value of " f^'(1.2)-(-0.9317)|=|-0.932 +0.9317|=0.0004`
This material is intended as a summary. Use your textbook for detail explanation.
Any bug, improvement, feedback then