You are on page 1of 21

Numerical Analysis

Lecture 2

1
Subsets of numbers
There are 5 basic subsets of numbers:

• Natural numbers (N)


• Integer numbers (Z)
• Rational numbers (Q)
• Real numbers (R)
• Complex numbers (C)

2
Subsets of numbers

Natural numbers (N)


• Sometimes called counting numbers
• Example: 0, 1, 2, 3, 4, 5, …..

Integers (Z)
• The integer numbers constitute of the natural numbers
and their negative values.
• Example: …., -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, …..

3
Subsets of numbers

Rational numbers (Q)


• Can be expressed as a fraction with an integer numerator and
an integer denominator.
• In rational numbers, the denominator can’t be zero.
1 3 2
• Example: , ,
2 7 3

Irrational Numbers
• Numbers that cannot be written as a ratio of two integers

• Example: π, 2, 3 4
Subsets of numbers

Real numbers (R)

• Real numbers include all the rational and irrational numbers.

Complex numbers (C)


• The complex numbers consist of all numbers of the form
𝑎 + 𝑖𝑏
where a and b are real numbers, i = −1

5
Subclasses of the integers

Even and odd numbers


• An even number is an integer that is divisible by two without remainder.
• Any even number m has the form 𝑚 = 2𝑘 where k is an integer

• For odd numbers, the remainder is always 1 when dividing by two.


• Any odd number 𝑛 may be constructed by the formula 𝑛 = 2𝑘 + 1

6
Subclasses of the integers

Prime numbers

• A prime number is an integer greater than 1 that is not the product of


two smaller positive integers.
• Every natural number greater than 1 is either a prime itself or can be
factorized as a product of primes that is unique up to their order.
For example: 30 → 5×3×2
100 → 5×5×2×2

7
Error Analysis

Absolute error
Consider two values, as one being the true value (m) and the other is the
computed value (p).
Absolute Error (AE) is the absolute difference between the measured
value and the true value.
𝐴𝐸 = 𝑝 − 𝑚

Relative error

𝑝−𝑚 𝐴𝐸
𝑅𝐸 = =
𝑚 𝑚
8
Error Analysis

Mean absolute error


Mean absolute error (MAE) is a measure of error between multiple
measurements.
𝑛
1
𝑀𝐴𝐸 = ෍ 𝑝𝑖 − 𝑚𝑖
𝑛
𝑖=1

Mean relative error


𝑛
1 𝑝𝑖 − 𝑚𝑖
𝑀𝑅𝐸 = ෍
𝑛 𝑚𝑖
𝑖=1
9
Error Analysis

Square error
Square error (SE) between two measurements is the square of the
absolute error between the two measurements.
2
𝑆𝐸 = 𝑝 − 𝑚

Mean square error

𝑛
1 2
𝑀𝑆𝐸 = ෍ 𝑝𝑖 − 𝑚𝑖
𝑛
𝑖=1

10
Error Analysis

Root mean square error


Root mean square error (RMSE) is the most popular evaluation metric
used in error analysis.

𝑛
1 2
𝑅𝑀𝑆𝐸 = ෍ 𝑝𝑖 − 𝑚𝑖
𝑛
𝑖=1

11
Error Analysis

Example
Suppose that the output of a machine learning model is 23.7. Compute
the absolute and relative error for the model if the target value is 25.

Solution
Predicted value (computed value): p= 23.7
Target value (True value): m= 25
𝐴𝐸 = 𝑝 − 𝑚 𝑝−𝑚 𝐴𝐸
𝑅𝐸 = =
𝑚 𝑚
𝐴𝐸 = 23.7 − 25 = 1.3
1.3
𝑅𝐸 = = 0.052
25
12
Error Analysis
Example
A student made a new device which Reading New device reading Reference value
1
used to measure the heart rate. He 88 88
2 107 104
recorded 10 measurements taken 3 78 78
from the new device and the 4 100 99
corresponding values which 5 68 67
measured with a calibrated device. 6 107 108
7
The measurements of the calibrated 83 82
8 88 85
device are taken as reference. 9 93 91
10 78 78

Compute MAE, MRE, and RMSE.

13
Error Analysis
Solution
1
1) 𝑀𝐴𝐸 = σ𝑛𝑖=1 𝑝𝑖 − 𝑚𝑖
𝑛
1
= ሾ 88 − 88 + 107 − 104 + 78 − 78 + 100 − 99 + 68 − 67
10
+ 107 − 108 + 83 − 82 + 88 − 85 + 93 − 91 + 78 − 78 ሿ = 1.2

1 𝑝𝑖 −𝑚𝑖
2) 𝑀𝑅𝐸 = σ𝑛𝑖=1
𝑛 𝑚𝑖

1 88 − 88 107 − 104 78 − 78 100 − 99 68 − 67 107 − 108


= ቈ + + + + +
10 88 104 78 99 67 108
83 − 82 88 − 85 93 − 91 78 − 78
+ + + + ቉ = 0.013
82 85 91 78

14
Error Analysis
Solution
3)

𝑛
1 2
𝑅𝑀𝑆𝐸 = ෍ 𝑝𝑖 − 𝑚𝑖
𝑛
𝑖=1

1
= ቆ ൣ 88 − 88 2 + 107 − 104 2 + 78 − 78 2 + 100 − 99 2
10
+ 68 − 67 2 + 107 − 108 2 + 83 − 82 2 + 88 − 85 2 + 93 − 91 2
0.5
+ 78 − 78 2 ൧ቇ = 1.61
15
Chapter 2
Solutions of Equations in One Variable

16
Solution of an equation
The solution of an equation is the value‐or values‐that a variable can take
on such that they make the equation true.

Example
Given the equation 4x - 8 = 4

The value x = 3 is a solution for this equation.

It is possible for an equation to have more than one solution. This occurs
when the degree of the polynomials used is not 1

Example

Given the equation 𝑥 2 + 6𝑥 = 16.


The solutions for this equation are 𝑥 = −8 and 𝑥 = 2
17
Solution of linear equations in one variable

Linear equations:
Degree (max power of the variable) =1

Ex. 𝟐𝒙 + 𝟑 = 𝟎 3(𝒙 + 𝟕) = 𝟓 𝟐 𝒙 + 𝟑 − 𝟏 = 𝟒𝒙

Solution Steps:
1. Carry out all distributions;
2. Regroup the variables on one side of the equal sign and the numbers
on the other;
3. Divide both sides by the coefficient of the variable.

18
Solution of linear equations in one variable
Example
Solve the equation

Solution
▪ Carry out all the distributions; ▪ Divide the two sides by the coefficient of the variable

3𝑥 27
=
3 3
𝑥=9
▪ Regroup the variables in one side
Thus, the solution for the equation is 𝑥 = 9
6𝑥 − 3𝑥 = 7 + 20
We can validate the solution by substituting 𝑥 = 9
3𝑥 = 27 in the equation
19
Solution of linear equations in one variable
Example
Solve the equation 6 2𝑥 + 3 + 𝑥 − 7 = 3 5𝑥 + 7 + 2𝑥

Solution
▪ Carry out all the distributions; ▪ Divide the two sides by the coefficient of the variable

12𝑥 + 18 + 𝑥 − 7 = 15𝑥 + 21 + 2𝑥 −4𝑥 10


=
−4 −4
13𝑥 + 11 = 17𝑥 + 21 𝑥 = −2.5

▪ Regroup the variables in one side


Thus, the solution for the equation is 𝑥 = −𝟐. 𝟓
13𝑥 − 17𝑥 = 21 − 11

−4𝑥 = 10
20
21

You might also like