Khalil Mikaela Compilation-Of-Algorithems PDF
Khalil Mikaela Compilation-Of-Algorithems PDF
TABLE OF CONTENTS
INTRODUCTION
INTRODUCTION
Numerical methods are methods for solving mathematical issues that include
analytical techniques cannot easily or possibly solve the engineering analysis. An
approximate computer method known as a numerical method is used to solve
mathematical problems, many of which lack an analytical solution. These
problems, which arise in the natural sciences, social sciences, engineering,
medicine, and business, typically come from real-world applications of algebra,
geometry, and calculus and involve variables that change constantly.
In mathematics, linear algebra is used to describe issues that need the solution of
networks of linear and nonlinear equations. In applied mathematics, resolving
linear programming systems is a common challenge. The standard notation for
linear systems is Ax = b, where x is the column vector of the unknown variables
x1, xn, and b is a predetermined column vector.
The goal is to find a set of values that simultaneously satisfies a collection of linear
algebraic equations. In engineering, these equations come up in a number of issue
scenarios. They have their roots in the mathematical modeling of vast systems of
connected elements like structures, electric circuits, and fluid networks.
Given that they are both concerned with values that satisfy equations, these issues
have a similar mindset as equations' roots. The goal is to find a set of values that
simultaneously satisfies a collection of linear algebraic equations, as opposed to
attempting to fulfill a single equation. In all engineering disciplines, these
equations come up in a number of issue scenarios. Specifically, they have their
roots in the mathematical modeling of vast systems of connected elements like
structures, electric circuits, and fluid networks. However, they are also seen in
other numerical method domains like curve fitting and differential equations.
4
MATRIX FORM
Systems of parallel equations naturally contain matrices. For the unknowns x and
y in the system below,
2x + 3y = 7
is a matrix with the coefficients of the unknowns as its elements. These values and
their specific arrangement are totally necessary for the equations' solution. The
answer would differ if the numbers 3 and 4 were switched.
5
6
SMALL SCALE
a. GRAPHICAL METHOD
The graphs for the preceding equations match. The answers to the equations are
the locations of each point on the lines. The above equations can therefore have an
endless number of solutions.
2. For example: 2x + 3y = 6 ⇒ 4x – 3y = 12
2x + 3(0) = 6 4x – 3(0) = 12
2x = 6 4x = 12
x = 3 (3,0) x=3
7
b. CRAMER’S RULE
One of the essential methods used to analyze a linear equation is Cramer's rule.
The determinants of matrices are used in this method to derive the values of the
system's variables. Thus, the determinant technique is another name for Cramer's
rule.
The AX=B form of the matrices can be solved using Cramer's rule formula, which
is simple to understand. The formula can be used to determine the values of the n
variables in a linear equation. The steps listed below must be followed in order to
solve the problem AX=B using Cramer's rule:
We must identify the determinants for matrix A, x1, x2, x3,..., xn in order
to solve by Cramer's rule.
For example, D = |A|, Dx1, Dx2, Dx3,..., Dxn, denotes each of these
determinant matrices.
Here, the determinant values of |A| are represented by the D, and the
determinant values of the x matrix are represented by Dxn, where the nth
column is replaced by the values of B.
We use the formula: once we have all of the determinant values for the
equations.
8
As many equations as there are in the matrix can be solved using the
formula Xn=Dxn/D. Never forget that the value of D should never be
zero (D0).
1. FOR EXAMPLE:
.x+y–z=6
3x - 2y + z = -5
x + 3y – 2z = 14
1 1 -1 6
3 -2 1 -5
1 3 -2 14
DETERMINANT 1 1 -1
3 -2 1
1 3 -2
DX -3
6 1 -1
-5 -2 1
14 3 -2
9
DY -9 1 6 -1
3 -5 1
1 14 -2
DZ 6
1 1 6
3 -2 -5
1 3 14
THEREFORE,
x=1
y=3
z = -2
c. ELIMINATION OF UNKNOWNS
FOR EXAMPLE:
3x+6y=14
7x-6y=36
10
First of all, take note of the y terms' 6 and -6 coefficients. Since they are additive
inverses, the total of these two numbers is 0. Therefore, the y terms will cancel
each other out if we add these equations.
Let us break down the second equation into two parts to get things started. Each
section might be broken up and rewritten as follows:
7x-6y=20 proves that the claims are accurate. As a result, if one side of this
equation equals z, then both sides must also equal z.
Now, we can rewrite the first equation in our system, 3x+6y=14, using the
Addition Property of Equality as follows:
3x+6y+z = 14+z
3x+6y+(7x-6y) = 14+36
10x = 50
x=5
Then, using one of our initial equations with 5 in place of x, we can find the value
of y.
7(5)-6y=36
y= -0.167
11
LARGE SCALE
The pivot is the name of this entry. If necessary, switch the rows around so that the
pivot is on the top row. Because you are less likely to add or subtract with
extremely small (or extremely large) values when pivoting, rounding errors are
reduced.
12
1. FOR EXAMPLE
2q + x – y + 2r = 5
4q + 5x – 3y + 6r = 9
-2q + 5x – 2y + 6r = 4
4q + 11x – 4y + 8r = 2
q x y r B
2 1 -1 2 5
PIVOT
4 5 -3 6 9
M21 = 2
M31 = -1 -2 5 -2 6 4
M41 = 2 4 11 -4 8 2
q x y r B
2 1 -1 2 5
0 3 -1 2 -1
PIVOT
M32 = 2 0 6 -3 8 9
M42 = 3 0 9 -2 4 -8
13
q x y r B
2 1 -1 2 5
0 3 -1 2 -1
0 0 -1 4 11
PIVOT
0 0 1 -2 -5
M43 = -1
r=3
y=1
x = -2
q=1
LU DECOMPOSITION
Lower-upper (LU) decomposition or factorization factors a matrix as the product
of a lower triangular matrix and an upper triangular matrix in numerical analysis
and linear algebra (see matrix decomposition).
With the aid of the solved example provided below, let's learn how to solve a
system of linear equations in three variables using the LU Decomposition method.
14
LUX = B….(1)
LY = B
Solution:
15
x1 + x2 + x3 = 1
3x1 + x2 – 3x3 = 5
x1 – 2x2 – 5x3 = 10
That implies,
l21u11 = 3,
16
l21u12 + u22 = 1,
u21u13 + u23 = -3
l31u11 = 1,
LUX = B
Let UX = Y
So, y1 = 1
3y1 + y2 = 5
y1 + (3/2)y2 + y3 = 10
y1 = 1, y2 = 2, y3 = 6
x1 + x2 + x3 = 1
-2x2 – 6x3 = 2
3x3 = 6
x3 = 2, x2 = -7 and x1 = 6
2a – b + 3c = 9
a+b+c=6
a–b+c=2
a b c B
2 -1 3 9
PIVOT
1 1 1 6
m21=0.5
m31=0.5 1 -1 1 2
18
a b c B
2 -1 3 9
PIVOT
0 1.5 -0.5 1.5
m32=
0 -0.5 -0.5 -2.5
-0.333
a b c B
2 -1 3 9
0 1.5 -0.5 1.5
0 0 -0.667 -2
A L
2 -1 3 1 0 0
1 1 1 0.5 1 0
1 -1 1 0.5 -0.333 1
2 -1 3
0 1.5 -0.5
0 0 -0.667
19
L Y B
1 0 0 Y1 9
0.5 1 0 Y2 6
0.5 -0.333 1 Y3 2
Y1 = 9
Y2 = 1.5
Y3 = -2
U X Y
2 -1 3 a 9
c -2
0 0 -0.667
a=1
b=2
c=3
20
e. ITERATION METHOD
i. JACOBI METHOD
FOR EXAMPLE:
4x - y- z =3 x=(y+z+3)/4
x y z B
4 -1 -1 3
-2 6 1 9
-1 1 7 -6
22
k x y z
0 0 0 0
1 0.750 1.500 -0.857
2 0.911 1.893 -0.964
3 0.982 1.964 -0.997
4 0.992 1.994 -0.997
5 0.999 1.997 -1.000
6 0.999 2.000 -1.000
7 1.000 2.000 -1.000
8 1.000 2.000 -1.000
9 1.000 2.000 -1.000
10 1.000 2.000 -1.000
11 1.000 2.000 -1.000
12 1.000 2.000 -1.000
13 1.000 2.000 -1.000
14 1.000 2.000 -1.000
The Gauss-Seidel methodology begins with projections and then iterates to obtain
accurate estimation of the result. The Gauss-Seidel technique is extremely well
suited to huge numbers of problems. When applying elimination techniques in
certain circumstances, round-off errors may happen. Since round-off error is
determined by the number of repeats, the Gauss-Seidel method does not have an
issue with it. Although there are situations where the Gauss-Seidel method will not
23
determine the correct answer. These and other trade-offs between iterative
techniques and elimination procedures will be covered in the pages that follow.
FOR EXAMPLE:
OPEN METHOD
Open approaches start with a first estimate at the root and then iteratively improve
the guess. Bracketing techniques usually work but converge slowly on an absolute
error estimate of the root's location. Open techniques, however, don't necessarily
converge.
Select xo as the starting point for the iterative process. Finding the
values of x = a and x = b for which f(a) 0 and f(b) > 0 is one method of
selecting xo. Take xo as the average of a and b after limiting the options
for a and b.
FOR EXAMPLE:
According to the procedure, we must discover a and b such that f(a) 0 and f(b) > 0
before we can determine the value of xo.
Now, f(0) = – 5
f(1) = – 5
f(2) = 7
Thus, a = 1 and b = 2
2x3 – 2x – 5 = 0
⇒ x = [(2x + 5)/2]1/3
b. NEWTON RAPHSON
The variables in the first technique are given rectangular coordinates, whereas
they are given polar coordinates in the second. Out of these two approaches, the
polar coordinate form is most frequently utilized. The Newton-Raphson method,
commonly referred to as Newton's method, is a rapid way to approximate the real-
valued function f (x) = 0 f(x) = 0 f(x)=0's root. It makes use of the notion that a
straight line tangent can serve as an approximation for a continuous and
differentiable function.
c. SECANT METHOD
FOR EXAMPLE:
28
k Xo X1 f(Xo) f(X1) e
1 1.00000 2.00000 -1.00000 5.00000
2 2.00000 1.16667 5.000000 -0.57870 0.50000
3 1.16667 1.25311 -0.57870 -0.28536 -0.71429
4 1.25311 1.33721 -0.28536 0.05388 0.06898
5 1.33721 1.32385 0.05388 -0.00370 0.06289
6 1.32385 1.32471 -0.00370 -0.00004 -0.01009
7 1.32472 1.32472 -0.00004 0.00000 0.00065
8 1.32472 1.32472 0.00000 0.00000 0.00001
9 1.32472 1.32472 0.00000 0.00000 0.00000
10 1.32472 1.32472 0.00000 0.00000 0.00000
BRACKETING METHOD
a. BISECTION METHOD
FOR EXAMPLE:
f(x)=8x^2’-3
interval (0.1, 2)
30
31
b. FALSE-POSITION METHOD
The false position method, also known as the regula falsi method, is a traditional
approach to solving one-variable equations in mathematics. Using "false" or "test"
values for the variable and then changing the test value in response to the outcome
is how the method is best expressed in plain English. This article will teach you
how to use the fake position approach to solve a one-variable equation.
Additionally, find here solved examples of the regula falsi approach.
FOR EXAMPLE
Given equation: 2ex sin x = 3
This can be written as: 2ex sin x – 3 = 0
Let f(x) = 2ex sin x – 3
So, f(0) = 2e0 sin 0 – 3
=0–3
= -3 < 0
And
f(1) = 2e1 sin 1 – 3
= 2e sin 1 – 3
= 1.5747 > 0
That means the root of f(x) lies between 0 and 1.
Let a = 0 and b = 1.
Therefore, the best approximation of the root up to three decimal places is 0.768 (up to three
decimal places).
33
Polynomials are mathematical formulas that are commonly employed for problem-
solving and modeling. In many situations, an equation that is written in the course
of addressing a problem is a polynomial, and the answer to the problem is the zero
of the polynomial. When we fit our data to the graph of a polynomial function, we
are doing polynomial curve fitting. The polynomial of a certain degree with the
least overall error can be found using the same least squares method.
WHAT IS REGRESSION?
The least square approach involves minimizing the sum of the squares of the offsets
(residual component) of the points from the curve to obtain the curve or line of best
fit that best fits a set of data points. The trend of the results is quantitatively
measured during the process of establishing a relationship between two variables.
Regression analysis is the name given to this technique. Curve fitting is a
technique for performing regression analysis. The least squares approach to
equation fitting approximates curves to provided raw data.
Y = a + bX
FOR EXAMPLE:
35
64.45 = a + 30.63
a = 64.45 – 30.63
a = 30.18
THEREFORE, y=ax+b
y=30.18+6.49x
36
b. POLYNOMIAL REGRESSION
FOR EXAMPLE:
1. Seniors who have never used the Internet before are offered instruction.
A random sample of 5 individuals had their monthly Internet usage hours
tracked for a period of six months. Determine whether a quadratic regression
line is a good fit for the data.
37
NUMERICAL INTEGRATION
a. Euler’s Method
Ordinary differential equations (ODE) can be solved using the Euler's method, a
first-order numerical technique, with a specified beginning value. At Euler's
approach, the curve of the solution can be roughly approximated at steps of h by
the tangent in each interval (i.e., by a series of brief line segments).
FOR EXAMPLE:
Analytical calculations reveal that the answer is y = ex and y(1)= 2.71828. (Note:
The purpose of this analytical solution is only to compare accuracy.)
The outcomes of Euler's approach can be seen in the diagram below when h = 0.2,
0.1, and 0.01.
38
You can notice, how accuracy improves when steps are small.
b. TRAPEZOIDAL METHOD
The Trapezoidal Rule divides the whole area into smaller trapezoids rather than
utilizing rectangles to calculate the area under the curves. This integration
determines the area by approximating the region beneath a function's graph as a
trapezoid.
The trapezoidal rule, also known as the trapezoid rule or trapezium rule, is a
method for approximating the definite integral in mathematics, more specifically in
numerical analysis.
39
The region under the graph of the function f(x) is approximated to be a trapezoid
in the trapezoidal rule, and its area is calculated.
FOR EXAMPLE:
0 3 6 9 12
∆x= 3
T4 594
40
c. SIMPSON’s RULE
One of the numerical techniques used to calculate the definite integral is Simpson's
rule. Typically, we employ the calculus fundamental theorem to get the definite
integral, which requires us to use antiderivative integration techniques. Finding
the antiderivative of an integral can be challenging, though, especially in scientific
experiments where the function must be known. based on the recorded readings.
Therefore, to estimate the integral, numerical techniques are required.
FOR EXAMPLE:
0 3 6 9 12
∆x= 3
T4 576
41
a. Range-Kutta Methods
FOR EXAMPLE:
42
CASE STUDIES
x−7=7(y−7)
x−7=7y−49
x−7y=−49+7
x−7y=−42
x+3=3(y+3)
x+3=3y+9
x−3y=9−3
x−3y=6
From the graph we can see that two lines will intersect at a point.
x−7y=−42
x−3y=6
43
4y=48
or y=12
x−36=6
∴x=42
44
REFERENCES
https://www.globalspec.com/reference/72167/203279/chapter-3-interpolation-
andcurve-fitting
https://www.cuemath.com/data/least-squares/
https://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html
Runge Kutta RK4 Method | Fourth Order Runge Kutta Method. (n.d.).
Byju's. Retrieved
from https://byjus.com/maths/runge-kutta-rk4-method/
https://math.libretexts.org/Courses/Mount_Royal_University/MATH_2200%
3A_
Calculus_for_Scientists_II/2%3A_Techniques_of_Integration/2.5%3A_Nume
rical
49
_Integration_-_Midpoint%2C_Trapezoid%2C_Simpson's_rule
Retrieved from
https://www.techtarget.com/whatis/definition/polynomialinterpolation