Professional Documents
Culture Documents
Problem Set 11: Numerical Difference EXERCISE 7. Solve The Following Problems Using Numerical Differentiation Approximation
Problem Set 11: Numerical Difference EXERCISE 7. Solve The Following Problems Using Numerical Differentiation Approximation
Arranguez
Course, Year and Section: BSIE 2-E
Advance Mathematics
Problem Set 11: Numerical Difference
Function values:
x f(x)
x-2h 0 1.2
x-h 0.25 1.103516
x 0.5 0.925
x+h 0.75 0.636328
x+2h 1 0.2
Forward Difference
( ) ( )
( )
( )
Backward Difference
( ) ( )
( )
( )
Centered Difference
( ) ( )
( )
( )
2.) Use centered difference approximations to estimate the first and second derivatives of
at for
Solution:
;
Function values:
Column1 x f(x)
x-2h 1.8 6.049647464
x-h 1.9 6.685894442
x 2 7.389056099
x+h 2.1 8.166169913
x+2h 2.2 9.025013499
1st derivative
3-Points Center Difference Formula
( ) ( )
( )
( )
2nd derivative
3-Points Center Difference Formula
( ) ( ) ( )
( )
( )
1st derivative
Method Exact Numerical Error
3PCDF 7.3890561 7.40137735 0.16675%
5PCDF 7.3890561 7.38903144 0.00033%
2nd derivative
Method Exact Numerical Error
3PCDF 7.3890561 7.3952157 0.08336%
5PCDF 7.3890561 7.38904788 0.00011%
Therefore, for the first and second derivative, the 5-Points Center Difference Formula or the 2nd
order central difference approximations provides the least error as compared to the other one.
3.) Compute the first order central difference approximations for each of the following functions at
the specified location and for the specified step size.
Solutions:
a.)
The Exact Value is:
Function values:
Column1 x f(x)
x-2h -0.5 -17.125
x-h -0.25 -16.015625
x 0 -15
x+h 0.25 -13.984375
x+2h 0.5 -12.875
( ) ( ) ( ) ( )
( )
( ) ( )
( )
( )
( )
| |
| |
b.)
Function Values:
x f(x)
x-2h 0.2 0.039202663
x-h 0.3 0.085980284
x 0.4 0.147369759
x+h 0.5 0.21939564
x+2h 0.6 0.297120821
| |
| |
c.) ( )
Function Values:
x f(x)
x-2h 2 0.786842889
x-h 2.5 1.100778369
x 3 1.557407725
x+h 3.5 2.338253564
x+2h 4 4.131728991
( ) ( ) ( ) ( )
( )
( ) ( )
( )
( )
( )
| |
| |
( √ )
d.)
The Exact Value is:
( √ ) ( √ )
Function Values:
x f(x)
x-2h 0.6 0.629480393
x-h 0.8 0.540568549
x 1 0.479425539
x+h 1.2 0.433953583
x+2h 1.4 0.398354598
( ) ( ) ( ) ( )
( )
( ) ( )
( )
( )
( )
| |
| |
e.)
Function Values:
x f(x)
x-2h 1.6 6.553032424
x-h 1.8 7.849647464
x 2 9.389056099
x+h 2.2 11.2250135
x+2h 2.4 13.42317638
| |
| |
Summary of results:
Exact Value Numerical Error
a 4 3.9998 0.005%
b 0.67454186 0.67450833 0.005%
c 1.14184 1.092487 4.322%
d -0.26003 -0.26028 0.096%
e 8.389056 8.388648 0.005%
4.) The objective of this problem is to compare second-order accurate forward, backward, and
centered finite-difference approximation of the first derivative of a function to the actual value
of the derivative. This will be done for ( )
a.) Use differential calculus to determine the correct value of the derivative at x=2.
( )
( )
( ) ( )
( )
( )
b.) To evaluate the centered finite-difference approximation start with . Thus, for the
first evaluation, the x values for the centered difference approximation will be
Then, decrease in increments of 0.01 down to a minimum value
of
h Central Error h Central Error h Central Error
0.5 -1.0430 0.6191 0.33 -1.0393 0.2622 0.16 -1.0373 0.0606
0.49 -1.0428 0.5934 0.32 -1.0392 0.2462 0.15 -1.0372 0.0533
0.48 -1.0425 0.5684 0.31 -1.0390 0.2308 0.14 -1.0371 0.0464
0.47 -1.0423 0.5439 0.30 -1.0389 0.2159 0.13 -1.0370 0.0400
0.46 -1.0420 0.5200 0.29 -1.0387 0.2015 0.12 -1.0370 0.0340
0.45 -1.0418 0.4968 0.28 -1.0386 0.1876 0.11 -1.0369 0.0286
0.44 -1.0415 0.4741 0.27 -1.0384 0.1743 0.1 -1.0369 0.0236
0.43 -1.0413 0.4520 0.26 -1.0383 0.1614 0.09 -1.0368 0.0191
0.42 -1.0411 0.4305 0.25 -1.0382 0.1491 0.08 -1.0368 0.0151
0.41 -1.0409 0.4096 0.24 -1.0381 0.1373 0.07 -1.0368 0.0166
0.4 -1.0407 0.3892 0.23 -1.0379 0.1260 0.06 -1.0367 0.0085
0.39 -1.0405 0.3694 0.22 -1.0378 0.1152 0.05 -1.0367 0.0059
0.38 -1.0403 0.3502 0.21 -1.0377 0.1048 0.04 -1.0367 0.0038
0.37 -1.0401 0.3315 0.20 -1.0376 0.0950 0.03 -1.0367 0.0021
0.36 -1.0399 0.3133 0.19 -1.0375 0.0857 0.02 -1.0366 0.0010
0.35 -1.0397 0.2958 0.18 -1.0374 0.0769 0.01 -1.0366 0.0003
0.34 -1.0395 0.2787 0.17 -1.0373 0.0685
c.) Repeat part (b) for the second-order forward & backward differences. (Note that these can
be done at the same time that the centered difference is computed in the loop.)
d.) Plot the results of (b) and (c) versus x. Include the exact result on the plot for comparison.
Therefore, the three methods yield the same result with the exact result.