Professional Documents
Culture Documents
Lab Report
Experiment no : 01
Roll no : 121087
Section : B
1.Bisection Method
2.Background :
3. Objectives :
Theory :
Methodology :
Practical EE Example :
w^4-25.78*w^2+0.0156 =0
and its a non-linear equation.
Algorithm :
Step 1: input a ,b ,n ; Where a and b are two initial guesses
and n is the number of maximum iteration and define the
function;
Step 8 : stop
Flow chart:
Matlab simulation:
clear
e=input('enter % of error = ');
x=-10;
for a=1:1:100
b=x^3-2*x-5;
if b<0
x=x+1;
b=x^3-2*x-5;
if b>0
p=x-1;
q=x;
break;
end
end
x=x+1;
end
for x=1:1:50
c(x)=(a(x)+b(x))/2;
d(x)=c(x)^3-2*c(x)-5;
if x>1
m(x)=abs(c(x)-c(x-1))*(100/c(x));
if m(x)<=e
break;
end
end
if d(x)>0
b(x+1)=c(x);
a(x+1)=a(x);
else
a(x+1)=c(x);
b(x+1)=b(x);
end
end
fprintf('Iteration.....a......b.......c=a+b/2......d(x)error \n')
disp(' a b c d m ')
out=[ a' b' c' d' m'];
disp(out);
output :
a b c d error
Application area :
Background :
Although bisection is a perfectly valid technique for
determining roots. its "brute-force"
3. Objectives :
Theory:
This is the oldest method for finding out the real root of a non-
linear equation f(x)=0 and closely resembles the bisection
method .In this method ,also known as regula falsi or the
method of chords, we choose two points a and b such that f(a)
and f(b) are of opposite signs .Hence ,the root lies between the
two points.
Methodology:
X0=(a*f(b)-b*f(a))/f(b)-f(a);
Practical EE Example:
The equation of the resonant frequency that the circuit
belongs to is as given by
w^4-25.78*w^2+0.0156 =0
and its a non-linear equation.
Algorithm :
Step 1: Input a ,b ,n; Where a and b are two initial guesses and
n is the maximum iteration number and define the function;
Step 8 : stop
Flow chart:
Matlab simulation:
clc
clear
for i=1:100
a=input('a = ');
b=input('b = ');
e=input('error = ');
f1=a^3-2*a-5;
f2=b^3-2*b-5;
if f1*f2<0
break;
end
end
a(1)=a;
b(1)=b;
fa(1)=f1;
fb(1)=f2;
for x=1:100
m(x)=x;
c(x)=(a(x)*fb(x)-b(x)*fa(x))/(fb(x)-fa(x));
d(x)=c(x)^3-2*c(x)-5;
if x>1
error(x)=(abs(c(x)-c(x-1)))*(100/c(x));
if error(x)<e
break;
end
end
if d(x)<0
a(x+1)=c(x);
fa(x+1)=d(x);
b(x+1)=b(x);
fb(x+1)=fb(x);
else
a(x+1)=a(x);
fa(x+1)=fa(x);
b(x+1)=c(x);
fb(x+1)=d(x);
end
end
disp(' iteration a fa(a) b fb(b) x f(x) error');
a=2
b=3
error = 0.001
The false position method is very easy to find out the root
and the iteration process is less longer than other methods ,
that means it is less time cosuming mehod .
2.Background :
The most widely method for solving simultaneous nonlinear
algebric equation is the Newtown Raphson method. Newtown
Raphson method is a successive approximation procedure
based on the Taylors series expansion.
3. Objectives :
4.Theory :
In Newton Raphson method we select a value at
first.Then we place the value in the given function.We take a
tangent using this co ordinates.The point of intersection in
the x axis is the root again.Then place the root in the function
again.Taking tangent again for the second co ordinate .
Continuing this process we get the root at last.
6.Algorithm:
1.Read x0
2.Compute f0=f(x0)
3. Compute x1=x0-f(x0)/fd(x0).
4.if abs((x1-x0)/x1)>E
x1=x0
else
root=x1
5.print root.
6.stop
7. Flow chart :
8. Simulation in Matlab programming environment :
clc
clear
a(1)=input(' a = ');
for x=1:100
m(x)=x;
b(x)=a(x)^3-2*a(x)-5;
c(x)=3*a(x)^2-2;
d(x)=a(x)-(b(x)/c(x));
g(x)=d(x)^3-2*d(x)-5;
if x>1
error(x)=(abs(d(x)-d(x-1)))*(100/abs(d(x)));
if error(x)<e||g(x)==0
break;
end
end
a(x+1)=d(x);
end
Output :
a = 5
error = 0.001
Comparison :
4.Secant Method:
Background:
Formulated for numerical analysis purposes,mainly used when
we dont have the derivative of a function.
Objective:
Theory:
Methodology:
X i1 f iX i f i1
X i +1=
f i f i1 Where Xi-1 and Xi two initialestimate.
Practical EEE example: Determine the angular frequency of the
following circuit.
(9*10^-14)w^4-(4.0106*10^-5)w^2+1=0
Algorithm:
XiXi+1
5. if Error<.1
Print x2
Go to step 6
else
Go to step 3
7. End
Flow chart:
Start
Calculate
X i1 f iX i f i1
X i +1=
f i f i1
XiXi+1 and
Xi-1 Xi
Error=(Xi+1(new) -Xi+1(old) )
*100/Xi+1(new)
No Is Error<0.1?
Yes
End
Simulation in Matlab programming :
clc
clear
a(1)=input('a= ');
b(1)=input('b= ');
e=input('error = ');
for x=1:100
m(x)=x;
f1(x)=a(x)^3-2*a(x)-5;
f2(x)=b(x)^3-2*b(x)-5;
c(x)=a(x)-(a(x)-b(x))*(f1(x)/(f1(x)-f2(x)));
d(x)=c(x)^3-2*c(x)-5;
if x>1
error(x)=(abs(c(x)-c(x-1)))*(100/c(x));
if error(x)<e||d(x)==0
break;
end
end
b(x+1)=a(x);
f2(x+1)=f1(x);
a(x+1)=c(x);
f1(x+1)=d(x);
end
disp([ m' b' f2' a' f1' c' d' error' ]);
possible result and comparison :
Output :
a= 3
b= 2
error = 0.001
Conclution:
Note the similarity between the secant method
and the false-position method. For example, are identical on a term-by-
term basis. Both use two initial estimates to
compute an approximation of the slope of the function that is used to