You are on page 1of 22

2/28/2024

CPE 310: Numerical Analysis for Engineers


Chapter 0: Introduction

Copyright notice: care has been taken to use only those web images deemed by the instructor to be in the public domain. If you see a copyrighted image on any slide and are the copyright owner, please contact the instructor. It will be removed.

Syllabus

2
2/28/2024

Goal of the Class

This is not a course to teach you to code


This is a course to teach you computer algorithms for analyzing and
solving science and engineering problems in numerical ways

4
2/28/2024

Why Numerical ?

We will learn how a computer can be used to solve problems that may not
be solvable by the techniques that are taught in most calculus courses

Analysis in Mathematics
Solve a problem through equations. The equations must then be reduced to an answer through the
procedures of algebra, calculus, differential equations, partial differential equations, or the like.

6
2/28/2024

Analysis in Mathematics
Solve a problem through equations. The equations must then be reduced to an answer through the
procedures of algebra, calculus, differential equations, partial differential equations, or the like.

𝑓 𝑥 = 𝑥 − 𝑥 − 3𝑥 + 3 𝑥 − 𝑥 − 3𝑥 + 3 = 0
𝑥 −𝑥 + (−3𝑥 + 3) = 0
𝑥 𝑥 − 1 − 3(𝑥 − 1) = 0
(𝑥 − 1)(𝑥 − 3) = 0
𝑥 = 1, ± 3

Analytical Answer

Numerical Analysis
The only procedures to solve the problem are arithmetic: add, subtract, multiply, divide, and
compare. Since these operations are exactly those that computers can do

Always an approximation
Accuracy needed or obtained???

8
2/28/2024

Numerical Analysis
The only procedures to solve the problem are arithmetic: add, subtract, multiply, divide, and
compare. Since these operations are exactly those that computers can do

𝑓 𝑥 = 𝑥 − 𝑥 − 3𝑥 + 3 −1.75 1 1.75

3 = 1.73205080757

Analytical Answer Numerical Answer

Analytical Answer Numerical Answer


The equations reduced to an answer through the
The only procedures that are used are arithmetic: add,
procedures of algebra, calculus, differential equations,
subtract, multiply, divide, and compare
partial differential equations, or the like.
“Always an Approximation”

While the numerical result is an approximation, this can


usually be as accurate as needed. The necessary accuracy
is, of course, determined by the application.

1.414
1.41421
1.41421356237

10
2/28/2024

Analytical Answer Numerical Answer


The equations reduced to an answer through the
The only procedures that are used are arithmetic: add,
procedures of algebra, calculus, differential equations,
subtract, multiply, divide, and compare
partial differential equations, or the like.
“Always an Approximation”

(3.14)(3) 28.26
𝑟=3

(3.141592)(3) 28.274328

(3.14159265359)(3) 28.2743338823
Area = 9𝜋

11

𝑥 =2

12
2/28/2024

𝑥 =2

What is x?

13

𝑥 =2

What is x?

14
2/28/2024

𝑥 =2

What is x?

(1.5) = 2.25 Too Large

15

𝑥 =2

What is x?

(1.5) = 2.25 Too Large

(1.4) = 1.96 Too Small

16
2/28/2024

𝑥 =2

What is x?

(1.5) = 2.25 Too Large

(1.4) = 1.96 Too Small

(1.45) = 2.1025 A Bit Closer

17

𝑥 =2

What is x?

(1.5) = 2.25 Too Large

(1.4) = 1.96 Too Small

(1.45) = 2.1025 A Bit Closer

(1.425) = 2.030625 Close

18
2/28/2024

𝑥 =2

What is x?

(1.5) = 2.25 Too Large

(1.4) = 1.96 Too Small

(1.45) = 2.1025 A Bit Closer

(1.425) = 2.030625 Close

(1.4125) = 1.919515625 Pretty Close

19

𝑥 =2

What is x?

(1.5) = 2.25 Too Large

(1.4) = 1.96 Too Small

(1.45) = 2.1025 A Bit Closer

(1.425) = 2.030625 Close

(1.4125) = 1.919515625 Pretty Close

2 = 1.41421356237

20
2/28/2024

𝑥 =2

What is x?

(1.5) = 2.25 Too Large

(1.4) = 1.96 Too Small

(1.45) = 2.1025 A Bit Closer

(1.425) = 2.030625 Close

(1.4125) = 1.919515625 Pretty Close


This is actually a root finding method called
“Bisection”
2 = 1.41421356237

21

Topics to cover

22
2/28/2024

Accuracy, Approximation, and Error


Examines the important topic of the accuracy of computations and the different sources of errors.
Errors that are due to the way that computers store numbers are examined in some detail

23

Solving Nonlinear Equations

24
2/28/2024

Solving Sets of Linear Equations

𝑥 − 2𝑦 = −1
4𝑥 + 3𝑦 = 7
3𝑥 + 5𝑦 = 8

25

Interpolation and Curve Fitting


Curve Fitting is the process of constructing a curve, or mathematical
function, that has the best fit to a series of data points

𝑥 𝑥 𝑥 𝑥 𝑥 𝑥

We would like to find intermediate


Fit Curves to Data Points If the curve passes all data points,
or predicted values
we call it interpolation

26
2/28/2024

Numerical Differentiation & Integration


approximate derivative values of a function and approximate definite integral, even when no
analytical form exists

27

Solution of Ordinary Differential Equations


An ordinary differential equation (ODE) is a differential equation containing one or more
functions of one independent variable and its derivatives.

28
2/28/2024

Modeling
Combustion
Flow in Coal
Power Plant

Network Simulation and


Traffic Networks

Structural/Mechanical analysis,
design, and behavior

Applications of Numerical Methods


Computational Fluid Dynamics

Estimation of Ocean Currents


Electromagnetics Analysis for
Weather Predictions
Detection by Radar

29

Numerical methods require such tedious and repetitive arithmetic operations


that only when we have a computer to carry out these many separate
operations it is practical to solve problems in this way

Why not Ask Human to do it?


A human would make so many mistakes that
there would be little confidence in the result

The manpower cost would be more than could


normally be afforded

30
2/28/2024

It is critically important to realize that errors can occur in


doing numerical procedures
Errors Original Data Blunders Truncation Error Propagated Error Round-Off Error

31

Error in Original Data


Real-world problems (e.g., Physical System) is modeled by a mathematical
equation, will nearly always have coefficients that are imperfectly known.
The reason is that the problems often depend on measurements of doubtful accuracy OR
the model itself may not reflect the behavior of the situation perfectly

32
2/28/2024

Blunders a stupid or careless mistake.

We always use a computer or programmable calculators in numerical analysis.


Such machines make mistakes very infrequently, but because computers and
calculators are programmed by humans blunders or gross errors do occur more
frequently than we like to admit.
Running test cases with known results, but it is no guarantee of freedom from foolish error

33

Truncation Errors
The error made by truncating an infinite sum and approximating it by a finite sum

𝑥
𝑒 = 𝑥 𝑥 𝑥
𝑛! 𝑒 ≈1+ + +
1! 2! 3!
Infinite Sum Series Finite Sum Series

Life is finite and computer time is costly, we must be satisfied with an


approximation to the exact analytical answer.

34
2/28/2024

Propagated Error
The error in the succeeding steps of a process due to an occurrence of an
earlier error

Step 1 Unstable Propagated Error


Step 2 Error magnified continuously as the
method continues, eventually
Step 3
overshadowing/destroying the true value
Step 4
Stable Propagated Error
Error made at early points die out as the
Step n method continues

35

Round-Off Error
Difference between result produced by given algorithm using exact arithmetic
and result produced by same algorithm using limited precision arithmetic
Due to inexact representation of real numbers and arithmetic operations upon them

1
≈ 0.167
6
1
≈ 0.1666667
6

1
≈ 0.1666666666666666666666666666667
6

36
2/28/2024

Computing Error
The accuracy of any computation is always of great importance. There are two
common ways to express the size of the error in a computed result

Absolute Error
Absolute Error = |True Value – Approximate Value| Relative Error =
Absolute error is usually more serious when the magnitude of the true value is small as its
|True Value|
dependent on the scale of the value The relative error is more independent of the scale of the value

37

Computing Error
The accuracy of any computation is always of great importance. There are two
common ways to express the size of the error in a computed result

Absolute Error
Absolute Error = |True Value – Approximate Value| Relative Error =
Absolute error is usually more serious when the magnitude of the true value is small as its
|True Value|
dependent on the scale of the value The relative error is more independent of the scale of the value

Example
True Value = Approximate Value = 3.333

Absolute Error = − 3.333 = 0.00033333 =

Relative Error = =

38
2/28/2024

39

Floating-Point Arithmetic
Even though a computer follows exactly the instructions that it is given, when it performs an arithmetic
operation it does not get exact answers unless only integers or exact powers of 2 are involved.

13.524 is stored as a floating-point number .13524 × 10

A computer stores numbers as floating-point .13524E2


quantities that resemble scientific notation.

0.0442 is stored as a floating-point number .442 × 10

.442E-1

40
2/28/2024

Numerical Analysis
Throughout this class
• Find where f(x) = 0 for a nonlinear equation or system of equations.
• Solve systems of linear equations, even large systems.
• Interpolate to find intermediate values from a table of values and fit curves to experimental data.
• Approximate functions with polynomials or with a ratio of polynomials.
• Approximate values for the derivatives of a function, even if this is known only by a table of function values.
• Evaluate the definite integral for any integrand, even if its values are known only from experimental
observations.
• Solve differential equations when initial values are given; these can be of any order and complexity.
Numerical analysis can even solve them if conditions are specified at the boundaries of a region.
• Find the minima or maxima of functions, even when subject to constraints.
• Solve all types of partial differential equations by several techniques.

©Amin Alqudah 2020

41

Computers and Numerical Analysis


• Numerical methods require such tedious and repetitive arithmetic
operations that only when we have a computer to carry out these
many separate operations is it practical to solve problems in this way
• One important trend in computer operations is the use of several
processors working in parallel to carry out procedures with greater
speed than can be obtained with a single processor

©Amin Alqudah 2020

42
2/28/2024

Error Origins
• Original Data
• Accuracy of measurements
• Models may not reflect the behavior perfectly
• Blunders
• Computers are programmed by humans
• Truncation
• is the error made by truncating an infinite sum and approximating it by a finite sum
• Propagated
• From former steps
• Stable vs unstable methods
• Round off
• Number representation (type and length)

©Amin Alqudah 2020

43

You might also like