Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 M 277 (60 h) Mathematics for Computer Sciences Bibliography  Discrete Mathematics and its applications, Kenneth H. Rosen  Numerical Analysis, Richard.

Similar presentations


Presentation on theme: "1 M 277 (60 h) Mathematics for Computer Sciences Bibliography  Discrete Mathematics and its applications, Kenneth H. Rosen  Numerical Analysis, Richard."— Presentation transcript:

1 1 M 277 (60 h) Mathematics for Computer Sciences Bibliography  Discrete Mathematics and its applications, Kenneth H. Rosen  Numerical Analysis, Richard L. Burden, J. Douglas Faires, Albert C. Reynolds. Prindle, Weber & Schmidt Boston, Massachusetts.  Applied Numerical Analysis, Curtis F. Gerald, Patrick O. Wheatley. Addison-wesley publishing company.

2 2 Introduction Numerical analysis is a way to higher mathematics problems on a computer, a technique widely used by scientists and engineers to solve their problems. A major advantage for numerical analysis is that a numerical answer can be obtained even when a problem has no “analytical” solution. Actually, evaluating an analytical result to get the numerical answer (approximation) for a specific application is subject to same errors.

3 3 Contents Algorithms: Introduction, Complexity, Recursive definitions, Recursive algorithms, program correctness Solve for the roots of a nonlinear equation. Solve large systems of linear equations (Direct Methods, Iterative Methods). Interpolate to find intermediate values within a table of data. Integrate any function even when known only as a table of values. Solve ordinary differential equations when given initial values for the variables. Cubic Spline interpolation

4 4 Four general steps 1)State the problem clearly, including any simplifying assumptions. 2)Develop a mathematical statement of the problem in a form that can be solved for a numerical answer. 3)Solve the equation(s) that result from step 2. 4)Interpret the numerical result to arrive at a decision. This will require experience and an understanding of the situation…

5 5 Computer arithmetic and Errors Truncation Error: The term truncation error refers to those errors caused by the method itself. We may approximate e x by the cubic We see that approximating e x with the cubic gives an inexact answer. The error is due to truncating the series.

6 6 Compute the cos(1) ? Error <10 -9

7 7 Round-Off Error: All computing devices represent numbers, except for integers, with some imprecision. Digital computers will nearly always use floating- point numbers of fixed word length. The true values are not expressed exactly by such representations. We call the error due to this computer imperfection the round-off-error. Computer represent their floating-point numbers in the general form: N B = ±.d 1 d 2 d 3 …d p *B e Where the d i ’s are digits or bits with value from zero to B-1 B: The number base that is used (2, 16, 10) P: The number of significand bits (precision) e: an integer exponent, ranging from E min to E max with the values going from from negative E min to positive E max

8 8 Compute 1.37 +.0269 =.137*10 1 +.269*10 -1 Errors Converting Values: The numbers that are input to a computer are ordinarily base-10 values. Thus the input must be converted to the computer’s internal number base (base 2). (0.3) 10 = (0.0100110011001100…) 2

9 9 Examples

10 10 Overflow and underflow: (2 15 -1) and - (2 15 -1) format: 2Bytes =16bits Error Original Data : Real-word problem, in which an existing or proposed physical problem situation is modeled by mathematical equation, will nearly always have coefficients that are imperfectly known.

11 11 Absolute error = true value – approximate value A more formal definition of significant digits follows, 1. Let the true value digits d 1 d 2 …d n d n+1 …d p 2. Let the approximate value have d 1 d 2 …d n e n+1 …e p Where d 1 ≠ 0 and with the first difference in the digits occurring at the (n+1)st digit. We then say (1) and (2) agree to n significant digits if |d n+1 – e n+1 |<5. Otherwise, we say they agree to n-1 significant digits

12 12 Let the true = 10/3 and the approximate value = 3.333 The absolute error is 0.000333…= 1/3000 The relative error is (1/3000)/(10/3) = 1/10000. The number of significant digits is 4.

13 13 Solving Nonlinear Equations Finding values of x to satisfy f(x) = 0. Such values are called the roots of the equation and also are known as the zero of f(x). Bisection method

14 14

15 15 Finding a root of f(x) = x 3 + x 2 - 3.x - 3 starting with a =1, b=2, and tolerance of 10 -4 root = 1.732150808=sqrt(3)

16 16 Bisection Algorithm To find a solution to f(x) = 0 Given the continuous f on the interval [a, b] where f(a) and f(b) have opposite signs: Input endpoints a, b; tolerance TOL maximum number of iterations N 0 Output approximate solution p or message of failure Step 1: Set i=1. Step 2: While i< N 0 do Steps 3-6 Step 3: Set P = a + (b-a)/2 Step 4: If f(p)=0 OR (b-a)/2 < TOL Then Output(p); STOP Step 5: Set i=i+1 Step 6: If f(a).f(b)>0 then Set a = P else set b = P Step 7: Output(‘Method failed after N 0 iterations’) STOP

17 17 Newton’s Method To determine a root of f(x) = 0, Given a value x 0 reasonably close to the root, and f’(x 0 ) ≠ 0 Compute f(x 0 ), f’(x 0 ). Set x 1 = x 0 If (f(x 0 ) ≠ 0) and (f’(x 0 ) ≠ 0) repeat Set x 0 = x 1 Set x 1 = x 0 –f(x 0 )/f’(x 0 ). Until (|x 0 -x 1 |)< tolerance value 1) OR (|f(x 1 )| < tolerance value 2) Note: The method may converge to a root different from the expected one or diverge if the starting value is not close enough to the root.

18 18 Newton Method

19 19 Fixed point method: x = g(x) Method We rearrange f(x) into an equivalent form x = g(x). Observe that if f(r) = 0 → r = g(r) where r is a root of f(r). The iteration form x n+1 = g(x n ) n = 0,1,2,3,.. Converge to the fixed point r, a root of f(x).

20 20

21 21 Another rearrangement of f(x) is

22 22 To determine a root of f(x)=0, given a value x 1 reasonably close to the root, rearrange the equation to an equivalent form x =g(x) Set x 2 = x 1 REPEAT Set x 1 = x 2 Set x 2 = g(x 1 ) UNTIL |x 1 -x 2 |< tolerance value Note: The method may converge to a root different from the expected one, or it may diverge. Different rearrangements will converge at different rates.

23 23 If g(x) and g’(x) are continuous on an interval about a root r of the equation x = g(x), and if |g’(x)| < 1 for all x in the interval, then x n+1 = g(x n ), n = 0,1,2,…, will converge to the root x = r, provided that x 1 is chosen in the interval.

24 24

25 25


Download ppt "1 M 277 (60 h) Mathematics for Computer Sciences Bibliography  Discrete Mathematics and its applications, Kenneth H. Rosen  Numerical Analysis, Richard."

Similar presentations


Ads by Google