Documente Academic
Documente Profesional
Documente Cultură
(These notes are based mainly on the 6th Edition of the textbook
Numerical Methods for Engineers by S.C. Chapra and R.P. Canale.)
This section discusses some advanced root-finding methods (including roots of polynomials) and mentions
about rate of convergence. In numerical solutions, the equation to be solved is typically arranged into the
form ( ) = 0 . The root-finding problem involves finding a root (or solution) of an equation of the form
( ) = 0. Therefore, the root of the equation ( ) = 0 is the value of x that makes ( ) = 0. In other words,
we call a number r satisfying ( ) = 0 a zero of the function f and a root of the equation ( ) = 0. Hence,
saying zero of is equivalent to saying root of ( ). There are two main types of numerical methods for
root finding; these are bracketing and open methods.
Bracketing Methods
Remember that the bisection and the false-position methods are the two bracketing methods which apply the
following algorithm:
1) Choose a lower initial-guess
and an upper initial-guess
such that ( ) ( ) < 0
2) The root estimate
is calculated as:
=
(
(
)(
)
)
)
Open methods
Open methods (e.g. fixed-point iteration, Newton-Raphson and Secant methods) usually converge much
faster than bracketing methods, but they sometimes diverge.
-It can be shown that when the fixed-point iteration method converges, the error is roughly proportional to
and less than the error at the previous step. Thus, fixed-point iteration has linear convergence.
- It can be shown that when the Newton-Raphson method converges, the error is roughly proportional to the
square of the error at the previous step. Thus, the Newton-Raphson method has quadratic convergence.
The Newton-Raphson Method
Let be an approximation for
such that ( ) 0 and | | is small. Note that
the root of ( ) i.e. ( ) = 0 . Apply Taylor Series expansion of ( ) about to get,
(
)=0= ( )+
( )(
)+
( )
(
2!
Dropping all the second and higher-order terms leads to: 0 ( ) + ( )( ) . This is a reasonable
approximation if is close enough to . Solving for gives, ( )/ ( ). The Newton-Raphson
Method says that if we start with an initial guess of for the root, an improved estimate
is given by:
=
( )
( )
( )
,
( )
) ( )
,
( )(
)
(
) ( )
)( )
)(
)
)( )
)(
)
(
(
)(
)(
)
)
Example2: Find a real root (or zero) of the polynomial function ( ) = 4.5
fzero. Try an initial guess of 2.
Solution2a: >> f=@(x) x.^3-4.5*x.^2+6.25*x-3.125; xsol=fzero(f,2)
xsol =
2.500000000000000
>> xsol=fzero('polyeqn',2)
xsol =
xsol =
2.500000000000000
2.500000000000000
)=0 ,
,,
( ,
,,
)=0 ,
( ,
,,
)=0
)=[
,,
( ,
,,
( ,
,,
( ,
)]
,,
Hence, we can express this system of n nonlinear equations with n unknowns in a concise form as
where 0 is a column vector of zeros.
( ) = 0
( ,
Define
)=0 ,
,,
,,
( ,
) = 0 for
=[
guesses). Then,
,,
( ,
,,
)=0
] which corresponds to the values of the latest root estimates (or the initial
=[
,,
)=0 ,
( )
( )
( )]
where
)=
( )+
+ +
)=
( )+
++
++
)=
( )+
All the partial derivatives are evaluated at . Set ( ) (i.e. the left-hand side of the above equations) to
zero so as to solve for the new root estimates . Finally, the following equation is obtained where ( ) is
] .
the Jacobian matrix of the system. Recall that = [
( )=
( )
= ( )
1
1
1
2
2
1
2
=
where
=
2
Note that the evaluation of the inverse of ( ) is computationally expensive. Therefore, the above system of
equations is written in an alternative form as follows:
( )(
)= ( ),
( )
= ( )
The equation ( )
= ( ) can be solved by Gauss Elimination to find
and then
is
obtained by adding
to . Gauss Elimination is the preferred way of solving linear system of equations
in terms of computation time and numerical accuracy (see Matlabs help file for the function inv).
Continuation
In Newtons Method, we need a good initial guess to find the roots. The set of equations we want to solve
can be expressed as ( ; ) = 0 where is the exact vector of roots for the parameter in the problem
and 0 is a column vector of zeros. Suppose we calculated the root for the value of the parameter
i.e.
( ; ) 0. However, we would also like to find the root for a different parameter value
. If
,
then would be a good initial guess. But if
is not sufficiently close to , then we should apply the
technique called continuation. In this technique, we form a sequence of s as follows:
=
+(
= 1,2, ,
then
and Newtons Method should converge quickly. Then, we solve ( ; ) 0 using as the
initial guess. This procedure is applied repeatedly until we reach the parameter value . The technique
given here can be generalised for a system of equations with many parameters.
Example3: A single-cylinder engine model, composed of three moving links, is shown below. The link
lengths are given as a 4 and b 8 . Calculate numerically the values of the joint variables s and when
the crank angle is = 30. Apply Newtons Method. The initial guesses for s and are
= 10 and
= 150, respectively.
Solution3: The kinematic equations for the given mechanism can be written as:
( )= +
( ) and
( )=
( )
( )
( ) = 0 and
( )
( )=
( ),
1
0
] =[
= 0,
( )=
( )=0
( )
=
( )
2
1
] . Then,
( )
( )
( )
] with
components.
2) The -norm (or max-norm) of is equal to the maximum component (in absolute value).
= max | |
3) The 1-norm (or
-norm) of is
=
| |
These different norms can be calculated by the function norm in Matlab; please read the help files.
( )
function F=pistoneqn(x)
global a b th
F=[a*cos(th)-x(1)-b*cos(x(2));
a*sin(th)-b*sin(x(2))
];
Then, use the initial guess x0 and type the following statements in the command window. (Note that the
angles must be in radians). Note that in the below statements, th corresponds to the angle .
>> global a b th; th=30*pi/180; a=4; b=8;
>> x0=[10; 150*pi/180]; [x,Fval]=fsolve(@pistoneqn,x0)
Optimization terminated: first-order optimality is less than options.TolFun.
x =
11.210068316000402
2.888912398711557
Fval =
1.0e-008 *
-0.792012944117459
0.204371120027247
The statement [x,Fval]=fsolve(@pistoneqn,x0) returns the value of the objective function pistoneqn at
the solution x.
See that the solution is (1) = = 11.210068316000402 and (2) = = 2.888912398711557 165.52
Note that there is an exact (analytical) solution which is given as follows:
=
( )
for
= 30 are
( )
( )
= 11.210068307552588 and
= 2.888912398447714.
Example5: Matrix equations can also be solved using fsolve. Solve the equation
where is the (2 2) identity matrix and
+4 =4 +
4 3
5 6
Solution5: Write a function m-file by putting the equation into the form F(X) = 0
function F=matrixeqn1(X)
F=X^2-4*X+4*eye(2)-[4 3;5 6];
-0.088103007556128
0.127717447284681
Show that three other solutions are also possible as given below. Try different initial guesses to find them.
X=[1/4 -3/4; -5/4 -1/4],
1/2],
X=[15/4
3/4; 5/4
17/4]
( + ) ( )
where is the step size which must be small and is the column vector whose only nonzero element is 1 in
the
coordinate. In Newton's method, if we approximate the Jacobian matrix using such finite difference
approximations, then the resulting method is called Finite-difference Newton's method. However, the
evaluation of each function can be expensive and we still have to solve the linear system involving the
approximate Jacobian matrix.
In order to circumvent the shortcomings mentioned in the previous paragraphs, algorithms called QuasiNewton methods were devised. Quasi-Newton methods replace the Jacobian matrix in Newton's method with
an approximate Jacobian matrix which is updated at each iteration. This is very useful if the Jacobian matrix
is difficult to calculate. The most well-known Quasi-Newton method is Broyden's method which utilises a
generalisation of the Secant method to systems of nonlinear equations. In Quasi-Newton methods, the
quadratic convergence of Newton's method is lost but the number of arithmetic calculations is significantly
reduced.
Broyden's Method
Recall the Secant method for a single nonlinear equation which replaces the derivative term
Newton-Raphson method by the backward finite-divided difference
( )
) ( )
( ) of the
) = ( ) (
(2.1)
In Eqn.(2.1),
is an approximation for the Jacobian matrix. However, the secant equation (Eqn.(2.1)) does
not determine
uniquely since Eqn.(2.1) is a system of
equations with
unknowns (there are
elements of to be determined).
In order to start Broyden's Method, we use an initial guess for the solution of the system ( ) = 0. We
calculate the next approximation (i.e. next root estimate) using Newton's method as shown in Eqn.(2.2).
( )
= ( )
(2.2)
If the calculation of ( ) is computationally expensive, we can approximate the partial derivatives using
finite differences. Now, let
= ( ). For the next steps (i.e. iterations), we do not want to use the exact
values of the Jacobian matrix. At each iteration, we would like to use an approximation for the Jacobian
matrix which can be calculated cheaply. As indicated in Eqn.(2.1), we would like to use
in place of ( )
so that we can obtain a cheap solution of ( ) = 0 as given in Eqn.(2.3).
( )
(2.3)
In order to determine
uniquely, an extra condition is needed. In a convergent numerical solution, the
Jacobian matrices from successive iterations are close to each other, then we should be able to update
cheaply an approximate Jacobian matrix from iteration to iteration. Consider two successive approximate
Jacobian matrices
and
(see Eqn.(2.3)). Broyden's method ensures that
is as close as possible to
while satisfying the secant equation (or condition)
by minimising the Frobenius norm
given in (2.1). Applying these conditions provides a unique solution for
as given in Eqn.(2.4).
=
(2.4)
In Eqn.(2.4),
= ( ) ( ) and =
. Eqn.(2.4) is called Broyden update formula. Thus,
once we obtain
from Eqn.(2.4), we use Eqn.(2.3) to calculate
for 1. Some authors advise
(
)
resetting to
at some steps without increasing the computational time considerably.
Note: For an
Notice that applying Eqn.(2.3) still requires the solution of an linear system of equations but we can
avoid this requirement by employing a matrix inversion formula of Sherman and Morrison as described
below. Consider an matrix which has the form
= + where and are given column
vectors in . is the outer product of and , thus = . The modification of to obtain
is called rank-one update since the matrix has rank one as every column of is a scalar multiple
of . Notice that Eqn.(2.4), which is the Broyden update formula, has the form
=
+ where
=(
)/ and = .
Sherman-Morrison formula says that if is a nonsingular square matrix and, and are column vectors,
then + is nonsingular. Then, provided that 1 +
0, the Sherman-Morrison formula is
( +
(2.5)
1+
Notice that the Sherman-Morrison formula applies to our problem when we let
= and =
in Eqn.(2.5). Then we can write
(2.6)
)/
1+
=(
directly from
= +
) ( +
)=
1+
+
1+
+
1+
= +
= +
See that
(1 +
1+
(1 +
1+
1+
is a scalar, then
= +
=(
) ( +
(
1+
= +
1+
)= .
) + 0.5
+ 0.1)
+ (10 3)/3 = 20
Solve this system using Broydens Method with an initial guess of = [0.1 0.1 0.1] . Apply the
Sherman-Morrison formula for matrix inversion.
Solution6: First of all, we have to put the equations in the form
( ) =
( ) = 0 .
) 0.5
3 cos(
(
)
+ sin
+ 1.06 81( + 0.1)
10 3
+
+ 20
3
For the first step, we will use the exact ( ) therefore we need to determine the Jacobian matrix ( )
analytically. For this purpose, we can use the functions of Symbolic Math Toolbox of Matlab. The Matlab
functions that we will use are syms, jacobian, double, subs and inv. In the Matlab command window,
type the following statements.
>> syms f1 f2 f3 x1 x2 x3
>> f1=3*x1-cos(x2*x3)-0.5;
>> f2=x1^2-81*(x2+0.1)^2+sin(x3)+1.06;
>> f3=exp(-x1*x2)+20*x3+(10*pi-3)/3;
>> J=jacobian([f1, f2, f3], [x1, x2, x3])
J =
[
[
3,
x3*sin(x2*x3), x2*sin(x2*x3)]
cos(x3)]
[ -x2*exp(-x1*x2), -x1*exp(-x1*x2),
20]
10
A0 =
3.000000000000000
0.000999983333417
0.200000000000000 -32.399999999999999
-0.099004983374917
-0.099004983374917
-0.000999983333417
0.995004165278026
20.000000000000000
0.000010238518631
0.000016157012988
0.002108606838122
-0.030868825519714
0.001535835927053
0.001660520446129
-0.000152757694651
0.050007682751761
( ). We determine
where = and
= ( ) ( ). Using Eqn.(2.3) together with Eqn.(2.6), we will continue
our iterations until ( ) <
where
is a stopping criterion. The given system of equations are
solved using = 10 and the results are given below.
At iteration no.1 the root estimates xr=[x1;x2;...;xn] are:
4.9986967293e-01
1.9466848537e-02
-5.2152047194e-01
The corresponding inf-norm of F(x) at xr is 3.4439e-01
At iteration no.2 the root estimates xr=[x1;x2;...;xn] are:
4.9998637546e-01
8.7378392993e-03
-5.2317457440e-01
The corresponding inf-norm of F(x) at xr is 1.4738e-01
At iteration no.3 the root estimates xr=[x1;x2;...;xn] are:
5.0000659706e-01
8.6727355579e-04
-5.2357234149e-01
The corresponding inf-norm of F(x) at xr is 1.4081e-02
11
12