Numerical differentiation
Let f(x) be a given function which is known at a number of (isolated) points, then numerical differentiation is a process of calculating derivative of f(x) at some point of x. It is an approximation to the derivative f(x). We know that derivative of f(x) at a is\( f'(a)=\displaystyle \lim_{h \to 0} \frac{f(a+h)-f(a)}{h}\)
Now, Numerical differentiation approximates the derivative of f(x) at a by
\( f'(a)=\frac{f(a+h)-f(a)}{h}\)
This approximation is called Newton’s difference quotient or Newton’s quotient.
Next, why do we need to approximated derivatives? there are several reasons, some of them are as follows
- we know values at a sample points but function does not exist
- function may exist, but we have a discrete data points only
- function exist, but formula are very complicated to compute
- If values of x are equi-spaced and\( \frac{dy}{dx} \) is required near beginning of the table, we employ Newton’s forward formula
- If values of x are equi-spaced and\( \frac{dy}{dx} \) is required near end of the table, we employ Newton’s backard formula
- If values of x are equi-spaced and\( \frac{dy}{dx} \) is required near middle of the table, we employ Stirling's or Bessel’s formula
- If values of x are not equi-spaced then\( \frac{dy}{dx} \) is calculated by Newton’s divided difference formula
Numerical differentiation: Newton’s forward formula
Suppose\(y=f( x )\)is tabulated for equally spaced valued
\( x=x_0,x_1,x_2,\ldots ,x_n \)
given by
\( y=y_0,y_1,y_2,\ldots ,y_n \)
Here,
\(x_i=x_0+ih\) for \(i=0,1,2,\ldots ,n\)
Since,
\(x=x_0+ph\)
Therefore,
\(dx=h dp\) or \(\frac{dp}{dx}=\frac{1}{h} \)
Now, Newton’s forward difference interpolation formula is
\(y=y_0+p\Delta y_0+\frac{p( p-1 )}{2!}\Delta ^2y_0+\frac{p( p-1 )( p-2 )}{3!}\Delta ^3y_0+\ldots \)
Differentiation both sides w. r. to x, we get
\(\frac{dy}{dx}=\frac{d}{dx} \left [y_0+p\Delta y_0+\frac{p( p-1 )}{2!}\Delta ^2y_0+\frac{p( p-1 )( p-2 )}{3!}\Delta ^3y_0+\ldots \right ] \)
or \(\frac{dy}{dx}=\frac{d}{dp} \left [y_0+p\Delta y_0+\frac{p( p-1 )}{2!}\Delta ^2y_0+\frac{p( p-1 )( p-2 )}{3!}\Delta ^3y_0+\ldots \right ]\frac{dp}{dx} \)
or \(\frac{dy}{dx}= \left [\Delta y_0+\frac{2p-1}{2!}\Delta ^2y_0+\frac{3{p^2}-6p+2}{3!}\Delta ^3y_0+\ldots \right ]\frac{1}{h} \)
or \(\frac{dy}{dx}= \frac{1}{h} \left [\Delta y_0+\frac{2p-1}{2!}\Delta ^2y_0+\frac{3{p^2}-6p+2}{3!}\Delta ^3y_0+\ldots \right ]\)
At \( x=x_0\), we have \(p=0\), therefore, we have
\( [ \frac{dy}{dx}]_{x=x_0} =\frac{1}{h}[ \Delta y_0+\frac{2p-1}{2!}\Delta ^2y_0+\frac{3p^2-6p+2}{3!}\Delta ^3y_0+\ldots ] \)
or
\( [\frac{dy}{dx}]_{x=x_0}=\frac{1}{h}[ \Delta y_0-\frac{1}{2}\Delta ^2y_0+\frac{1}{3}\Delta ^3y_0+\ldots ] \)
X | Y | 1st diff | 2nd diff | 3rd diff | 4th diff | 5th diff | 6th diff | Coefficient |
\( x_0\) | \( y_0\) | |||||||
\( \Delta y_0\) | 1 | |||||||
\( x_1\) | \( y_1\) | \( \Delta^2 y_0\) | \(- \frac{1}{2}\) | |||||
\( \Delta y_1\) | \( \Delta^3 y_0\) | \( \frac{1}{3}\) | ||||||
\( x_2\) | \( y_2\) | \( \Delta^2 y_1\) | \( \Delta^4 y_0\) | \(- \frac{1}{4}\) | ||||
\( \Delta y_2\) | \( \Delta^3 y_1\) | \( \Delta^5 y_0\) | \(\frac{1}{5}\) | |||||
\( x_3\) | \( y_3\) | \( \Delta^2 y_2\) | \( \Delta^4 y_1\) | \( \Delta^6 y_0\) | \(- \frac{1}{6}\) | |||
\( \Delta y_3\) | \( \Delta^3 y_2\) | \( \Delta^5 y_1 \) | ||||||
\( x_4\) | \( y_4\) | \( \Delta^2 y_3\) | \( \Delta^4 y_2\) | |||||
\( \Delta y_4\) | \( \Delta^3 y_3\) | |||||||
\( x_5\) | \( x_5\) | \( \Delta^2 y_4\) | ||||||
\( \Delta y_5\) | ||||||||
\( x_6\) | \( x_6\) |
Similarly,
\(\frac{dy}{dx}= \frac{1}{h}\left [\Delta y_0+\frac{2p-1}{2!}\Delta ^2y_0+\frac{3{p^2}-6p+2}{3!}\Delta ^3y_0+\ldots \right ] \)
Differentiation both sides w. r. to x, we get
\(\frac{d^2y}{dx^2}=\frac{d}{dx} \frac{1}{h} \left [\Delta y_0+\frac{2p-1}{2!}\Delta ^2y_0+\frac{3{p^2}-6p+2}{3!}\Delta ^3y_0+\ldots \right ] \)
or \(\frac{d^2y}{dx^2}=\frac{1}{h} \frac{d}{dp} \left [\Delta y_0+\frac{2p-1}{2!}\Delta ^2y_0+\frac{3{p^2}-6p+2}{3!}\Delta ^3y_0+\ldots \right ] \frac{dp}{dx} \)
or \(\frac{d^2y}{dx^2}=\frac{1}{h} \left [\frac{2}{2!}\Delta ^2y_0+\frac{6p-6}{3!}\Delta ^3y_0+\ldots \right ] \frac{1}{h} \)
or \(\frac{d^2y}{dx^2}=\frac{1}{h^2} \left [\Delta ^2y_0+(p-1) \Delta ^3y_0+\ldots \right ] \)
Now, at \( x=x_0\), we have \(p=0\), therefore
\(\frac{d^2y}{dx^2}|_{x=x_0}=\frac{1}{h^2}[ \Delta ^2y_0-\Delta ^3y_0+\frac{11}{12}\Delta ^4y_0-\frac{5}{6}\Delta ^5y_0+\frac{137}{180}\Delta ^6y_0-\ldots ]\)
X | Y | 1st diff | 2nd diff | 3rd diff | 4th diff | 5th diff | 6th diff | Coefficient |
\( x_0\) | \( y_0\) | |||||||
\( \Delta y_0\) | ||||||||
\( x_1\) | \( y_1\) | \( \Delta^2 y_0\) | \(1\) | |||||
\( \Delta y_1\) | \( \Delta^3 y_0\) | -\(1\) | ||||||
\( x_2\) | \( y_2\) | \( \Delta^2 y_1\) | \( \Delta^4 y_0\) | \(\frac{11}{12}\) | ||||
\( \Delta y_2\) | \( \Delta^3 y_1\) | \( \Delta^5 y_0\) | -\(\frac{5}{6}\) | |||||
\( x_3\) | \( y_3\) | \( \Delta^2 y_2\) | \( \Delta^4 y_1\) | \( \Delta^6 y_0\) | \(\frac{137}{180}\) | |||
\( \Delta y_3\) | \( \Delta^3 y_2\) | \( \Delta^5 y_1 \) | ||||||
\( x_4\) | \( y_4\) | \( \Delta^2 y_3\) | \( \Delta^4 y_2\) | |||||
\( \Delta y_4\) | \( \Delta^3 y_3\) | |||||||
\( x_5\) | \( x_5\) | \( \Delta^2 y_4\) | ||||||
\( \Delta y_5\) | ||||||||
\( x_6\) | \( x_6\) |
Example
Form the following data, find the first and second derivative at x=1.2
1 | 1.2 | 1.4 | 1.6 | 1.8 | 2 | 2.2 |
2.718 | 3.32 | 4.055 | 4.953 | 6.049 | 7.389 | 9.025 |
Solution
The difference table is given below
X | Y | 1st diff | 2nd diff | 3rd diff | 4th diff | 5th diff | 6th diff |
1 | 2.718 | ||||||
0.602 | |||||||
1.2 | 3.32 | 0.133 | |||||
0.735 | 0.03 | ||||||
1.4 | 4.055 | 0.163 | 0.005 | ||||
0.898 | 0.035 | 0.006 | |||||
1.6 | 4.953 | 0.198 | 0.011 | -0.011 | |||
1.096 | 0.046 | -0.005 | |||||
1.8 | 6.049 | 0.244 | 0.006 | ||||
1.34 | 0.052 | ||||||
2 | 7.389 | 0.296 | |||||
1.636 | |||||||
2.2 | 9.025 |
Now, the first derivative is
\( [\frac{dy}{dx}]_{x=x_0}=\frac{1}{h}[ \Delta y_0-\frac{1}{2}\Delta ^2y_0+\frac{1}{3}\Delta ^3y_0+\ldots ] \)
or
\( [\frac{dy}{dx}]_{x=1.2}=
\frac{1}{0.2}[ 0.735-\frac{1}{2}0.163+
\frac{1}{3}0.035-\frac{1}{4}0.011+\frac{1}{5}(-0.005)] =3.3205\)
Now, the second derivative is
\(\frac{d^2y}{dx^2}|_{x=x_0}=\frac{1}{h^2}[ \Delta ^2y_0-\Delta ^3y_0+\frac{11}{12}\Delta ^4y_0-\frac{5}{6}\Delta ^5y_0+\frac{137}{180}\Delta ^6y_0-\ldots ]\)
or
\(\frac{d^2y}{dx^2}|_{x=1.2}=\frac{1}{0.04}[ 0.163-0.035+\frac{11}{12}0.011-\frac{5}{6}(-0.005) ]=3.32\)
Numerical differentiation: Newton’s backward formula
Suppose\(y=f( x )\)is tabulated for equally spaced valued
\( x=x_0,x_1,x_2,\ldots ,x_n \)
given by
\( y=y_0,y_1,y_2,\ldots ,y_n \)
Here,
\(x_i=x_0+ih\) for \(i=0,1,2,\ldots ,n\)
Since,
\(x=x_n+ph\)
Therefore,
\(dx=h dp\) or \(\frac{dp}{dx}=\frac{1}{h} \)
Now, Newton’s backward difference interpolation formula is
\( y=y_n+p\nabla y_n+\frac{p( p+1 )}{2!}\nabla ^2y_n+\frac{p( p+1 )( p+2 )}{3!}\nabla ^3y_n+\ldots \)
Differentiation both sides w. r. to x, we get
\( \frac{dy}{dx}= \frac{d}{dx} \left [ y_n+p\nabla y_n+\frac{p( p+1 )}{2!}\nabla ^2y_n+\frac{p( p+1 )( p+2 )}{3!}\nabla ^3y_n+\ldots \right ]\)
or \( \frac{dy}{dx}= \frac{d}{dp} \left [ y_n+p\nabla y_n+\frac{p( p+1 )}{2!}\nabla ^2y_n+\frac{p( p+1 )( p+2 )}{3!}\nabla ^3y_n+\ldots \right ] \frac{dp}{dx}\)
or \( \frac{dy}{dx}= \left [ \nabla y_n+\frac{2p+1}{2!}\nabla ^2y_n+\frac{3{p^2}+6p+2}{3!}\nabla ^3y_n+\ldots \right ] \frac{1}{h}\)
or \( \frac{dy}{dx}= \frac{1}{h} \left [ \nabla y_n+\frac{2p+1}{2!}\nabla ^2y_n+\frac{3{p^2}+6p+2}{3!}\nabla ^3y_n+\ldots \right ] \)
Now, at \( x=x_n\), we have \(p=0\), therefore
\( [ \frac{dy}{dx}]_{x=x_n} =\frac{1}{h}[ \nabla y_n+\frac{2p+1}{2!}\nabla ^2y_n+\frac{3{p^2}+6p+2}{3!}\nabla ^3y_n+\ldots ] \)
or \( [ \frac{dy}{dx}]_{x=x_n} =\frac{1}{h}[ \nabla y_n+\frac{1}{2!}\nabla ^2y_n+\frac{2}{3!}\nabla ^3y_n+\ldots ] \)
or \( [ \frac{dy}{dx}]_{x=x_n} =\frac{1}{h}[ \nabla y_n+\frac{1}{2}\nabla ^2y_n+\frac{1}{3}\nabla ^3y_n+\ldots ] \)
Similarly, we can show that
\(\frac{d^2y}{dx^2} |_{x=x_n}=\frac{1}{h^2}[ \nabla ^2y_n+\nabla ^3y_n+\frac{11}{12}\nabla ^4y_n+\frac{5}{6}\nabla ^5y_n+\frac{137}{180}\nabla ^6y_n+\ldots ]\)
Example
Form the following data, find the first and second derivative at x=5
0 | 1 | 2 | 3 | 4 | 5 | 6 |
0 | 1 | 10 | 33 | 76 | 145 | 246 |
Solution
The difference table is given below
X | Y | 1st diff | 2nd diff | 3rd diff |
0 | 0 | |||
1 | ||||
1 | 1 | 8 | ||
9 | 6 | |||
2 | 10 | 14 | ||
23 | 6 | |||
3 | 33 | 20 | ||
43 | 6 | |||
4 | 76 | 26 | ||
69 | 6 | |||
5 | 145 | 32 | ||
101 | ||||
6 | 246 |
Numerical differentiation: Stirling’s central formula
Suppose,\(y=f( x )\)is tabulated for equally spaced valued
\(x=\ldots ,x_{-3},x_{-2},x_{-1},x_0,x_1,x_2,x_3,\ldots \)
correspond to the values
\(y=\ldots ,y_{-3},y_{-2},y_{-1},y_0,y_1,y_2,y_3,\ldots \)
Since,
\(x=x_0+ph\)
Therefore,
\(dx=h dp\) or \(\frac{dp}{dx}=\frac{1}{h} \)
Then, Stirling’s central interpolation formula is
\(y=y_0+p[ \frac{\delta y_{-1/2} +\delta y_{1/2}}{2} ]+\frac{p^2}{2!} \delta ^2 y_0+ \frac{p(p^2-1)}{3!} [ \frac{ \delta ^3 y_{-1/2}+ \delta ^3 y_{1/2}}{2} ]+\frac{p^2( p^2-1 )}{4!} \delta ^4 y_0+\frac{p( p^2-1 )( p^2-4 )}{5!} \frac{ \delta ^5 y_{-1/2}+\delta ^5 y_{1/2}}{2}+...\)
Differentiation both sides w. r. to x, we get
\(\frac{dy}{dx}= \frac{d}{dx} [ \frac{\delta y_{-1/2} + \delta y_{1/2}}{2} ]+p\delta ^2 y_0+\frac{( 3p^2-1 )}{3!}[ \frac{\delta^3 y_{-1/2}+\delta^3 y_{1/2}}{2} ]+\frac{( 4p^3-2p )}{4!}\delta^4 y_0+...\)
or \(\frac{dy}{dx}= \frac{d}{dp} \left [ [ \frac{\delta y_{-1/2} + \delta y_{1/2}}{2} ]+p\delta ^2 y_0+\frac{( 3p^2-1 )}{3!}[ \frac{\delta^3 y_{-1/2}+\delta^3 y_{1/2}}{2} ]+\frac{( 4p^3-2p )}{4!}\delta^4 y_0+... \right ] \frac{dp}{dx}\)
or \(\frac{dy}{dx}= \left [ [ \frac{\delta y_{-1/2} + \delta y_{1/2}}{2} ]+p\delta ^2 y_0+\frac{( 3p^2-1 )}{3!}[ \frac{\delta^3 y_{-1/2}+\delta^3 y_{1/2}}{2} ]+\frac{( 4p^3-2p )}{4!}\delta^4 y_0+... \right ] \frac{1}{h}\)
Now, at \( x=x_0\), we have \(p=0\), therefore
\(\frac{dy}{dx} |_{x=x_0}=\frac{1}{h}[ \frac{\delta y_{-1/2} + \delta y_{1/2}}{2}-\frac{1}{6} \frac{\delta^3 y_{-1/2} + \delta^3 y_{1/2}}{2}+ \frac{1}{30} \frac{\delta^5 y_{-1/2} + \delta^5 y_{1/2}}{2} + \ldots ]\)
Similarly, we can show that
\(\frac{d^2y}{dx^2} |_{x=x_0}=\frac{1}{h^2}[ \delta ^2 y_0-\frac{1}{12} \delta ^4 y_0+\frac{1}{90} \delta ^6 y_0-\ldots ]\)
Example 1
Using Stirling's formula to find derivatives at x=900x | 0 | 300 | 600 | 900 | 1200 | 1500 | 1800 |
y | 135 | 149 | 157 | 183 | 201 | 205 | 193 |
According to given set of data values, we form difference table as below
X | Y | 1st diff | 2nd diff | 3rd diff | 4th diff | 5th diff | 6th diff |
0 | 135 | ||||||
14 | |||||||
300 | 149 | -6 | |||||
8 | 24 | ||||||
600 | 157 | 18 | -50 | ||||
26 | -26 | 70 | |||||
900 | 183 | -8 | 20 | -86 | |||
18 | -6 | -16 | |||||
1200 | 201 | -14 | 4 | ||||
4 | -2 | ||||||
1500 | 205 | -16 | |||||
-12 | |||||||
1800 | 193 |
\( h=300\)
Thus, using formula, we get
\( \frac{dy}{dx} |_{x=x_0}=\frac{1}{h}[ \frac{\delta y_{-1/2} + \delta y_{1/2}}{2}-\frac{1}{6} \frac{\delta^3 y_{-1/2} + \delta^3 y_{1/2}}{2}+ \frac{1}{30} \frac{\delta^5 y_{-1/2} + \delta^5 y_{1/2}}{2} + \ldots ]\)
or \(\frac{dy}{dx} |_{x=900}=\frac{1}{300}[ \frac{(26)+(18)}{2}-\frac{1}{6} \frac{(-26)+(-6)}{2}+ \frac{1}{30} \frac{(70)+(-16)}{2} + \ldots ]\)
or \(\frac{dy}{dx} |_{x=900}=0.085\)
This completes
Exercise
- The following data gives the velocity of a particle for twenty seconds
at an interval of five seconds. Find the initial acceleration using the entire
data [answer= 1]
time t 0 5 10 15 20 velocity v 0 3 14 69 228 - Find solution of f'(10) of an equation \(x^2-x+1\) using a = 2 and b= 10, step value h = 1.
- Find solution of f'(3.5) of an equation \(2x^3-4x+1\) using a = 2 and b= 4, step value h = 0.5.
- The elevation above a datum line of seven points of a road are given below, Find the gradient of the road at the point x=6.
x 3 5 7 9 11 y 3 15 35 63 99
No comments:
Post a Comment