`f(x)=cosx` and `h = 0.05`, estimate `f^'(1.2) and f^('')(1.2)`
using Three 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.1 | 1.15 | 1.2 | 1.25 | 1.3 |
---|
y | 0.4536 | 0.4085 | 0.3624 | 0.3153 | 0.2675 |
---|
Three-point FDF (Forward difference formula)
`f^'(x)=1/(2h)[-3f(x)+4f(x+h)-f(x+2h)]`
`f^'(1.2)=1/(2*0.05)[-3f(1.2)+4f(1.2+0.05)-f(1.2+2*0.05)]`
`f^'(1.2)=1/0.1[-3f(1.2)+4f(1.25)-f(1.3)]`
`f^'(1.2)=1/0.1[-3(0.3624)+4(0.3153)-0.2675]`
`f^'(1.2)=-0.9328`
Absolute Error:`|"exact value of " f^'(1.2)-(-0.9328)|=|-0.932 +0.9328|=0.0008`
Three-point BDF (Backward difference formula)
`f^'(x)=1/(2h)[f(x-2h)-4f(x-h)+3f(x)]`
`f^'(1.2)=1/(2*0.05)[f(1.2-2*0.05)-4f(1.2-0.05)+3f(1.2)]`
`f^'(1.2)=1/0.1[f(1.1)-4f(1.15)+3f(1.2)]`
`f^'(1.2)=1/0.1[0.4536-4(0.4085)+3(0.3624)]`
`f^'(1.2)=-0.9328`
Absolute Error:`|"exact value of " f^'(1.2)-(-0.9328)|=|-0.932 +0.9328|=0.0008`
Three-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`
Three-point FDF (Forward difference formula) for second derivatives
`f^('')(x)=(f(x)-2f(x+h)+f(x+2h))/(h^2)`
`f^('')(1.2)=(f(1.2)-2f(1.2+0.05)+f(1.2+2*0.05))/((0.05)^2)`
`f^('')(1.2)=(f(1.2)-2f(1.25)+f(1.3))/(0.0025)`
`f^('')(1.2)=(0.3624-2(0.3153)+0.2675)/(0.0025)`
`f^('')(1.2)=-0.3153`
Absolute Error:`|"exact value of " f^('')(1.2)-(-0.3153)|=|-0.3624 +0.3153|=0.0471`
Three-point BDF (Backward difference formula) for second derivatives
`f^('')(x)=(f(x-2h)-2f(x-h)+f(x))/(h^2)`
`f^('')(1.2)=(f(1.2-2*0.05)-2f(1.2-0.05)+f(1.2))/((0.05)^2)`
`f^('')(1.2)=(f(1.1)-2f(1.15)+f(1.2))/(0.0025)`
`f^('')(1.2)=(0.4536-2(0.4085)+0.3624)/(0.0025)`
`f^('')(1.2)=-0.4084`
Absolute Error:`|"exact value of " f^('')(1.2)-(-0.4084)|=|-0.3624 +0.4084|=0.046`
Three-point CDF (Central difference formula) for second derivatives
`f^('')(x)=(f(x-h)-2f(x)+f(x+h))/(h^2)`
`f^('')(1.2)=(f(1.2-0.05)-2f(1.2)+f(1.2+0.05))/(0.05)^2`
`f^('')(1.2)=(f(1.15)-2f(1.2)+f(1.25))/(0.0025)`
`f^('')(1.2)=(0.4085-2(0.3624)+0.3153)/(0.0025)`
`f^('')(1.2)=-0.3623`
Absolute Error:`|"exact value of " f^('')(1.2)-(-0.3623)|=|-0.3624 +0.3623|=0.0001`
This material is intended as a summary. Use your textbook for detail explanation.
Any bug, improvement, feedback then