Anda di halaman 1dari 31

HEAVENS LIGHT IS OUR GUIDE

Department of Electrical & Electronic Engineering

Course name : Computational methods in


electrical engineering

Course no : EEE - 3110

Lab Report

Name : MD. ARAFAT RAHMAN

Experiment no : 01
Roll no : 121087
Section : B
1.Bisection Method

Title : Finding out the root of a non-linear equation by


bisection method.

2.Background :

The first technique, based on the Intermediate Value Theorem,


is called the Bisection, or In computer science, the process of
dividing a set continually in half to search for the solution to a problem,
as the bisection method does, is known as a binary search procedure.

3. Objectives :

1. To find the root of a non linear equation .


2. To find root by easy calculation.

Theory :

This method states that if a function f(x) is continuous


between a and b , and f(a) and f(b) are of opposite signs ,
then there exists at least one root between a and b .For
definiteness ,let f(a) be negative and f(b) be positive .Then
the root lies between a and b let its approximate value
be given by x0 = (a+b)/2. If f(x0) =0 ,we conclude that x0
is the root of the equation .

Methodology :

x0=(a+b)/2; Where a and b are two initial


guesses .

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 number of maximum iteration and define the
function;

Step 2: Check f(a)<0 and f(b)>0 ;

Step 3: c(i)=(a+b)/2; where i is for iteration;

Step 4:Using loop continue the iteration till n;

Step 5: if f(c(i)) <0 then ac(i) or if f(c(i))>0 then bc(i);part


of step 4;

Step 6 : find the root from last iteration ,c(i);

Step 7 : Error=abs(a-b)/a; find the error;

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

fprintf('bracketing limit p = %d q = %d \n',p,q);


a(1)=p;
b(1)=q;

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 :

enter % of error = 0.001

bracketing limit p = 2 q=3

a b c d error

2.0000 3.0000 2.5000 5.6250 0

2.0000 2.5000 2.2500 1.8906 11.1111

2.0000 2.2500 2.1250 0.3457 5.8824

2.0000 2.1250 2.0625 -0.3513 3.0303

2.0625 2.1250 2.0938 -0.0089 1.4925

2.0938 2.1250 2.1094 0.1668 0.7407

2.0938 2.1094 2.1016 0.0786 0.3717

2.0938 2.1016 2.0977 0.0347 0.1862

2.0938 2.0977 2.0957 0.0129 0.0932

2.0938 2.0957 2.0947 0.0020 0.0466

2.0938 2.0947 2.0942 -0.0035 0.0233

2.0942 2.0947 2.0945 -0.0008 0.0117

2.0945 2.0947 2.0946 0.0006 0.0058

2.0945 2.0946 2.0945 -0.0001 0.0029


2.0945 2.0946 2.0946 0.0003 0.0015

2.0945 2.0946 2.0946 0.0001 0.0007

Result and comparison:

Root from matlab programm is 0.0244 and from built in


function is 0.0246 and they are slightly different .

Discussion and conclusion :

The bisection method is very


easy to find out the root but the iteration process is longer
than other methods , that means it is very time cosuming
mehod .

Application area :

Its an important method for numerical


analysis. Basically this method is used to find the root of a
non-lilnear equation that means for which value of varirable
the functional value of the function is zero. Method for
locating and computing periodic orbits in molecular system.

2.False position Method

Title : Finding out the root of a non-linear equation by false-


position method.

Background :
Although bisection is a perfectly valid technique for
determining roots. its "brute-force"

proach is relatively inefficient. False position is an ahernative based on


a graphical insight.the bisection method guarantees that the iterative
process will converge.it is however slow .thus attempt have been made to
speed up bisection method retaining its guaranteed convergences.

3. Objectives :

1. To find the root of a non linear equation .


2. To reduce the iteration time.
3. To get the result fast.

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 2: Check f(a)<0 and f(b)>0 ;

Step 3: c(i)=(a*f(b)-b*f(a))/(f(b)-f(a));where i is for iteration;


Step 4:Using loop continue the iteration till n;
Step 5: if f(c(i)) <0 then ac(i) or if f(c(i))>0 then bc(i); part
of step 4;

Step 6 : find the root from last iteration ,c(i);

Step 7 : Error=abs(a-b)/a; find the error;

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');

disp([ m' a' fa' b' fb' c' d' error' ])


output :

a=2

b=3

error = 0.001

iteration a fa(a) b fb(b) x f(x) error

1.0000 2.0000 -1.0000 3.0000 16.0000 2.0588 -0.3908 0

2.0000 2.0588 -0.3908 3.0000 16.0000 2.0813 -0.1472 1.0782

3.0000 2.0813 -0.1472 3.0000 16.0000 2.0896 -0.0547 0.4008

4.0000 2.0896 -0.0547 3.0000 16.0000 2.0927 -0.0202 0.1481

5.0000 2.0927 -0.0202 3.0000 16.0000 2.0939 -0.0075 0.0546

6.0000 2.0939 -0.0075 3.0000 16.0000 2.0943 -0.0027 0.0201

7.0000 2.0943 -0.0027 3.0000 16.0000 2.0945 -0.0010 0.0074

8.0000 2.0945 -0.0010 3.0000 16.0000 2.0945 -0.0004 0.0027

9.0000 2.0945 -0.0004 3.0000 16.0000 2.0945 -0.0001 0.0010

10.0000 2.0945 -0.0001 3.0000 16.0000 2.0945 -0.0001 0.0004


Result and comparison:

Root from matlab programm is 0.0243


and from built in function is 0.0246 and they are slightly
different .

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 .

Practical Application area :

It is also an important method for numerical analysis.


Basically this method is used to find the root of a non-lilnear
equation that means for which value of variable the functional
value of the function is zero. . Method for locating and
computing periodic orbits in molecular system.

1.Title of the experiment : Finding a root from a non linear


equation using Newton Raphson method.

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.

Isaac Newton (16411727) was one of the most brilliant


scientists of all time. The late 17th century was a vibrant
period for science and mathematics and Newtons work touched
nearly every aspect of mathematics. His method for solving was
introduced to find a root of the equation y3 2y 5 = 0.
Although he demonstrated the method only for polynomials, it
is clear that he realized its broader applications.

Joseph Raphson (16481715) gave a description of the method


attributed to Isaac Newton in 1690, acknowledging Newton as
the source of the discovery. Neither Newton nor Raphson
explicitly used the derivative in their description since both
considered only polynomials. Other mathematicians,
particularly James Gregory (16361675), were aware of the
underlying process at or before this time.

3. Objectives :

4. To find the root of a non linear equation .


5. To reduce the iteration time.
6. To get the result fast.

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.

5.Methodology with a practical EE example

If we only want an algorithm, we can consider the


technique graphically, as is often done in calculus. Another
possibility is to derive Newtons method as a technique to
obtain faster convergence than offered by other types of
functional iteration. Third means of introducing Newtons
method, which is discussed next, is based on Taylor
polynomials.We will see there that this particular derivation
produces not only the method, but also a bound for the error of
the approximation.

The NewtonRaphson formula can be derived from the


Taylor series expansion of f (x) about x:

f (xi+1) = f (xi ) + f _(xi )(xi+1 xi ) + O(xi+1 xi )2 (a)

If xi+1 is a root of f (x) = 0, Eq. (a) becomes

0 = f (xi ) + f _(xi) (xi+1 xi ) + O(xi+1 xi )2 (b)

Assuming that xi is a close to xi+1, we can drop the last term in


Eq. (b) and solve for xi+1. The result is the NewtonRaphson
formula
xi+1 = xi f (xi )/f _(xi )

If x denotes the true valueof the root, the error in xi is Ei = x


xi . It can be shown
that if xi+1 is computed from Eq. the corresponding error is

Ei+1 = (f __(xi )/2 f _(xi ))*Ei ^2

indicating that the NewtonRaphson method converges


quadratically (the error is the square of the error inthe previous
step). As a consequence, the number of significant figures is
roughly doubled in every iteration, provided that xi is close to
the root.
Figure illustrates how the approximations are obtained using
successive tangents. Starting with the initial approximation p0,
the approximation p1 is the x-intercept of the tangent line to
the graph of f at ( p0, f ( p0)). The approximation p2 is the x-
intercept of the tangent line to the graph of f at ( p1, f ( p1))
and so on.

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 = ');

e=input(' error = ');

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

disp(' iteration Xn Xn+1 f(Xn+1) error ');

disp([ m' a' d' g' error' ])


9. Possible result and comparison :

Output :

a = 5

error = 0.001

iteration Xn Xn+1 f(Xn+1) error

1.0000 5.0000 3.4932 30.6375 0

2.0000 3.4932 2.6078 7.5197 33.9483

3.0000 2.6078 2.1992 1.2381 18.5806

4.0000 2.1992 2.1002 0.0637 4.7125

5.0000 2.1002 2.0946 0.0002 0.2706

6.0000 2.0946 2.0946 0.0000 0.0009

Comparison :

Normally by calculator we get the root is 2.0945 and in this


method the result is 2.0946 .

10. Practical application area :


We can find any root of any non linear equtation or any
graph.Using this process we can find also the maxima and
minima of a graph with it by modifying the equation.The
inverse square rule for the gravitational pull in NASA used also
this bisection method.

11. Discussion and conclusion :

Although the NewtonRaphson method converges fast near the


root, its global convergence characteristics are poor. The
reason is that the tangent line is not always an acceptable
approximation of the function.But the method can
bemadenearly fail-safe by combining it with bisection, as in
Brentsmethod.In a newton raphson method the assuming value
should be nearest from the root.Otherwise it takes much
iteration to converges to the root.

4.Secant Method:

Title: Finding out the root of a non-linear equation by secant


method.

Background:
Formulated for numerical analysis purposes,mainly used when
we dont have the derivative of a function.

Objective:

Main objectives of the secant method are

1. To study the theory, algorithm and flow chart of secant


method.

2. To find a root of a non-linear equation.

Theory:

Secant methoduse two initial estimate Xi-1 and Xi to compute


an approximation of the slope of the function f(x) that is used
to project to the axis for a new estimate Xi+1 of the root. This
method replaces the values in strict sequence, with new value
Xi+1 replacing Xi and Xi replacing Xi-1 . As a result, the two values
can sometime lie on the same side of the root.

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.

Where, R=225 ohm , C=.6*10^-6 F, L=.5H

Equation of the angular frequency is

(9*10^-14)w^4-(4.0106*10^-5)w^2+1=0

Algorithm:

1. Read Xi-1 and Xi

2. Evaluate fi-1 and fi


X i1 f iX i f i1
X i +1=
3. Evaluate f i f i1
Then Xi-1Xi and

XiXi+1

4.CalculateError=abs(Xi+1(new) - Xi+1(old) )*100/Xi+1(new))

Print Xi-1,fi-1 ,Xi,fi and Error

5. if Error<.1

Print x2

Go to step 6

else

Go to step 3

7. End
Flow chart:
Start

Input Xi-1 and


Xi

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)

Print Xi-1, fi-1, Xi, fi


Xi+1fi+1 and Error

No Is Error<0.1?

Yes

Display Root= Xi+1

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(' iteration b f2(b) a f1(a) c(x) d(x) error ');

disp([ m' b' f2' a' f1' c' d' error' ]);
possible result and comparison :

Output :

a= 3

b= 2

error = 0.001

iteration b f2(b) a f1(a) c(x) d(x) error

1.0000 2.0000 -1.0000 3.0000 16.0000 2.0588 -0.3908 0

2.0000 3.0000 16.0000 2.0588 -0.3908 2.0813 -0.1472 1.0782

3.0000 2.0588 -0.3908 2.0813 -0.1472 2.0948 0.0030 0.6473

4.0000 2.0813 -0.1472 2.0948 0.0030 2.0945 -0.0000 0.0131

5.0000 2.0948 0.0030 2.0945 -0.0000 2.0946 -0.0000 0.0001

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

project to the x axis


for a new estimate of the root. However, a critical difference between the
methods is how
.,
one of the initial values is replaced by the new estimate. Recall that in
the lalse-po,;iti,';'
method the latest estimate of the root replaces whichever of the original
values yielded function value with the same sign asf(xr). Consequently,
the two estimates always the root. Therefore. for all practical purposes,
the method always converges because root is kept within the bracket. In
contrast, the secant method replaces the vah.:.es in strict.
sequence, with the new value Xi+l replacing Xi and Xi replacing Xi-I.
As a result, the two values can sometimes lie on the same side of the
root. For certain cases, this can lead to divergence.

Practical application area :


We can find any root of any non linear equtation or
any graph.Using this process we can find also the maxima and
minima of a graph with it by modifying the equation.The
inverse square rule for the gravitational pull in NASA used also
this secant method.

Anda mungkin juga menyukai