chapter 1: numeric analysis

15
Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim 1 Chapter 1: Numeric Analysis Introduction As an engineer you may deal with problems in elasticity and need to solve a difficult equation, or a more difficult problem of finding the roots of a higher order polynomial. Such problems, which are difficult or impossible to solve algebraically, arise frequently in applications. We call for numeric methods, that is, systematic methods that are suitable for solving, numerically, the problems on computers or calculators. Floating-Point Form of Numbers In decimal notation, every real number is represented by a finite or an infinite sequence of decimal digits. Now most computers have two ways of representing numbers, called fixed point and floating point. In a fixed-point system all numbers are given with a fixed number of decimals after the decimal point; For example, numbers given with 3 decimals (3D) are 62.358, 0.014, 1.000. Fixed-point representations are impractical in most scientific computations because of their limited range (explain!) and will not concern us. In a floating-point system we write, for instance, We see that in this system the number of significant digits is kept fixed, whereas the decimal point is “floating.” Here, a significant digit of a number c is any given digit of c, except for zeros to the left of the first nonzero digit; these zeros serve only to fix the position of the decimal point. (Thus any other zero is a significant digit of c.) For instance, 13600, 1.3600, 0.0013600 all have 5 significant digits (5S). Example 1: Find the roots of the equation x 2 + 40x + 2 = 0 using 4 significant digits (abbreviated 4S) in the computation. Solution x1,2 = 20 ± √398 = – 20 ± 19.949937; x1 = 0.0500626567 = 0.05006 (4S); x2 = 39.949937 = 39.95 (4S)

Upload: others

Post on 17-Feb-2022

14 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Chapter 1: Numeric Analysis

Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim

1

Chapter 1: Numeric Analysis

Introduction

As an engineer you may deal with problems in elasticity and need to solve a difficult equation, or

a more difficult problem of finding the roots of a higher order polynomial.

Such problems, which are difficult or impossible to solve algebraically, arise frequently in

applications. We call for numeric methods, that is, systematic methods that are suitable for

solving, numerically, the problems on computers or calculators.

Floating-Point Form of Numbers

In decimal notation, every real number is represented by a finite or an infinite sequence of

decimal digits. Now most computers have two ways of representing numbers, called fixed point

and floating point.

In a fixed-point system all numbers are given with a fixed number of decimals after the decimal

point;

For example, numbers given with 3 decimals (3D) are 62.358, 0.014, 1.000.

Fixed-point representations are impractical in most scientific computations because of their

limited range (explain!) and will not concern us.

In a floating-point system we write, for instance,

We see that in this system the number of significant digits is kept fixed, whereas the decimal

point is “floating.”

Here, a significant digit of a number c is any given digit of c, except for zeros to the left of the

first nonzero digit; these zeros serve only to fix the position of the decimal point. (Thus any other

zero is a significant digit of c.)

For instance, 13600, 1.3600, 0.0013600 all have 5 significant digits (5S).

Example 1:

Find the roots of the equation x2 + 40x + 2 = 0 using 4 significant digits (abbreviated 4S) in the

computation.

Solution

x1,2 = – 20 ± √398 = – 20 ± 19.949937;

x1 = – 0.0500626567 = – 0.05006 (4S); x2 = – 39.949937 = – 39.95 (4S)

Page 2: Chapter 1: Numeric Analysis

Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim

2

Solution of Equations by Iteration

Find solutions of a single equation f(x) = 0.

The solution is x = s , a number such that f(s) = 0.

There are a very large number of applications in engineering, where we have to solve a single

equation when there is no formula for the exact solution available.

We can use an approximation method, such as an iteration method.

This is a method in which we start from an initial guess x0 (which may be poor) and compute

step by step (in general better and better) approximations x1, x2, … of an unknown solution of

f(x) = 0.

Fixed-Point Iteration for Solving Equations f (x) = 0.

f (x) = 0. … (1)

Make x = g(x). … (2) Then we choose an x0 and compute x1 = g(x0), x2 = g(x1) and in general

xn+1 = g(xn) … (3) n = 0, 1, …

A solution of (2) is called a fixed point of g.

Example 2: Set up an iteration process for f(x) = x2 – 3x + 1 = 0. (exact solutions x = 2.618034 and 0.381966)

Solution

The equation may be written

Check convergence: [g'(x) < 1]; g'(x) = 2x / 3 < 1 for x < 1.5

If we choose x0 = 1, we obtain the sequence

x0 = 1.000, x1 = 0.667, x2 = 0.481, x3 = 0.411, x4 = 0.390, … It is approaching the smaller solution.

If we choose x0 = 3, we obtain the sequence

x0 = 3.000, x1 = 3.333, x2 = 4.037, x3 = 5.766, x4 = 11.415, … which diverges.

[see Fig. a]

Page 3: Chapter 1: Numeric Analysis

Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim

3

Our equation may also be written (dividing by x)

Check convergence: [g'(x) < 1]; g'(x) = – 1 / x2 < 1 for any x

If we choose x0 = 1, we obtain the sequence

x0 = 1.000, x1 = 2.000, x2 = 2.500, x3 = 2.600, x4 = 2.615, … It is approaching the larger solution.

If we choose x0 = 3, we obtain the sequence

x0 = 3.000, x1 = 2.667, x2 = 2.625, x3 = 2.619, x4 = 2.618, …

[see Fig. b]

HW

Find a solution of f(x) = x3 + x – 1 = 0 by iteration.

Hint: write the equation as x (x2 + 1) = 1 then x = g(x) = 1 / (1 + x2)

Page 4: Chapter 1: Numeric Analysis

Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim

4

Newton’s method, also known as Newton–Raphson’s method, is another iteration method for

solving equations f(x) = 0, where f is assumed to have a continuous derivative f ′.

… (4)

… (5)

Example 3:

Page 5: Chapter 1: Numeric Analysis

Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim

5

Example 4:

Example 5:

Page 6: Chapter 1: Numeric Analysis

Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim

6

Page 7: Chapter 1: Numeric Analysis

Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim

7

We are given the values of a function f(x) at different points x0, x1, … xn. We want to find

approximate values of the function f(x) for “new” x’s that lie between these points for which the

function values are given. This process is called interpolation.

A standard idea in interpolation now is to find an interpolation polynomial pn(x) of degree n (or

less) that assumes the given values; thus

Lagrange Interpolation

This gives the linear Lagrange polynomial

Example 6:

Page 8: Chapter 1: Numeric Analysis

Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim

8

Example 7:

Compute ln 9.2 from ln 9.0 = 2.1972, ln 9.5 = 2.2513 and ln 11.0 = 2.3979.

Note: Exact ln 9.2 = 2.2192 (4D).

Solution:

Page 9: Chapter 1: Numeric Analysis

Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim

9

Newton’s Divided Difference Interpolation NDDI

Newton’s divided difference interpolation formula:

Example 8:

Compute f(9.2) from the table below using NDDI

xj 8.0 9.2 9.5 11.0

fj = f (xj) 2.079442 2.197225 2.251292 2.397895

Solution:

The required values in the NDDI formula are circled.

At x = 9.2;

Page 10: Chapter 1: Numeric Analysis

Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim

10

Equal Spacing: Newton’s Forward Difference Formula NFDF

in many applications the ’s are regularly spaced—for instance, in measurements taken at regular

intervals of time. Then, denoting the distance by h, we can write

Newton’s (or Gregory–Newton’s) forward difference interpolation formula:

= kth forward difference

Example 9: Compute cosh 0.56 from NFDF and the four values in the following table.

xj 0.5 0.6 0.7 0.8

fj = cosh xj 1.127626 1.185465 1.255169 1.337435

Solution

We compute the forward differences as shown in the table. The values we need are circled.

r = (0.56 – 0.50) / 0.1 = 0.6, so that NFDF formula gives:

Note: The exact 6D-value is cosh 0.56 = 1.160941.

Page 11: Chapter 1: Numeric Analysis

Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim

11

Page 12: Chapter 1: Numeric Analysis

Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim

12

Numeric Integration

In applications, the engineer often encounters integrals that are very difficult or even impossible

to solve analytically. We then need methods from numerical analysis to evaluate such integrals.

Numeric integration means the numeric evaluation of integrals

where a and b are given and f is a function given analytically by a formula or empirically by a

table of values. Geometrically, J is the area under the curve of f between a and b (Fig. 440),

taken with a minus sign where f is negative.

Rectangular Rule

The simplest formula, the rectangular rule, is obtained if we subdivide the interval of

integration a ≤ x ≤ b into n subintervals of equal length h = (b – a) / n and in each subinterval

approximate f by the constant, the value of f(xj*) at the midpoint xj

* of the jth subinterval (Fig.

441). Then f is approximated by a step function (piecewise constant function), the n rectangles

in Fig. 441 have the areas f(xj*)h and the rectangular rule is

Page 13: Chapter 1: Numeric Analysis

Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim

13

Trapezoidal Rule

The trapezoidal rule is generally more accurate. We obtain it if we take the same subdivision as

before and approximate f by a broken line of segments (chords) with endpoints [a, f(a)], [x1,

f(x1)], … , [b, f(b)] on the curve of f (Fig. 442). Then the area under the curve of f between a and

b is approximated by n trapezoids of areas

By taking their sums,

Example 10:

Solution:

Page 14: Chapter 1: Numeric Analysis

Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim

14

Simpson’s Rule of Integration

Piecewise constant approximation of f led to rectangular rule, piecewise linear approximation to

trapezoidal rule, and piecewise quadratic approximation will lead to Simpson’s rule, which is of

great practical importance because it is sufficiently accurate for most problems, but still

sufficiently simple.

Example 11:

Solution:

Page 15: Chapter 1: Numeric Analysis

Eng. Math. Ch 1 Numeric Analysis Prof Dr Bayan Salim

15