Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

P HILIPPINE S CIENCE H IGH S CHOOL - C ENTRAL M INDANAO C AMPUS

P HYSICS 4: E XPERIMENTAL , T HEORETICAL AND C OMPUTATIONAL (ETC) P HYSICS

A Concise Introduction to Numerical Methods


Cabahug, Logarta, Ouano, Ruiz, Tobillo a∗
a
Philippine Science High School - Central Mindanao Campus, Nangka, Balo-i, Lanao del Norte, 9217,
Philippines

This journal offers an introduction to numerical methods. It includes discussion on how integers and floating-point
numbers are represented in a binary system, and a discussion on some types of errors, such as, blunder, random, approx-
imation, and round off. Also, Root Finding and Taylor Series Expansion are introduced and discussed in this journal.

1. Introduction system is the basis in which all computers write


and store data. Binary counting follows the same
Mathematical models are a central piece of sci- principle of decimal counting but instead of going
ence and engineering. Some models have closed- through 10 digits it goes only up to two. Counting
form solutions, thus they can be solved analytically. starts at 0, then the next number is 1, after that the
But many models can’t be solved analytically or the first digit will reset back to zero and another digit
analytic solution is too costly to be practical. Ana- to the left of it containing the value of 1 is added.
lytical methods may give exact solutions but can be Therefore binary counting is as follows: 0, 1, 10,
more time consuming and sometimes impossible. 11, 100, 101, 111, 1000, etc.
Hence, professionals prefer to use numerical meth-
ods to give approximate solutions with allowable
tolerance, less time and possible for most cases. 2.1. Decimal to Binary
Numerical methods are techniques to approxi- A way to write a decimal number in its binary
mate mathematical procedures. It is an approach form is to use the ladder method of dividing num-
for solving complex mathematical problems using bers. As an example, let’s use the number 142. First
simple arithmetic operations. It involves the formu- you write the number in the first ladder step, and
lation of a model of physical situations that can be then you divide the number by 2. As you go down
solved by arithmetic operations. the ladder, you keep dividing the resulting number
by 2 while also writing the remainder from divid-
2. Binary Systems ing by two. You stop dividing when you reach zero.
Then, you write down each remainder from bottom
Integers. Integers are numbers that can be ex- to top to get the binary form of the decimal num-
pressed without a fractional component. They can ber. In our example the binary form of the decimal
be either positive, negative or zero. In the decimal number 142 is 10001110.
system, these numbers are expressed in base 10 us-
ing symbols called digits; 1, 2, 3, 4, 5, 6, 7, 8, 9, and
0. The number 12345 is an example of an integer.
Floating-Point Numbers. Floating-point num-
bers are numbers with decimal places or numbers
that are expressed in fraction form. The term
floating-point comes from the reason that there is
no fixed number before or after the decimal point.
Floating-point numbers can be broken down into 3
components; sign, mantissa, and exponent. As an
example, let’s use the number −6.9420 ∗ 104 . The
sign is either 1 for negative or 0 for positive. The
mantissa is the actual number, 6.9420. And lastly,
the exponent is 4.
Binary. Binary (base-2) is a numeric that only
uses two digits called bits, 0 and 1. This number Figure 1. Decimal to Binary

∗ E-mail address: analogarta@cmc.pshs.edu.ph


PHY4: INTRODUCTION TO NUMERICAL METHODS — 2

2.2. Floating-point to Binary otherwise we write 1 and omit the 1 from the result.
There are 2 formats for floating-point numbers, We can continue this cycle for as long as we can
single precision and double precision. Single preci- because some fractions cannot be exactly expressed
sion uses 32 bits, 1 for the sign, 8 for the exponent, in binary, only an approximation. The binary for the
and 23 for the mantissa. Double precision on the decimal 0.2323 is shown in the figure. The binary
other hand uses 64 bits, 1 for the sign, 11 for the for the decimal 0.2323 is 0.00111011. We can keep
exponent, and 52 for the mantissa. going but we’ll stop there for simplicity’s sake.

Figure 2. Two formats for floating-point numbers

For this example, we will be using single pre-


cision floating-point numbers. Take the number
−623.23.
First thing’s first, we need to turn it into sci-
entific notation. -623.23 in scientific notation is
−6.2323 ∗ 102 . Now, we can determine the parts Figure 4. Converting the ecimal of the Mantissa to Binary
of the number, the sign is negative, the exponent is
2, and the mantissa is 6.2323. Finally, we combine the two to get 110.00111011
1st Step: Sign Final Step: Combine
The sign is negative so we denote it as 1.
And to get the binary of the floating-point num-
2nd Step: Exponent ber we combine the sign, exponent and mantissa as
shown in the table.
Then for the exponent, we need to add 127 to the
exponent. 127 + 2 = 129. Then we convert it into
binary. 129 in binary is 10000001.
3rd Step: Mantissa
For the mantissa, we get the binary of the whole
number and the binary of the fraction/decimal then
combine then.
The binary for the number 6 and the solution is
shown in the figure. The binary for 6 is 110.

Figure 5. Final step in converting Floating-Point Num-


bers to Binary

Therefore, the binary float point number of


−623.23 is 11000000111000111011000000000000.
Figure 3. Converting the whole number of the Mantissa
3. Types of Errors
to Binary
3.1. Blunder Error
For the decimal, we multiply the decimal by two A final source of error, called a blunder, is an
and whenever the result is less than 1, we write 0, outright mistake. A person may record a wrong

Cabahug, Logarta, Ouano, Ruiz, Tobillo • AY 2019 - 2020


3 — PHY4: INTRODUCTION TO NUMERICAL METHODS

value, misread a scale, forget a digit when reading a 3.3. Approximation Error
scale or recording a measurement, or make a simi- Truncation errors are introduced when exact
lar blunder. These blunder should stick out like sore mathematical formulas are represented by approx-
thumbs if we make multiple measurements or if one imations. An effective way to understand trunca-
person checks the work of another. Blunders should tion error is through a Taylor Series approxima-
not be included in the analysis of data. tion. Let’s say that we want to approximate some
function, f(x) at the point xi+1, which is some dis-
3.2. Random and Systematic Error tance, h, away from the basepoint xi, whose true
Using the same classical example, we can also value is shown in black in Figure 8. The Taylor se-
differentiate the errors in hitting the target (i.e., the ries approximation starts with a single zero order
difference between the positions of the dart throws term and as additional terms are added to the se-
and the Bull’s eye) into two types of error: random ries, the approximation begins to approach the true
error and systematic error. A random error is the value. However, an infinite number of terms would
error due to natural fluctuations in measurement or be needed to reach this true value.
computational systems. By definition, these fluctu-
ations are random and therefore, the average ran-
dom error is zero. For the accurate throws shown in
Figure 6 (left column), whether the measurements
are precise or not, the average position of the five
throws is the Bull’s eye. In other words, the average
error is zero. A systematic error is a repeated “bias”
in the measurement or computational system. For
the inaccurate throws shown in Figure 6 (right col-
umn), the thrower has a tendency or bias to throw
into the left bottom side of the Bull’s eye. So, in
addition to the random error, there is a systematic
error (bias).
An example of a systematic error is if a scale Figure 8. Graphical representation of a Taylor Series ap-
reads 1kg when there is nothing on it so it adds 1 proximation (Chapra, 2017)
kg to its actual measurement. This additional 1kg is
a systematic error.
The Taylor Series can be written as follows:

f 00(xi ) 2
f (xi+1 ) ∼
= f (xi ) + f 0 (xi )h + h
2! (1)
f (n) (xi ) n
+... + h + Rn
n!
where Rn is a remainder term used to account for
all of the terms that were not included in the series
and is therefore a representation of the truncation
error. The remainder term is generally expressed
as Rn=O(hn+1) which shows that truncation error
Figure 6. Illustration of accuracy and precision is proportional to the step size, h, raised to the n+1
where n is the number of terms included in the ex-
pansion. It is clear that as the step size decreases,
so does the truncation error.

3.4. Round off Error


Round off errors occur because computers have a
limited ability to represent numbers. For example,
π has infinite digits, but due to precision limitations,
Figure 7. Degree of precision of a ruler only 16 digits may be stored in MATLAB. While
this round off error may seem insignificant, if your

Cabahug, Logarta, Ouano, Ruiz, Tobillo • AY 2019 - 2020


PHY4: INTRODUCTION TO NUMERICAL METHODS — 4

process involves multiple iterations that are depen- and added together:
dent on one another, these small errors may accu-
mulate over time and result in a significant deviation 2c
x= √
from the expected value. Furthermore, if a manipu- −b ± b2 − 4ac
lation involves adding a large and small number, the 2(6)
effect of the smaller number may be lost if round- = p (8)
47.91 ± (−47.91)2 − 4(0.2)(6)
ing is utilized. Thus, it is advised to sum numbers
12
of similar magnitudes first so that smaller numbers =
are not “lost” in the calculation. 47.91 ± 47.86
One interesting example to illustrate this point is
the quadratic formula. The quadratic formula is rep-
x1 = 240 (9)
resented as follows:
√ x2 = 0.1253001984 (10)
−b ± b2 − 4ac
x= (2)
2a actual − approx
AbsErrorx1 =| | ∗100
actual
Using a = 0.2, b = – 47.91, c = 6 and if we carry 239.42470 − 240
= ∗100 (11)
out rounding to two decimal places at every inter-
239.42470
mediate step:
= 0.24%
p
−47.91 ± (−47.91)2 − 4(0.2)(6)
x= 0.1253004 − 0.1253
2(0.2) AbsErrorx2 =| | ∗100
√ 0.1253004 (12)
−47.91 ± 2295.36 − 4.8 (3) 1.25× 10−4 %
=
0.4
−47.91 ± 47.86
= 4. Root Finding
0.4
The root finding problem is essential in compu-
tational problems. It is used in the determination of
x1 = 239.425 (4) any unknown appearing in scientific formulas with
x2 = 0.125 (5) practical applicatIons in physics, engineering, bio-
sciences, chemistry, etc.
The error between our approximations and true The root finding problem involves finding a root
values can be found as follows: of the equation f (x) = 0, where f (x) is a function
of a single variable x. Specifically, the problem is
actual − approx
AbsErrorx1 =| | ∗100 stated as follows:
actual
239.42470 − 239.425 (6)
= ∗100 The Root Finding Problem
239.42470
−4
= 1.25×10 %
Given a function f (x), find a number x = ξ such
that f (ξ) = 0.
0.12530 − 0.125
AbsErrorx2 =| | ∗100
0.12530 (7)
= 24% 4.1. Root Finding of Polynomial using Factor-
ing
As can be seen, the smaller root has a larger error Find the roots of
associated with it because deviations will be more
apparent with smaller numbers than larger numbers. P (x) = x2 + 2x − 15 (13)
If you have the insight to see that your compu-
tation will involve operations with numbers of dif- The function above is a polynomial. The roots of
fering magnitudes, the equations can sometimes be P (x) could be solved by first factoring the polyno-
cleverly manipulated to reduce round off error. In mial and equating them to zero.
our example, if the quadratic formula equation is
rationalized, the resulting absolute error is much x2 + 2x − 15 = (x + 5)(x − 3) = 0 (14)
smaller because fewer operations are required and
numbers of similar magnitudes are being multiplied Thus, the roots are: x = −5, x = 3.

Cabahug, Logarta, Ouano, Ruiz, Tobillo • AY 2019 - 2020


5 — PHY4: INTRODUCTION TO NUMERICAL METHODS

4.2. Root Finding using Bisection Method note that


Given that x3 + 2x − 2 = 0 has a root between Z x
0 and 1, find the root to 1 decimal place using the f n+1 (x)dx = [f (n) (x)]xx0
bisection method. x0 (23)
Let = f (n) (x) − f (n) (x0 ),
f (x) = x3 + 2x − 2 (15)
Then, we integrate the second time. Now, we get
Substitute values into x that narrow down into the
Z x Z x
root.

n+1
f (x)dx dx
x0 x
f (0) = −2 (16) Z x0
f (1) = 1 (17) = [f (n) (x) − f (n) (x0 )]dx
x0 v (24)
f (0.5) = −0.875 (18)
=[f (n−1) (x)]xx0 − (x − x0 )f (n) (x0 )
f (0.75) = −0.078 (19)
=f (n−1) (x) − f (n−1) (x0 )
f (0.875) = 0.419 (20)
f (0.8125) = 0.161 (21) − (x − x0 )f (n) (x0 ),

The root lies in the interval between 0.75 and Afterwards, we integrate for the third time. We
0.8125. Since both return the same value to one get Z xZ xZ x
decimal place which is 0.8, we know that the root is f n+1 (x)(dx)3
approximately x = 0.8 in one decimal place. x0 x0 x0
(n−2)
=f (x) − f (n−2) (x0 )
5. Taylor Series Expansion (25)
− (x − x0 )f (n−1) (x0 )
The Taylor Series is an expansion of some func- (x − x0 )2 (n)
tion into an infinite sum of terms, where each term − f (x0 ),
2!
has a larger exponent like x, x2 , x3 , etc. (”Math is
Continuing up to to n+1 integration and further
Fun (Taylor Series)”, n.d.). Basically, it is a series
simplifying, we get
of expansion of a function about a point and that
most of the functions can be expressed as infinite f (x) =f (x0 ) + (x − x0 )f 0 (x0 )
sum of polynomials.
Assuming that x=a, then the one-dimensional (x − x0 )2 00
+ f (x0 ) + ...
Taylor Series is 2!
(x − x0 )n (n) (26)
+ f (x0 ) + Rn
f (x) = f (a) + f 0 (a)(x − a) n!
n
X (x − x0 )k f (k) (x0 )
f 00 (a) f (3) (a)
+ (x − a)2 + (x − a)3 (22) = + Rn
2! 3! k!
k=0
f (n) (a)
+ ... + (x − a)n + ... The equation above shows the general formula
n!
for the one-dimensional Taylor Series Expansion.
Moreover, these are some of the common func-
tions that has a Taylor Series Expansion: The Importance

One of the applications of the Taylor Series is that it


can approximate solutions to differential equations.
Then, it can also be used to determine various infi-
nite sums.
There are also applications of the series in
Physics. The equation of a simple harmonic oscilla-
tor can be derived if a system under a conservative
Figure 9. Common functions that has a Taylor Series Ex- force is at stable equilibrium point.
pansion Moreover, this series can be used to understand
asymptotic behavior. It is very important to really
To derive the following function, we have to take identify the asymptotes of a graph wherein it can

Cabahug, Logarta, Ouano, Ruiz, Tobillo • AY 2019 - 2020


PHY4: INTRODUCTION TO NUMERICAL METHODS — 6

show how a function behaves in an important part 7. Penjee. (2014). Retrieved from Binary numbers - floating
of the domain. point convertion: https://blog.penjee.com/binary-numbers-
floating-point-conversion/
In addition, the pendulum motion can also be de- 8. Ryans Tutorials. (2020). Retrieved from Binary
rived using the Taylor Series. In this equation, we Tutorial-5. Binary Fractions and Floating Point:
assume that θ is negligible on the fact that sin θ = θ. https://ryanstutorials.net/binary-tutorial/binary-floating-
point.php
θ3 θ5 θ7 9. Rivasa and RivasaRivasa. (1962, September 1).
sinθ = θ − + − + ... (27) What are the practical applications of the Tay-
3! 5! 7!
lor Series? Retrieved March 15, 2020, from
Lastly, the most famous equation in physics, E = https://math.stackexchange.com/questions/218421/what-
mc2 , is an approximation for low velocities which are-the-practical-applications-of-the-taylor-series
can be derived using the Taylor series. 10. Taylor Series. (n.d.). Retrieved March 15, 2020, from
https://mathworld.wolfram.com/TaylorSeries.html
1
γ=q (28)
v2
1− c2

Wherein v is the velocity and c is the speed of


light.

6. Conclusion
Solving problems is what we often imagine that
mathematicians are doing, but unfortunately you
can’t swing a cat in the sciences without hitting a
problem that can’t be solved analytically. In reality
“doing math” generally involves finding an answer
rather than the answer. While you may not be able
to find the exact answer, you can often find answers
with “arbitrary precision”.
Numerical methods do something rather bizarre:
they find solutions close to the answer without ever
knowing what that answer is. As such, an impor-
tant part of every numerical method is a proof that
it works. To get the answer: we need numerical
methods because a lot of problems are not analyti-
cally solvable or the solutions are not practical, and
we know they work because each separate method
comes packaged with a proof that it works.

7. References
1. Adeeb, S. (2020). Introduction to Solid Mechanics and Fi-
nite Element Analysis. Retrieved from https://sameradeeb-
new.srv.ualberta.ca
2. Gupta, R. (2018). Types of Errors in
Numerical Methods. Retrieved from
https://waterprogramming.wordpress.com/2018/02/21/types-
of-errors-in-numerical-methods/
3. HG. (2011, October 11). Numerical Methods
for the Root Finding Problem. Retrieved from
http://www.math.niu.edu/ dattab/MATH435.2013
4. How I Taught My Mother Binary Numbers.
(2009, May 26). Retrieved from Exploring Binary:
https://www.exploringbinary.com/how-i-taught-my-mother-
binary-numbers/
5. Math is Fun (Taylor Series). (n.d.). Retrieved March
15, 2020, from https://www.mathsisfun.com/algebra/taylor-
series.html
6. New Mexico State University (n.d.). Types of Ex-
perimental Errors Retrieved March 15, 2020, from
http://physics.nmsu.edu/research/lab110g/html/ERRORS

Cabahug, Logarta, Ouano, Ruiz, Tobillo • AY 2019 - 2020

You might also like