Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

473 - CSC 251

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

COURSE CODE: CSC 251

COURSE TITLE: Numerical Analysis I


NUMBER OF Units: 2 Units

Course Duration: Three hours per week

COURSE DETAILS:
Course Lecturers: Dr. (Mrs.) O. R. Vincent
Email: vincent.rebecca@gmail.com
Office Location: Room B201, COLNAS
Consultation hours: 12-2pm, Wednesdays & Fridays

Course Content:

NUMERICAL ANALYSIS I
Introduction
Numerical analysis is concerned with the process by which mathematical problems are solved by the
operations of ordinary arithmetic.
We shall be concerned with fundamental mathematical problems such as solution of equations, the
evaluation of functions and integration etc. Although, quite a lot of these problems have exact solutions, the range
of problems which can be solved exactly is very limited. Therefore, we require efficient methods of obtaining
good approximation.

Computer Arithmetic and Errors


A feature of numerical methods is that they usually provide only approximation solutions: a deliberate
error may be made e.g. Truncation of a series, so that the problem can be reconstructed to get a stable solution.

Types of Errors
1. Blunder called Human Error: This occurs when a different answer is written from what is obtained e.g.
writing 0.7951 instead of 0.7591.
2. Truncation Error: These arises when an infinite process is replaced by a finite one. For instance, consider
a finite number of terms in any infinite series e.g.
√ +1=1+ - + … has truncation error of + …
½ ½ x 2
(x + 1) - (1 + x) = 1 + ½ + ½(½ - 1) x + ½ (½ - 1) (½ - 2) + 3x …

If we consider
( ) ( )( )
(x +1)1/2 √ + 1 = 1 + xn + n !
x2 + !
x3 + …
= 1 + - (1/2 – 1)x2
-1 2
= = + !=
Consider the taylor series expansion
ex = 1 + x
If the formular is used to calculate f = e0.1 we get
f = 1 + 0.1 +
Where do we stop? Theoretically, the calculation will never stop. There are always more terms to add on. If we do
stop after a finite number of terms, we will not get the exact answer.
3. Round-off Error: Numbers having decimal or binary representations are often rounded e.g. 1/3 = 0.3333.
If we multiply by 3 we have 0.9999 which is not exactly 1.
Round-off errors can be avoided by preventing cancellation of large terms.
1.2 Notation: Let ∑ (Epsilon) be the error. Let true value and appropriate be x and x1 respectively. The absolute
error = |∑| = |x – x1| and relative
| |
Error = provided x ≠ 0
| |
Definition: A number x is said to be rounded to a d-decimal place number x(d) if error ∑ is given by |∑| = |x – x(d)|
-d
≤ ½ 10
Example: Take = 0.142857142
0.14 (2 dec. place)
Subtract it.
0.002857142 (is the error)
0.002857142 ≤ ½ 10 -2 = 0.005
Suppose x1 = 0.1429 (4 dec. place)
|∑| = |x – x1| = 0.000042858 ≤ ½ 10 -4 = 0.00005

1.3 ARITHMETICAL ERRORS


Let x, y be two numbers and let x1, y1 be their respective approximation with error ∑ and ŋ (eta)
Solution: x1 + y1 = (x –∑) + (y – ŋ)
(x + y) - (y – ŋ)
(x +y) - (x1 + y1) = ∑ +ŋ
Error in sum is sum of errors.
(ii) Subtraction:
x1 – y1 = (x – ∑) – (y – ŋ)
(x – y) – (x1 – y1) = ∑ – ŋ
Error in difference is difference in errors.

Assignment
Compute the multiplication and division

2.0 Condit and Stability


The condition of a function is a measure of the sensitivity of that function to small changes in its
parameters.
If small change sin the parameters induce only a small change in the behaviour of the function the function
is well-conditioned otherwise it is ill-conditioned.
A numerical method is said to be stable, if small changes in the data induce only small changes in the
solution of the process otherwise, the process is unstable. It is therefore clear that the stability of a numerical
process is related to its conditioning.
Let the error, ∑n at the nth iteration be such that |∑n| αn, then the growth in eror is called linear whereas if
n
|∑n|α|< (n > 1), the growth is exponential and if K < 1, the error decreases exponentially.
It is desirable to aim at linear error growth and try as much as possible to avoid exponentially error growth.
If we consider a sequence
1, ⅓, 1/9, 1/27, …, 1/3 n.
Our x0 = 1 and xi = 1/3
We can have a relation A the form
xn = α (1/3)n + β (3)n …
where α = 1 and β = 0, so that the correct value of xn = (1/3)n. if we now compute our xn (in 4 decimal places) the
errors rapidly increase.
1 n
n xn= /3 -
0 1.0000 1.0000
1 0.3333 0.3333
2 0.1111 0.1111
3 0.0372 0.0370
4 0.0128 0.0125
5 0.0057 0.0041
6 0.0062 0.0014
At the sixth iteration, the solution x6 is significantly different from the correct value.
Error = i.e. 0.0057 – 0.00141
= 0.0043
Thus, this is an exponential error growth and such should be avoided.
Disadvantages
1. Only one value of x can be derived
2. Least value of x can only be derived through one point formula.
3.0 Polynomials and their zeros
This section is concern with solution of non-linear algebraic equation.
3.1 Iterative method without derivatives
A problem which frequently occurs in scientific works is finding roots of equation of the type.
F (x) = 0 (3.1)
For example
5x3 + 3x2 – 17x + 1 = 0
ex Sin x = 0 etc.
sometimes it may be possible to get exact root of 3.1 as in the case of factorisable polynomials such as
x2 + 3x + 2 = 0 which roots are .
In general, we have to get approximate solutions by applying some computational procedure, usually iterative. We
carefully choose some initial estimates of a root and improve on it by an iterative formula.
3.1.1 Fixed Point Formula: (One point formula)
This formula is also known as successive substitution or one point formula.
To find a root α of equation (3.1), we write the equation in the form.
x = f (x) … (3.2) and given an initial estimate x0, we improve by the scheme
x1 = f (x0)
x2 = f (x1)
x3 = f (x2)
:
xn+1 = f(xn)
where x0, x1, …xn are successive approximations to the root.
For example
F(x) = x2 – 4x + 2 = 0 (3.3)
We can write (3.3) in the form (3.2) as follows
X = √4 − 2 or x = , or x = ¼ (x2 + 2)
but in this case, let us use
x = ¼ (x2 + 2)
This suggest a scheme
Xn+1 = ¼ (xn2 + 2)
Choose x0 as 0, 3, and 4.

X0 0 3 4
xi 0.5000 2.75 4.5000
x2 0.5625 2.3906 5.5628
x3 0.5791 1.9287 8.2354
x4 0.5838 1.4300 17.4554
x5 0.5852 1.0112 76.6715
x6 0.5856 0.7556
x7 0.5857 0.6427
x8 0.5858 0.6033
x9 0.5858 0.5910

x 0.5858 which is given by initial estimates 0, 3. 4 is obviously a bad initial value. The actual root are x2 – 4x
+2=0
± – ( )
1. x = = 2 ± √2
x = 0.586 or 3.414
The actual root are 0.586 and 3.414. The other root 3.414 cannot be obtained by this method. The case can be
illustrated below.

Assignment
1. Find an approximation to the smallest positive root of F(x) = 8x4 – 8x2 + 1 = 0 (Take x0 = 0.3).
2. Draw a flow chart illustrating the use of fixed point formula to solve x2 – 4x + 2 = 0
Hence, write a FORTRAN program to solve the equation.

3.1.2 Bisection Rule


Using the formula, too initial estimates x0 and x1 are needed so that F(x0) and F(x1) are of opposite signs. A
new estimate is
X2 = ½ (x0 + x1) of generally Cn = (an + b n)/2
X2 is used to replace which ever of x0 or x1 has the same sign in F(x)
The process is repeated
For example
F(x = y = x – Cos(x)
an bn Cn(an + bn)/2 F(cn)
0.0 1.5 0.75 +
0.0 0.75 0.375 -
0.375 0.75 0.5625 -
0.5625 0.75 0.65625 -
0.65625 0.75 0.70313 -
0.70313 0.72656 -
0.72565 0.73828 -
0.73828 0.74414 0.74414 +
0.73728 0.74121 +

Once an interval has been located, the method is very easy to implement, very reliable and has good error bounds.
The only disadvantage is that the method is slow.
The interval ‘halving’ or ‘bisection’ method can be sped up by making better use of the information computed.
The method only uses the sign of the function f and not its value. Thus, if the absolute value of the function is
much smaller at one end than at the other it is likely that the root will be closed to the end where the function is
smaller. The idea is exploited in the Regulafalsi method.
3.1.3 Regular Falsi

xi (xi, F(xi)

Consider two initial estimates x0 and xi


y0 = F(x0) and y1 = F(x1)
It is possible to express the equation of a straight line through (x0, y0), (x1, y1) as
x = y – y1 y – y0
y0 – y1 x0 + y1 – y0 xi … (3.4)
It is possible to express the equation as a linear interpolation in the form of
= x0 F(x1) – x1 F(x0)
F(x1) – F(x0)

Bisection Rule
Example F(x) = x2 – 3x + 1 = 0
X0 = 0 So that F(x0) = 1 +ve
Choose
x1 = 1 F(x1) = -1 –ve

x2 = ½ (x0 + x1) = ½ (0 + 1) = 0.5


F(0.5) = -0.25 is –ve
We neglect x1 and we have
X3 = ½ (x0 + x2) = ½ (0 + 0.5) = 0.25
F(0.25) = 0.3125 –ve
We neglect x0 and we have
x4 = ½ (x2 + x3) = ½ (0.5 + 0.25) = 0.375
F (0.375) is +ve
We reject x3 and we have
x5 = ½ (x2 + x4) = ½ (0.5 + 0.375) = 0.4375
F(0.4375) is –ve
We reject x2, and have
x6 = ½ (x4 + x5) = ½ (0.375 + 0.4375)
F(x0) = +1
F(x1) = -1
X0 = 9 n x1 = bn ½ (x0 + x1) F (cn)
0 1 0.5 -0.25 –ve
0 0.5 0.25 0.3125 +ve
0.5 0.25 0.375 0.0156 +ve
0.5 0.375 0.4375 -0.12109 -ve
0.375 0.4375 0.40625
This is linear function x(y) with x(y0) = x0 and x(y1) = x1
The line intersects the x – axis at the point obtained by putting y = 0 in (3.4)
-y1 -y0
x2 y0 – y1 x0 + y1 – y0 x1

= x0 y1 – x1 y0
y1 – y0
This may be re-written on a linear interpolation form as x0 F(x1) – x1 F(x0)
F(x1) – F(x0) … 3.5
This can also be written as
X2 = x1 – (x1 – x0) F (x1)
F (xi) – F(x0) … 3.5
It may be repeated such that an iterative scheme results. As in the case of binary search (bisection rule) the two
estimates slid give opposite signs in F(x).
The convergence in this method is faster than that in bisection rule.
Example F(x) = x2 – 3x + 1 = 0
Choose x0 = 0
x1 = 1
Since F(x0) is +ve = 1
and F (x1) is –ve = -1
x2 = x0 F(x1) – x1 F(x0)
F(x1) – F (x0)
x2 = 0 – 1
-1 – 1 = ½ = 0.5
F(x2) = F(0.5) = (0.5)2 – 3(0.5) + 1 = 0.25 -1.5 + 1 = -0.25 +ve
So, we reject x1
x3 = x0 F(x2) – x2 F(x0)
F(x2) – F (x0)
x3 = 0 – 0.5 x 1 0.5
-0.25 – 1 = 1.25 = 0.4
F(x3) = F(0.4) = 0.4 2 – 3(0.4) + 1 = -0.04 -ve
So, we reject x2
x4 = x0 F(x3) – x3 F(x0)
F(x3) – F (x0)
x3 = -0.4 0.4
-0.04 – 1 = 1.04 = 0.3846
F(x4) = (0.3846)2 – 3(.3846) + 1 = -0.154
And so on, we continue until convergence is achieved.
Assignment
Write a FROTRAN to illustrate the use of regula falsi to solve x2 – 5x + 1 = 0.

4.0 ITERATIVE METHODS WITH DERIVATIVES


4.1 Order of Convergence:
Let α be a root of F(α) = 0
α = F(α)
suppose the estimate α has error ∑n
Comments:
1. Convergence is first order if f'(α) ≠ 0, f''α =, …, = 0
2. Convergence is second order if
f'(α) = 0 and f''(α)
3. Convergence is third order if
f'(α) = 0 and f''(α)
f'''(α) ≠ 0

4.2 Newton-Raphson Method

From the figure, a is the point at which f(x) = 0 and x0 is an estimate of a. the Newton Raphson method
computes a new estimate, x1 in the following way:
This is the second order convergence.
Let x be a root of equation (3.1) – F(x) = 0
If xn is the nth estimate with error ∑n,
then x = xn + ∑n … 4.1
F(x) = F(xn + ∑n) = 0
= F(xn) +n F'(xn) + ∑n2 F''(xn) + … + = 0
2!
Ω F(xn) + ∑nF'(xn) = 0p
= ∑n = -F (xn)
F'(xn)
The iteration scheme in 4.1 becomes
xn + 1 = xn – F(xn)
F'(xn) - N – R method.

For example
F(x) = x2 – 4x + 2 = 0
F'(x) = 2x – 4
Therefore xn + 1 = xn – (xn2 – 4xn + 2)
2xn – 4
Using our former initial estimate
X0 0 3
xi 0.5 3.5
x2 0.5833 3.4162
x3 0.5858 3.4142
x4 0.5858 3.4142
x5

You might also like