Anda di halaman 1dari 8

Roots of a Polynomial:

Root of a polynomial is the value of the independent variable at which the


polynomial intersects the horizontal axis (the function has zero value) . The formulae
for the roots of a 2nd degree polynomial are given below
 b  b2  4 a c
x1 
a x bx c  0
2 2a
 b  b2  4 a c
x2 
2a
The formulae for the roots of a 3rd degree polynomial are given below

a x3  b x 2  c x  d  0
First root (of three)
Roots of a Polynomial:

The Matlab program can be used to calculate the roots of an n degree polynomial.

Example: Find the roots of the given polynomial.

5 x3  8 x 2  6 x  6  0
ans =

>>p=[5 8 6 -6]; roots(p) -1.0604 + 1.0863i


-1.0604 - 1.0863i
0.5207

Example: Find the roots of the given polynomial.

x  4 x  16 x  20  0
5 3 2 ans =

1.0043 + 2.7517i
>>p=[1 0 4 16 0 -20]; roots(p) 1.0043 - 2.7517i
-1.4940 + 0.3852i
-1.4940 - 0.3852i
All coefficients including those with zero must be specified.
0.9793
Otherwise the polynomial degree will be reduced.
Solutions of Nonlinear Equations:

NEWTON-RAPHSON ITERATION METHOD


f(x)
The Newton-Raphson method, or
Newton’s method, is a powerful Slope at this
technique for solving equations f(xi) point is f'(xi)
numerically. Like so much of the Tangent line
differential calculus, it is based on
the simple idea of linear f(xi)-0
approximation. This method is a
method for finding successively 0 Xi+1 xi (İnitial value) x
better approximations to the real
roots (or zeroes) of a real valued
function. x i  x i 1

f(x i )  0
f (x i )  xi  xi1  f(xi )  f(xi )
x i  x i 1
ε (error)
f(x i )
x i 1  x i  f(x i )
f (x i ) x i 1  x i    f(xi )   f(xi )
f (x i )
Solutions of Nonlinear Equations:

Newton-Raphson Example 1:

2  4     1 Find one of the θ values, which satisfies the given


equation.
f()  0
f  2  4    1
f
1 1  , x n 1  x n  
f  2   f
2 1 (tet + 1)1/2 + tet2 - 4

40

35

θ f f' ε 30

25
1 -1.5858 2.3536 0.6738
20

f(tet)
1.6738 0.4368 3.6534 -0.1196 15

10

1.5542 0.0139 3.4213 -0.0041 5

0
1.5501 -0.00013 3.4134 3.95e-5
-5
-1 0 1 1.55 2 3 4 5 6
tet
Solutions of Nonlinear Equations:

Newton-Raphson Example 2:

5u  cos(3u)  1.6 Find one of the u values, which satisfies the given
equation.
f(u)  0
f  5u  cos(3u)  1.6 f
 , x n 1  x n  
f   5  3 sin(3u) f
5 u - cos(3 u) - 8/5
30

u f f' ε 20

1 4.3899 5.4233 -0.8094 10

0
f(u)

0.1905 -1.4883 6.6229 0.2247


-10
0.4152 0.1569 7.8429 -0.0200
-20
0.3952 0.00025 7.7801 -3.32e-5
-30

-6 -4 -2 0 2 4 6
u
Solutions of Nonlinear Equations:

MATLAB CODES
The following changes are made in the program (nr1.m) to solve the problems.

Newton-Raphson Example 1: Newton-Raphson Example 2:


clc, clear clc, clear
x=1;xe=0.001*x; x=1;xe=0.001*x;
niter=20; niter=20;
%---------------------------------------------- %----------------------------------------------
for n=1:niter for n=1:niter
%---------------------------------------------- %----------------------------------------------
f=x^2-4+sqrt(x+1); f=5*x-cos(3*x)-1.6;
df=2*x+0.5/(sqrt(x+1)); df=5+3*sin(3*x);
%---------------------------------------------- %----------------------------------------------
x1=x x1=x
x=x1-f/df x=x1-f/df
if abs(x-x1)<xe if abs(x-x1)<xe
kerr=0;break kerr=0;break
end end
end end
kerr,x kerr,x

x = fzero(@(x)x^2-4+sqrt(x+1),1) x = fzero(@(x)5*x-cos(3*x)-1.6,1)
Solutions of Nonlinear Equations:

Newton-Raphson iteration method is used to solve the nonlinear system of equations. Since
there are more than one equations and unknown variables, partial derivatives of the
equations with respect to each unkown variable are used in the solution procedure.

 f1 f1 
f1(x1,x2)=0  x x 2  1   f1 
f    f  1  
f2(x1,x2)=0  f2 f2  2   f2 
 x 1 x 2 
Arbitrary initial values for x1 and x2 are assigned and the iteration procedure is started by
making the necessary changes in the computer program (newtonrn). The variables are
stated as x() in the program.
Newton-Raphson Example 3: The equation of a circle with center coordinates
(3,2) and a radius 5 is given on the right hand side.
x  32  y  22  25 How do you find the intersection point of this circle
and the parabola y=x2 ?
f1 f1
 2x  3,  2y  2
f1  x  32  y  22  25 x y
f2  y  x 2 f2 f2
 2x , 1
x y
Solutions of Nonlinear Equations:

The following changes are made in the program (nr.m) to solve the problem.
clc, clear y
x=[1 4] ; fe=[0.01 0.01];
niter1=5;niter2=50; 9
fe=transpose(abs(fe));kerr=1;
for n=1:niter2 (2.643, 6.987)
x
%Error Equations---------------------------
a(1,1)=2*(x(1)-3);a(1,2)=2*(x(2)-2); (-1.82, 3.321) 4
a(2,1)=-2*x(1);a(2,2)=1;
b(1)=-((x(1)-3)^2+(x(2)-2)^2-25); 2
b(2)=-(x(2)-x(1)^2); 1
%---------------------------------------------- 1 2 3 x
bb=transpose(b);eps=inv(a)*bb;x=x+transpose(eps);
if n>niter1
if abs(eps)<fe
kerr=0; break
else
display ('Roots are not found')
end
end
As shown in the figure, there are two valid solution sets. The output
end solution set is determined by the initial values of the unkown variables.

Anda mungkin juga menyukai