Numerical Methods Lecture #1
Numerical Methods Lecture #1
Methods
Lecture-1
[MA-200]
ARISHA ALI
Numerical method
ARISHA ALI 2
Need of Numerical Methods
▪ Analytical methods exist but are time consuming, very laborious to apply or
may be huge data is involved or may not be easily computed.
ARISHA ALI 3
Error
Error is the difference between the actual value and Approximated (Calculated)
value.
If we denote the actual value with 𝒙 and the calculated value with 𝒙∗
then error will be,
∈ = 𝐸 = 𝑥 − 𝑥∗
ARISHA ALI 4
Example
𝐴𝑐𝑡𝑢𝑎𝑙 𝑉𝑎𝑙𝑢𝑒 = 𝟕. 𝟖𝟗𝟑 𝑎𝑛𝑑 𝐴𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑒𝑑 𝑉𝑎𝑙𝑢𝑒 = 𝟕. 𝟔𝟕𝟐
𝑆𝑜, 𝐸𝑟𝑟𝑜𝑟 = 𝟎. 𝟐𝟐𝟏
𝐸𝑟𝑟𝑜𝑟 𝑚𝑎𝑦 𝑏𝑒 𝑛𝑒𝑔𝑎𝑡𝑖𝑣𝑒, 𝑜𝑟 𝑒𝑟𝑟𝑜𝑟 𝑚𝑎𝑦 𝑏𝑒 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒
𝐼𝑓 𝐴𝑐𝑡𝑢𝑎𝑙 𝑉𝑎𝑙𝑢𝑒 = 𝟕. 𝟔𝟕𝟐 𝑎𝑛𝑑 𝐴𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑒𝑑 𝑉𝑎𝑙𝑢𝑒 = 𝟕. 𝟖𝟗𝟑
𝑆𝑜, 𝐸𝑟𝑟𝑜𝑟 = −𝟎. 𝟐𝟐𝟏
ARISHA ALI 5
Example
The derivative of a function 𝑓 𝑥 at a particular value of 𝑥 can be approximately
calculated by
𝑓 𝑥 + ℎ − 𝑓(𝑥)
𝑓′ 𝑥 ≡
ℎ
Find 𝑓 ′ 2 for 𝑓 𝑥 = 7𝑒 0.5𝑥 and ℎ = 0.3, Find
a) The approximate value of 𝑓 ′ 2
b) The actual value of 𝑓 ′ 2
c) The Error
ARISHA ALI 6
Cont…
𝑓 𝑥+ℎ −𝑓(𝑥)
a) 𝑓′ 𝑥 ≡ ,
ℎ
𝑥 = 2 𝑎𝑛𝑑 ℎ = 0.3
𝑓 2 + 0.3 − 𝑓(2)
𝑓′2 ≡
0.3
′
𝑓 2.3 − 𝑓(2)
𝑓 2 =
0.3
22.107 − 19.028
=
0.3
= 10.265
ARISHA ALI 7
Cont…
b) 𝑓 𝑥 = 7𝑒 0.5𝑥
𝑓 ′ 𝑥 = 7 ∗ 0.5 ∗ 𝑒 0.5𝑥
𝑓 ′ 2 = 7 ∗ 0.5 ∗ 𝑒 0.5(2)
= 9.5140
c) Error = Actual Value – Approximated Value
ARISHA ALI 8
Types of Error
We have three types of errors
▪ Absolute Error
▪ Relative Error
▪ Percentage Error
ARISHA ALI 9
Absolute Error
If 𝒙 is the actual value and 𝒙∗ is the calculated value, then
𝐴. 𝐸 = 𝐸𝑎 = |𝑥 − 𝑥 ∗ |
For example,
𝐼𝑓 𝑝 = 0.3000 ∗ 101 𝑎𝑛𝑑 𝑝∗ = 0.3100 ∗ 101
𝐸𝑎 = −0.1 = 0.1
ARISHA ALI 10
Relative Error
Relative error is the ratio of the absolute error to the actual value
𝐸𝑎 |𝑥−𝑥 ∗ |
𝑅. 𝐸 = 𝐸𝑅 = =
|𝑥| |𝑥|
For example,
𝐼𝑓 𝑃 = 0.3000 ∗ 101 𝑎𝑛𝑑 𝑝∗ = 0.3100 ∗ 101
𝐸𝑎 0.1
𝐸𝑅 = = = 0.03333 = 0.3333 ∗ 10−1
|𝑝| |0.30000 ∗101 |
ARISHA ALI 11
Percentage Error
Relative Error expresses in terms of a percentage error
𝐸𝑎
𝑃. 𝐸 = ∗ 100
|𝑥|
For example,
𝐼𝑓 𝑃 = 0.3000 ∗ 101 𝑎𝑛𝑑 𝑝∗ = 0.3100 ∗ 101
𝐸𝑎 0.1
𝐸𝑅 = = = 0.03333 = 0.3333 ∗ 10−1
|𝑝| |0.30000 ∗101 |
𝐸𝑎
𝑃. 𝐸 = ∗ 100 = 0.03333 ∗ 100 = 3.333%
|𝑥|
ARISHA ALI 12
If we Don’t have Actual Value
▪ 𝐴. 𝐸 = 𝐸𝑎 = |𝐶𝑢𝑟𝑟𝑒𝑛𝑡 𝐸𝑠𝑡𝑖𝑚𝑎𝑡𝑒 − 𝑃𝑟𝑒𝑣𝑖𝑜𝑢𝑠 𝐸𝑠𝑡𝑖𝑚𝑎𝑡𝑒|
𝐸𝑎 |𝐶𝑢𝑟𝑟𝑒𝑛𝑡 𝐸𝑠𝑖𝑡𝑖𝑚𝑎𝑡𝑒 −𝑃𝑟𝑒𝑣𝑖𝑜𝑢𝑠 𝐸𝑠𝑡𝑖𝑚𝑎𝑡𝑒|
▪ 𝑅. 𝐸 = 𝐸𝑅 = =
|𝑥| |𝐶𝑢𝑟𝑟𝑒𝑛𝑡 𝐸𝑠𝑡𝑖𝑚𝑎𝑡𝑒|
𝐸𝑎
▪𝑃. 𝐸 = ∗ 100
|𝑥|
ARISHA ALI 13
Homework
▪ If 𝑃 = 0.3000 ∗ 10−3 𝑎𝑛𝑑 𝑝∗ = 0.3100 ∗ 10−3 , Find the absolute error and
relative error and percentage error.
▪ If 𝑃 = 0.3000 ∗ 104 𝑎𝑛𝑑 𝑝∗ = 0.3100 ∗ 104 , Find the absolute error and
relative error and percentage error
ARISHA ALI 14
Significant Digits
A significant digit in a number is a digit which gives a reliable information about
the size of a number
Rules:
▪ Every nonzero digit is significant E.g.,
▪ 8.7456 has five significant digits
▪ 495 has three significant digits
▪ Zero between nonzero digits are always significant. E.g.
▪ 2047 has four significant digits,
▪ 50.032 has five significant digits.
ARISHA ALI 15
Cont…
▪ Zeros before nonzero digits are not significant. E.g,
▪ 0.0123 has three significant digits
▪ 0.00000000123 has three significant digits
ARISHA ALI 16
Examples
▪ 6.4320 ℎ𝑎𝑠 𝑓𝑖𝑣𝑒 𝑠𝑖𝑔𝑛𝑖𝑓𝑖𝑐𝑎𝑛𝑡 𝑑𝑖𝑔𝑖𝑡𝑠
▪ 0.06432 ℎ𝑎𝑠 𝑓𝑜𝑢𝑟 𝑠𝑖𝑔𝑛𝑖𝑓𝑖𝑐𝑎𝑛𝑡 𝑑𝑖𝑔𝑖𝑡𝑠
▪ 64 ℎ𝑎𝑠 𝑡𝑤𝑜 𝑠𝑖𝑔𝑛𝑖𝑓𝑖𝑐𝑎𝑛𝑡 𝑑𝑖𝑔𝑖𝑡𝑠
▪ 64.0 ℎ𝑎𝑠 𝑡ℎ𝑟𝑒𝑒 𝑠𝑖𝑔𝑛𝑖𝑓𝑖𝑐𝑎𝑛𝑡 𝑑𝑖𝑔𝑖𝑡𝑠
▪ 6.432 ∗ 104 ℎ𝑎𝑠 𝑓𝑜𝑢𝑟 𝑠𝑖𝑔𝑛𝑖𝑓𝑖𝑐𝑎𝑛𝑡 𝑑𝑖𝑔𝑖𝑡𝑠
▪ 6.43200 ℎ𝑎𝑠 𝑠𝑖𝑥 𝑠𝑖𝑔𝑛𝑖𝑓𝑖𝑐𝑎𝑛𝑡 𝑑𝑖𝑔𝑖𝑡𝑠
▪ 5000 ℎ𝑎𝑠 𝑜𝑛𝑒 𝑠𝑖𝑔𝑛𝑖𝑓𝑖𝑐𝑎𝑛𝑡 𝑑𝑖𝑔𝑖𝑡
ARISHA ALI 17