0% found this document useful (0 votes)
23 views51 pages

CE 2201 - Full+Assignment at Last Slide

Uploaded by

nafidahnaf33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views51 pages

CE 2201 - Full+Assignment at Last Slide

Uploaded by

nafidahnaf33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

1/14/2025

Introduction
Objectives of Numerical Methods
CE 2201: Numerical Methods & Computer Programming o introduce common numerical techniques/methods (involving systems of
linear equations, interpolation, regression, and root finding etc.)
available for solving engineering problems

Outcomes
At the completion of this course, students will have-
o Wide range of knowledge about different numerical analyses
o Ability to solve critical civil engineering problems easily using numerical
https://ocw.mit.edu/courses/18-330-introduction-to-numerical-analysis-spring-2012/
techniques

Introduction
2nd Year Even Semester Md. Masud Rana

Introduction Analytical, Numerical and Empirical Solution


Syllabus
o Numerical solution of algebraic and transcendental equations o Analytical- Exact solution. Example: Quadratic equation
o Matrices o Empirical- Experimental solution. Example: Deflection from load test
o Solution of systems of linear equations o Numerical- An approximation. Example: Finite Element Analysis
o Curve-fitting by least squares
o Finite differences
o Divided differences
o Interpolation
o Numerical differentiation and integration
o Numerical solution of differential equations
Reference Books
1. Introductory Methods of Numerical Analysis- S. S. Sastry
2. Numerical Methods for Engineers- Raymond and Steven
https://featips.com/2022/03/23/analytical-vs-numerical-vs-empirical/

1
1/14/2025

Numerical Methods and Analysis Engineering Analysis and Numerical Methods


o Numerical Methods- an approximate method
Numerical Methods
 Methods of finding the roots of an equation
 Methods of solving the system of linear algebraic equations
 Interpolation and regression analysis
 Numerical differentiation.
 Numerical integration
 Solution of differential equation
o Numerical Analysis- the study of numerical methods

https://slideplayer.com/slide/8588078/
Applied Engineering Analysis, Author: Tai-Ran Hu
https://www.sciencedirect.com/topics/engineering/numerical-method#:~:text=A%20numerical%20method%20is%20an,often%20has%20no%20analytical%20solution.

Necessity of Numerical Methods Solution of Algebraic and Transcendental Equations


o Mathematical solutions analytically using calculus • Algebraic equation: the form f(x) = 0 where f(x) is purely a polynomial
o Equations have to be solved using numerical methods • Transcendental equation: f(x) involves trigonometrical, arithmetic or exponential
o No analytical solution terms
o Complex mathematical problems using arithmetic operation Numerical methods for finding the roots of an equation:
 Bisection method
 Method of False Position
 Iteration Method
 Newton-Raphson Method
 Secant Method
 Ramanujan’s Method
 Muller’s Method
 Lin-Bairstow’s Method etc.

2
1/14/2025

Bisection/Bipartition Method Bisection Method…


Theorem: If a function f(x) is a continuous function defined on the interval [a, b], with f(a) and f(b) of o Convergence- narrows the gap towards exact solution
opposite sign. The Intermediate Value Theorem implies that a number exists in (a, b) with f(p) = 0
o Divergence- Opposite of convergence
Computational Steps: o Bisection Method never diverges being bracket
o Bracketing Method- starting and maximum limit
o Open Method- one initial guess

Bisection Method… Algorithm of Bisection Method


o Process or set of rules to be followed in calculations or other problem‐
solving operations, especially by a computer
1. Start
*Use Bisection method to determine the drag coefficient c needed for a parachutist of mass 2. Define function f(x)
m 568.1 kg to have a velocity of 40 m/s after free falling for time t = 10 s. Note: The
acceleration due to gravity is 9.81 m/s2
3. Choose initial guesses x0 and x1 such that f(x0)f(x1) < 0
4. Choose pre-specified tolerable error e.
5. Calculate new approximated root as x2 = (x0 + x1)/2
6. Calculate f(x0)f(x2)
a. if f(x0)f(x2) < 0 then x0 = x0 and x1 = x2
b. if f(x0)f(x2) > 0 then x0 = x2 and x1 = x1
c. if f(x0)f(x2) = 0 then goto (8)
7. if |f(x2)| > e then goto (5) otherwise goto (8)
8. Display x2 as root.
9. Stop

3
1/14/2025

Flow Chart of Bisection Method Advantages and Disadvantages of Bisection Method


A flowchart is a visual representation
of the sequence of steps and decisions
needed to perform a process.
• The Oval or Pill Shape- the
start/end.
• The Rectangle Shape- process.
• The Parallelogram Shape-
input/output
• The Diamond Shape- decision.
• The Arrow Shape- sequence.

Method of False Position Method of False Position…


o Also called Regula Falsi Method or Linear o The point of intersection-
Interpolation Method or Method of Chords
o Suitable for non-linear equations
o If a function f(x) is a continuous function defined
on the interval [a, b], with f(a) and f(b) of
opposite sign, root lies between a and b.
o The equation of chord joining

4
1/14/2025

Method of False Position… Method of False Position…


1. Start
2. Read values of x0, x1 and e
Find a root for the equation 2ex sin x = 3 using the false position method and correct it to three decimal 3. Computer function of f(x0) and f(x1)
places. 4. Check whether the product of f(x0) and f(x1) is negative or not
 If it is positive take another initial guesses.
The floating ball has a specific gravity of 0.6 and has a radius of 5.5cm. You are asked to find the depth to  If it is negative then goto step 5.
which the ball is submerged when floating in water. The equation that gives the depth x to which the ball is 5. Determine:
submerged under water is given by x = [x0*f(x1) – x1*f(x0)] / (f(x1) – f(x0))
6. Check whether the product of f(x0) and f(x1) is negative or not
Use the false-position method of finding roots of equations to find the depth x to which the ball is submerged  If it is negative, then assign x0 = x;
under water. Conduct three iterations to estimate the root of the above equation. Find the absolute relative  If it is positive, assign x1 = x;
approximate error at the end of each iteration, and the number of significant digits at least correct at the end 7. Check whether the value of f(x) is greater than 0.00001 or not.
of third iteration.  If yes, goto step 5.
 If no, goto step 8.
8. Display x as root.
9. Stop

Iteration Method Iteration Method…


• Find the solution of an equation f(x) = 0  Find the first approximate root of the equation x3 – x – 1 = 0
• The equation can be expressed as x = g(x). up to 4 decimal places.
• Choose g(x) such that |g’(x)| < 1 at x = xo where xo, is some initial Solution:
guess Given f(x) = x3 – x – 1 = 0
• Then the iterative method is applied by successive approximations We find the value of xo, for which we have to find a and b such
given by xn = g(xn – 1), that is, x1 = g(xo), x2 = g(x1) and so on. that f(a) < 0 and f(b) > 0
 Find the first approximate root of the equation 2x3 – 2x – 5 = 0
up to 4 decimal places.

https://byjus.com/maths/fixed-point-iteration/

5
1/14/2025

Newton-Raphson Method Newton-Raphson Method…

Newton-Raphson Method… Algorithm of N-R Method


• a tangent is drawn at the point [x0, f(x0)]
• cuts the x-axis at x1
• drawing another tangent at [x1, f(x1)],
which cuts the x-axis at x2
• continued till the desired accuracy is
achieved

https://www.codewithc.com/newton-raphson-method-algorithm-flowchart/
https://byjus.com/maths/newton-raphson-method/

6
1/14/2025

Failing of N-R Method Advantages and Disadvantages of N-R Method


(i) If any of the approximations encounters a zero derivative (extreme point), Advantages: Disadvantages:
then the tangent at that point goes parallel to 𝑥-axis • Convergence- Fast • First derivative- difficult
(ii) Sometimes Newton-Raphson method may run into an infinite cycle or loop • Guess- one only • Fails- first derivative=0
(iii) In case of a point of discontinuity subsequent roots may diverge • Formulation- Easy • Sensitive- initial guess
• Formula- simple • Diverges at inflection points
• Behavior- easy to understand

https://www.codewithc.com/newton-raphson-method-algorithm-flowchart/

Secant Method Secant Method..


• A serious disadvantage of the Newton – Raphson method is the The above formula can be written as,
need to calculate 𝑓′ (𝑥) in each iteration. The situations where a
closed form for 𝑓′ (𝑥) is not available, secant method is suitable.
Graphical:

where 𝑥𝑛 and 𝑥𝑛 1 are the two approximations to the root. The iterative
formula for (𝑛 + 1)th approximation is given by

7
1/14/2025

Secant Method vs False Position Secant Method vs False Position


• Both use two initial estimates
• the latest estimate of the root replaces
whichever of the original values yielded in false
position
• two estimates always bracket the root in false
position; always convergent
• the secant method replaces the values in strict
sequence
• the two values can sometimes lie on the same
side of the root
• can be divergent

Problems Problem#01

8
1/14/2025

Problem#02 Problem#02
You are designing a spherical tank to hold water for a small village in a
developing country. The volume of liquid it can hold can be computed as

where V = volume (m3), h = depth of water in


tank (m), and R=the tank radius (m). If R = 3 m,
what depth must the tank be filled to so that it
holds 30 m3? Use three iterations of the Newton-
Raphson method to determine your answer.
Determine the approximate relative error after
each iteration.

Math Math

9
1/14/2025

Problem#02 Matrices

Matrices… Matrices…

10
1/14/2025

Matrices… Matrices…
Properties Transpose of Matrix

Matrices… Matrices…
Inverse of Matrix Upper Triangular Matrix

Lower Triangular Matrix

11
1/14/2025

Matrices… Matrices…

Matrices… Matrices…
by combining the matrices for each of the systems

12
1/14/2025

Matrices… Solution of Systems of Linear Equations


Simultaneous linear equations

Solution of Systems of Linear Equations Cramer’s Rule


The solution is obtained by This is best suited to small number of equations.
• Graphical method- A graphical solution is obtainable for two equations The determinant can be illustrated for a set of three equations:
• Cramer’s rule
• Elimination of unknowns
Prob.: Use the graphical method to solve

Soln: Let x1 be the abscissa. Solve 1st


Eq. for x2:

13
1/14/2025

Cramer’s Rule… Elimination of Unknowns


The solution is obtained by

Direct methods Indirect methods


Similar for x2 with the replacement of second column.
Gauss Gauss
Elimination Jacobi

Gauss Gauss
Jordan Seidel

Direct and Indirect/Iterative Methods Gauss-Elimination Method


Direct methods are those in which One of the most popular techniques for solving simultaneous linear equations
• Computation- in a finite number of steps of the form
• Solution- exact [A][X] = [C]
• The amount of computation- specified in advance Consists of 2 steps
• Accuracy- independent
1. Forward Elimination of Unknowns.
Indirect/iterative methods are those in which
2. Back Substitution
• Computation- infinite number of steps
• Solution- approximate
• The amount of computation- an improved solution with each step of iteration
• Accuracy- depends on the number of iterations performed

14
1/14/2025

Forward Elimination… Problem


Step 1. Elimination of x1 from the second and third equations

Step 2. Elimination of x2 from the third equation

Step 3. From third equation x3 is known. Using x3 in the second equation x2 is


obtained. using both x2 And x3 in the first equation, the value of x1 is obtained.

Gauss-Elimination Method Gauss-Elimination Method…


Solve the problem:

Solution:

15
1/14/2025

Gauss-Elimination Method… Gauss-Jordan Method


Solve the problem:

Solution:

Gauss-Jordan Method… Gauss-Elimination and Gauss-Jordan Method


Solution of Systems of Linear
Equations

Traditional Method Matrix Method


Matrix Method

R2/1.6667
R1=R1-R2/10 Row Echelon Method Upper Triangular
Reduced Row Echelon Identity Matrix
Method

16
1/14/2025

Gauss-Elimination Method Gauss-Elimination Method…

Gauss-Elimination Method… Gauss-Jordan Method

17
1/14/2025

Gauss-Jordan Method… Gauss-Jordan Method…

Gauss-Jordan Method… Pitfalls of Elimination Methods

• Division by Zero- elimination and the back-substitution phases

18
1/14/2025

Pitfalls of Elimination Methods Pitfalls of Elimination Methods


• Round-Off Errors- large number of equations
• Ill-Conditioned Systems

Pitfalls of Elimination Methods Gauss-Jacobi/Jacobian Method


• Round-Off Errors- large number of equations For a system of linear equations:
• Ill-Conditioned Systems

Solution to this system of equations Ax = B


Substitution of the results into the original equations would alert you to
the problem

https://byjus.com/maths/iterative-methods-gauss-seidel-and-jacobi/

19
1/14/2025

Gauss-Jacobi/Jacobian Method… Gauss-Jacobi/Jacobian Method…


solve equation 1 for x1, equation 2 for x2 and so on equation n for xn Substituting these values only to the right-hand side of the above
equations, First approximation. Continue up to accuracy

Convergence of Approximations
The system of equations is diagonally dominant

substituting these values only to the right hand side of the


above equations

https://byjus.com/maths/iterative-methods-gauss-seidel-and-jacobi/ https://byjus.com/maths/iterative-methods-gauss-seidel-and-jacobi/

Gauss-Jacobi/Jacobian Method… Gauss-Seidel Method

https://byjus.com/maths/iterative-methods-gauss-seidel-and-jacobi/ https://byjus.com/maths/iterative-methods-gauss-seidel-and-jacobi/

20
1/14/2025

Matrix Form-Jacobi Method Matrix Form-Jacobi Method

Gauss-Seidel Method Gauss-Seidel Method


The upward velocity of a rocket is given at three different times in the
following table Time (sec) Velocity (m/s)
5 106.8
8 177.2
12 279.2
The velocity data is approximated by a polynomial as

Find the values of 𝑎1, 𝑎2, 𝑎𝑛𝑑 𝑎3 using the Gauss-Seidel method. Assume an
initial guess of the solution as

and conduct two iterations.

https://byjus.com/maths/iterative-methods-gauss-seidel-and-jacobi/

21
1/14/2025

Gauss-Seidel Method Gauss-Seidel Method

Problem Problem
Suppose that a team of three parachutists is connected by a weightless cord while free-falling at a
velocity of 5 m/s

22
1/14/2025

Interpolation Polynomial Interpolation


Interpolation: derive value between two points having a prescribed value General formula for an nth-order polynomial is
Extrapolation: predicting the value or state of a variable based on its
current state
(a) First-order (linear) connecting two points
(b) Second order (quadratic or parabolic) connecting three points
(c) Third-order (cubic) connecting four points

Linear Interpolation Quadratic Interpolation


Using similar triangles The error in linear interpolation resulted from our approximating a curve with a
straight line
AA particularly convenient form for this purpose is

linear-interpolation formula

23
1/14/2025

Quadratic Interpolation.. General Form of Newton’s Interpolating Polynomials


We can generalize the linear and quadratic interpolation formulas for an nth order
polynomial passing through n+1 points

Data points required:


We use these data points and the following equations to evaluate the coefficients:

General Form of Newton’s Interpolating Polynomials.. General Form of Newton’s Interpolating Polynomials..
The first finite divided difference is represented generally as

The second finite divided difference is represented generally as

Substituting into general formula

nth finite divided difference is represented generally as

Newton’s divided-difference interpolating polynomial

24
1/14/2025

Problem Newton’s Forward Difference for Equally Spaced Data


The following logarithmic table is given.

Forward Difference for Equally Spaced Data.. Forward Difference Table

25
1/14/2025

Forward Difference.. General Form..


Newton’s divided-difference interpolating polynomial

b3
Newton’s Forward Interpolation Formula

bn

Backward Difference for Equally Spaced Data General Form


We choose the form
b0 b1 b2
b3

bn

26
1/14/2025

Backward Difference Formula Backward Difference Table

Newton’s Backward Interpolation Formula

Problem Gauss’ Central Difference Formulae


Gauss’ Forward Difference Formulae

27
1/14/2025

Gauss’ Forward Central Difference Formulae Gauss’ Central Difference Formulae


Proof:

Gauss’ Backward Central Difference Formula Gauss’ Backward Central Difference Formula..

28
1/14/2025

Gauss’ Backward Central Difference Formula.. Gauss’ Backward Central Difference Formula..

Gauss’ Backward Central Difference Formula.. Stirling’s Formula

29
1/14/2025

Stirling’s Formula Bessel’s Formula

Bessel’s Formula… Laplace-Everett’s Formula

30
1/14/2025

Laplace-Everett’s Formula… Laplace-Everett’s Formula…

Choice of an Interpolation Formula Problems

31
1/14/2025

Lagrange Interpolation Lagrange Interpolation…

Lagrange Interpolation… Lagrange Interpolation…


Find Solution using Lagrange's Interpolation formula

32
1/14/2025

Curve-fitting by Least Squares Curve-fitting by Least Squares


Curve fitting- noise, general trend
Interpolation- curves directly through each point
Regression- a link between two variables: the
independent variable X and the dependent variable
Y

Applications are generally encountered:


Trend analysis-forecast dependent variable
Hypothesis testing- existing mathematical model is
compared with measured data

Fitting a Straight Line Fitting a Straight Line…

33
1/14/2025

Fitting a Straight Line… Fitting a Straight Line…

Multiple Linear Least Square Multiple Linear Least Square…

34
1/14/2025

Multiple Linear Least Square… Linearization of Nonlinear Relationships


o Linear regression provides a powerful technique for fitting the best line
to data, where the relationship between the dependent and
independent variables is linear
o But, this is not always the case, thus first step in any regression analysis
should be to plot and visually inspect whether the data is a linear model
or not

data is ill-suited
for linear
regression

Linearization of Nonlinear Relationships.. Linearization of Nonlinear Relationships..


Three common examples and their linearization

All are expressed as

35
1/14/2025

Linearization of Nonlinear Relationships.. Linearization of Nonlinear Relationships..


Linearization of a Power equation and fit equation to
the data in table below using a logarithmic transformation of
the data.

Solution:

Linearization of Nonlinear Relationships.. Linearization of Nonlinear Laws…

36
1/14/2025

Linearization of Nonlinear Laws… Linearization of Nonlinear Relationships..


Linearization of a saturation-growth rate equation
to the data in table below.

Linearization of Nonlinear Relationships.. Linearization of Nonlinear Relationships

37
1/14/2025

Curve Fitting by Polynomial Polynomial Regression…


The least-squares procedure can be readily extended to fit the data to Taking the derivative of the above equation
a higher-order polynomial
Let us consider a second–order polynomial or quadratic

Polynomial Regression… Polynomial Regression…


Setting the equations equal to zero and rearrange

In matrix form:

38
1/14/2025

Polynomial Regression… Numerical Differentiation and Integration


Newton-Cotes Integration Formulas

Numerical Integration… Numerical Integration…


The Trapezoidal Rule The Trapezoidal Rule

39
1/14/2025

Numerical Integration… Numerical Integration


The Trapezoidal Rule

Numerical Integration… Numerical Integration…

40
1/14/2025

Numerical Integration… Numerical Integration…

Numerical Integration… Numerical Integration…

41
1/14/2025

Numerical Integration… Numerical Integration…

Numerical Integration… Numerical Integration…


The cross-sectional area of a channel can be computed as

42
1/14/2025

Numerical Integration… Numerical Integration…


A wind force distributed against the side of a skyscraper is measured as

Compute the net force and the line of action due to this distributed wind.

Numerical Differentiation Numerical Differentiation…

43
1/14/2025

Numerical Differentiation… Numerical Differentiation…

Numerical Differentiation… Numerical Differentiation…

44
1/14/2025

Numerical Differentiation… Numerical Differentiation…

Numerical Differentiation… Numerical Differentiation…

45
1/14/2025

Numerical Differentiation… Numerical Differentiation…

Numerical Differentiation… Solution of Ordinary Differential Equation


• no "nice" algebraic solution of differential equations
• Even if we can solve some differential equations algebraically, the solutions
may be quite complicated

https://www.intmath.com/differential-equations/11-eulers-method-des.php

46
1/14/2025

Solution of Ordinary Differential Equation Solution of Ordinary Differential Equation

This gives us a reasonably good approximation if we take plenty of terms, and if the
value of h is reasonably small.

https://www.intmath.com/differential-equations/11-eulers-method-des.php https://www.intmath.com/differential-equations/11-eulers-method-des.php

Solution of Ordinary Differential Equation Solution of Ordinary Differential Equation

https://www.intmath.com/differential-equations/11-eulers-method-des.php https://www.intmath.com/differential-equations/11-eulers-method-des.php

47
1/14/2025

Solution of Ordinary Differential Equation Solution of Ordinary Differential Equation

https://www.intmath.com/differential-equations/11-eulers-method-des.php

Solution of Ordinary Differential Equation Solution of Ordinary Differential Equation

48
1/14/2025

Solution of Ordinary Differential Equation Solution of Ordinary Differential Equation

Solution of Ordinary Differential Equation Solution of Ordinary Differential Equation


Runge-Kutta (R-K)
These R-K

49
1/14/2025

Solution of Ordinary Differential Equation Solution of Ordinary Differential Equation

Solution of Ordinary Differential Equation Solution of Ordinary Differential Equation

50
1/14/2025

Solution of Ordinary Differential Equation Solution of Ordinary Differential Equation

Solution of Ordinary Differential Equation Assignment-02 (For A & C Section)

*Please select one math on your own for the following


methods and provide solution:
1. Simpson’s 1/3 rule
2. Numerical differentiation from central difference formula
3. Fourth order RK method

51

You might also like