5 Linear Homotopy

advertisement
Algebraic Geodesy and Geoinformatics - 2009 PART I METHODS
5 Linear Homotopy
5- 1 Introduction
Most often, there exist a fundamental task of solving systems of equations in geodesy. In such cases, many geodetic problems
are represented as systems of multivariate polynomials. Frequently the bottleneck in solving such systems is to find out
proper initial starting values for iterative methods, which lead to convergence to solutions with physical meaning. Although
symbolic methods such as Groebner basis or resultants have been shown to be very efficient, providing solutions for systems
of only modest size. In addition, in some cases the nonlinear equations representing the geodetic problems are not polynomial
ones. Therefore, in case of some real life problems one should employ global numerical methods to avoid initial value
problem.
Using numerical algorithms to solve polynomial systems with tools originating from algebraic geometry is the main activity
in the so called Numerical Algebraic Geometry. This is a new developing field on the crossroads of algebraic geometry,
numerical analysis, computer science and engineering. Homotopy continuation method is a global numerical method to solve
not only polynomial systems, but also nonlinear system in general.
5- 2 Definition and basic concepts
The continuous deformation of an object to an other object is known as homotopy. Let us consider two univariate polynomials p1 and q1 of the same degree,
p1 HxL = x2 - 3
q1 HxL = -x2 - x + 1
Define the linear convex function, H in variables x and Λ, called as homotopy function as,
H Hx, ΛL = H1 - ΛL p1 HxL + Λ q1 HxL
In geometric terms, the homotopy H provides us a continuous, smooth deformation from p1 -which is obtained for Λ = 0 by
H(x, 0) - to q1 - which is obtained for Λ = 1 by H(x, 1). The homotopy function can be seen in the figure 5.1 for different Λ
values, Λ = 0., 0.1,...,1. We call it linear homotopy because H is a linear function of the variable Λ.
Let us define these functions,
2
Linear_Homotopy_05.nb
Clear@"Global‘*"D
p1 @x_D := x2 - 3
q1 @x_D := - x2 - x + 1
H@x_, Λ_ D := H1 - ΛL p1 @xD + Λ q1 @xD
Now we can plot the homotopy function with different constant Λ values, illustrating the deformation of p1 (x) into q1 (x).
Show@
8Plot@Table@H@x, ΛD, 8Λ, 0, 1, 0.1<D, 8x, - 2, 1.5<, AxesLabel ® 8"x"<, ImageSize ® 300D,
Graphics@Text@"p1 ", 8- 0.5, - 3.<DD, Graphics@Text@"q1 ", 80.35, 0.8<DD,
Graphics@Text@"H Hx,ΛL", 80.3, 1.25<DD<D
HHx,ΛL
1
-2.0
-1.5
-1.0
q1
x
-0.5
0.5
1.0
1.5
-1
-2
p1
-3
Fig. 5.1 Deformation of the function H from p1 to q1 as function of Λ
Now let us consider two univariate polynomials p2 and q2 of the different degrees,
p2 HxL = x2 - 1
q2 HxL = x2 Define the linear convex homotopy again with,
1
4
Ix2 - 4M
H Hx, ΛL = H1 - ΛL p2 HxL + Λ q2 HxL
Similarly, the functions are
p2 @x_D := x2 - 1
q2 @x_D := x2 -
1
4
Ix2 - 4M
H@x_, Λ_ D := H1 - ΛL p2 @xD + Λ q2 @xD
and
Linear_Homotopy_05.nb
Show@8Plot@Table@H@x, ΛD, 8Λ, 0, 1, 0.1<D, 8x, - 2.5, 2.5<, AxesLabel ® 8"x"<D,
Graphics@Text@" p2 ", 8- 1.5, 2.<DD, Graphics@Text@"q2 ", 80.9, - 2.4<DD<D
8
6
4
p2
2
-2
x
-1
1
-2
2
q2
Fig. 5.2 Deformation of the function H from p2 to q2 as function of Λ
5- 3 Solving nonlinear equation via homotopy
Homotopy continuation method deforms the known roots of the start system into the roots of the target system. Now, let us
look at how homotopy can be used to solve a simple polynomial equation. Consider the polynomial equation of degree two,
q HxL = x2 + 8 x - 9 = 0
q@x_D := x2 + 8 x - 9
By deleting the middle term, we can get a more simple equation, which can be solved easily by inspection,
p@x_D := x2 - 9
This equation also has two roots and will be considered as start system for the target system. The linear homotopy can be
defined as it follows
H@x_, Λ_ D := H1 - ΛL p@xD + Λ q@xD
or
H@x, ΛD  Expand
- 9 + x2 + 8 x Λ
Let us plot the homotopy H for the polynomials p(x) and q(x)
Show@8Plot@Table@H@x, ΛD, 8Λ, 0, 1, 0.1<D, 8x, - 10, 10<, AxesLabel ® 8"x"<D,
Graphics@Text@"pHxL", 88, 35.<DD, Graphics@Text@"qHxL", 88, 140<DD<D
150
qHxL
100
50
pHxL
-10
-5
x
5
10
Fig. 5.3 Deformation of the function H from p HxL to q HxL as function of Λ
3
4
Linear_Homotopy_05.nb
Fig. 5.3 Deformation of the function H from p HxL to q HxL as function of Λ
Homotopy continuation method deforms p(x) = 0, the known roots of the start system, into q(x) = 0, the roots of the target
system. Let us solve the equation H(x, Λ) = 0 for different values of Λ. Considering x0 = 3 one of the solutions of p(x) = 0
as initial guess value, and solving H(x, Λ1 ) = 0, where let Λ1 = 0.2, employing Newton-Raphson method subsequently, we get
x0 = 3; Λ1 = 0.2; x1 = x . FindRoot@H@x, Λ1 D == 0, 8x, x0 <D
2.30483
Using the result as guess value for the next solution step
Λ2 = 0.4; x2 = x . FindRoot@H@x, Λ2 D == 0, 8x, x1 <D
1.8
and so on,
Λ3 = 0.6; x3 = x . FindRoot@H@x, Λ3 D == 0, 8x, x2 <D
1.44187
Λ4 = 0.8; x4 = x . FindRoot@H@x, Λ4 D == 0, 8x, x3 <D
1.18634
Λ5 = 1; x5 = x . FindRoot@H@x, Λ5 D == 0, 8x, x4 <D
1.
Let us display the transition of a root of the polynomial p(x) into a root of the polynomial q(x),
Show@8Plot@Table@H@x, ΛD, 8Λ, 0, 1, 0.2<D, 8x, 0, 5<, AxesLabel ® 8"x"<D,
ListPlot@883, 0<, 8x1 , 0<, 8x2 , 0<, 8x3 , 0<, 8x4 , 0<, 8x5 , 0<<,
PlotStyle -> 8PointSize@0.016D, RGBColor@1, 0, 0D<D,
Graphics@Text@"pHxL", 85, 10.<DD, Graphics@Text@"qHxL", 84, 45<DD<D
50
qHxL
40
30
20
pHxL
10
x
1
2
3
4
5
-10
Fig. 5.4 The transition of the root from x = 3 to x = 1 during the deformation of the function H
The homotopy path is the function x = x (Λ), where in every point H (x,Λ) = 0.
Fig. 5.5 shows the path of homotopy transition of the root of p(x) into the root of q(x).
Λ0 = 0.;
Show@8ListPlot@Table@8Λi , xi <, 8i, 0, 5<D, Joined ® True, AxesLabel ® 8"Λ", "xHΛL"<D,
ListPlot@Table@8Λi , xi <, 8i, 0, 5<D, PlotStyle ® 8PointSize@0.016D, RGBColor@1, 0, 0D<D,
Graphics@8Text@"pH3L=0", 80.12, 2.95<D, Text@"qH1L=0", 80.95, 1.25<D<D <D
Linear_Homotopy_05.nb
xHΛL
3.0
pH3L=0
2.5
2.0
1.5
qH1L=0
Λ
0.2
0.4
0.6
0.8
1.0
Fig. 5.5 The homotopy path is the function x = x (Λ), where in every point H = 0.
5- 4 Tracing homotopy path as initial value problem
Comparing homotopy solution with the traditional Newton-Raphson solution, it is clear that if DΛ is small enough, the
convergence may be ensured in every step.
However, one can consider this root tracing procedure as an initial value problem of an ordinary differential equation. Since
H (x, Λ) = 0 for every Λ Î [0, 1], therefore
dH Hx, ΛL =
¶H
¶x
dx +
Then the initial value problem is
Hx
with
¶H
¶Λ
dx HΛL
dΛ
dΛ º 0
Λ Î @0, 1D
+HΛ= 0
x H0L = x0
Here Hx is the Jacobian of H with respect to xi , i = 1,..., n, in case of n nonlinear equations with n variables.
In our single variable case, the two partial derivates of the homotopy function are
dHdΛ = D@H@x, ΛD, ΛD
8x
dHdx = D@H@x, ΛD, xD
2 x H1 - ΛL + H8 + 2 xL Λ
Then the right hand side of the differential equation to be solved is
dHdΛ
deqrhs = dHdx
. x -> x@ΛD
8 x@ΛD
-
2 H1 - ΛL x@ΛD + Λ H8 + 2 x@ΛDL
The differential equation,
5
6
Linear_Homotopy_05.nb
deq = D@x@ΛD, ΛD == deqrhs
x¢ @ΛD Š -
8 x@ΛD
2 H1 - ΛL x@ΛD + Λ H8 + 2 x@ΛDL
The initial value is
x0 = x0
3
The numerical solution
sol = NDSolve@8deq, x@0D Š x0<, 8x@ΛD<, 8Λ, 0, 1<D
88x@ΛD ® InterpolatingFunction @880., 1.<<, <>D@ΛD<<
The trajectory is the homotopy path,
Plot@x@ΛD . sol, 8Λ, 0, 1<, AxesLabel ® 8"Λ", "xHΛL"<,
Epilog ® 8PointSize@0.016D, Blue, Point@80, x0<D,
PointSize@0.016D, Red, Point@81, First@Hx@ΛD . solL . Λ ® 1D<D<D
xHΛL
3.0
2.5
2.0
1.5
Λ
0.2
0.4
0.6
0.8
1.0
Fig. 5.6 The trajectory of the solution as the homotopy path
The value of the corresponding root of q(x) is x(Λ) at Λ =1,
First@x@ΛD . sol . Λ ® 1D
1.
5- 5 Types of linear homotopy
5- 5- 1 General linear homotopy
As we have seen , the start system can be constructed intuitively, reducing the original system (target system) to a more
simple system (start system), which roots can be easily computed. In order to get all of the roots of the target system, the start
system should have so many roots as many the target system has.
The start system can be constructed in different ways, however there are two typical techniques for generating the start
sytems, which are usually employed.
Linear_Homotopy_05.nb
5- 5- 2 Fixed-point homotopy
The start system can be considered as
p HxL = x - x0
where x0 is a guess value for the root of the target system q HxL = 0.
In that case the homotopy function is
H Hx, ΛL = H1 - ΛL Hx - x0 L + Λ q HxL
5- 5- 3 Newton homotopy
An other construction for the start system, when we consider p(x) as
p HxL = q HxL - q Hx0 L
in that case the homotopy function is
or
H Hx, ΛL = H1 - ΛL Hq HxL - q Hx0 LL + Λ q HxL
H Hx, ΛL = q HxL - H1 - ΛL q Hx0 L
There are other methods to construct start system for linear homotopy. In a section, following later, we shall see how one
can define start system for polynomial systems automatically.
It is known that local methods, like Newton-Raphson method, require initial guess of a root, which is close to the intended
root for the particular application. Global methods, like homotopy continuation method can find solution from a start guess,
which is far from the solution. Now, we shall illustrate some situations when Newton-Raphson method fails, but homotopy
method can be successful. We shall consider two usual problems with the Newton-Raphson method, namely when the
Jacobi matrix is singular or when the convergency is too slow.
5- 6 Newton-Raphson vs. homotopy method
5- 6- 1 Singular Jacobi matrix
Let us consider the following univariate polynomial of degree three,
q HxL = 27 x3 + 108 x2 + 108 x + 40
This polynomial has one real and two conjugate complex roots.
q@x_D := 27 x3 + 108 x2 + 108 x + 40
Plot@q@xD, 8x, - 3, 1<, AxesLabel ® 8"x", "qHxL"<, ImageSize ® 350D
7
8
Linear_Homotopy_05.nb
qHxL
100
50
-3
-2
-1
x
1
Fig. 5.7 The real root of the polynomial
Let us try to find the real root using Newton- Raphson method, with an initial guess value x0 = -2,
FindRoot@q@xD, 8x, - 2<D
FindRoot::jsing : Encountered a singular Jacobian at the point 8x< = 8-2.<. Try perturbing the initial pointHsL. ‡
8x ® - 2.<
This method also fails when x0 = -1.5
FindRoot@q@xD, 8x, - 1.5<D
FindRoot::lstol :
The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal
but was unable to find a sufficient decrease in the merit function. You may need
more than MachinePrecision digits of working precision to meet these tolerances. ‡
8x ® - 0.666667<
Now we use homotopy method. Let us employ fixed- point homotopy with x0 = -2,
Fig. 5.8 shows the plot of fixed - point homotopy curves for target system q HxL in case of x0 = -2,
x0 = - 2;
H@x_, Λ_ D := H1 - ΛL Hx - x0L + Λ q@xD
Show@8Plot@Table@H@x, ΛD, 8Λ, 0, 1, 0.1<D, 8x, - 3, - 2<,
AxesLabel ® 8"x", "pHxL,qHxL"<, PlotRange -> 8- 10, 40<, ImageSize ® 350D,
Graphics@8Text@"pHxL=x - x0 ", 8- 2.15, 1.5<D, Text@"qHxL", 8- 2.45, 31<D<D<D
Linear_Homotopy_05.nb
pHxL,qHxL
40
qHxL
30
20
10
pHxL=x - x0
-2.8
-2.6
-2.4
-2.2
-2.0
x
-10
Fig. 5.8 The homotopy function of the problem with parameter Λ
Let us generate the fixed - pont homotopy path for q HxL = 0 in case of x0 = -2,
D@H@x, ΛD, ΛD
rhs = D@H@x, ΛD, xD
. x -> x@ΛD; 0
sol = NDSolve@8D@x@ΛD, ΛD Š rhs, x@0D Š x0<, 8x@ΛD<, 8Λ, 0, 1<D;
Plot@x@ΛD . sol, 8Λ, 0, 1<, PlotRange -> 8- 1.9, - 2.9<, AxesLabel ® 8"Λ", "xHΛL"<,
Epilog ® 8PointSize@0.016D, Blue, Point@80, x0<D, PointSize@0.016D,
Red, Point@81, First@Hx@ΛD . solL . Λ ® 1D<D<, ImageSize ® 350D
0
xHΛL
-2.0
-2.2
-2.4
-2.6
Λ
0.2
0.4
0.6
Fig. 5.9 The homotopy path of the problem
A value of the real root is
First@x@ΛD . sol . Λ ® 1D
- 2.73587
This fixed-point homotopy also works with x0 = - 1.5.
5- 6- 2 Slow convergency
Let us consider now a two- dimensional problem. The target sytem is
0.8
1.0
9
10
Linear_Homotopy_05.nb
f1 Hx, yL = x2 - x y - 1
f2 Hx, yL =
x+1 +y
Fig. 5.10 shows the contour plot of the system of equations in case of f1 = 0 and f2 = 0
f1@x_, y_D := x ^ 2 - x y - 1
f2@x_, y_D := Sqrt@x + 1D + y
Show@8ContourPlot@8f1@x, yD Š 0, f2@x, yD Š 0<, 8x, - 1.1, 2<, 8y, - 2, 1<,
FrameLabel ® 8"x", "y"<, ImageSize ® 350D, Graphics@8Text@"f1 Hx, yL=0", 81.43, 0<D,
Text@"f2 Hx, yL=0", 8- 0.5, - 1<D, Text@"f1 Hx, yL=0", 8- 0.45, 0.3<D<D<D
1.0
0.5
f1 Hx, yL=0
f1 Hx, yL=0
y
0.0
-0.5
f2 Hx, yL=0
-1.0
-1.5
-2.0
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
x
Fig. 5.10 The real roots of the nonlinear system
We try Newton-Raphson method with x0 = - 0.1 and y0 = 0.5,
x0 = - 0.1; y0 = 0.5;
FindRoot@8f1@x, yD, f2@x, yD<, 8x, x0<, 8y, y0<D
FindRoot::cvmit : Failed to converge to the requested accuracy or precision within 100 iterations. ‡
9x ® - 1. - 0.0000512881 ä, y ® 4.30262 ´ 10-7 - 0.000102576 ä=
Now let us employ Newton homotopy,
H@x_, y_, Λ_ D := FlattenB- H1 - ΛL K
f1@x0, y0D
f1@x, yD
O+ K
OF
f2@x0, y0D
f2@x, yD
H@x, y, ΛD
:- 1 + x2 - x y - 0.94 H- 1 + ΛL,
1 + x + y + 1.44868 H- 1 + ΛL>
Let us generate the contour plot of the start system in case of Newton homotopy with x0 = - 0.1 and y0 = 0.5,
Linear_Homotopy_05.nb
Show@8ContourPlot@H@x, y, 0D@@1DD == 0, 8x, - 1, 2<, 8y, - 2, 1<,
FrameLabel ® 8"x", "y"<, ImageSize ® 350D, Graphics@Text@"HHx,y,0L = 0", 80.75, - 1<DD,
ContourPlot@H@x, y, 0D@@2DD == 0, 8x, - 1, 2<, 8y, - 2, 1<, ImageSize ® 350D<D
1.0
0.5
y
0.0
-0.5
HHx,y,0L = 0
-1.0
-1.5
-2.0
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
x
Fig. 5.11 The homotopy function contours at H = 0
Let us define a function for the Jacobi computation as it follows,
Jacobi@F_, X_D := Outer@D, F, XD
¶H ¶H ¶H
)
¶y ¶Λ
Then the total Jacobian, ( ¶x
JxyΛ = Jacobi@H@x, y, ΛD, 8x, y, Λ<D; MatrixForm@JxyΛD
2 x - y -x
1
2
1
- 0.94
1.44868
1+x
The Jacobian respecting to x and y
Jxy = Take@JxyΛ, 81, 2<, 81, 2<D; MatrixForm@JxyD
2 x - y -x
1
2
1
1+x
Now, in case of system of two variables, X ={x, y}, we should solve a linear system in order to get explicit form of the
differential equation system,
HX
namely
dX HΛL
dX HΛL
dΛ
The right hand side of the linear system
dΛ
+HΛ= 0
= -HX -1 H Λ
11
12
Linear_Homotopy_05.nb
The right hand side of the linear system
b = - Take@JxyΛ, 81, 2<, 82 + 1<D; MatrixForm@bD
K
0.94
O
- 1.44868
Solving the linear system, we get
rhs = HLinearSolve@Jxy, bD  SimplifyL . Map@ð ® ð@ΛD &, 8x, y<D  Flatten
:
1. + x@ΛD I- 2.89737 x@ΛD2 - 0.94 y@ΛD + x@ΛD H1.88 + 1.44868 y@ΛDLM
H2. x@ΛD - 1. y@ΛDL J0.5 x@ΛD + 2. x@ΛD
2.89737 x@ΛD +
0.47
- 1.44868 y@ΛD
1.+x@ΛD
2. x@ΛD +
0.5 x@ΛD
,
1. + x@ΛD - 1.
1. + x@ΛD y@ΛDN
>
- 1. y@ΛD
1.+x@ΛD
Then the left hand side of the differential equation system is,
lhs = Map@D@ð@ΛD, 8Λ, 1<D &, 8x, y<D
8x¢ @ΛD, y¢ @ΛD<
Therefore the differential equation system,
deqs = MapThread@ð1 Š ð2 &, 8lhs, SetPrecision @rhs, 20D<D
:x¢ @ΛD Š
J 1.0000000000000000000 + x@ΛD I- 2.8973665961010275360 x@ΛD2 - 0.93999999999999994666
y@ΛD + x@ΛD H1.8799999999999998934 + 1.4486832980505137680 y@ΛDLMN ’
JH2.0000000000000000000 x@ΛD - 1.0000000000000000000 y@ΛDL J0.50000000000000000000
x@ΛD + 2.0000000000000000000 x@ΛD
1.0000000000000000000
1.0000000000000000000 + x@ΛD -
1.0000000000000000000 + x@ΛD y@ΛDNN,
y¢ @ΛD Š - 1.0000000000000000000
2.8973665961010275360 x@ΛD +
0.46999999999999997335
- 1.4486832980505137680 y@ΛD
“
1.0000000000000000000 + x@ΛD
0.50000000000000000000 x@ΛD
2.0000000000000000000 x@ΛD +
1.0000000000000000000 + x@ΛD
1.0000000000000000000 y@ΛD >
Here we used an extra precision because this system is stiff. The initial values are also given in rational form representing
infinite precision. The numerical solution,
sol = NDSolve@Join@deqs, 8x@0D Š - 1  10, y@0D Š 1  2<D,
8x@ΛD, y@ΛD<, 8Λ, 0, 1<, WorkingPrecision ® 20D
88x@ΛD ® InterpolatingFunction @880, 1.0000000000000000000 <<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880, 1.0000000000000000000 <<, <>D@ΛD<<
The plot of the homotopy solution of the system in case of Newton homotopy with x0 = - 0.1 and y0 = 0.5,
Linear_Homotopy_05.nb
13
Show@8Plot@8x@ΛD, y@ΛD< . sol, 8Λ, 0, 1<, FrameLabel ® 8"Λ", "xHΛL, yHΛL"<, Frame ® True,
Epilog ® 8PointSize@0.016D, Blue, Point@880, x0<, 80, y0<<D, PointSize@0.016D, Red,
Point@881, First@Hx@ΛD . solL . Λ ® 1D<, 81, First@Hy@ΛD . solL . Λ ® 1D<<D<D,
Graphics@Text@"xHΛL", 80.6, - 0.6<DD, Graphics@Text@"yHΛL", 80.4, 0.4<DD<D
yHΛL
0.4
0.2
xHΛL, yHΛL
0.0
-0.2
-0.4
-0.6
xHΛL
-0.8
-1.0
0.0
0.2
0.4
0.6
0.8
1.0
Λ
Fig. 5.12 The homotopy paths of the solution
The solution of the system,
8xs, ys< = Flatten@H8x@ΛD, y@ΛD< . solL . Λ ® 1D
9- 0.9999999999999999364 , - 5.3040028184 ´ 10-10 =
We can round these values,
8xs, ys< = 8xs, ys<  Round
8- 1, 0<
5- 7 Regularization of the homotopy function
Sometimes this form of homotopy methods may also fail, because of singularity resulting diverging path. Let us consider the
following system,
f1 Hx, yL = x2 + y - 3
f2 Hx, yL = x +
f1@x_, y_D := x ^ 2 + y - 3
f2@x_, y_D := x + 1  8 y ^ 2 - 1
1
8
y2 - 1
14
Linear_Homotopy_05.nb
Show@8ContourPlot@8f1@x, yD Š 0, f2@x, yD Š 0<,
8x, - 10, 10<, 8y, - 10, 10<, FrameLabel ® 8"x", "y"<D,
Graphics@Text@"f1 Hx,yL=0", 80, - 9<D, Text@"f2 Hx,yL=0", 8- 8, 6.5<DD<D
10
5
y
0
-5
f1 Hx,yL=0
-10
-10
-5
0
5
10
x
Fig. 5.13 The real roots of the polynomial system
First, let us try to solve the problem using Newton- Rapson method, starting with x0 = - 1 and y0 = -1,
FindRoot@8f1@x, yD, f2@x, yD<, 8x, - 1<, 8y, - 1<D
FindRoot::lstol :
The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal
but was unable to find a sufficient decrease in the merit function. You may need
more than MachinePrecision digits of working precision to meet these tolerances. ‡
8x ® 1.56598, y ® 1.27716<
This result is not correct,
8f1@x, yD, f2@x, yD< . %
80.729457, 0.769873<
or with x0 = 1 and y0 = -1,
FindRoot@8f1@x, yD, f2@x, yD<, 8x, 1<, 8y, - 1<D
FindRoot::lstol :
The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal
but was unable to find a sufficient decrease in the merit function. You may need
more than MachinePrecision digits of working precision to meet these tolerances. ‡
8x ® 1.27083, y ® 1.57379<
again, this is not a solution
8f1@x, yD, f2@x, yD< . %
80.188785, 0.580427<
These mean that none of them is a correct solution, Newton - Raphson method fails.
Let us try to solve the problem with homotopy method. We consider the following obvious functions as start system of { f1 ,
f2 } by deleting the low order terms,
Linear_Homotopy_05.nb
15
Let us try to solve the problem with homotopy method. We consider the following obvious functions as start system of { f1 ,
f2 } by deleting the low order terms,
g1@x_, y_D := x ^ 2 - 1
g2@x_, y_D := y ^ 2 - 1
Remark: The degree of the start and the target system should be the same.
Solve@8g1@x, yD Š 0, g2@x, yD Š 0<, 8x, y<D
88x ® - 1, y ® - 1<, 8x ® - 1, y ® 1<, 8x ® 1, y ® - 1<, 8x ® 1, y ® 1<<
The zeros of this system are (1, 1), (-1, 1), (-1, -1) and (1, -1). Let us consider
x0 = 1; y0 = - 1;
The homotopy function is
H@x_, y_, Λ_ D := FlattenBH1 - ΛL K
g1@x, yD
f1@x, yD
O+ ΛK
OF
g2@x, yD
f2@x, yD
H@x, y, ΛD
:I- 1 + x2 M H1 - ΛL + I- 3 + x2 + yM Λ, I- 1 + y2 M H1 - ΛL + - 1 + x +
y2
Λ>
8
The total Jacobian,
JxΛ = Jacobi@H@x, y, ΛD, 8x, y, Λ<D; MatrixForm@JxΛD
2 x H1 - ΛL + 2 x Λ
Λ
Λ
2 y H1 - ΛL +
-2 + y
yΛ
4
x-
7 y2
8
The Jacobian respecting to x and y
Jx = Take@JxΛ, 81, 2<, 81, 2<D; MatrixForm@JxD
2 x H1 - ΛL + 2 x Λ
Λ
Λ
2 y H1 - ΛL +
yΛ
4
Now, we set up the differential equation system for tracing homotopy paths. Explicit form of the differential equation system
should be expressed.
The right hand side of the linear system
b = - Take@JxΛ, 81, 2<, 82 + 1<D; MatrixForm@bD
2-y
-x +
7 y2
8
Solving the linear system, we get the right hand side,
rhs = HLinearSolve@Jx, bD  SimplifyL . Map@ð ® ð@ΛD &, 8x, y<D  Flatten
:
- 8 Λ x@ΛD + 4 H- 8 + 7 ΛL y@ΛD + H16 - 7 ΛL y@ΛD2
4 I2 Λ2 + H- 8 + 7 ΛL x@ΛD y@ΛDM
The left hand side is,
lhs = Map@D@ð@ΛD, 8Λ, 1<D &, 8x, y<D
8x¢ @ΛD, y¢ @ΛD<
Then the differential equation system can be written as,
,
8 x@ΛD2 - 4 Λ H- 2 + y@ΛDL - 7 x@ΛD y@ΛD2
2 I2 Λ2 + H- 8 + 7 ΛL x@ΛD y@ΛDM
>
16
Linear_Homotopy_05.nb
Then the differential equation system can be written as,
deqs = MapThread@ð1 Š ð2 &, 8lhs, rhs<D
:x¢ @ΛD Š
y¢ @ΛD Š
- 8 Λ x@ΛD + 4 H- 8 + 7 ΛL y@ΛD + H16 - 7 ΛL y@ΛD2
4 I2 Λ2 + H- 8 + 7 ΛL x@ΛD y@ΛDM
8 x@ΛD2 - 4 Λ H- 2 + y@ΛDL - 7 x@ΛD y@ΛD2
2 I2 Λ2 + H- 8 + 7 ΛL x@ΛD y@ΛDM
,
>
The numerical solution of the system with the initial values {x0, y0},
sol = NDSolve@Join@deqs, 8x@0D Š x0, y@0D Š y0<D,
8x@ΛD, y@ΛD<, 8Λ, 0, 1<, Method ® "ExplicitRungeKutta "D
NDSolve::ndstf :
At Λ == 0.6638177018550038`, system appears to be stiff. Methods Automatic, BDF or StiffnessSwitching
may be more appropriate. ‡
88x@ΛD ® InterpolatingFunction @880., 0.663818<<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880., 0.663818<<, <>D@ΛD<<
or
sol = NDSolve@Join@deqs, 8x@0D Š x0, y@0D Š y0<D,
8x@ΛD, y@ΛD<, 8Λ, 0, 1<, Method ® "StiffnessSwitching "D
NDSolve::ndsz :
At Λ == 0.6638182484984101`, step size is effectively zero; singularity or stiff system suspected. ‡
88x@ΛD ® InterpolatingFunction @880., 0.663818<<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880., 0.663818<<, <>D@ΛD<<
The integration has failed because singularity of the Jacobi matrix of H(x, y, Λ) occured.
In order to avoid singularity in real field, we consider a modified complex homotopy function,
H Hx, ΛL = Γ H1 - ΛL p1 HxL + Λ q1 HxL
where Γ is a complex number. For almost all choices of a complex constant Γ, all solution paths defined by the homotopy
above are regular, i.e.: for all ΛÎ [0, 1], the Jacobian matrix of H (x, Λ) is regular and no path diverges. Let us now consider,
Γ = 1 + ä;
Then the homotopy function,
H@x_, y_, Λ_ D := FlattenBΓ H1 - ΛL K
g1@x, yD
f1@x, yD
O+ ΛK
OF
g2@x, yD
f2@x, yD
H@x, y, ΛD
:H1 + äL I- 1 + x2 M H1 - ΛL + I- 3 + x2 + yM Λ, H1 + äL I- 1 + y2 M H1 - ΛL + - 1 + x +
y2
Λ>
8
The total Jacobian,
JxΛ = Jacobi@H@x, y, ΛD, 8x, y, Λ<D; MatrixForm@JxΛD
H2 + 2 äL x H1 - ΛL + 2 x Λ
Λ
The Jacobian respecting to x and y
- 3 + x2 - H1 + äL I- 1 + x2 M + y
Λ
H2 + 2 äL y H1 - ΛL +
yΛ
4
-1 + x +
y2
8
- H1 + äL I- 1 + y2 M
Linear_Homotopy_05.nb
Jx = Take@JxΛ, 81, 2<, 81, 2<D; MatrixForm@JxD
H2 + 2 äL x H1 - ΛL + 2 x Λ
Λ
Λ
H2 + 2 äL y H1 - ΛL +
yΛ
4
The right hand side of the linear system
b = - Take@JxΛ, 81, 2<, 82 + 1<D; MatrixForm@bD
3 - x2 + H1 + äL I- 1 + x2 M - y
1-x-
y2
8
+ H1 + äL I- 1 + y2 M
Solving the linear system,
rhs = HLinearSolve@Jx, bD  SimplifyL . Map@ð ® ð@ΛD &, 8x, y<D  Flatten
9I8 Λ H1 - ä x@ΛDL - 2 HH- 8 - 8 äL + H7 + 8 äL ΛL IH- 1 - 2 äL + x@ΛD2 M y@ΛD +
HH- 16 + 16 äL + H8 - 7 äL ΛL y@ΛD2 M ‘ I4 I2 ä Λ2 + I16 - H23 + 9 äL Λ + H7 + 8 äL Λ2 M x@ΛD y@ΛDMM,
I4 HH- 2 + 2 äL + ΛL x@ΛD2 + 4 Λ HH1 + 2 äL - ä y@ΛDL - HH- 1 + äL + ΛL x@ΛD I- 8 ä + H7 + 8 äL y@ΛD2 MM ‘
I2 I2 ä Λ2 + I16 - H23 + 9 äL Λ + H7 + 8 äL Λ2 M x@ΛD y@ΛDMM=
Then the differential equation system is,
lhs = Map@D@ð@ΛD, 8Λ, 1<D &, 8x, y<D
8x¢ @ΛD, y¢ @ΛD<
deqs = MapThread@ð1 Š ð2 &, 8lhs, rhs<D
9x¢ @ΛD Š I8 Λ H1 - ä x@ΛDL -
2 HH- 8 - 8 äL + H7 + 8 äL ΛL IH- 1 - 2 äL + x@ΛD2 M y@ΛD + HH- 16 + 16 äL + H8 - 7 äL ΛL y@ΛD2 M ‘
I4 I2 ä Λ2 + I16 - H23 + 9 äL Λ + H7 + 8 äL Λ2 M x@ΛD y@ΛDMM, y¢ @ΛD Š
I4 HH- 2 + 2 äL + ΛL x@ΛD2 + 4 Λ HH1 + 2 äL - ä y@ΛDL - HH- 1 + äL + ΛL x@ΛD I- 8 ä + H7 + 8 äL y@ΛD2 MM ‘
I2 I2 ä Λ2 + I16 - H23 + 9 äL Λ + H7 + 8 äL Λ2 M x@ΛD y@ΛDMM=
The numerical solution
sol = NDSolve@Join@deqs, 8x@0D Š x0, y@0D Š y0<D, 8x@ΛD, y@ΛD<, 8Λ, 0, 1<D
88x@ΛD ® InterpolatingFunction @880., 1.<<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880., 1.<<, <>D@ΛD<<
The solution of the polynomial system,
H8x@ΛD, y@ΛD< . solL . Λ ® 1
881.5247 + 0.797778 ä, 1.31173 - 2.43275 ä<<
Now we have got a complex root,
17
18
Linear_Homotopy_05.nb
Show@8ParametricPlot @8Re@y@ΛDD, Im@y@ΛDD< . sol,
8Λ, 0, 1<, PlotRange ® All, FrameLabel ® 8"Re", "Im"<, Frame ® True,
Epilog ® 8PointSize@0.02D, Blue, Point@8Re@y0D, Im@y0D<D, PointSize@0.02D, Red,
Point@8First@HRe@y@ΛDD . solL . Λ ® 1D, First@HIm@y@ΛDD . solL . Λ ® 1D<D,
PointSize@0.02D, Blue, Point@8Re@x0D, Im@x0D<D, PointSize@0.02D, Red,
Point@8First@HRe@x@ΛDD . solL . Λ ® 1D, First@HIm@x@ΛDD . solL . Λ ® 1D<D<D,
ParametricPlot @8Re@x@ΛDD, Im@x@ΛDD< . sol, 8Λ, 0, 1<, PlotRange ® AllD,
Graphics@Text@"xHΛL", 81.5, 0.5<DD, Graphics@Text@"yHΛL", 80.5, - 2<DD<D
0.5
xHΛL
0.0
Im
-0.5
-1.0
-1.5
yHΛL
-2.0
-1.0
-0.5
0.0
0.5
1.0
1.5
Re
Fig. 5.14 The homotopy paths on complex plain
Basically, our original system, the target system has four solutions,
NSolve@8f1@x, yD Š 0, f2@x, yD Š 0<, 8x, y<D
88x ® 1.5247 + 0.797778 ä, y ® 1.31173 - 2.43275 ä<,
8x ® 1.5247 - 0.797778 ä, y ® 1.31173 + 2.43275 ä<,
8x ® - 0.115088, y ® 2.98675<, 8x ® - 2.93432, y ® - 5.61022<<
The other roots can be also computed using different start values, namely
x0 = 1; y0 = 1;
sol = NDSolve@Join@deqs, 8x@0D Š x0, y@0D Š y0<D, 8x@ΛD, y@ΛD<, 8Λ, 0, 1<D;
H8x@ΛD, y@ΛD< . solL . Λ ® 1
881.5247 - 0.797778 ä, 1.31173 + 2.43275 ä<<
and the real roots
x0 = - 1; y0 = 1;
sol = NDSolve@Join@deqs, 8x@0D Š x0, y@0D Š y0<D, 8x@ΛD, y@ΛD<, 8Λ, 0, 1<D;
H8x@ΛD, y@ΛD< . solL . Λ ® 1
99- 0.115088 + 1.00373 ´ 10-6 ä, 2.98675 - 5.53723 ´ 10-7 ä==
These complex "tails" can be eliminated by using computation with high precision,
Linear_Homotopy_05.nb
19
These complex "tails" can be eliminated by using computation with high precision,
sol = NDSolve@Join@deqs, 8x@0D Š x0, y@0D Š y0<D, 8x@ΛD, y@ΛD<,
8Λ, 0, 1<, AccuracyGoal ® 20, PrecisionGoal ® 20, WorkingPrecision ® 30D;
H8x@ΛD, y@ΛD< . solL . Λ ® 1
99- 0.11508799467984843796387115844 + 5.7506633782 ´ 10-19 ä,
2.98675475348057117714368577390 - 1.76779770518 ´ 10-19 ä==
Chop@%D  N
88- 0.115088, 2.98675<<
The other real root can be computed similarly,
x0 = - 1; y0 = - 1;
sol = NDSolve@Join@deqs, 8x@0D Š x0, y@0D Š y0<D, 8x@ΛD, y@ΛD<, 8Λ, 0, 1<D;
H8x@ΛD, y@ΛD< . solL . Λ ® 1
99- 2.93432 - 1.21005 ´ 10-7 ä, - 5.61022 - 5.96536 ´ 10-7 ä==
Now, again complex "tails" can be eliminated,
sol = NDSolve@Join@deqs, 8x@0D Š x0, y@0D Š y0<D, 8x@ΛD, y@ΛD<,
8Λ, 0, 1<, AccuracyGoal ® 20, PrecisionGoal ® 20, WorkingPrecision ® 30D;
H8x@ΛD, y@ΛD< . solL . Λ ® 1
99- 2.93431716517985510207174092895 - 2.7255438650 ´ 10-19 ä,
- 5.6102172258691410516284787558 - 1.1662715476 ´ 10-18 ä==
Chop@%D  N
88- 2.93432, - 5.61022<<
5- 8 Start system for polynomial systems
How we can find the proper start system, which will provide all of the solutions of the target system automatically? This
problem can be solved if the nonlinear system is specially a system of polynomial equations.
Let us consider the case when we are looking for the homotopy solution of f(x) = 0, where f(x) is a polynomial system,
f(x): R n ®R n . To get all of the solutions, one should find out a proper polynomial system, as start system, g(x) = 0, where
g(x): R n ®R n with known or easily computable solutions.
An appropriate start system can be generated in the following way,
Let fi Hx1 , ..., xn L, i = 1, ..., n be a system of n polynomials. We are interested of the common
zeros of the system, namely f = H f1 HxL, ..., fn HxLL = 0.
Let d j denote the degree of the j th polynomial - that is the degree of the highest order monomial
in the equation. Then such a starting system is,
g j HxL = ãi Φ j Jx j d j - I ãi Θ j M
dj
= 0,
j = 1, ..., n
where Φ j and Θ j are random real numbers in the interval [0, 2 Π]. The equation above has the obvious particular solution x j =
ãi Θ j and the complete set of the starting solutions for j = 1, ..., n is given by
20
Linear_Homotopy_05.nb
Ki Θ j +
ã
2Πik
dj
O
, k = 0, 1, ..., d j -1
Bezout’s theorem states that the number of isolated roots of such a system is bounded by the total degree of the system,
Ûni=1 di = d1 d2 ...dn.
Let us consider the following system
f1@x_, y_D := x ^ 2 + y ^ 2 - 1
f2@x_, y_D := x ^ 3 + y ^ 3 - 1
The degrees of the polynomials are
d1 = 2; d2 = 3;
Indeed, this system has the following six roots (d1 d2 = 2 * 3 = 6), as it is expected. Indeed using built-in Global Numerical
Solver,
NSolve@8f1@x, yD Š 0, f2@x, yD Š 0<, 8x, y<D
88x ® - 1. + 0.707107 ä, y ® - 1. - 0.707107 ä<, 8x ® - 1. - 0.707107 ä, y ® - 1. + 0.707107 ä<,
8x ® 1., y ® 0.<, 8x ® 1., y ® 0.<, 8x ® 0., y ® 1.<, 8x ® 0., y ® 1.<<
Length@%D
6
Now, we compute the start system. We generate random real numbers in the interval [0, 2Π] as it follows
Φ1 = Random@Real, 80, 2 Π<D
2.38834
Φ2 = Random@Real, 80, 2 Π<D
1.68058
Θ1 = Random@Real, 80, 2 Π<D
5.23443
Θ2 = Random@Real, 80, 2 Π<D
2.77893
The start system is,
g1@x_, y_D := ãä Φ1 Jxd1 - Iãä Θ1 M N
d1
g2@x_, y_D := ãä Φ2 Jyd2 - Iãä Θ2 M N
d2
g1@x, yD
H- 0.729469 + 0.684014 äL IH0.502701 + 0.864461 äL + x2 M
g2@x, yD
H- 0.109565 + 0.99398 äL IH0.464279 - 0.885689 äL + y3 M
Then the complete set of the starting solutions,
Xi = Table@Exp@ä Θ1 + 2 Π ä k  d1D, 8k, 0, d1 - 1<D
80.498648 - 0.866805 ä, - 0.498648 + 0.866805 ä<
and
Linear_Homotopy_05.nb
21
and
Yi = Table@Exp@ä Θ2 + 2 Π ä k  d2D, 8k, 0, d2 - 1<D
8- 0.934957 + 0.354761 ä, 0.160246 - 0.987077 ä, 0.774711 + 0.632316 ä<
We need all of the combination of the initial values {Xi , Yj =, i = 1, 2, j = 1, 2
X0 = Tuples@8Xi, Yi<D
880.498648 - 0.866805 ä, - 0.934957 + 0.354761 ä<,
80.498648 - 0.866805 ä, 0.160246 - 0.987077 ä<,
80.498648 - 0.866805 ä, 0.774711 + 0.632316 ä<,
8- 0.498648 + 0.866805 ä, - 0.934957 + 0.354761 ä<,
8- 0.498648 + 0.866805 ä, 0.160246 - 0.987077 ä<,
8- 0.498648 + 0.866805 ä, 0.774711 + 0.632316 ä<<
These values are satisfy the start system,
Map@g1@ð@@1DD, ð@@2DDD &, X0D
90. + 0. ä, 0. + 0. ä, 0. + 0. ä, - 7.59408 ´ 10-17 - 8.09873 ´ 10-17 ä,
- 7.59408 ´ 10-17 - 8.09873 ´ 10-17 ä, - 7.59408 ´ 10-17 - 8.09873 ´ 10-17 ä=
Chop@%D
80, 0, 0, 0, 0, 0<
Map@g2@ð@@1DD, ð@@2DDD &, X0D
90. + 0. ä, - 1.17565 ´ 10-15 + 1.54583 ´ 10-15 ä, - 8.94119 ´ 10-16 + 1.01839 ´ 10-15 ä,
0. + 0. ä, - 1.17565 ´ 10-15 + 1.54583 ´ 10-15 ä, - 8.94119 ´ 10-16 + 1.01839 ´ 10-15 ä=
Chop@%D
80, 0, 0, 0, 0, 0<
So we have six initial values for solving our homotopy equations. These initial values will provide the start point of the six
homotopy paths. The end points of these paths are the six solutions of the target system.
Before carring out the computation, it is high time to implement four Mathematica functions to carry out linear homotopy
computations in Mathematica environment.
5- 9 Implementation of homotopy methods in Mathematica
5- 9- 1 Function for computing start system for polynomials
This function will compute the start system as well as the initial values for the computation of the homotopy paths in case of
polynomial system.
Input variables
F - list of functions of the polynomial system to be solved, F = { f1 (x), f2 (x),..., fn (x)}
X - list of the independent variables, X = {x1 ,x2 ,...,xn }
d - list of the degrees of the polynomials, d = {d1 ,d2 ,...,dn }
Output variables
G
- list of start system, G = {g1 (x), g2 (x),...,gn (x)}
X0 - list of initial values, X0 = {{x01 ,x02 ,...,x0n <1 ,{x01 ,x02 ,...,x0n <2 ,...,{x01 ,x02 ,...,x0n <m }
where m is the number of the roots of F
22
G
Linear_Homotopy_05.nb
- list of start system, G = {g1 (x), g2 (x),...,gn (x)}
X0 - list of initial values, X0 = {{x01 ,x02 ,...,x0n <1 ,{x01 ,x02 ,...,x0n <2 ,...,{x01 ,x02 ,...,x0n <m }
where m is the number of the roots of F
StartingSystem @F_, X_, d_D := ModuleB8n, k, Φ, Θ, G, Xi, X0<,
n = Length@XD;
Φ = Table@Random@Real, 80, 2 Π<D, 8n<D;
Θ = Table@Random@Real, 80, 2 Π<D, 8n<D;
G = MapThreadBãä ð1 Jð4ð2 - Iãä ð3 M N &, 8Φ, d, Θ, X<F;
ð2
Xi = MapThread@Table@Exp@ä ð1 + 2 Π ä k  ð2D, 8k, 0, ð2 - 1<D &, 8Θ, d<D;
X0 = Tuples@XiD;
8G, X0<F
Now, let us create the start system with this function.
The list of the functions of the system we considered above is,
F = 8f1@x, yD, f2@x, yD<
9- 1 + x2 + y2 , - 1 + x3 + y3 =
The list of variables
X = 8x, y<
8x, y<
The list of the degrees of the polynomials,
d = 8d1, d2<
82, 3<
Now, employing our function
sol = StartingSystem @F, X, dD;
The start system is
G = sol@@1DD
9H- 0.700051 + 0.714093 äL IH0.89637 - 0.443306 äL + x2 M,
H- 0.691095 - 0.722764 äL IH- 0.825174 - 0.564878 äL + y3 M=
and the initial values are
X0 = sol@@2DD
88- 0.227629 - 0.973748 ä, - 0.31789 - 0.948127 ä<,
8- 0.227629 - 0.973748 ä, 0.980048 + 0.198763 ä<,
8- 0.227629 - 0.973748 ä, - 0.662157 + 0.749365 ä<,
80.227629 + 0.973748 ä, - 0.31789 - 0.948127 ä<,
80.227629 + 0.973748 ä, 0.980048 + 0.198763 ä<,
80.227629 + 0.973748 ä, - 0.662157 + 0.749365 ä<<
They are the solutions of the start system,
Map@G@@1DD . 8x -> ð@@1DD, y -> ð@@2DD< &, X0D  Chop
80, 0, 0, 0, 0, 0<
Linear_Homotopy_05.nb
23
Map@G@@2DD . 8x -> ð@@1DD, y -> ð@@2DD< &, X0D  Chop
80, 0, 0, 0, 0, 0<
5- 9- 2 Function for direct path tracing
This function will compute the homotopy paths using Newton-Raphson method successively.
Input variables
F - list of functions of the polynomial system to be solved, F = { f1 (x), f2 (x),..., fn (x)}
G - list of the start system, G = 8g1 HxL,g2 (x),...,gn HxL},
X - list of the independent variables X = {x1 ,x2 ,...,xn }
X0 - list of initial values, X0 = {{x01 ,x02 ,...,x0n <1 ,{x01 ,x02 ,...,x0n <2 ,...,{x01 ,x02 ,...,x0n <m }
where m is the number of the roots of F
Γ - list of complex numbers, {Γ1 , Γ2 ,...,Γn }, it means Γi can be different for every gi (x),
If the start system is generated for polynomials all Γi = 1.
n - number of the subintervalls in [0, 1].
Output variables
sol[1]
sol[2]
- list of the i-th solutions correspondig to the i-th initial values, {x01 ,x02 ,...,x0n <i , i = 1...m
- list of the path of i-th solutions in form of interpolating functions of the variables
correspondig with the i-th initial values, {x01 ,x02 ,...,x0n <i , i = 1...m,
{{j1 , j2 , ..., jn <1 ,{j1 , j2 , ..., jn <2 ,...,{j1 , j2 , ..., jn <m }, ji =ji (Λ)
LinearHomotopyFR @F_, G_, X_, X0_, Γ_ , n_D :=
ModuleB8H, X0L, Λ0 , i, Β, m, R, RR, j, k, sol<,
Off@FindRoot::"lstol"D;
1
Λ0 = TableBi , 8i, 0, n<F;
n
H = Flatten@H1 - ΒL Thread@G ΓD + Β FD;
m = Length@XD;
k = Length@X0D;
RR = 8<;
Do@
X0L = 8X0@@jDD<;
Do@AppendTo@X0L, Map@ð@@2DD &,
FindRoot@H . Β ® Λ0 @@i + 1DD, MapThread@8ð1, ð2< &, 8X, X0L@@iDD<DDDD, 8i, 1, n<D;
R = 8<;
Do@AppendTo@R, Interpolation @MapThread@8ð1, ð2@@iDD< &, 8Λ0 , X0L<DDD, 8i, 1, m<D;
AppendTo@RR, 8Map@Chop@N@ð@1DDD &, RD, R<D,
8j, 1, k<D;
sol = Transpose@RRD;
8sol@@1DD, Table@MapThread@ð1@ΛD ® ð2@ΛD &, 8X, sol@@2, iDD<D, 8i, 1, Length@X0D<D<F
Remark: It is reasonable to carry out computation with n = 100, however sometimes one may need more subintervalls, but it
also possible that less will enough to get satisfactory result.
In case of polynomial system, when we generate a start system in complex domain, we do not need to use complex Γ,
Γ = 81, 1<;
24
Linear_Homotopy_05.nb
sol = LinearHomotopyFR @F, G, X, X0, Γ, 100D;
The first output gives the roots of the system,
sol1FR = ChopAsol@@1DD, 10-8 E
881., 0<, 80, 1.<, 81., 0<, 8- 1. + 0.707107 ä, - 1. - 0.707107 ä<,
80, 1.<, 8- 1. - 0.707107 ä, - 1. + 0.707107 ä<<
The second output is the list of the interpolation functions of the paths,
sol2FR = sol@@2DD
88x@ΛD ® InterpolatingFunction @880., 1.<<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880., 1.<<, <>D@ΛD<,
8x@ΛD ® InterpolatingFunction @880., 1.<<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880., 1.<<, <>D@ΛD<,
8x@ΛD ® InterpolatingFunction @880., 1.<<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880., 1.<<, <>D@ΛD<,
8x@ΛD ® InterpolatingFunction @880., 1.<<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880., 1.<<, <>D@ΛD<,
8x@ΛD ® InterpolatingFunction @880., 1.<<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880., 1.<<, <>D@ΛD<,
8x@ΛD ® InterpolatingFunction @880., 1.<<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880., 1.<<, <>D@ΛD<<
5- 9- 3 Function for path tracing with integration
This function will compute the homotopy paths using numerical integration of the differencial equation system employing
Runge-Kutta method. In this implementation we compute the inverse of the Jacobian, namely the initial value problem will
be expressed as
dx HΛL
dΛ
with
= - Hx -1 H Λ
x H0L = x0
Here Hx -1 is the inverse of the Jacobian (Hx ) with respect to xi , i = 1,..., n, in case of n nonlinear equations with n variables.
The inverse will be computed in symbolic way therefore the number of equations may be limited by n = 6 - 8.
Input variables
F - list of functions of the polynomial system to be solved, F = { f1 (x), f2 (x),..., fn (x)}
G - list of the start system, G = 8g1 HxL,g2 (x),...,gn HxL},
X - list of the independent variables X = {x1 ,x2 ,...,xn }
X0 - list of initial values, X0 = {{x01 ,x02 ,...,x0n <1 ,{x01 ,x02 ,...,x0n <2 ,...,{x01 ,x02 ,...,x0n <m }
where m is the number of the roots of F
Γ - list of complex numbers, {Γ1 , Γ2 ,...,Γn }, it means Γi can be different for every gi (x),
If start system is generated for polynomials all Γi = 1.
p - indicating numerical precision of the computation., p = 0 standard precision, p =1 high precision
Output variables
sol[1] - list of the i-th solutions correspondig to the i-th initial values, {x01 ,x02 ,...,x0n <i , i = 1...m
sol[2] - list of the path of i-th solutions in form of interpolating functions of the variables
correspondig with the i-th initial values, {x01 ,x02 ,...,x0n <i , i = 1...m,
{{j1 , j2 , ..., jn <1 ,{j1 , j2 , ..., jn <2 ,...,{j1 , j2 , ..., jn <m }, where ji =ji (Λ)
Linear_Homotopy_05.nb
sol[1] - list of the i-th solutions correspondig to the i-th initial values, {x01 ,x02 ,...,x0n <i , i = 1...m
sol[2] - list of the path of i-th solutions in form of interpolating functions of the variables
correspondig with the i-th initial values, {x01 ,x02 ,...,x0n <i , i = 1...m,
{{j1 , j2 , ..., jn <1 ,{j1 , j2 , ..., jn <2 ,...,{j1 , j2 , ..., jn <m }, where ji =ji (Λ)
LinearHomotopyNDS01 @X_, F_, G_, X0_, Γ_ , p_D :=
ModuleA8H, n, JΛ, J, u, i, j, b, A, a, B, rhs, lhs, deqs, sol, pa, pp, wp<,
Off@NDSolve::"precw"D; H = Flatten@H1 - ΛL Thread@G ΓD + Λ FD;
n = Length@XD;
JΛ = Outer@D, H, Join@X, 8Λ<DD;
J = Take@JΛ, 81, n<, 81, n<D;
u = - Take@JΛ, 81, n<, 8n + 1<D;
A = TableAai,j , 8i, 1, n<, 8j, 1, n<E;
B = Table@bi , 8i, 1, n<D;
rhs =
ISimplify@LinearSolve@A, BDD . IJoinATable@bi ® u@@iDD, 8i, 1, n<D, FlattenATableA
ai,j ® J@@i, jDD, 8i, 1, n<, 8j, 1, n<EEEM . Map@ð ® ð@ΛD &, XDM  Flatten;
lhs = Map@D@ð@ΛD, 8Λ, 1<D &, XD;
deqs = MapThread@ð1 Š ð2 &, 8lhs, rhs<D;
8pa, pp, wp< = If@p Š 1,
8AccuracyGoal ® 20, PrecisionGoal ® 20, WorkingPrecision ® 30<, 88<, 8<, 8<<D;
sol = Map@Flatten@NDSolve@Join@deqs, MapThread@ð1@0D Š ð2 &, 8X, ð<DD,
Map@ð@ΛD &, XD, 8Λ, 0, 1<, pa, pp, wpDD &, X0D;
8Map@Chop@N@HMap@ð@ΛD &, XD . ð . Λ ® 1LDD &, solD, sol<E
Now we solve the same problem. First, we use standard precision,
sol = LinearHomotopyNDS01 @X, F, G, X0, Γ, 0D;
sol@@1DD
991. + 6.37644 ´ 10-8 ä, 0.000275431 + 0.00055946 ä=,
9- 0.000132059 - 0.00029217 ä, 1. + 6.86275 ´ 10-8 ä=,
91. - 5.92307 ´ 10-8 ä, - 0.000218479 - 0.000291157 ä=, 8- 1. + 0.707107 ä, - 1. - 0.707107 ä<,
9- 0.00050925 - 0.0000296627 ä, 1. + 6.64996 ´ 10-8 ä=, 8- 1. - 0.707107 ä, - 1. + 0.707107 ä<=
ChopAsol@@1DD, 10-3 E
881., 0<, 80, 1.<, 81., 0<, 8- 1. + 0.707107 ä, - 1. - 0.707107 ä<,
80, 1.<, 8- 1. - 0.707107 ä, - 1. + 0.707107 ä<<
Using higher precision, the computation takes a considerably longer time,
sol = LinearHomotopyNDS01 @X, F, G, X0, Γ, 1D;
sol1NDS = sol@@1DD
991., 8.68738 ´ 10-9 - 3.81661 ´ 10-9 ä=, 9- 1.06733 ´ 10-10 - 1.89959 ´ 10-8 ä, 1.=,
91., - 2.91337 ´ 10-8 + 4.54623 ´ 10-9 ä=, 8- 1. + 0.707107 ä, - 1. - 0.707107 ä<,
9- 2.84189 ´ 10-9 + 2.46094 ´ 10-8 ä, 1.=, 8- 1. - 0.707107 ä, - 1. + 0.707107 ä<=
but we have smaller values for the "tails",
25
26
Linear_Homotopy_05.nb
ChopAsol1NDS, 10-7 E
881., 0<, 80, 1.<, 81., 0<, 8- 1. + 0.707107 ä, - 1. - 0.707107 ä<,
80, 1.<, 8- 1. - 0.707107 ä, - 1. + 0.707107 ä<<
The interpolation functions for the paths
sol2NDS = sol@@2DD
88x@ΛD ® InterpolatingFunction @880, 1.00000000000000000000000000000 <<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880, 1.00000000000000000000000000000 <<, <>D@ΛD<,
8x@ΛD ® InterpolatingFunction @880, 1.00000000000000000000000000000 <<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880, 1.00000000000000000000000000000 <<, <>D@ΛD<,
8x@ΛD ® InterpolatingFunction @880, 1.00000000000000000000000000000 <<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880, 1.00000000000000000000000000000 <<, <>D@ΛD<,
8x@ΛD ® InterpolatingFunction @880, 1.00000000000000000000000000000 <<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880, 1.00000000000000000000000000000 <<, <>D@ΛD<,
8x@ΛD ® InterpolatingFunction @880, 1.00000000000000000000000000000 <<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880, 1.00000000000000000000000000000 <<, <>D@ΛD<,
8x@ΛD ® InterpolatingFunction @880, 1.00000000000000000000000000000 <<, <>D@ΛD,
y@ΛD ® InterpolatingFunction @880, 1.00000000000000000000000000000 <<, <>D@ΛD<<
Remarks :
1) To get explicit form for the differential equation system, the linear equation system is solved in symbolic way. Therefore, the maximum number of equation can be about n = 6 - 8,
2) High precision solution (p = 1) would take much longer time than standard precision does ( p = 0).
In order to avoid to compute the inverse in this implementation, we consider a new parameter, t, namely
dH Hx HtL, Λ HtLL =
¶H
¶x
dx HtL +
¶H
¶Λ
dΛ HtL º 0
Λ HtL Î @0, 1D
this means with s(t) = {x (t), Λ(t)} we get
Hs Hs HtLL
ds
= 0
dt
where Hs is the Jacobian of the homotopy function respect to vector s having n + 1 dimensions.
Then the i th derivate function can be expressed as
dsi
dt
= H-1Li+1 det IHs H1L , ..., Hs Hi-1L , Hs Hi+1L , ... Hs Hn+1L M
where Hs HiL is the ith column of the Jacobian matrix Hs Hs HtLL.
However, in that case one need to check the upper bound of the integration parameter,
while integration should be carried out up to t* , where Λ Ht* L = 0.
Therefore it is reasonable to eliminate the last derivate of vector s, namely
dsn+1
=
dΛ
dt
dt
Considering that
dsi
dt
for i = 1, 2, ..., n.
=
d xi
dt
=
d xi dΛ
dΛ dt
=
d xi dsn+1
dΛ
dt
Linear_Homotopy_05.nb
d xi
=
dΛ
d xi
dt
“
dΛ
=
dt
dsi
dt
“
dsn+1
dt
now the integration can be carried out with independent variable Λ on [0, 1]. The new implementation considering these
changes is the following,
LinearHomotopyNDS02 @X_, F_, G_, X0_, Γ_ , p_D :=
ModuleA8H, n, JΛ, rhs, rhs0, i, lhs, deqs, sol, pa, pp, wp<,
Off@NDSolve::"precw"D; H = Flatten@H1 - ΛL Thread@G ΓD + Λ FD;
n = Length@XD;
JΛ = Outer@D, H, Join@X, 8Λ<DD;
rhs0 = TableAH- 1Li+1 Det@Transpose@Drop@Transpose@JΛD, 8i, i<DDD, 8i, 1, n + 1<E;
rhs = Drop@Map@ð  Last@rhs0D &, rhs0D, 8n + 1, n + 1<D . Map@ð ® ð@ΛD &, XD  Flatten;
lhs = Map@D@ð@ΛD, 8Λ, 1<D &, XD;
deqs = MapThread@ð1 Š ð2 &, 8lhs, rhs<D;
8pa, pp, wp< = If@p Š 1,
8AccuracyGoal ® 20, PrecisionGoal ® 20, WorkingPrecision ® 30<, 88<, 8<, 8<<D;
sol = Map@Flatten@NDSolve@Join@deqs, MapThread@ð1@0D Š ð2 &, 8X, ð<DD,
Map@ð@ΛD &, XD, 8Λ, 0, 1<, pa, pp, wpDD &, X0D;
8Map@Chop@N@HMap@ð@ΛD &, XD . ð . Λ ® 1LDD &, solD, sol<E
The input and output are the same as in case of the function LinearHomotopyNDS01.
sol = LinearHomotopyNDS02 @X, F, G, X0, Γ, 1D;
sol@@1DD
991., 8.61624 ´ 10-9 + 8.99564 ´ 10-9 ä=, 98.02991 ´ 10-9 + 7.33881 ´ 10-9 ä, 1.=,
91., - 3.00594 ´ 10-8 - 1.59162 ´ 10-9 ä=, 8- 1. + 0.707107 ä, - 1. - 0.707107 ä<,
91.49992 ´ 10-9 + 2.06486 ´ 10-8 ä, 1.=, 8- 1. - 0.707107 ä, - 1. + 0.707107 ä<=
ChopAsol@@1DD, 10-7 E
881., 0<, 80, 1.<, 81., 0<, 8- 1. + 0.707107 ä, - 1. - 0.707107 ä<,
80, 1.<, 8- 1. - 0.707107 ä, - 1. + 0.707107 ä<<
5- 9- 4 Function for visualization of paths
This function plots the homotopy paths computed by either direct method or by integration.
Input variables
X - the list of the independent variables X = {x1 , x2 ,...,xn }
sol - list of the interpolation functions of the variables
{{j1 , j2 , ..., jn <1 ,{j1 , j2 , ..., jn <2 ,...,{j1 , j2 , ..., jn <m }
X0 - list of initial values, X0 = {{x01 ,x02 ,...,x0n <1 ,{x01 ,x02 ,...,x0n <2 ,...,{x01 ,x02 ,...,x0n <m }
where m is the number of the roots of F ,
Paths@X_, sol_, X0_D :=
GraphicsArray @Table@ParametricPlot @8Re@X@@iDD@ΛDD, Im@X@@iDD@ΛDD< . sol@@jDD,
8Λ, 0, 1<, PlotRange ® All, BaseStyle -> 8FontSize ® 10, FontFamily -> "Times"<,
Axes -> None, FrameLabel ® 8"Re", "Im"<, Frame ® True, AspectRatio ® 0.6,
PlotLabel -> StringJoin@ToString@X@@iDDD, "HΛL "D, Epilog ® 8PointSize@0.02D,
Blue, Point@8Re@X0@@j, iDDD, Im@X0@@j, iDDD<D, PointSize@0.02D, Red, Point@
8HRe@X@@iDD@ΛDD . sol@@jDDL . Λ ® 1, HIm@X@@iDD@ΛDD . sol@@jDDL . Λ ® 1<D<D,
8j, 1, Length@X0D<, 8i, 1, Length@XD<DD;
Let us plot the result of the solution of system above
27
28
Linear_Homotopy_05.nb
Let us plot the result of the solution of system above
pNDS = Paths@X, sol@@2DD, X0D
Linear_Homotopy_05.nb
yHΛL
0.0
0.0
-0.5
-0.5
Im
Im
xHΛL
-1.0
-1.0
-1.5
-1.5
0.0
0.5
1.0
-2.0
-0.4-0.2 0.0 0.2 0.4 0.6 0.8 1.0
1.5
Re
Re
xHΛL
yHΛL
Im
Im
0.0
-0.2
-0.4
-0.6
-0.8
-1.0
-1.2
-0.2
-0.1
0.0
0.1
0.20
0.15
0.10
0.05
0.00
-0.05
-0.10
0.2
1.0
1.1
1.3
1.4
-0.8 -0.6 -0.4 -0.2
0.0
Re
xHΛL
yHΛL
0.8
-0.2
0.6
Im
Im
-0.4
-0.6
0.4
-0.8
0.2
-1.0
-0.2 0.0 0.2 0.4 0.6 0.8 1.0
0.0
Re
Re
xHΛL
yHΛL
-0.2
-0.4
Im
1.3
1.2
1.1
1.0
0.9
0.8
0.7
-1.0 -0.8 -0.6 -0.4 -0.2 0.0 0.2
-0.6
-0.8
-1.0
-0.8
-0.6
Re
Re
xHΛL
yHΛL
1.2
1.0
0.8
0.6
0.4
0.2
0.0
-0.4
0.2
0.1
Im
Im
1.2
Re
0.0
Im
29
0.0
-0.1
-0.4 -0.3 -0.2 -0.1 0.0 0.1 0.2
0.6
Re
0.7
0.8
0.9
1.0
Re
xHΛL
yHΛL
1.6
1.0
Im
Im
1.4
0.5
1.2
0.0
1.0
-0.5
0.8
-1.5
-1.0
-0.5
0.0
Re
-1.4 -1.2 -1.0 -0.8 -0.6 -0.4
Re
Fig. 5.15 The homotopy paths
Remark: These functions are implemented in the GeoAlgebra application package and you can use them, but in a slightly
different way, see in Chapters of Part II.
30
Linear_Homotopy_05.nb
Remark: These functions are implemented in the GeoAlgebra application package and you can use them, but in a slightly
different way, see in Chapters of Part II.
5- 10 Examples
5- 10- 1 3D Resection Problem
The three-dimensional resection problem concerns itself with the determination of position and orientation of point P0
connected by angular observations, ji, j , i, ,j = 1,2,3 to three known stations, Pi , i = 1,2,3, see Fig. 5.16. It means, that the
space angles, ji, j as well as the distances Si, j , i, ,j = 1, 2, 3 are known and the distances Si , i = 1, 2, 3 should be computed.
Fig. 5.16 The geometrical interpretation of the 3D resection problem
Grunert proposed the following distance equations,
S1,2 2 = S1 2 + S2 2 - 2 S1 S2 cos Ij1,2 M
S2,3 2 = S2 2 + S3 2 - 2 S2 S3 cos Ij2,3 M
S3,1 2 = S3 2 + S1 2 - 2 S3 S1 cos Ij3,1 M
This is a system of polynomial equations for the variables S1 S2 and S3 representing distances.
Let us intruduce the folllowing variables
cos Iji, j M = fi, j , Si = xi and Si, j =
d i, j
then our system can be written in the following form,
p1 = x12 - 2 f12 x1 x2 + x22 - d12;
p2 = x22 - 2 f23 x2 x3 + x32 - d23;
p3 = x32 - 2 f31 x1 x3 + x12 - d31;
Data are
data = SetPrecision A9d12 -> 1560.3302 2 , d23 -> 755.8681 2 , d31 -> 1718.1090 2 ,
f12 -> Cos@1.843620D, f23 -> Cos@1.768989D, f31 -> Cos@2.664537D=, 20E;
X = 8x1, x2, x3<;
Linear_Homotopy_05.nb
F = 8p1, p2, p3< . data
9- 2.4346303330320403911 ´ 106 + x12 + 0.53890348757379025191 x1 x2 + x22 ,
- 571 336.58459761005361 + x22 + 0.39379541340558754658 x2 x3 + x32 ,
- 2.9518985358809996396 ´ 106 + x12 + 1.7767014278358685963 x1 x3 + x32 =
d = 82, 2, 2<;
The start system
ss = StartingSystem @F, X, dD;
G = ss@@1DD
9H0.770029 - 0.638009 äL IH0.999466 + 0.0326609 äL + x12 M,
H0.376117 - 0.926572 äL IH0.149403 - 0.988776 äL + x22 M,
H- 0.0163211 - 0.999867 äL IH- 0.628837 + 0.777537 äL + x32 M=
The initial values
X0 = ss@@2DD
88- 0.0163326 + 0.999867 ä, - 0.652149 - 0.758091 ä, - 0.902451 + 0.430792 ä<,
8- 0.0163326 + 0.999867 ä, - 0.652149 - 0.758091 ä, 0.902451 - 0.430792 ä<,
8- 0.0163326 + 0.999867 ä, 0.652149 + 0.758091 ä, - 0.902451 + 0.430792 ä<,
8- 0.0163326 + 0.999867 ä, 0.652149 + 0.758091 ä, 0.902451 - 0.430792 ä<,
80.0163326 - 0.999867 ä, - 0.652149 - 0.758091 ä, - 0.902451 + 0.430792 ä<,
80.0163326 - 0.999867 ä, - 0.652149 - 0.758091 ä, 0.902451 - 0.430792 ä<,
80.0163326 - 0.999867 ä, 0.652149 + 0.758091 ä, - 0.902451 + 0.430792 ä<,
80.0163326 - 0.999867 ä, 0.652149 + 0.758091 ä, 0.902451 - 0.430792 ä<<
The upper bound of the number of the estimated isolated roots
Length@X0D
8
Let
Γ = 81, 1, 1<;
Employing direct path tracing algorithm
sol = LinearHomotopyFR @F, G, X, X0, Γ, 100D;
The solutions are
sol@@1DD
8822 456.5 - 1735.3 ä, - 4375.48 + 22 037.5 ä, - 20 757.3 - 8626.43 ä<,
81580.11, - 770.958, 153.711<,
822 456.5 + 1735.3 ä, - 4375.48 - 22 037.5 ä, - 20 757.3 + 8626.43 ä<,
81324.24, 542.261, 430.529<, 8- 1324.24, - 542.261, - 430.529<,
8- 22 456.5 - 1735.3 ä, 4375.48 + 22 037.5 ä, 20 757.3 - 8626.43 ä<,
8- 1580.11, 770.958, - 153.711<,
8- 22 456.5 + 1735.3 ä, 4375.48 - 22 037.5 ä, 20 757.3 + 8626.43 ä<<
Selecting real, positive solution
Select@sol@@1DD, HIm@ð@@1DDD Š 0 ì ð@@1DD > 0L ì
HIm@ð@@2DDD Š 0 ì ð@@2DD > 0L ì HIm@ð@@3DDD Š 0 ì ð@@3DD > 0L &D  Flatten
81324.24, 542.261, 430.529<
The position of the this solution
31
32
Linear_Homotopy_05.nb
The position of the this solution
p = Position@sol@@1DD, %D  Flatten  First
4
Homotopy solution paths of the 3D resection problem,
P = Paths@X, 8sol@@2, pDD<, 8X0@@pDD<D
x1HΛL
200
Im
150
100
50
0
0
200
400
600
800
1000
1200
Re
x2HΛL
100
50
Im
0
-50
-100
-150
-200
0
100
200
300
400
500
Re
x3HΛL
300
Im
200
100
0
0
200
400
600
Re
Fig. 5.17 The real root of the polynomial
800
Linear_Homotopy_05.nb
33
5- 10- 2 GPS Positioning 4-point Problem
Throughout history, position determination has been one of the most important tasks of mountaineers, pilots, sailor, civil
engineers etc. In modern times, Global Positioning System (GPS) employing Global Navigation Satellite Systems (GNSS)
provide an ultimate method to accomplish this task. If one has a hand held GPS receiver, the receiver measures the travel
time of the signal transmitted from the satellites. Then this distance can be computed by multiplying the measured time by
the speed of light in vacuum. The distance of the receiver from the i-th satellite, di is related to the unknown position of the
receiver, {X,Y, Z}
di =
where 8ai , bi , ci <, i = 0 ...
Hai - XL2 + Hbi - YL2 + Hci - ZL2 + Ξ
3 are the coordinates of the ith satellite.
The distance is influenced also by the satellite and receiver’ clock biases. The satellite clock biases can be modeled while the
receiver’ clock biases have to be considered as an unknown variable, Ξ. This means, we have four unknowns, consequently
we need four satellite signals as minimum observation. Let us employ x1 , x2 , x3 and x4 variables for the four unknowns,
{X,Y, Z, Ξ,} then our equations are, ei = 0, i = 1...4, where
Clear@d, bD
e1 = Hx1 - a0 L2 + Hx2 - b0 L2 + Hx3 - c0 L2 - Hx4 - d0 L2 ;
e2 = Hx1 - a1 L2 + Hx2 - b1 L2 + Hx3 - c1 L2 - Hx4 - d1 L2 ;
e3 = Hx1 - a2 L2 + Hx2 - b2 L2 + Hx3 - c2 L2 - Hx4 - d2 L2 ;
e4 = Hx1 - a3 L2 + Hx2 - b3 L2 + Hx3 - c3 L2 - Hx4 - d3 L2 ;
or
8f1, f2, f3, f4< = 8e1, e2, e3, e4<  Expand
9x12 + x22 + x32 - x42 - 2 x1 a0 + a20 - 2 x2 b0 + b20 - 2 x3 c0 + c20 + 2 x4 d0 - d20 ,
x12 + x22 + x32 - x42 - 2 x1 a1 + a21 - 2 x2 b1 + b21 - 2 x3 c1 + c21 + 2 x4 d1 - d21 ,
x12 + x22 + x32 - x42 - 2 x1 a2 + a22 - 2 x2 b2 + b22 - 2 x3 c2 + c22 + 2 x4 d2 - d22 ,
x12 + x22 + x32 - x42 - 2 x1 a3 + a23 - 2 x2 b3 + b23 - 2 x3 c3 + c23 + 2 x4 d3 - d23 =
Now let us create the start system in a different way. We consider the univariable parts of the equations as start system.
Namely,
g1 = a20 + b20 + c20 - d02 + Coefficient@f1, x1, 1D x1 + Coefficient@f1, x1, 2D x12
x12 - 2 x1 a0 + a20 + b20 + c20 - d20
g2 = a21 + b21 + c21 - d12 + Coefficient@f2, x2, 1D x2 + Coefficient@f2, x2, 2D x22
x22 + a21 - 2 x2 b1 + b21 + c21 - d21
g3 = a22 + b22 + c22 - d22 + Coefficient@f3, x3, 1D x3 + Coefficient@f3, x3, 2D x32
x32 + a22 + b22 - 2 x3 c2 + c22 - d22
g4 = a23 + b23 + c23 - d32 + Coefficient@f4, x4, 1D x4 + Coefficient@f4, x4, 2D x42
- x42 + a23 + b23 + c23 + 2 x4 d3 - d23
The observation data are,
34
Linear_Homotopy_05.nb
data =
9a0 ® 1.483230866 107 , a1 ® - 1.579985405 107 , a2 ® 1.98481891 106 , a3 ® - 1.248027319 107 ,
b0 ® - 2.046671589 107 , b1 ® - 1.330112917 107 , b2 ® - 1.186767296 107 ,
b3 ® - 2.338256053 107 ,
c0 ® - 7.42863475 106 , c1 ® 1.713383824 107 , c2 ® 2.371692013 107 ,
c3 ® 3.27847268 106 ,
d0 ® 2.4310764064 107 , d1 ® 2.2914600784 107 , d2 ® 2.0628809405 107 ,
d3 ® 2.3422377972 107 =;
The target system,
F = 8f1, f2, f3, f4< . data
91.03055 ´ 1014 - 2.96646 ´ 107 x1 + x12 + 4.09334 ´ 107 x2 + x22 +
1.48573 ´ 107 x3 + x32 + 4.86215 ´ 107 x4 - x42 , 1.95045 ´ 1014 + 3.15997 ´ 107 x1 +
x12 + 2.66023 ´ 107 x2 + x22 - 3.42677 ´ 107 x3 + x32 + 4.58292 ´ 107 x4 - x42 ,
2.81726 ´ 1014 - 3.96964 ´ 106 x1 + x12 + 2.37353 ´ 107 x2 + x22 - 4.74338 ´ 107 x3 +
x32 + 4.12576 ´ 107 x4 - x42 , 1.64642 ´ 1014 + 2.49605 ´ 107 x1 + x12 +
4.67651 ´ 107 x2 + x22 - 6.55695 ´ 106 x3 + x32 + 4.68448 ´ 107 x4 - x42 =
The start system consisting of univariate polynomials,
G = 8g1, g2, g3, g4< . data
91.03055 ´ 1014 - 2.96646 ´ 107 x1 + x12 , 1.95045 ´ 1014 + 2.66023 ´ 107 x2 + x22 ,
2.81726 ´ 1014 - 4.74338 ´ 107 x3 + x32 , 1.64642 ´ 1014 + 4.68448 ´ 107 x4 - x42 =
Let us compute the initial values as the solution of the start system,
X = 8x1, x2, x3, x4<;
X0 =
Transpose@Partition@Map@ð@@2DD &, Flatten@MapThread@NSolve@ð1 Š 0, ð2D &, 8G, X<DDD, 2DD
994.01833 ´ 106 , - 1.33011 ´ 107 - 4.25733 ´ 106 ä, 6.96083 ´ 106 , - 3.28436 ´ 106 =,
92.56463 ´ 107 , - 1.33011 ´ 107 + 4.25733 ´ 106 ä, 4.0473 ´ 107 , 5.01291 ´ 107 ==
Employing the path tracing algorithm by integration,
Γ = ä 81, 1, 1, 1<;
Off@NDSolve::"ndsz"D;
Off@InterpolatingFunction ::"dmval"D;
Off@NDSolve::"mxst"D;
sol = LinearHomotopyNDS01 @X, F, G, X0, Γ, 1D;  AbsoluteTiming
836.1093750, Null<
sol@@1DD
991.11159 ´ 106 + 1.95007 ´ 10-10 ä, - 4.34826 ´ 106 - 6.42863 ´ 10-10 ä,
4.52735 ´ 106 + 4.2815 ´ 10-10 ä, 100.001 + 5.04578 ´ 10-10 ä=, 80, 0, 0, 0<=
Eliminating imaginary tails
Chop@%, 9D
991.11159 ´ 106 , - 4.34826 ´ 106 , 4.52735 ´ 106 , 100.001=, 80, 0, 0, 0<=
The first (real) solution has physical meaning,
Linear_Homotopy_05.nb
35
NumberForm@%@@1DD, 16D
91.111590459962204 ´ 106 , -4.348258630909096 ´ 106 ,
4.527351820245797 ´ 106 , 100.0005506747956 =
The direct path search is much faster,
sol = LinearHomotopyFR @F, G, X, X0, Γ, 100D;  AbsoluteTiming
80.4375000, Null<
and gives practically one solution
sol@@1DD
991.11159 ´ 106 , - 4.34826 ´ 106 , 4.52735 ´ 106 , 100.001=,
91.11159 ´ 106 , - 4.34826 ´ 106 , 4.52735 ´ 106 , 100.001==
or
NumberForm@%@@1DD, 16D
91.111590459962204 ´ 106 , -4.348258630909095 ´ 106 ,
4.527351820245796 ´ 106 , 100.000550673451 =
The built function NSolve employing numerical Groebner basis provides the same result,
NSolve@F, XD
99x1 ® - 2.89212 ´ 106 , x2 ® 7.56878 ´ 106 , x3 ® - 7.20951 ´ 106 , x4 ® 5.74799 ´ 107 =,
9x1 ® 1.11159 ´ 106 , x2 ® - 4.34826 ´ 106 , x3 ® 4.52735 ´ 106 , x4 ® 100.001==
%@@2DD  NumberForm@ð, 16D &
9x1 ® 1.111590459962204 ´ 106 , x2 ® -4.348258630909095 ´ 106 ,
x3 ® 4.527351820245798 ´ 106 , x4 ® 100.0005506746748 =
5- 10- 3 Parallel Computing
Having acces to more processors and/ or more cores, homotopy solution can be computed in parallel way, since every
homotopy path belonging to different start values can be traced independently, simultaneously. Mathematica can utilize such
hardware configuration. You need a very small modification in calling our function.
Let us compute the GPS solution with single and with double core. The computation time can be reduced considerably,
especially when the original running time is high.
Here, in case of direct path tracing we used 1000 subintervall instead of 100 in order to stress the difference in the running
time, between one and double core computations.
AbsoluteTiming @sol = LinearHomotopyFR @F, G, X, X0, Γ, 1000D;D
83.2031250, Null<
Now, we employ a pure function for the elements of the list of the initial values (start values),
AbsoluteTiming @sol = ParallelTry@LinearHomotopyFR @F, G, X, 8ð<, Γ, 1000D &, X0D;D
82.9843750, Null<
Now employing the path tracing algorithms by integration with high precision,
36
Linear_Homotopy_05.nb
AbsoluteTiming @sol = LinearHomotopyNDS01 @X, F, G, X0, Γ, 1D;D
826.0625000, Null<
AbsoluteTiming @sol = ParallelTry@LinearHomotopyNDS01 @X, F, G, 8ð<, Γ, 1D &, X0D;D
84.2656250, Null<
and using numerical inverse,
AbsoluteTiming @sol = LinearHomotopyNDS02 @X, F, G, X0, Γ, 1D;D
891.1875000, Null<
AbsoluteTiming @sol = ParallelTry@LinearHomotopyNDS02 @X, F, G, 8ð<, Γ, 1D &, X0D;D
812.0312500, Null<
If the computation time with one core is short then the improvement using two cores is small because of the communication
time consumption between the cores. However in case of longer time, the improvement can be considerable.
Download