ENCE 201. EXAMPLE PROGRAMS

This web page contains example programs that will be covered in class.
Programs are written in Java and Matlab.
Web page in progress!!!

 BASIC NUMERICAL ANALYSIS PROGRAM OUTPUT AND SOURCE CODE Loss of Numerical Precision. This program illustrates the limitations of finite precision representation of floating point numbers, and how seemingly simple calculations can lead to a steady accumulation of numerical errors. This program works through three experiments: (1) Simple arithmetic (4.0/3.0) with floating point (32-bit) numbers; (2) Simple arithmetic (4.0/3.0) with double precision floating point (64-bit) numbers; and (3) Simple arithmetic with a number (0.10) whose binary representation contains an infinite series of digits. Standalone Program: NumericalPrecision.java Program Output: output Substractive Cancellation. Subtractive cancellation occurs when two numbers of almost equal value are subtracted. The result is a loss of significant digits. This program illustrates two common strategies for avoiding subtractive cancellation: (1) rewrite arithmetic expressions to avoid subtraction; and (2) replace an arithmetic expression with an approximation that evaluates to a more accurate numerical value. Standalone Program: SubtractiveCancellation.java Program Output: output Root finding with the Method of Bisection. Demonstrate use of bisection method to compute roots of the quadratic. ``` f(x) = (x-3)*(x-3) - 2; ``` M-files: myfunc3.m bisection.m testroot1.m Program Output: output Root finding with the Newton Raphson Algorithm. Demonstrate use of newton-raphson algorithm by computing roots of the quadratic equation ``` f(x) = (x-3)*(x-3) - 2; ``` The derivative is given by: ``` df(x)/dx = 2x - 6. ``` M-files: myfunc3.m myfunc3dfdx.m newtonraphson.m testroot2.m Program Output: output Gauss Elimination. M-files: gaussnaive.m gausspivot.m testgauss1.m Program Output: output Gauss Seidel Iteration. M-files: gaussseidel.m testgaussseidel.m Program Output: output

ACKNOWLEDGEMENTS

1. ......

Developed in February 2007 by Mark Austin
Copyright © 2007, Department of Civil and Environmental Engineering, University of Maryland