Numerical Computations

 


COMSATS University Islamabad, Pakistan



NUMERICAL COMPUTATIONS

What is numerical Computation?

Numerical Computation is concerned with the derivation, analysis, and implementation of methods for obtaining reliable numerical answers to complex mathematical problems. In other words, NC is the subject concerned with the construction, analysis, and use of algorithms for the numerical solutions of mathematical problems to the given degree of numerical accuracy.

When mathematical problems can be solved analytically, their solution may be exact, but more frequently, there may not be a known method of obtaining its solution. e.g.

Many more such examples can be cited for which solutions by analytical means are either impossible or may be so complex that they are quite unsuitable for practical purposes.

    During the last century, numerical techniques have witnessed a veritable explosion in research, both in their application to complex mathematical systems and in the very development of these techniques. At many places in this course, we will compare numerical techniques with analytical techniques, and point out various problems which cannot be solved through analytical techniques, and to which numerical techniques provide quite good approximate solutions. Many researchers are using numerical techniques to investigate research problems.

Error Analysis

     Numerical methods provide estimates that are very close to an exact analytical solution, obviously an error is introduced into the computation therefore it is important to understand the errors. Numerical computation can also be defined as a vehicle to study errors in computations.

             

 Error

Error is the difference between the actual value and the computed value. Let x be the actual value of a certain problem and  be its approximate value then mathematically error can be written as

                

Let x=2 be the actual value and be its approximate solution then an error is 0.01

 

Three Important steps in Error Analysis

 

It is the study and evaluation of errors. An error analysis generally consists of the following three steps:

  1. ·         To identify the errors, secondly
  2. ·         To quantify the errors, and then the lastly
  3. ·         To minimize as per our need.

 

SOURCES OF ERROR:

A numerical method for solving a given problem will, in general, involve an error of one or several types. Although different sources initiate the error, they all cause the same effect: diversion from the exact answer. Some errors are small and may be neglected, while others may be devastating if overlooked. In all cases, error analysis must accompany the computational scheme, whenever possible.
The main sources of error are as follows:
 Gross errors, Rounding errors, and Truncation errors.


1. Gross Errors


Gross errors are either caused by human mistakes or by the computer. A few examples of these errors are as follows:

i.             Misreading or misquoting the figures, particularly in the interchanges of adjacent. digits,

ii.            Use of inaccurate mathematical formula (algorithm) to solve a particular problem, and

iii.           Use of inaccurate data.

Although gross errors are not directly concerned with most of the numerical methods discussed, they can sometimes have a great impact on the success of modeling efforts. Thus, they always are kept in mind when applying numerical techniques in the context of real-world problems. These errors are not very serious and can be avoided if enough care is taken in using proper numerical analysis techniques. We shall primarily concern ourselves with the latter types of errors.

2. Rounding Errors

When a numerical method is actually run on a digital computer after transcription to a computer program form a kind of error called round-off error is introduced.

The error introduced by rounding-off numbers to a limited number of decimal places is called the rounding error. For example, it would be impracticable to mention the distance between two points on the earth as 15.2967 meters. It would be more reasonable if it were to be rounded to the nearest whole number, i.e. 15 meters, Thus, the error introduced by rounding is 0.2967 meters. Another example is the value of n =3.1415926353 which may be meaningfully rounded-off to 3. 1416 or 3.142.
Rounding-off errors play an important role in numerical analysis. In order to obtain a
smaller error as a result of rounding-off, we may apply the following rules when performing
manual calculations (these rules are not normally applied when performing extensive computer calculations).


3. Truncation error:


It is defined as the replacement of one series with another with fewer terms.

Example:

  • ·    Binomial expression.
  • ·         Infinite geometric series, 
  •       Taylor’s or McLaren’s series.

 Bisection Method

The bisection method is one of the first numerical methods developed to find the root of a nonlinear equation f(x)=0, also called the binary-search method. 

In the Bisection method, we start with two initial approximations ‘a’ and ‘b’, and we suppose that f is a continuous function defined on the interval [a, b], with f(a) and f(b) of opposite sign. Furthermore if f(a)*f(b)<0, has at least one root between a and b, and if f(a)*f(b)>0, there may or may not be any root between a and b.  If f(a)*f(b)>0, then there may be more than one root between a and b.  So the method only guarantees one root between a and b.

Since the method is based on finding the root between two points, the method falls under the category of bracketing methods.

Since the root is bracketed between two points, a and b, one can find the mid-point, 

  1. Choose a and b as two guesses for the root such that f(a)*f(b)<0, or in other words, f(x) changes the sign between a and b.
  2. Estimate the root, C, of the equation f(x)=0 as the mid-point between a and b as

            C(n)=(a+b)/2

  1. Now check the following

a)      If f(a)*f(c)<0, then the root lies between a and c; then a=a1 and b=c.  

b)      If f(a)*f(b)>0, then the root lies between c and b; then a=c and b=b1.

c)      If f(a)*f(b)=0; then the root is c.  Stop the algorithm if this is true.

  1. Find the new estimate of the root

            C(n)=(a+b)/2

            Find the absolute relative approximate error as

            

  1. Compare the absolute relative approximate error  with the pre-specified relative error tolerance. 





Maple Program Bisection Method

restart;

 with(Student[NumericalAnalysis]):

f := x^3 + 4*x^2 - 10;

Bisection(f, x = [1, 2], tolerance = 10^(-4));

1.365112304

Bisection(f, x = [1, 2], tolerance = 10^(-4), output = sequence);

[1., 2.], [1., 1.500000000], [1.250000000, 1.500000000], [1.250000000, 1.375000000], [1.312500000, 1.375000000], [1.343750000, 1.375000000], [1.359375000, 1.375000000], [1.359375000, 1.367187500], [1.363281250, 1.367187500], [1.363281250, 1.365234375], [1.364257812, 1.365234375]

Bisection(f, x = [1, 2], tolerance = 10^(-2), stoppingcriterion = absolute);

1.367187500

Bisection(f, x = [1, 2], output = animation, tolerance = 10^(-3), stoppingcriterion = function_value);


Bisection(f, x = [1, 2], output = plot, tolerance = 10^(-3), maxiterations = 15, stoppingcriterion = relative);


Bisection(f, x = [1, 2], output = animation, tolerance = 10^(-3), maxiterations = 15, stoppingcriterion = relative);

Bisection(f, x = [1, 2], output = information, tolerance = 10^(-9), maxiterations = 15, stoppingcriterion = function_value);

Newton-Raphson Method

Newton-Raphson method is an open method. in this method we start with only one initial approximation x(i), the approximation x(i+1) is the x-intercept of the tangent line to the graph of f at ( x(i), f ( x(i+1))). The approximation x(i+2) is the x-intercept of the tangent line to the graph of f at ( x(i+1), f ( x(i+1))) and so on.  From fig. 1 uses the definition of the slope of a function, at x=x(i) 

                                           
Equation (1) is called the Newton-Raphson formula for solving nonlinear equations of the form f(x)=0.  So starting with an initial guess, x(i), one can find the next guess, x(i+1), by using Equation (1).  One can repeat this process until one finds the root within a desirable tolerance.

Maple Setup

[> NewtonsMethod(x^3 + 4*x - 10, x = 1);

                          1.556773264


[> NewtonsMethod(x^3 + 4*x - 10, x = 2, output = sequence);

2, 1.625000000, 1.558650066, 1.556774723, 1.556773264, 1.556773264


[> NewtonsMethod(x^3 + 4*x - 10, x = 0, view = [0 .. 3, DEFAULT], output = animation);


Fixed Point Iteration Method


Fixed-Point

The number p is a fixed point for a given function g if

                                    g( p) = p.

A fixed point for a function is a number at which the value of the function does not change when the function is applied.

Example 1: Determine any fixed points of the function g(x) = x2-2

Solution:      A fixed point p for g has the property that

                                                                p = g( p) =p2− 2

which implies that

                                                  0 = p2 − p − 2 = ( p + 1)( p − 2).


A fixed point for g occurs precisely when the graph of y = g(x) intersects the graph of y = x, so g has two fixed points, one at p = −1 and the other at p = 2. These are shown in the following figure.

Theorem:

(i) If g ∈ C[a, b] and g(x) ∈ [a, b] for all x ∈ [a, b], then g has at least one fixed point in [a, b].

(ii) If, in addition, g(x) exists on (a, b) and a positive constant k < 1 exists with |g(x)| ≤ k, for all 
     x ∈ (a, b), then there is exactly one fixed point in [a, b]. 

Example 2:  Show that g(x) = (x2 − 1)/3 has a unique fixed point on the interval [−1, 1].

Fixed-Point Iteration

Let g ∈ C[a, b] be such that g(x) ∈ [a, b], for all x in [a, b]. Suppose, in addition, that g exists on (a, b) and that a constant 0 < k < 1 exists 

Then for any number p0 in [a, b], the sequence defined by


                                                                pn = g( pn-1), n ≥ 1,


converges to the unique fixed point p in [a, b]. 
This technique is called fixed-point, or functional iteration. The procedure is illustrated in the following figure.


Maple Solution:

restart;
with(Student[NumericalAnalysis]);
f := x-cos(x);
                           x - cos(x)
plot(f, x = 0 .. 4);

g1 := cos(x);
                             cos(x)
plot([f, g1, x], x = 0 .. 5, color = [black, red, blue]);









Assignments

Assignment No 1

1.      Use Newton’s method to find solutions accurate to within 10-3 for the following problems.

                

2.      Find all the zeros of the following function by using the fixed-point iteration method for an appropriate iteration function g. Find the zeros accurate to within 10-3.

               

3.      Find an approximation tocorrect to within 10-2 using the Bisection Algorithm.

 

4.      Use Secant and False-Position Methods to approximate the root of

     


 

Submission Date: 17-10-22

Lab Assignment No 1

Make a Maple Program for the following given numerical technique to approximate the solution of f(x)=x-0.8-0.2sin(x) with predefined accuracy of 10-5. Choose the same interval for all techniques, and at the end write your conclusion that which technique is the best on the basis of your solution.

i.                    Bisection Method

ii.                  Secant Method

iii.                Regula Falsi Method

iv.                Newton’s Method

v.                  Fixed point method

vi.                Muller’s method

Note:- Make a word file of all the above techniques, and submit it in the hard form on October 27, 2022, at 5pm in the theory class.


Assignment 3

 

1.      Use Lagrange interpolation formula to construct an appropriate polynomial, and then interpolate f(8.2) and f(8.5) using the following data.

2.      Construct the interpolating polynomial of degree three using Newton Divided different formula

3.      Show that the polynomial interpolating the following data has degree 3

4.      Find First and the second derivative at x=2 from the following given table

                              
Submission Date: 20-12-22

Solution of Quiz Number 3





Assignment No 4

1.      Find Solution of an equation 1/x using Trapezoidal rule x1 = 1 and x2 = 2
step size (h) = 0.25

2.      Find Solution of an equation 1/x using Simpson's 1/3 rule x1 = 1 and x2 = 2
step size (h) = 0.25

3.      Find Solution of an equation 1/x using Simpson's 3/8 rule x1 = 1 and x2 = 2
with n = 6

4.      Find Solution using Simpson's 1/3 rule

x

f(x)

0.0

1.0000

0.1

0.9975

0.2

0.9900

0.3

0.9776

0.4

0.8604

 

 

 

 

 

 

                 Note: Submit it on 26-12-22

Lab Assignment No 2

Make a Maple Program for the following given numerical technique to approximate the solution of f(x)=x/(x2+4) over the interval [1, 3] with n=6. Choose the same interval for all techniques, and at the end write your conclusion that which technique is the best on the basis of your solution. Also compare your results with the exact solutions.

i.                    Trapezoidal Rule

ii.                  Simpson’ 1/3 rule

iii         Simpson’s 3/8 rule

Note: - Make a word file of all the above techniques, and submit it in the hard form on Dec. 29, 2022, at 5pm in the theory class.

 MCQs on Runge-Kutta Methods

1) What is the order of the classical fourth-order Runge-Kutta method for solving differential equations?
a) 1st
b) 2nd
c) 3rd
d) 4th

2) What is the primary disadvantage of using the Runge-Kutta method to solve differential equations?
a) It is computationally expensive
b) It is prone to round-off error
c) It is not very accurate
d) It is not suitable for stiff equations

3) How many stages are there in the explicit third-order Runge-Kutta method?
a) 1
b) 2
c) 3
d) 4

4) What is the main advantage of using an implicit Runge-Kutta method to solve differential equations?
a) It is more accurate
b) It is faster
c) It is more stable
d) It is easier to implement

5) Which of the following is NOT a common application of the Runge-Kutta method?
a) Simulating the motion of celestial bodies
b) Modeling population dynamics
c) Solving the Schrödinger equation
d) Estimating the value of pi

6) What is the main difference between the classical fourth-order Runge-Kutta method and the Ralston method?
a) The Ralston method is more accurate
b) The Ralston method is faster
c) The Ralston method is more stable
d) The Ralston method uses fewer function evaluations

7) What is the order of the implicit trapezoidal rule method for solving differential equations?
a) 1st
b) 2nd
c) 3rd
d) 4th

8) What is the main disadvantage of using an adaptive Runge-Kutta method to solve differential equations?
a) It is more computationally expensive
b) It is less accurate
c) It is less stable
d) It is more difficult to implement

9) How does the Midpoint method compare to the classical fourth-order Runge-Kutta method in terms of accuracy and efficiency?
a) It is more accurate but less efficient
b) It is less accurate but more efficient
c) It is equally accurate and efficient
d) It is both less accurate and less efficient

10) Which of the following is NOT a type of Runge-Kutta method?
a) Explicit
b) Implicit

Post a Comment

0 Comments