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.
5 x3 8 x 2 6 x 6 0
ans =
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:
f(x i ) 0
f (x i ) xi xi1 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:
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
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
0
f(u)
-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.
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 32 y 22 25 How do you find the intersection point of this circle
and the parabola y=x2 ?
f1 f1
2x 3, 2y 2
f1 x 32 y 22 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.