lecture13
lecture13
An Example
The LORAN (LOng RAnge Navigation) system calculates the position of a boat at sea using signals from
fixed transmitters. From the time differences of the incoming signals, the boat obtains differences of distances
to the transmitters. This leads to two equations each representing hyperbolas defined by the differences of
distance of two points (foci). An example of such equations1 are
x2 y2
− = 1 and
1862 3002 − 1862
(13.1)
(y − 500)2 (x − 300)2
2
− = 1.
279 5002 − 2792
Solving two quadratic equations with two unknowns would require solving a 4 degree polynomial equation.
We could do this by hand, but for a navigational system to work well, it must do the calculations automat-
ically and numerically. We note that the Global Positioning System (GPS) works on similar principles and
must do similar computations.
Vector Notation
In general, we can usually find solutions to a system of equations when the number of unknowns matches
the number of equations. Thus, we wish to find solutions to systems that have the form
f1 (x1 , x2 , x3 , . . . , xn ) = 0
f2 (x1 , x2 , x3 , . . . , xn ) = 0
f3 (x1 , x2 , x3 , . . . , xn ) = 0 (13.2)
..
.
fn (x1 , x2 , x3 , . . . , xn ) = 0.
f (x) = 0,
i.e. we wish to find a vector that makes the vector function equal to the zero vector.
1
E. Johnston, J. Mathews, Calculus, Addison-Wesley, 2001
53
54 LECTURE 13. NONLINEAR SYSTEMS - NEWTON’S METHOD
As in Newton’s method for one variable, we need to start with an initial guess x0 . In theory, the more
variables one has, the harder it is to find a good initial guess. In practice, this must be overcome by using
physically reasonable assumptions about the possible values of a solution, i.e. take advantage of engineering
knowledge of the problem.
In the single variable case, Newton’s method was derived by considering the linear approximation of the
function f at the initial guess x0 . From Calculus, the following is the linear approximation of f at x0 , for
vectors and vector-valued functions:
f (x) ≈ f (x0 ) + Df (x0 )(x − x0 ).
Here Df (x0 ) is an n × n matrix whose entries are the various partial derivative of the components of f ,
evaluated at x0 . Specifically,
∂f ∂f1 ∂f1 ∂f1
∂x1 (x0 )
1
∂x2 (x0 ) ∂x3 (x0 ) . . . ∂xn (x0 )
∂f2 ∂f2 ∂f2 ∂f2
∂x1 (x0 ) ∂x2 (x0 ) ∂x3 (x0 ) . . . ∂xn (x0 )
Df (x0 ) = . (13.3)
.. .. .. .. ..
. . . . .
∂fn ∂fn ∂fn ∂fn
∂x1 (x0 ) ∂x2 (x 0 ) ∂x3 (x 0 ) . . . ∂xn (x0 )
Newton’s Method
We wish to find x that makes f equal to the zero vectors, so let’s choose x1 so that
f (x0 ) + Df (x0 )(x1 − x0 ) = 0.
Since Df (x0 ) is a square matrix, we can solve this equation by
x1 = x0 − (Df (x0 ))−1 f (x0 ),
provided that the inverse exists. The formula is the vector equivalent of the Newton’s method formula we
learned before. However, in practice we never use the inverse of a matrix for computations, so we cannot
use this formula directly. Rather, we can do the following. First solve the equation
Df (x0 )∆x = −f (x0 ) , (13.4)
where we want to have
∆x = x1 − x0 .
Since Df (x0 ) is a known matrix and −f (x0 ) is a known vector, this equation is just a system of linear
equations, which can be solved efficiently and accurately. Once we have the solution vector ∆x, we can
obtain our improved estimate x1 by
x1 = x0 + ∆x.
x3+y=1,
3
y −x=−1
4
0
y
−1
−2
−3
−4
−4 −3 −2 −1 0 1 2 3 4
x
Figure 13.1: Graphs of the equations x3 + y = 1 and y 3 − x = −1. There is one and only one
intersection; at (x, y) = (1, 0).
An Experiment
We can put these equations into vector-function form (13.2) by letting x1 = x, x2 = y and
f1 (x1 , x2 ) = x31 + x2 − 1
f2 (x1 , x2 ) = x32 − x1 + 1 ,
or, equivalently,
x31 + x2 − 1
f (x) = .
x32 − x1 + 1
The partial derivatives are
∂f1 ∂f1 ∂f2 ∂f2
= 3x21 , = 1, = −1, and = 3x22 . (13.6)
∂x1 ∂x2 ∂x1 ∂x2
Thus,
3x21
1
Df = . (13.7)
−1 3x22
56 LECTURE 13. NONLINEAR SYSTEMS - NEWTON’S METHOD
Now that we have the equations in vector-function form, we can write the following script program:
format long ;
f = @ ( x )[ x (1)^3+ x (2) -1 ; x (2)^3 - x (1)+1 ]
x = [.5;.5]
x = fsolve (f , x )
Save this program as myfsolve.m and run it. You will see that the internal Matlab solving command
fsolve approximates the solution, but only to about 7 decimal places. While that would be close enough
for most applications, one would expect that we could do better on such a simple problem.
Next we will implement Newton’s method for this problem. Modify your myfsolve program to:
% mymultnewton - solve an example nonlinear system
format long ;
n =8 % set some number of iterations , may need adjusting
f = @ ( x )[ x (1)^3+ x (2) -1 ; x (2)^3 - x (1)+1] % the vector function
% the matrix of partial derivatives
Df = @ ( x )[3* x (1)^2 , 1 ; -1 , 3* x (2)^2]
x = [.5;.5] % starting guess
for i = 1: n
Dx = - Df ( x )\ f ( x ); % solve for increment
x = x + Dx % add on to get new guess
f(x) % see if f ( x ) is really zero
end
Save and run this program (as mymultnewton) and you will see that it finds the root exactly (to machine
precision) in only 6 iterations. Why is this simple program able to do better than Matlab’s built-in program?
Exercises
13.1 (a) Put the LORAN equations (13.1) into the function form (13.2).
(b) Calculate (by hand) the partial derivatives of f and construct the matrix Df (see (13.6) and
(13.7)).
(c) Adapt the mymultnewton program to find a solution for these equations. By trying different
starting vectors, find at least three different solutions. (There are actually four solutions.)
(d) Think of at least one way that the navigational system could determine the correct solution.