Let’s first know some basics about numbers used in floating-point arithmetic or in other words Numerical analysis and how they are calculated.

Basically, all the numbers that we use in Numerical Analysis are of two types as follows.

**Exact Numbers –**

Numbers that have their exact quantity, means their value isn’t going to change. For example- 3, 2, 5, 7, 1/3, 4/5, or √2 etc.**Approximate Numbers –**

These numbers are represented in decimal numbers. They have some certain degrees of accuracy. Like the value of*π*is*3.1416*if we want more precise value, we can write*3.14159265,*but we can’t write the exact value of π.These digits that we use in any approximate value, or in other way digits which represent the numbers are called Significant Digits.

**How to count significant digits in a given number :**

**For example –**

In the normal value of π (3.1416), there are *5* significant digits and when we write more precise value of it (3.14159265) we get *9* significant digits.

Let’s say we have numbers: 0.0123, 1.2300, and 0.10234. Now we have 4, 3, and 5 significant digits respectively.

**In the Scientific Representation of numbers –**

2.345×10^{7}, 8.7456 ×10^{4}, 5.4×10^{6} have 4, 5 and 2 significant digits respectively.

**Absolute Error :**

Let the true value of a quantity be X and the approximate value of that quantity be X_{1}. Hence absolute error has defined the difference between X and X_{1}. Absolute Error is denoted by E_{A}.

Hence E_{A}= X-X_{1}=δX

**Relative Error :**

It is defined as follow.

E_{R}= E_{A}/X = (Absolute Error)/X

**Percentage Error :**

It is defined as follow.

E_{P}= 100×E_{P}= 100×E_{A}/X

Let’s say we have a number δX = |X_{1}-X|_{, } It is an upper limit on the magnitude of Absolute Error and known as Absolute Accuracy.

Similarly the quantity δX/ |X| or δX/ |X_{1}| called Relative Accuracy.

Now let’s solve some examples as follows.

**Ex-1 :**

We are given an approximate value of π is 22/7 = 3.1428571 and true value is 3.1415926. Calculate absolute, relative and percentage errors?

**Solution –**We have True value X= 3.1415926, And Approx. value X

_{1}= 3.1428571. So now we calculate*Absolute error,*we know that E_{A}= X - X_{1}=δX Hence E_{A}= 3.1415926- 3.1428571 = -0.0012645 Answer is -0.0012645 Now for Relative error we’ve (absolute error)/(true value of quantity) Hence E_{R}= E_{A}/X = (Absolute Error)/X, E_{A}=(-0.0012645)/3.1415926 = -0.000402_{ans}. Percentage Error, E_{P}= 100 × E_{A}/X = 100 × (-0.000402) = - 0.0402ans.**Ex-2 :**

Let the approximate values of a number 1/3 be 0.30, 0.33, 0.34. Find out the best approximation.

**Solution –**

Our approach is that we first find the value of Absolute Error, and any value having the least absolute will be best. So, we first calculate the absolute errors in all approx values are given.

<pre

|X-X_{1}| = |1/3 – 0.30| = 1/30

|1/3 – 0.33| = 1/300

|1/3 – 0.34| = 0.02/3 = 1/500Hence, we can say that 0.33 is the most precise value of 1/3;

**Ex-3 :**Finding the difference—

√5.35 - √4.35

**Solution –**√5.35 = 2.31300 √4.35 = 2.08566 Hence, √5.35 - √4.35 = 2.31300 – 2.08566 = 0.22734

Here our answer has 5 significant digits we can modify them as per our requirements.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the **CS Theory Course** at a student-friendly price and become industry ready.