0% found this document useful (0 votes)
8 views

01 Modeling, Computers, And Error Analysis

The document discusses mathematical modeling, computer-aided numerical calculations, and error analysis. It explains the importance of dependent and independent variables in modeling, the role of numerical methods for solving complex math problems, and various types of errors that can occur in calculations. Additionally, it emphasizes the significance of accuracy and precision in numerical solutions and outlines the iterative nature of many numerical methods.

Uploaded by

Jeran DLr
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

01 Modeling, Computers, And Error Analysis

The document discusses mathematical modeling, computer-aided numerical calculations, and error analysis. It explains the importance of dependent and independent variables in modeling, the role of numerical methods for solving complex math problems, and various types of errors that can occur in calculations. Additionally, it emphasizes the significance of accuracy and precision in numerical solutions and outlines the iterative nature of many numerical methods.

Uploaded by

Jeran DLr
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 36

Modeling, Computers,

and Error
Analysis
• Mathematical model
Outli • Computer-aided numerical calculations
• Errors
ne
Eg
g
• An egg can be cooked as soft-
boiled or hard-boiled depending
on how it is cooked.
Eg
g
(𝑀 ≈ 57 𝑔) at room temperature (𝑇𝑒𝑔𝑔 = 21 °𝐶) in boiling water (𝑇𝑤𝑎𝑡𝑒𝑟 =
• According to The Science of Boiling an Egg by Charles D. H. Williams, a medium egg

100 °𝐶) will take


• 3.6 minutes to reach a temperature Tyolk = 63 °C when soft-boiled, and
• 8.2 minutes to reach a temperature Tyolk = 80 °C when hard-boiled.

𝑡𝑐𝑜𝑜𝑘𝑒𝑑 = 𝜆𝑀2/3 0.76 𝑇𝑒𝑔𝑔 −


× 𝑇𝑦𝑜𝑙
log 𝑇𝑘𝑤𝑎𝑡𝑒𝑟
𝑤𝑎𝑡𝑒

− 𝑇 𝑟

𝜆 𝑐𝜌1/
=
3 4 2/3
𝜋2 3
𝜋
𝜅
Mathematical
Model
𝐷𝑒𝑝𝑒𝑛𝑑𝑒𝑛𝑡
𝑖𝑛𝑑𝑒𝑝𝑒𝑛𝑑𝑒𝑛𝑡
𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒 , 𝑝𝑎𝑟𝑎𝑚𝑒𝑡𝑒𝑟𝑠, 𝑓𝑜𝑟𝑐𝑖𝑛𝑔
=𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒𝑠
𝑓 𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛𝑠
• Dependent variable – characteristic that usually
reflects the behavior or state of the system
• Independent variables – dimensions along which
the system’s behavior is determined
• Parameters – reflects the system’s properties or
composition
• Forcing functions – external influences acting
upon the system
Mathematical
Model
• The actual mathematical expression can range
from a single algebraic relationship to large
complicated sets of differential equations.

𝐹 = 𝑚𝑎
• Example: Newton’s 2nd Law of Motion

𝑎 �


=

Mathematical
Model
• What if we want to predict the velocity of a falling

of time, 𝑣(𝑡)?
parachutist near the Earth’s surface as a function

𝑑𝑣
𝑎 𝐹 =
𝑑𝑡
=
𝐹 =𝑚 𝐹𝐷 + 𝐹𝑈
𝐹𝐷 = 𝑚𝑔 𝑔𝑟𝑎𝑣𝑖𝑡𝑦
𝐹𝑈 = −𝑐𝑑𝑣 (𝑎𝑖𝑟
𝑑𝑣 𝑚𝑔 − 𝑐𝑑𝑣 𝑐𝑑
𝑟𝑒𝑠𝑖𝑠𝑡𝑎𝑛𝑐𝑒)
= =𝑔
𝑑𝑡 − 𝑚 𝑣
𝑚
Mathematical
Model
• What if we want to predict the velocity of a falling

of time, 𝑣(𝑡)?
parachutist near the Earth’s surface as a function

• If jumper is initially at rest, 𝑣 0 = 0, the


𝑔
𝑣 𝑡 =𝑚 1
closed-form
analytical or solution is:
− 𝑚 �
𝑐
−𝑒 𝑐𝑑

𝑑
Mathematical
Model
• A parachutist of mass 68.1 kg jumps out of a
stationary hot air balloon. Compute velocity prior
to opening the chute. The drag coefficient is
equal to 12.5 kg/s.
Mathematical
• Aside from Newton’s second
law, there are other major Model
organizing principles in
engineering.
• Among the most important of
these are the conservation

𝐶ℎ𝑎𝑛𝑔𝑒
laws.

= 𝑖𝑛𝑐𝑟𝑒𝑎𝑠𝑒𝑠 −
𝑑𝑒𝑐𝑟𝑒𝑎𝑠𝑒𝑠
Mathematical
• Aside from Newton’s second
law, there are other major Model
organizing principles in
engineering.
• Among the most important of
these are the conservation

𝐶ℎ𝑎𝑛𝑔𝑒
laws.

= 𝑖𝑛𝑐𝑟𝑒𝑎𝑠𝑒𝑠 −
𝑑𝑒𝑐𝑟𝑒𝑎𝑠𝑒𝑠
Computer-aided
numerical
calculations
• Computer-aided numerical calculations or simply
Numerical Methods are techniques by which
Math problems are formulated in order to be
solved using arithmetic and logical operations.
• Reduces higher Math to basic arithmetic
operations
• Greatly expands the types of problems to be
solved
• Large systems of equations
• Nonlinear systems
• Complicated geometries
Computer-aided
numerical
calculations
• Computer-aided numerical calculations or simply
Numerical Methods are techniques by which
Math problems are formulated in order to be
solved using arithmetic and logical operations.
• Efficient way to learn how to use computers
• Numerical methods are designed for computer
implementation
• Allows the designing of programs/scripts to
solve
problems involving Mathematical models
Computer-aided
numerical
calculations
• Programming – process of creating a set of
instructions that tells a computer how to perform
a task
• Done for automation purposes
• Programming languages/softwares
• C, C++, Java, SQL, VBA, Python
• Mathcad, MATLAB, Octave, Maple,
Mathematica
Computer-aided
numerical
calculations
• Algorithm – sequence of logical steps required to
perform a specific task
• Pseudocode – worded description of a program
(usually in English)
• Flowchart – visual/graphical representation of a
program
Computer-aided
numerical
calculations
sin(𝑥) using the following Taylor series
• Example: Write a computer program to calculate


expansion:

sin 𝑥 = −1
∑ ❑ 2𝑛 + 1
!
𝑛= 𝑛 𝑥 2𝑛+1
0
Computer-aided
numerical
Algorithm
calculations
• Enter 𝑥 and the sin(𝑥) using the following Taylor series
• Example: Write a computer program to calculate

use, 𝑛

number of terms to expansion:

sin 𝑥 = −1
• Calculate sin(𝑥) ∑ ❑ 2𝑛 + 1
!
𝑛= 𝑛 𝑥 2𝑛+1
using the Taylor series 0

• Print the result


Computer-aided
Pseudocode numerical
calculations
• Input 𝑥, 𝑛
sin(𝑥) using the following Taylor series
• sin = 0
• Example: Write a computer program to calculate

• Loop 𝑘 from 1 ∞
expansion:

sin 𝑥 = −1
to•𝑛𝑠𝑖𝑛 = 𝑠𝑖𝑛 + −1 𝑘+1 ∗ 𝑥 2𝑘−1 / ∑ ❑ 2𝑛 + 1
2𝑘 − 1 !
!
𝑛= 𝑛 𝑥 2𝑛+1
0
• End loop
• Output 𝑥, 𝑠𝑖𝑛
Flowchart
Computer-aided
numerical
calculations
sin(𝑥) using the following Taylor series
• Example: Write a computer program to calculate


expansion:

sin 𝑥 = −1
∑ ❑ 2𝑛 + 1
!
𝑛= 𝑛 𝑥 2𝑛+1
0
Notes:
Computer-aided
• For clarity: numerical
• put comments to explain
variables, purpose of code
calculations
segments Programming errors (bugs)
• use variable names that • Syntax error – will not compile, compiler will help you
• Example: typographical error, writing 𝑝𝑟𝑖𝑚𝑡𝑓 instead of
make sense to find it.
• For testing: 𝑝𝑟𝑖𝑛𝑡𝑓
• Test with typical data • Run-time error – will compile but may stop running at
• Test with unusual but valid some point
data • Example: division by zero, trying to read from a non-
• Test with invalid data to existent file
check error handling • Logical error – will compile and run, but the result is

• Example: all terms of sin(𝑥) in Taylor expansion is


wrong

positive
Error
s
• Significant figures
• Digits of the number which are known to be
correct
• Designate the reliability of a number
• Depends on the origin of the number
Error
s
• Accuracy and Precision
• Computers used to obtain numerical solution
are imperfect tools; limited to represent the
magnitudes and precision of numbers.
• Errors from calculations (and measurements)
can be characterized with regard to their
accuracy and precision.
Error
s
• Accuracy – how closely a computed or measured
value agrees with the true value
• Precision – how closely a computed or measured
values agree with each other

• Inaccuracy – systematic deviation from the truth, also


called bias
• Imprecision – magnitude of the scatter, also called
uncertainty

𝐸𝑟𝑟𝑜𝑟 = 𝐼𝑛𝑎𝑐𝑐𝑢𝑟𝑎𝑐𝑦 + 𝐼𝑚𝑝𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛


Error
s
• True error (𝑬𝒕)
• Approximate error
(𝑬𝒂)
• Round-off Error
• Truncation Error
• Gross Error/Blunder
• Model Error
• Data Unncertainty
Error
s
• True error (𝑬𝒕) – exact/absolute value of
the error
• Doesn’t consider the order of magnitude of the
value

𝐸𝑡 = 𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 − 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛


under examination

• Fractional𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 −
𝜀𝑡 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛
𝑡𝑟𝑢𝑒
relative true error
=
• Percentage relative𝑣𝑎𝑙𝑢𝑒
𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 −
true error
𝜀𝑡 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛 ×
𝑡𝑟𝑢𝑒
= 100%
𝑣𝑎𝑙𝑢𝑒
Error
s
• Approximate error (𝑬𝒂) – in actual
situations, true value is rarely available
• Error estimates (or approximations) are

𝐸
determined in
𝜀𝑎
𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡
absence of knowledge regarding the true value
=
𝑎
𝑖𝑜𝑛
𝑝𝑟𝑒𝑠𝑒𝑛𝑡 𝑎𝑝𝑝𝑟𝑜𝑥 − 𝑝𝑟𝑒𝑣𝑖𝑜𝑢𝑠
• Fractional relative approximate error
𝜀𝑎 𝑎𝑝𝑝𝑟𝑜𝑥
𝑝𝑟𝑒𝑠𝑒𝑛𝑡
= 𝑎𝑝𝑝𝑟𝑜𝑥
𝑝𝑟𝑒𝑠𝑒𝑛𝑡 𝑎𝑝𝑝𝑟𝑜𝑥 − 𝑝𝑟𝑒𝑣𝑖𝑜𝑢𝑠
• Percentage relative approximate error
𝜀𝑎 𝑎𝑝𝑝𝑟𝑜𝑥 ×
𝑝𝑟𝑒𝑠𝑒𝑛𝑡
= 100%
𝑎𝑝𝑝𝑟𝑜𝑥
Error
s
• Iterative process – a process in which repetition
of a sequence of operations yields results
successively closer to a desired result.
• Many numerical methods work in an iterative
manner, thus there should be an exit or stopping
criterion for these methods.
Error
s
Exit criteria
• In iteration, we can either define the number of
iterations to be performed (which is not practical
since we won’t know how many should be
performed beforehand) or set a rule on when to
stop.
Error
s
• Let 𝒙 be a vector with 𝑵 elements:
P-Norm in Finite Dimensions

𝒙 = {𝑥1, 𝑥2, 𝑥3, … , 𝑥𝑛}


• For a real number 𝑝 ≥ 1, the 𝐿𝑝 − 𝑛𝑜𝑟𝑚
of 𝒙 𝒙is: 𝒑 = 𝒙𝟏 𝒑 +𝒙𝟐 𝒑 + ⋯ + 𝟏/
𝒑
• Meanwhile,𝒙𝒏 the
𝒑 𝐿∞ − 𝑛𝑜𝑟𝑚 of 𝒙 is defined

𝒙 ∞ = 𝒎𝒂𝒙{ 𝒙𝟏 , 𝒙𝟐 , … ,
as:

𝒙𝒏 }
Error
s
been converged if the 𝐿𝑝 − 𝑛𝑜𝑟𝑚 of the difference
• A solution in solving a system of equation is said to have

value of a variable) is below a tolerance, 𝜀𝑠.


vector (difference of the current and the previous

𝑥𝑖(𝑘+1) = + ∆𝑥𝑖 where 𝑖 is the 𝑖 𝑡ℎ of 𝑛


𝑖
𝑘
(𝑘) (𝑘 + 1)
unknowns 𝑘 𝑡ℎ and 𝑘 + 1 𝑡ℎ
𝑥 Δ 𝑖 = 𝑥𝑖(𝑘+1) − 𝑖
where and are the

𝑥
iterations
𝐿1 𝑒𝑥𝑖𝑡 ∆𝑥 + ∆x + ⋯ + ∆𝑥 ≤
1 2 𝑛
𝑐𝑟𝑖𝑡𝑒𝑟𝑖𝑜𝑛: 𝑥(𝑘)∆𝑥2 + ∆𝑥2 + ⋯ + ∆𝑥2
𝜀𝑠
≤ 𝜀𝑠
𝐿2 𝑒𝑥𝑖𝑡 1 2 𝑛

𝑐𝑟𝑖𝑡𝑒𝑟𝑖𝑜𝑛: max{ ∆𝑥1 , ∆𝑥2 , … , ∆𝑥𝑛


𝐿∞ 𝑒𝑥𝑖𝑡 } ≤ 𝜀𝑠
𝑐𝑟𝑖𝑡𝑒𝑟𝑖𝑜𝑛:
Error
s
• Round-off Error
• Computers cannot represent some
quantities exactly
• Conversion from base-10 to base-2 number

• Example: 𝜋, 1/3
system may create problems

• Computers cannot use infinitely many digits


to store numbers
• Single precision (7-8 digits) vs.
• Double precision (15-16 digits)
Error
Try to add 0.1 a thousand
s
• Round-off Error
times. • Computers cannot represent some quantities exactly
Use both single and • Conversion from base-10 to base-2 number system may

• Example: 𝜋, 1/3
double create problems
precision.
• Computers cannot use infinitely many digits to store
Compare the results. numbers
• Single precision (7-8 digits) vs.
• Double precision (15-16 digits)
• Round-off errors cannot be totally eliminated,
but clever algorithms may help to minimize them.
Error
At x =
s
• Truncation Error
π/2:
• Results from using an approximation in place of
an exact mathematical procedure.

the value of sin(𝑥)


• Example: using Taylor expansion to calculate

sin 𝑥 = −1 𝑛 𝑥 2𝑛+1 𝑥3 𝑥5
∑❑
𝑛=0
2𝑛 + 1
𝑥!7
=𝑥−
+⋯
3!
+
5!

7!
Error
s
• Gross Error/Blunder – computer malfunctions or
human imperfections
• Model Error – incorrect mathematical model
• Data Uncertainty – measurement errors

• We will assume no gross errors/blunders, that we


have a sound model, and deal with error-free
measurements in this course.
Any
questions?

You might also like