SlideShare a Scribd company logo
1 of 22
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 1
GAUSS AND JACOBY ELIMINATION METHOD
1) Solve the linear equation system follow using Gauss Method
{
Solution:
{
( , ( + ( ,
The linear equation system (1) is , where:
Since . We will use the Gauss formula:
and . The linear equation system (1) will be ,
we will compute values of .
( *
( *
( *
( *
( *
( *
Now presented by:
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 2
{
The linear equation system (2) is , where:
Since . We will use the Gauss formula:
and . The linear equation system (2) will be , we
will compute values of .
( *
( *
Now presented by:
{
We get , and then , we get: and .
using this formula to get :
{
( βˆ‘ )
( βˆ‘ ) ( )
( βˆ‘ ) ( ( )*
So, solution for (1) is { }
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 3
2) Solve the linear equation system follow using Gauss Elimination Method
{
Solution:
{
By change of row:
[ ] βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ— [ ]
[ ] [ ]
The linear equation system (1) will be , we will compute values of
by , where .
( *
( *
( *
( *
( *
( *
* + βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ— * +
We get a new linear equation system , that is
* +
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 4
We will use the Gauss formula: and .
The linear equation system (2) will be , we will compute values of .
( *
( *
[ ]
Now presented by:
{
We get , , .
By change of column:
[ ] [ ]
The linear equation system (3) will be , we will compute values of
by , where .
( *
( *
( *
( *
( *
( *
* + βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ— [ ]
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 5
We get a new linear equation system , that is
[ ]
We will use the Gauss formula: and .
The linear equation system (2) will be , we will compute values of .
( *
( *
[ ]
Now presented by:
{
We get , , .
BY DECOMPOSITION
[ ] [ ] [ ]
Where each entry of is determined by:
{
βˆ‘
βˆ‘
We get each entry of and ,
{
βˆ‘
(
βˆ‘
+
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 6
If we have a system we can solve its system by Decomposition Assume
, defined:
[ ] [ ] [ ]
We get:
{
βˆ‘
And form of defined by
[ ] [ ] [ ]
So, we get the solutions of is
{
( βˆ‘ )
Example 1: Solve this system
{
Solution:
(3)3 (2) 2 (5) 5 (6) 6
(-1) (4) (3) (5)
(1) (-1) (3) (1)
And then we get:
[ ], * + * +
And we get
[ ] [ ] [ ]
So we get solution
Exercise 2. No 3.
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 7
Solve this a linear equation system by Decomposition!
* + * + * +
Solution:
(1)1 (2) 2 (3) 3 (4) 4 (2)2
(1) (4) (9) (16) (10)
(1) (8) (27) (64) (44)
(1) (16) (81) (256) (190)
And we get
* + * + * +
So we get solution
Solution by MATLAB:
>> A=[1 2 3 4;1 4 9 16;1 8 27 64;1 16 81 256]
A =
1 2 3 4
1 4 9 16
1 8 27 64
1 16 81 256
>> b=[2;10;44;190]
b =
2
10
44
190
>> x=(Ab)'
x = -1.0000 1.0000 -1.0000 1.0000
JACOBI METHOD
Suppose a system n-equation,
{ (1)
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 8
If , Eq. (1) can we write:
{ (2)
Where , and
( *
[ ] [ ] (3)
So, solution of Eq. (1) is
(4)
Alghoritm for Jacobi Method:
1. ( ) with initial value ( )
2.
3.
( βˆ‘ )
4. β€– β€–
5. For
Example 1:
{
By using (4), we get:
{
With initial value , we get:
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 9
And the next we will calculate by using MS Excel, we obtain:
Table 1
0 0 0 0
1 7.2 8.3 8.4
2 9.71 10.7 11.5
3 10.57 11.571 12.482
4 10.8535 11.8534 12.8282
5 10.95098 11.95099 12.94138
6 10.983375 11.983374 12.980394
7 10.9944162 11.9944163 12.9933498
8 10.99811159 11.99811158 12.9977665
9 10.99936446 11.99936446 12.99924463
Assume , since β€– β€– β€– β€– , then,
process stopped. So, we get final solution:
, or .
GAUSS-SEIDEL METHOD
Suppose a system n-equation,
{ (5)
If , Eq. (1) can we write:
{
(6)
Where , and
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 10
[ ] [ ]
Solution of Eq.(5) is
(7)
Alghoritm for Gauss-Seidel Method:
1. ( ) with initial condition ( )
2.
3.
ο‚·
( βˆ‘ )
ο‚·
( βˆ‘ βˆ‘ )
ο‚·
( βˆ‘ )
4. β€– β€– , then
5. For
Example 2.
{
By using (6), with initial value , we get:
( )
( )
( )
And the next we will calculate by using MS Excel, we obtain:
Tabel 2
0 0 0 0
1 7.2 9.02 11.644
2 10.4308 11.67188 12.820536
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 11
3 10.9312952 11.95723672 12.97770638
4 10.99126495 11.99466777 12.99718654
5 10.99890409 11.99932772 12.99964636
6 10.99986204 11.99991548 12.9999555
Assume , since β€– β€– β€– β€–
,then, process stopped. So, we get final solution:
, or
Exercise page 89 number (1)
Use Jacobi method and Gauss-Seidel method to solve this system:
[ ] [ ] [ ]
(8)
With initial condition:
 By using Jacobi method
By using (4), we get:
{
With initial condition , we get:
And the next we will calculate by using MS Excel, we obtain:
Tabel 1
0 0 0 0 0 0 0
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 12
1 1.2 -3 2 -1.42 0.8 0.8
2 1.206 -2.8636 3.2794 -1.646 0.44086 0.35914
3 1.147936 -2.5552898 3.1008986 -2.0192692 0.87358 0.43272
4 1.09169802 -2.62921629
3.54091715
2
-
1.977922984
0.86700482
2 0.006575178
5
1.00131316
5 -2.58155443
3.54377891
4
-
2.061826638
1.01538009
7 0.148375275
6
0.96179561
3 -2.601802339
3.70257364
1
-
2.036178359
1.04463921
6 0.029259119
7
0.91266332
7 -2.595286119
3.72566523
2
-
2.060214779
1.10538006
8 0.060740852
8
0.89030797
2 -2.602097962
3.79128381
5
-
2.049953094
1.12595881
4 0.020578746
9
0.86655543
6 -2.601469385
3.80838238
3
-
2.057964588
1.15297405
7 0.027015243
1
0
0.85467021
6 -2.604128265
3.83723832
1
-
2.054246735
1.16461871
4 0.011644657
1
1
0.84339169
7 -2.604307402
3.84744106
3
-
2.057105832
1.17706750
4 0.012448789
1
2
0.83724727
6 -2.605423563 3.86053428
-
2.055810531
1.18325222
1 0.006184718
Assume , since β€– β€– β€– β€– ,
then, process stopped. So, we get final solution:
,
or .
 By using Gauss-Seidel method
By using (6), with initial value , we get:
( )
( )
( )
( )
( )
And the next we will calculate by using MS Excel, we obtain:
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 13
Tabel 1
0 0 0 0 0 0 0
1 1.2 -2.8636 2 -1.42 0.8 0.8
2 1.19236 -2.55979 3.260304 -1.66919 0.46814 0.33186
3 1.117419 -2.6365 3.091333 -2.06055 0.930169 0.462029324
4 1.091481 -2.57466 3.618334 -1.94957 0.853079 0.077090124
5 0.977438 -2.60858 3.514119 -2.09152 1.053798 0.200718593
6 0.96397 -2.59109 3.752752 -2.01513 1.033902 0.019895339
7 0.899536 -2.60569 3.706912 -2.07598 1.124904 0.091001323
8 0.89202 -2.59942 3.816874 -2.03865 1.120177 0.004726487
Assume , since β€– β€– β€– β€– , then,
process stopped. So, we get final solution:
, or
.
LAGRANGE INTERPOLATION
Suppose the data pair in [ ]available, the Lagrange interpolation is
the n-order polynomial interpolation, such that
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 14
Thus, the Lagrange interpolation results at the observation point are equal to the observed
value of itself. At point x which is not the point of observation Lagrange value is calculated
through the following formula:
βˆ‘
where ∏ ( ) is called coefficient of Lagrange.
Note that
{
So, for we get:
With the error is determined by the formula:
∏
So, the form of Lagrange interpolation for order-2 formula is as follows:
with a error determined as follows:
| |
Example 1.1
Given and a table of data pair :
10 11 12 13 14
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 15
2.302 6 2.397 9 2.484 9 2.564 9 2.639 1
By using Lagrange interpolation, find value of !
Solution:

First, we must compute , with
ο‚·
ο‚·
Then,
So,
With error:
, we get:
| |
Then

First, we must compute , with
ο‚·
ο‚·
ο‚·
Then,
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 16
So,
With error:
, we get:
| |
Then
Lagrange Interpolation Algorithm:
Declaration
Int ;
Real
Deskription
1. Input order polynomial (n)
2. Input pair for
3. Input point try xk;
4. Initial value ;
5. Load for i=0 to i=n
a. P(i)=1;
b. for j=0 to j=n
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 17
i. if then
c.
6. print (β€˜for x= ’, xk, β€˜then y= β€˜,L);
7. Stop
Program’s MATLAB Lagrange method
clear; help lagrang;
n = input('Order polinomial n = ');
x = zeros(n+1, 1);
y = zeros(n+1, 1);
z = zeros(n+1, 1);
for i = 1: n+1
fprintf('data ke-%2dn', i-1);
x(i) = input('x : ');
y(i) = input('y : ');
end
disp(' x y');
for i = 1: n+1
fprintf('%8.4f %10.6fn', x(i),y(i));
end
again=1;
while (lagi==1)
xk = input('input point xk: ');
L = 0;
for i = 1:n+1
P(i)=1;
for j= 1:n+1
if (i~=j)
P(i) = P(i)*(xk-x(j))/(x(i)-x(j));
end
end
L = L + P(i)*y(i);
end
fprintf('Value y= %10.8f on x= %8.6f n', L,xk);
disp(β€˜Press 1 to reload, Press 0 to exit');
again=input(' ');
end
Example 1.2
Estimate the error of √ at the point x=116 in the interval [100,144] using Lagrange
orde-2, calculated at , and .
Solution:
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 18
√ then
√
,
√
and
√
[ ]
√
|√ | ( *
Example 1.3
Draw the Lagrange chart for the following table, then estimate the value of y at point
x 1 3 5 7 9 11
y -3 4 5 -8 -3 0
>> myLAGRANG
input vektor sb-x: [1 3 5 7 9 11]
input vektor sb-y: [-3 4 5 -8 -3 0]
input point xk: 4.5
Value yk= 7.14111328 at xk= 4.500000
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 19
Example 1.4 : Interpolate at point x = 1.5 in the following observation table:
x -2 -1 1 2
y -6 0 0 6
>> myLAGRANG
Input vector sb-x: [-2 -1 1 2]
Input vector sb-y: [-6 0 0 6]
Input point xk: 1.5
Value yk= 1.87500000 at xk= 1.500000
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 20
NEWTON INTERPOLATION
Suppose is the -th Lagrange polynomial whose value corresponds to the value of
at points then model of divided difference of can written:
For coefficents that corresponds.
The coefficient or constant can be calculated in the following way:
ο‚· for , then
ο‚· for then such that
[ ]
using notation of divided difference:
ο‚· Divided Difference (Zeroth): [ ]
ο‚· Divided Difference (First): [ ]
{ [ ] [ ]}
ο‚· Divided Difference (Second):
[ ]
{ [ ] [ ]}
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 21
Divided Difference is more easily understood through the following table:
[ ] [ ] [ ] [ ] [ ]
[ ]
[ ]
{ [ ] [ ]}
[ ]
{ [ ] [ ]}
[ ]
[ ] [ ]
[ ]
[ ] [ ]
[ ]
[ ]
{ [ ] [ ]}
[ ]
{ [ ] [ ]}
[ ]
[ ] [ ]
[ ]
[ ]
{ [ ] [ ]}
[ ]
{ [ ] [ ]}
[ ]
[ ]
{ [ ] [ ]}
[ ]
-
Example 2.1
Given the following table. Look for the polynomial approach y value on x=2.
X -1 0 3 6 7
Y 3 -6 39 822 1611
Solution:
Consider the following Dived Difference table:
[ ]
[ ] [ ] [ ] [ ]
-
From the table, we get:
[ ] [ ] [ ] [ ] and
[ ] ; such that:
( ) ( ) ( ) ( )
So, for x=2, we obtain
Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 22
Program’s MATLAB
clear; help NForward;
N = input(β€˜pait data : ');
T = zeros(N, N+1);
disp('input data: ');
for i = 1: N
fprintf('data th-%2dn', i);
x(i) = input('x : ');
y(i) = input('y : ');
T(i,1) = x(i);
T(i,2) = y(i);
end
for kol = 3:N+1
br = (N+2-kol);
for brs = 1:br
T(brs,kol)=T(brs+1, kol-1)-T(brs, kol-1);
end
end
disp(' x y delta1 delta2 ..........');
for i = 1: N
for j=1:N+1
fprintf('%8.4f ',T(i,j));
end
fprintf('n');
end
%interpolasi
lagi=1;
while (lagi==1)
h=x(2)-x(1);
xk = input(β€˜input point interpolation: ');
t = (xk - x(1))/h;
yk = T(1,2) + t*T(1,3);
for kol = (N+1):-1:4
fak = kol-2;
t1 = 1;
for j = (kol-3) : -1 : 1
t1 = t1*(t-j);
fak = fak*j;
end
t1 = t*t1;
yk = yk + t1*T(1,kol)/fak;
end
fprintf('At x= %8.6f value of y = %12.8f n',xk,yk);
disp(β€˜Press 1 to reload, Press 0 to exit');
lagi=input(' ');
end

More Related Content

What's hot

4.3 cramer’s rule
4.3 cramer’s rule4.3 cramer’s rule
4.3 cramer’s rule
joannahstevens
Β 
Romberg’s method
Romberg’s methodRomberg’s method
Romberg’s method
Jennifer Cabrera
Β 

What's hot (20)

classification of second order partial differential equation
classification of second order partial differential equationclassification of second order partial differential equation
classification of second order partial differential equation
Β 
Chapter 22 Finite Field
Chapter 22 Finite FieldChapter 22 Finite Field
Chapter 22 Finite Field
Β 
Iterative methods
Iterative methodsIterative methods
Iterative methods
Β 
Solving Laplace differential equation using finite element method
Solving Laplace differential equation using finite element methodSolving Laplace differential equation using finite element method
Solving Laplace differential equation using finite element method
Β 
Newton cotes integration method
Newton cotes integration  methodNewton cotes integration  method
Newton cotes integration method
Β 
Numerical integration
Numerical integrationNumerical integration
Numerical integration
Β 
Discrete Mathematics and Its Applications 7th Edition Rose Solutions Manual
Discrete Mathematics and Its Applications 7th Edition Rose Solutions ManualDiscrete Mathematics and Its Applications 7th Edition Rose Solutions Manual
Discrete Mathematics and Its Applications 7th Edition Rose Solutions Manual
Β 
Higher order differential equation
Higher order differential equationHigher order differential equation
Higher order differential equation
Β 
Matlab matrices and arrays
Matlab matrices and arraysMatlab matrices and arrays
Matlab matrices and arrays
Β 
Information theory
Information theoryInformation theory
Information theory
Β 
Romberg's Integration
Romberg's IntegrationRomberg's Integration
Romberg's Integration
Β 
My Lecture Notes from Linear Algebra
My Lecture Notes fromLinear AlgebraMy Lecture Notes fromLinear Algebra
My Lecture Notes from Linear Algebra
Β 
4.3 cramer’s rule
4.3 cramer’s rule4.3 cramer’s rule
4.3 cramer’s rule
Β 
Presentation on Matlab pde toolbox
Presentation on Matlab pde toolboxPresentation on Matlab pde toolbox
Presentation on Matlab pde toolbox
Β 
Laplace transformation
Laplace transformationLaplace transformation
Laplace transformation
Β 
Aplicacion Libre 2. Metodos de Trapecio y Metodos de Simpson
Aplicacion Libre 2. Metodos de Trapecio y Metodos de SimpsonAplicacion Libre 2. Metodos de Trapecio y Metodos de Simpson
Aplicacion Libre 2. Metodos de Trapecio y Metodos de Simpson
Β 
Romberg’s method
Romberg’s methodRomberg’s method
Romberg’s method
Β 
Secant Method
Secant MethodSecant Method
Secant Method
Β 
Higher Differential Equation
Higher Differential Equation Higher Differential Equation
Higher Differential Equation
Β 
Inverse laplace transforms
Inverse laplace transformsInverse laplace transforms
Inverse laplace transforms
Β 

Similar to Jacobi method and lagrange interpolation

engineeringmathematics-iv_unit-v
engineeringmathematics-iv_unit-vengineeringmathematics-iv_unit-v
engineeringmathematics-iv_unit-v
Kundan Kumar
Β 
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptxdddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
SubramaniyanChandras1
Β 

Similar to Jacobi method and lagrange interpolation (20)

Engineering Mathematics-IV_B.Tech_Semester-IV_Unit-V
Engineering Mathematics-IV_B.Tech_Semester-IV_Unit-VEngineering Mathematics-IV_B.Tech_Semester-IV_Unit-V
Engineering Mathematics-IV_B.Tech_Semester-IV_Unit-V
Β 
engineeringmathematics-iv_unit-v
engineeringmathematics-iv_unit-vengineeringmathematics-iv_unit-v
engineeringmathematics-iv_unit-v
Β 
INVERSION OF MATRIX BY GAUSS ELIMINATION METHOD
INVERSION OF MATRIX BY GAUSS ELIMINATION METHODINVERSION OF MATRIX BY GAUSS ELIMINATION METHOD
INVERSION OF MATRIX BY GAUSS ELIMINATION METHOD
Β 
Ca 1.6
Ca 1.6Ca 1.6
Ca 1.6
Β 
Week 9-Quadratic Function.pptx
Week 9-Quadratic Function.pptxWeek 9-Quadratic Function.pptx
Week 9-Quadratic Function.pptx
Β 
Numerical solution of linear volterra fredholm integro-
Numerical solution of linear volterra fredholm integro-Numerical solution of linear volterra fredholm integro-
Numerical solution of linear volterra fredholm integro-
Β 
Bender schmidt method
Bender schmidt methodBender schmidt method
Bender schmidt method
Β 
Sixth order hybrid block method for the numerical solution of first order ini...
Sixth order hybrid block method for the numerical solution of first order ini...Sixth order hybrid block method for the numerical solution of first order ini...
Sixth order hybrid block method for the numerical solution of first order ini...
Β 
Uniform Order Legendre Approach for Continuous Hybrid Block Methods for the S...
Uniform Order Legendre Approach for Continuous Hybrid Block Methods for the S...Uniform Order Legendre Approach for Continuous Hybrid Block Methods for the S...
Uniform Order Legendre Approach for Continuous Hybrid Block Methods for the S...
Β 
Derivation and Application of Six-Point Linear Multistep Numerical Method for...
Derivation and Application of Six-Point Linear Multistep Numerical Method for...Derivation and Application of Six-Point Linear Multistep Numerical Method for...
Derivation and Application of Six-Point Linear Multistep Numerical Method for...
Β 
Mqm em
Mqm emMqm em
Mqm em
Β 
Chapter001
Chapter001Chapter001
Chapter001
Β 
Solving Quadratic Equation by Completing the Square.pptx
Solving Quadratic Equation by Completing the Square.pptxSolving Quadratic Equation by Completing the Square.pptx
Solving Quadratic Equation by Completing the Square.pptx
Β 
Numerical solution of system of linear equations
Numerical solution of system of linear equationsNumerical solution of system of linear equations
Numerical solution of system of linear equations
Β 
Simultaneous Equations Practical Construction
Simultaneous Equations Practical ConstructionSimultaneous Equations Practical Construction
Simultaneous Equations Practical Construction
Β 
Solution of matlab chapter 3
Solution of matlab chapter 3Solution of matlab chapter 3
Solution of matlab chapter 3
Β 
Calculus Homework Help
Calculus Homework HelpCalculus Homework Help
Calculus Homework Help
Β 
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptxdddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
Β 
WCS Specialist Maths An Introduction to Matrices PowerPoint
WCS Specialist Maths An Introduction to Matrices PowerPointWCS Specialist Maths An Introduction to Matrices PowerPoint
WCS Specialist Maths An Introduction to Matrices PowerPoint
Β 
Solving First Derivative Equation
Solving First Derivative EquationSolving First Derivative Equation
Solving First Derivative Equation
Β 

Recently uploaded

Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
SΓ©rgio Sacani
Β 
module for grade 9 for distance learning
module for grade 9 for distance learningmodule for grade 9 for distance learning
module for grade 9 for distance learning
levieagacer
Β 
Seismic Method Estimate velocity from seismic data.pptx
Seismic Method Estimate velocity from seismic  data.pptxSeismic Method Estimate velocity from seismic  data.pptx
Seismic Method Estimate velocity from seismic data.pptx
AlMamun560346
Β 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Lokesh Kothari
Β 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and Classifications
Areesha Ahmad
Β 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
PirithiRaju
Β 

Recently uploaded (20)

GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)
Β 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Β 
Hire πŸ’• 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire πŸ’• 9907093804 Hooghly Call Girls Service Call Girls AgencyHire πŸ’• 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire πŸ’• 9907093804 Hooghly Call Girls Service Call Girls Agency
Β 
Kochi ❀CALL GIRL 84099*07087 ❀CALL GIRLS IN Kochi ESCORT SERVICE❀CALL GIRL
Kochi ❀CALL GIRL 84099*07087 ❀CALL GIRLS IN Kochi ESCORT SERVICE❀CALL GIRLKochi ❀CALL GIRL 84099*07087 ❀CALL GIRLS IN Kochi ESCORT SERVICE❀CALL GIRL
Kochi ❀CALL GIRL 84099*07087 ❀CALL GIRLS IN Kochi ESCORT SERVICE❀CALL GIRL
Β 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)
Β 
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verifiedConnaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
Β 
Factory Acceptance Test( FAT).pptx .
Factory Acceptance Test( FAT).pptx       .Factory Acceptance Test( FAT).pptx       .
Factory Acceptance Test( FAT).pptx .
Β 
Clean In Place(CIP).pptx .
Clean In Place(CIP).pptx                 .Clean In Place(CIP).pptx                 .
Clean In Place(CIP).pptx .
Β 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
Β 
module for grade 9 for distance learning
module for grade 9 for distance learningmodule for grade 9 for distance learning
module for grade 9 for distance learning
Β 
Seismic Method Estimate velocity from seismic data.pptx
Seismic Method Estimate velocity from seismic  data.pptxSeismic Method Estimate velocity from seismic  data.pptx
Seismic Method Estimate velocity from seismic data.pptx
Β 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Β 
American Type Culture Collection (ATCC).pptx
American Type Culture Collection (ATCC).pptxAmerican Type Culture Collection (ATCC).pptx
American Type Culture Collection (ATCC).pptx
Β 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and Classifications
Β 
Feature-aligned N-BEATS with Sinkhorn divergence (ICLR '24)
Feature-aligned N-BEATS with Sinkhorn divergence (ICLR '24)Feature-aligned N-BEATS with Sinkhorn divergence (ICLR '24)
Feature-aligned N-BEATS with Sinkhorn divergence (ICLR '24)
Β 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
Β 
COST ESTIMATION FOR A RESEARCH PROJECT.pptx
COST ESTIMATION FOR A RESEARCH PROJECT.pptxCOST ESTIMATION FOR A RESEARCH PROJECT.pptx
COST ESTIMATION FOR A RESEARCH PROJECT.pptx
Β 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdf
Β 
9999266834 Call Girls In Noida Sector 22 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 22 (Delhi) Call Girl Service9999266834 Call Girls In Noida Sector 22 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 22 (Delhi) Call Girl Service
Β 
Site Acceptance Test .
Site Acceptance Test                    .Site Acceptance Test                    .
Site Acceptance Test .
Β 

Jacobi method and lagrange interpolation

  • 1. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 1 GAUSS AND JACOBY ELIMINATION METHOD 1) Solve the linear equation system follow using Gauss Method { Solution: { ( , ( + ( , The linear equation system (1) is , where: Since . We will use the Gauss formula: and . The linear equation system (1) will be , we will compute values of . ( * ( * ( * ( * ( * ( * Now presented by:
  • 2. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 2 { The linear equation system (2) is , where: Since . We will use the Gauss formula: and . The linear equation system (2) will be , we will compute values of . ( * ( * Now presented by: { We get , and then , we get: and . using this formula to get : { ( βˆ‘ ) ( βˆ‘ ) ( ) ( βˆ‘ ) ( ( )* So, solution for (1) is { }
  • 3. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 3 2) Solve the linear equation system follow using Gauss Elimination Method { Solution: { By change of row: [ ] βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ— [ ] [ ] [ ] The linear equation system (1) will be , we will compute values of by , where . ( * ( * ( * ( * ( * ( * * + βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ— * + We get a new linear equation system , that is * +
  • 4. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 4 We will use the Gauss formula: and . The linear equation system (2) will be , we will compute values of . ( * ( * [ ] Now presented by: { We get , , . By change of column: [ ] [ ] The linear equation system (3) will be , we will compute values of by , where . ( * ( * ( * ( * ( * ( * * + βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ—βƒ— [ ]
  • 5. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 5 We get a new linear equation system , that is [ ] We will use the Gauss formula: and . The linear equation system (2) will be , we will compute values of . ( * ( * [ ] Now presented by: { We get , , . BY DECOMPOSITION [ ] [ ] [ ] Where each entry of is determined by: { βˆ‘ βˆ‘ We get each entry of and , { βˆ‘ ( βˆ‘ +
  • 6. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 6 If we have a system we can solve its system by Decomposition Assume , defined: [ ] [ ] [ ] We get: { βˆ‘ And form of defined by [ ] [ ] [ ] So, we get the solutions of is { ( βˆ‘ ) Example 1: Solve this system { Solution: (3)3 (2) 2 (5) 5 (6) 6 (-1) (4) (3) (5) (1) (-1) (3) (1) And then we get: [ ], * + * + And we get [ ] [ ] [ ] So we get solution Exercise 2. No 3.
  • 7. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 7 Solve this a linear equation system by Decomposition! * + * + * + Solution: (1)1 (2) 2 (3) 3 (4) 4 (2)2 (1) (4) (9) (16) (10) (1) (8) (27) (64) (44) (1) (16) (81) (256) (190) And we get * + * + * + So we get solution Solution by MATLAB: >> A=[1 2 3 4;1 4 9 16;1 8 27 64;1 16 81 256] A = 1 2 3 4 1 4 9 16 1 8 27 64 1 16 81 256 >> b=[2;10;44;190] b = 2 10 44 190 >> x=(Ab)' x = -1.0000 1.0000 -1.0000 1.0000 JACOBI METHOD Suppose a system n-equation, { (1)
  • 8. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 8 If , Eq. (1) can we write: { (2) Where , and ( * [ ] [ ] (3) So, solution of Eq. (1) is (4) Alghoritm for Jacobi Method: 1. ( ) with initial value ( ) 2. 3. ( βˆ‘ ) 4. β€– β€– 5. For Example 1: { By using (4), we get: { With initial value , we get:
  • 9. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 9 And the next we will calculate by using MS Excel, we obtain: Table 1 0 0 0 0 1 7.2 8.3 8.4 2 9.71 10.7 11.5 3 10.57 11.571 12.482 4 10.8535 11.8534 12.8282 5 10.95098 11.95099 12.94138 6 10.983375 11.983374 12.980394 7 10.9944162 11.9944163 12.9933498 8 10.99811159 11.99811158 12.9977665 9 10.99936446 11.99936446 12.99924463 Assume , since β€– β€– β€– β€– , then, process stopped. So, we get final solution: , or . GAUSS-SEIDEL METHOD Suppose a system n-equation, { (5) If , Eq. (1) can we write: { (6) Where , and
  • 10. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 10 [ ] [ ] Solution of Eq.(5) is (7) Alghoritm for Gauss-Seidel Method: 1. ( ) with initial condition ( ) 2. 3. ο‚· ( βˆ‘ ) ο‚· ( βˆ‘ βˆ‘ ) ο‚· ( βˆ‘ ) 4. β€– β€– , then 5. For Example 2. { By using (6), with initial value , we get: ( ) ( ) ( ) And the next we will calculate by using MS Excel, we obtain: Tabel 2 0 0 0 0 1 7.2 9.02 11.644 2 10.4308 11.67188 12.820536
  • 11. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 11 3 10.9312952 11.95723672 12.97770638 4 10.99126495 11.99466777 12.99718654 5 10.99890409 11.99932772 12.99964636 6 10.99986204 11.99991548 12.9999555 Assume , since β€– β€– β€– β€– ,then, process stopped. So, we get final solution: , or Exercise page 89 number (1) Use Jacobi method and Gauss-Seidel method to solve this system: [ ] [ ] [ ] (8) With initial condition:  By using Jacobi method By using (4), we get: { With initial condition , we get: And the next we will calculate by using MS Excel, we obtain: Tabel 1 0 0 0 0 0 0 0
  • 12. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 12 1 1.2 -3 2 -1.42 0.8 0.8 2 1.206 -2.8636 3.2794 -1.646 0.44086 0.35914 3 1.147936 -2.5552898 3.1008986 -2.0192692 0.87358 0.43272 4 1.09169802 -2.62921629 3.54091715 2 - 1.977922984 0.86700482 2 0.006575178 5 1.00131316 5 -2.58155443 3.54377891 4 - 2.061826638 1.01538009 7 0.148375275 6 0.96179561 3 -2.601802339 3.70257364 1 - 2.036178359 1.04463921 6 0.029259119 7 0.91266332 7 -2.595286119 3.72566523 2 - 2.060214779 1.10538006 8 0.060740852 8 0.89030797 2 -2.602097962 3.79128381 5 - 2.049953094 1.12595881 4 0.020578746 9 0.86655543 6 -2.601469385 3.80838238 3 - 2.057964588 1.15297405 7 0.027015243 1 0 0.85467021 6 -2.604128265 3.83723832 1 - 2.054246735 1.16461871 4 0.011644657 1 1 0.84339169 7 -2.604307402 3.84744106 3 - 2.057105832 1.17706750 4 0.012448789 1 2 0.83724727 6 -2.605423563 3.86053428 - 2.055810531 1.18325222 1 0.006184718 Assume , since β€– β€– β€– β€– , then, process stopped. So, we get final solution: , or .  By using Gauss-Seidel method By using (6), with initial value , we get: ( ) ( ) ( ) ( ) ( ) And the next we will calculate by using MS Excel, we obtain:
  • 13. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 13 Tabel 1 0 0 0 0 0 0 0 1 1.2 -2.8636 2 -1.42 0.8 0.8 2 1.19236 -2.55979 3.260304 -1.66919 0.46814 0.33186 3 1.117419 -2.6365 3.091333 -2.06055 0.930169 0.462029324 4 1.091481 -2.57466 3.618334 -1.94957 0.853079 0.077090124 5 0.977438 -2.60858 3.514119 -2.09152 1.053798 0.200718593 6 0.96397 -2.59109 3.752752 -2.01513 1.033902 0.019895339 7 0.899536 -2.60569 3.706912 -2.07598 1.124904 0.091001323 8 0.89202 -2.59942 3.816874 -2.03865 1.120177 0.004726487 Assume , since β€– β€– β€– β€– , then, process stopped. So, we get final solution: , or . LAGRANGE INTERPOLATION Suppose the data pair in [ ]available, the Lagrange interpolation is the n-order polynomial interpolation, such that
  • 14. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 14 Thus, the Lagrange interpolation results at the observation point are equal to the observed value of itself. At point x which is not the point of observation Lagrange value is calculated through the following formula: βˆ‘ where ∏ ( ) is called coefficient of Lagrange. Note that { So, for we get: With the error is determined by the formula: ∏ So, the form of Lagrange interpolation for order-2 formula is as follows: with a error determined as follows: | | Example 1.1 Given and a table of data pair : 10 11 12 13 14
  • 15. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 15 2.302 6 2.397 9 2.484 9 2.564 9 2.639 1 By using Lagrange interpolation, find value of ! Solution:  First, we must compute , with ο‚· ο‚· Then, So, With error: , we get: | | Then  First, we must compute , with ο‚· ο‚· ο‚· Then,
  • 16. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 16 So, With error: , we get: | | Then Lagrange Interpolation Algorithm: Declaration Int ; Real Deskription 1. Input order polynomial (n) 2. Input pair for 3. Input point try xk; 4. Initial value ; 5. Load for i=0 to i=n a. P(i)=1; b. for j=0 to j=n
  • 17. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 17 i. if then c. 6. print (β€˜for x= ’, xk, β€˜then y= β€˜,L); 7. Stop Program’s MATLAB Lagrange method clear; help lagrang; n = input('Order polinomial n = '); x = zeros(n+1, 1); y = zeros(n+1, 1); z = zeros(n+1, 1); for i = 1: n+1 fprintf('data ke-%2dn', i-1); x(i) = input('x : '); y(i) = input('y : '); end disp(' x y'); for i = 1: n+1 fprintf('%8.4f %10.6fn', x(i),y(i)); end again=1; while (lagi==1) xk = input('input point xk: '); L = 0; for i = 1:n+1 P(i)=1; for j= 1:n+1 if (i~=j) P(i) = P(i)*(xk-x(j))/(x(i)-x(j)); end end L = L + P(i)*y(i); end fprintf('Value y= %10.8f on x= %8.6f n', L,xk); disp(β€˜Press 1 to reload, Press 0 to exit'); again=input(' '); end Example 1.2 Estimate the error of √ at the point x=116 in the interval [100,144] using Lagrange orde-2, calculated at , and . Solution:
  • 18. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 18 √ then √ , √ and √ [ ] √ |√ | ( * Example 1.3 Draw the Lagrange chart for the following table, then estimate the value of y at point x 1 3 5 7 9 11 y -3 4 5 -8 -3 0 >> myLAGRANG input vektor sb-x: [1 3 5 7 9 11] input vektor sb-y: [-3 4 5 -8 -3 0] input point xk: 4.5 Value yk= 7.14111328 at xk= 4.500000
  • 19. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 19 Example 1.4 : Interpolate at point x = 1.5 in the following observation table: x -2 -1 1 2 y -6 0 0 6 >> myLAGRANG Input vector sb-x: [-2 -1 1 2] Input vector sb-y: [-6 0 0 6] Input point xk: 1.5 Value yk= 1.87500000 at xk= 1.500000
  • 20. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 20 NEWTON INTERPOLATION Suppose is the -th Lagrange polynomial whose value corresponds to the value of at points then model of divided difference of can written: For coefficents that corresponds. The coefficient or constant can be calculated in the following way: ο‚· for , then ο‚· for then such that [ ] using notation of divided difference: ο‚· Divided Difference (Zeroth): [ ] ο‚· Divided Difference (First): [ ] { [ ] [ ]} ο‚· Divided Difference (Second): [ ] { [ ] [ ]}
  • 21. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 21 Divided Difference is more easily understood through the following table: [ ] [ ] [ ] [ ] [ ] [ ] [ ] { [ ] [ ]} [ ] { [ ] [ ]} [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] { [ ] [ ]} [ ] { [ ] [ ]} [ ] [ ] [ ] [ ] [ ] { [ ] [ ]} [ ] { [ ] [ ]} [ ] [ ] { [ ] [ ]} [ ] - Example 2.1 Given the following table. Look for the polynomial approach y value on x=2. X -1 0 3 6 7 Y 3 -6 39 822 1611 Solution: Consider the following Dived Difference table: [ ] [ ] [ ] [ ] [ ] - From the table, we get: [ ] [ ] [ ] [ ] and [ ] ; such that: ( ) ( ) ( ) ( ) So, for x=2, we obtain
  • 22. Mohamad Tafrikan (moh.tafrikan@gmail.com) Page 22 Program’s MATLAB clear; help NForward; N = input(β€˜pait data : '); T = zeros(N, N+1); disp('input data: '); for i = 1: N fprintf('data th-%2dn', i); x(i) = input('x : '); y(i) = input('y : '); T(i,1) = x(i); T(i,2) = y(i); end for kol = 3:N+1 br = (N+2-kol); for brs = 1:br T(brs,kol)=T(brs+1, kol-1)-T(brs, kol-1); end end disp(' x y delta1 delta2 ..........'); for i = 1: N for j=1:N+1 fprintf('%8.4f ',T(i,j)); end fprintf('n'); end %interpolasi lagi=1; while (lagi==1) h=x(2)-x(1); xk = input(β€˜input point interpolation: '); t = (xk - x(1))/h; yk = T(1,2) + t*T(1,3); for kol = (N+1):-1:4 fak = kol-2; t1 = 1; for j = (kol-3) : -1 : 1 t1 = t1*(t-j); fak = fak*j; end t1 = t*t1; yk = yk + t1*T(1,kol)/fak; end fprintf('At x= %8.6f value of y = %12.8f n',xk,yk); disp(β€˜Press 1 to reload, Press 0 to exit'); lagi=input(' '); end