Rob
Rob
a2x+b2y+c2z=d2…………………2)
a3x+b3y+c3z=d3…………………3)
Solution:
Step 1):
Eliminate ‘x’ from 2nd and 3rd equation using 1st equation as follows:
When we solve above two equations, we get two new equations in ‘y’ and ‘z’
a1x+b1y+c1z=d1 …………4)
b1’y+c1’z=d1’ …………..5)
b2’y+c2’z=d2’ …………..6)
Step 2):
Eliminate ‘y’ from 4th and 6th equation using 5th equation as follows:
When we solve above two equations, we get two new equations, write these equations
in the following form. (Note that we are writing 5th equation as it is and defining it as
8th equation)
a1”x+c1”=d1” …………….7)
b1’y+c1’z=d1’ …………….8)
c2”z=d2” ..…………..9)
Don’t get over exited, here we don’t use value of z from 9th equation directly. Since it
is not an elimination method.
Step 3):
Eliminate ‘z’ from 7th and 8th equation using 9th equation as follows:
After solving above two equation, we directly get two new equations contains only
one variable each.
Let us discuss Gauss Jordan method by solving one simple set of linear equation.
Example:
Find roots of following set of linear equations:
x+y+z=9…………………1)
2x-3y+4z=13…………..2)
3x+4y+5z=40…………..3)
Solution:
Step 1):
Eliminate ‘x’ from 2nd and 3rd equation using 1st equation as follows:
x+y+z=9………………..4)
-5y+2z=-5….……………5)
y+2z=13………………….6)
Step 2):
Eliminate ‘y’ from 4th and 6th equation using 5th equation as follows:
eq.(4)+(1/5)*eq.(5) ; eq.(6)+(1/5)*eq.(5) ;
x+(7/5)z=8 ……………….7)
-5y+2z=-5 ..…………….8)
(12/5)z=12 ….…………..9)
Step 3):
Eliminate ‘z’ from 7th and 8th equation using 9th equation as follows:
Now it is sufficient. If you observe above two sets of roots, they are almost same.
Hence the roots of given simultaneous equations using Jacobi’s iterative method are:
x=1; y = -1; z=1
MATLAB Program For Jacobi’s Iterative Method:
MATLAB code for Jacobi’s iterative method
Many times we are required to find out solution of linear equations. We also know
that, we can find out roots of linear equations if we have sufficient number of
equations. For example if we have to calculate three unknown variables, then we
must have three equations. Many times we have solved such problems by eliminating
one of the root and keep on decreasing number of variables. But in some cases it is
not possible or it will take more time to solve.
Gauss elimination method is one of the simple and famous methods used for finding
roots of linear equations. Let us discuss this method assuming we have three linear
equations in x, y and z. That is we have to find out roots of that equations (values of x,
y and z).
Steps to find out roots of linear equations using Gauss elimination
method:
In this method we just eliminate ‘x’ from first equation using second and third
equation. After that we get only two equations with two unknowns. Similarly, we then
eliminate ‘y’ from first (among two equations that we get from last step) equation
using second equation. Finally we get single equation in z having constant in its right
side. Now we can find ‘z’, using ‘z’ we can find ‘y’, similarly ‘x’.
Don’t get confused, I will explain each step clearly.
Let us consider three linear equations as follows:
a1x+b1y+c1z=d1…………………1)
a2x+b2y+c2z=d2…………………2)
a3x+b3y+c3z=d3…………………3)
From above three equations we are asked for finding values of x, y and z (values of a1,
b1, c1,……..,d3 are given).
Step 1: Eliminate ‘x’ from first equation using second and third equation. For doing
this we have to subtract 1st eq. from 2nd eq. by making coefficient of ‘x’ (of 1stequation)
equals to coefficient of ‘x’ (of 2nd equation). Similarly we have to do same thing for
third equation.
In short we have to solve following equations:
eq.(2) – (a2/a1)*eq.(1) and eq.(3) – (a3/a1)*eq.(1)
We get two new equations in y and z as follows:
b2’y+c2’z=d2’……..4)
b3’y+c3’z=d3’……..5)
Step 2: similarly, we have to eliminate ‘y’ from 4th equation using 5th equation.
We have to solve following equation.
eq.(5) – (b3’/b2’)*eq.(4)
we get c3”z=d3”……………6)
solving above equation we get, z=d3”/c3”
Step 3: Finally we have to put above value of ‘z’ in equation 4) (or (5)), then we get
‘y’. now we have two roots (y and z). put ‘y’ and ‘z’ in eq.(1) (or (2) or eq.(3)), we will
get ‘x’.
Example 1:
Find the roots of following equations using Gauss Elimination method.
X + 4y – z = -5 ………….1)
X + y – 6z = -12…………2)
3x – y – z = 4 ………3)
Solution:
Step 1: Perform eq.(2) – (a2/a1)*eq.(1) and eq.(3) – (a3/a1)*eq.(1)
We get, 3y +5z =7……………4)
And
-13y +2z = 19…………..5)
Step 2: Now perform eq.(5) – (b3’/b2’)*eq.(4)
We get, -13y + 2z – (-13/3)*(3y + 5z) = 19 + (13/3)*7
71z = 148
i.e. z=148/71.
Step 3: From eq.(5) – 13y = 19 – 2*(148/71)
= 19 – 296/71
Y= -81/71
From eq.(1) x+4(-81/71)-148/71=-5
Therefore, x=117/71.
Thus roots of given linear equations using Gauss elimination method is
X=117/71; y=-81/71; z=148/71.
Example 2:
Find roots of following linear equations using Gauss Elimination method:
2x+y+z=10………1)
3x+2y+3z=18……..2)
X+4y+9z=16………..3)
Solution :
Step 1: Perform eq.(2)-(3/2)*eq(1) and eq(3)-(1/2)*eq(1)
We get, y+3z=6…………4)
And 7y+17z=22……….5)
Step 2: Perform eq(5) – 7*eq(4)
We get, -4z=-20
i.e. z=5;
Step 3: From equation (5) y=-63/7 i.e. y=-9
From equation (1) 2x=14 i.e. x=7
Thus the roots of given linear equations is
X=7; y=-9; z=5.
You May Also Like:
Jacobi’s iteration method
Gauss elimination method
lagrange interpolation with MATLAB Program
Simpson’s 3/8th Rule MATLAB Program example
Simpson’s 1/3rd rule MATLAB Program examples
MATLAB Programming for Trapezoidal rule with example
Name(required)
Email(required)
Website
Comment(required)
Submit »
Second Example :
Question: Evaluate the integral 1/(1+x) within limits 0 to 6 using
Simpson’s 3/8th rule.
Solution:
Let y(x)=1/(1+x)
here a=0 and b=6
therefore (b-a)=6
let ‘n’ be the number of intervals. assume n=6 in this case.
also h=(b-a)/n = 6/6 =1
x: 0 1 2 3 4 5 6
y: 1.0000 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429
According to Simpson’s 3/8th rule:
answer= (3h/8)*[(y1+y7)+3*(y2+y3+y5+y6)+2*(y4)]
answer=1.9660
MATLAB code for Simpson’s 3/8th rule :
%Created by myclassbook.wordpress.com (Mayuresh)
%Created on 24 May 2013
%Question: Evaluate the integral 1/(1+x) within limits 0 to 6
clc;
clear all;
close all;
f=@(x)1/(1+x); %Change here for different function
a=0;b=6; %Given limits
n=b-a; %Number of intervals
h=(b-a)/n;
p=0;
for i=a:b
p=p+1;
x(p)=i;
y(p)=1/(1+i); %Change here for different function
end
l=length(x);
x
y
answer=(3*h/8)*((y(1)+y(l))+3*(y(2)+y(3)+y(5)+y(6))+2*(y(4)))
Image Format:
Second Example :
Question: Evaluate the integral 1/(1+x) within limits 0 to 6 using Simpson’s 1/3 rd
rule.
Solution:
Let y(x)=1/(1+x)
here a=0 and b=6
therefore (b-a)=6
let ‘n’ be the number of intervals. assume n=6 in this case.
also h=(b-a)/n = 6/6 =1
x: 0 1 2 3 4 5 6
y: 1.0000 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429
According to Simpson’s 1/3 rd rule.
answer= (h/3)*[(y1+y7)+2*(y3+y5)+4*(y2+y4+y6)]
answer=1.9587.
MATLAB code for Simpson’s 1/3rd rule :
%Created by myclassbook.wordpress.com (Mayuresh)
%Created on 24 May 2013
%Question: Evaluate the integral 1/(1+x) within limits 0 to 6
clc;
clear all;
close all;
f=@(x)1/(1+x); %Change here for different function
a=0;b=6; %Given limits
n=b-a; %Number of intervals
h=(b-a)/n;
p=0;
for i=a:b
p=p+1;
x(p)=i;
y(p)=1/(1+i); %Change here for different function
end
l=length(x);
x
y
answer=(h/3)*((y(1)+y(l))+2*(y(3)+y(5))+4*(y(2)+y(4)+y(6)))
Image Format:
MATLAB code for Simpson’s one third rule
Second Example :
Question: Evaluate The Integral 1/(1+X) Within
Limits 0 To 6 Using Trapazoidal Rule.
Solution:
Let y(x)=1/(1+x)
here a=0 and b=6
therefore (b-a)=6
let ‘n’ be the number of intervals. assume n=6 in this case.
also h=(b-a)/n = 6/6 =1
x: 0 1 2 3 4 5 6
y: 1.0000 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429
According to trapazoidal rule:
answer= (h/2)*[(y1+y7)+2*(y2+y3+y4+y5+y6)]
answer=2.0214.
MATLAB Code For Trapazoidal Rule :
%Created by myclassbook.wordpress.com (Mayuresh)
%Created on 24 May 2013
%Question: Evaluate the integral 1/(1+x) within limits 0 to 6
clc;
clear all;
close all;
f=@(x)1/(1+x); %Change here for different function
a=0;b=6; %Given limits
n=b-a; %Number of intervals
h=(b-a)/n;
p=0;
for i=a:b
p=p+1;
x(p)=i;
y(p)=1/(1+i); %Change here for different function
end
l=length(x);
x
y
answer=(h/2)*((y(1)+y(l))+2*(sum(y)-y(1)-y(l)))
Image Format:
Where ‘a+ph’ is the value for which the value of the function f(x) is to be
estimated. Here ‘a’ is the initial value of x and ‘h’ is the interval of
differencing.
Question:
Table gives the distance between nautical miles of the visible horizon for
the given height in feet above the earth surface. Find the value of y when
x= 218 feet .
May 9, 2013
Name(required)
Email(required)
Website
Comment(required)
Submit »
April 20, 2013