groebner basis 04 - springerextras.springer.com/.../pdfversion/groebner_basis_04.pdf · algebraic...
Post on 27-Apr-2018
218 Views
Preview:
TRANSCRIPT
Algebraic Geodesy and Geoinformatics 2009 PART I - METHODS
4 Groebner Basis
4- 1 Greatest common divisor of integers
Let us consider the following integer numbers 12, 20 and 18. Factorize them,
Clear@"Global‘*"D
FactorInteger@12D
882, 2<, 83, 1<<or
CenterDot �� HSuperscript ��� %L
22 × 31
similarly
FactorInteger@20D
882, 2<, 85, 1<<CenterDot �� HSuperscript ��� %L
22 × 51
and
FactorInteger@18D
882, 1<, 83, 2<<CenterDot �� HSuperscript ��� %L
21 × 32
From there the common factors give us the greatest common divisors,
21 * 30 * 50
2
One can compute it directly
GCD@12, 20, 18D
2
The original expression can be written as,
The original expression can be written as,
812, 20, 18< � 86 , 10, 9< * 2
True
4- 2 Greatest common divisor of univariate polynomials
Let us consider the following two polynomials.
f1 = 1 - 2 x2 + x4;
f2 = 3 - 2 x - x2;
If we are looking for the the common roots, then we should find out the greatest common divisor of the polynomials. This isthe highest degree polynomial that divides the two polynomials exactly. The roots of this polynomial will be the commonroots!
We employ elimination technique, which is essentially analog for polynomials of the Euclidean algorithm for integers. Let
f1 = f1; f2 = f2;
Step 1. f1 > f2, since
Exponent@f1 , xD > Exponent@f2 , xD
True
Let us multiply f2 by x2 and add to f1 in order to eliminate the highest order term, x4 from f1. With other words we reducethe highest order exponent of f1,
f1 = f1 + x2 f2 �� Expand
1 + x2 - 2 x3
Step 2. f1 > f2
Similarly
f1 = f1 - 2 x f2 �� Expand
1 - 6 x + 5 x2
Now, both polynomials are second order, although f1 ¹ f2,
f1 � -5 �� Expand
-1
5+6 x
5- x2
Step 3. f1 > f2
we need to eliminate x2 from f1
f1 = f1 + 5 f2 �� Expand
16 - 16 x
Step 4. f1 < f2
now we eliminate x2 from f2
2 Groebner_Basis_04.nb
f2 = x f1 � -16 + f2 �� Expand
3 - 3 x
But now it is clear that,
f1 � 16 � f2 � 3 �� Expand
True
and the greatest common divisor is,
-f1 � 16 �� Expand
-1 + x
Their greatest common divisors with the built in function,
gcd = PolynomialGCD@f1, f2D
-1 + x
and the reduced polynomials,
f1r = PolynomialQuotient@f1, x - 1, xD
-1 - x + x2 + x3
f2r = PolynomialQuotient@f2, x - 1, xD
-3 - x
Consequently the original polynomials can be expressed as
8f1, f2< == Hx - 1L 8f1r, f2r< �� Simplify
True
and
Solve@gcd � 0, xD �� Flatten
8x ® 1<Therefore the common root of the two polynomial is x = 1.
4- 3 Lexicographic order
In order to find the greatest common divisor of multivariate polynomials we may use the similar elimination technique butnow, the problem is the ordering. Which polynomial is greater than the other? In Mathematica we use lexicographic order, x> y , i.e., x comes before y. Let p1= x and p2 = y5 z9 two polynomials, then p1 is greater than p2.
Considering the following polynomial
poly = 2 x2 y8 - 3 x5 y z4 + x y z3 - x y4;
The list of the monomials in lexicographic order,
MonomialList@poly, 8x, y, z<D
9-3 x5 y z4, 2 x2 y8, -x2 y5, x y z3=This is the list of the monomials represented as exponent vectors and coefficients,
Groebner_Basis_04.nb 3
CoefficientRules@poly, 8x, y, z<D
885, 1, 4< ® -3, 82, 8, 0< ® 2, 82, 5, 0< ® -1, 81, 1, 3< ® 1<or
CoefficientRules@polyD
885, 1, 4< ® -3, 82, 8, 0< ® 2, 82, 5, 0< ® -1, 81, 1, 3< ® 1<By default the monomials are sorted lexicographically and given in the decreasing order.
In this example, 85, 1, 4< - corresponding to x5 y x4 -
is taken to precede 82, 8, 0< - corresponding to x2 y8 z0 - by the second element.
The numbers - 3 and 2 are the corresponding coefficients of these terms.
The following functions can be defined:
- the leading coefficient,
LC@p_D := CoefficientRules@pD@@1, 2DD
LC@polyD
-3
- the leading term,
LT@p_D := MonomialList@pD@@1DD
LT@polyD
-3 x5 y z4
- the leading monomial,
LM@p_D := LT@pD � LC@pD �� Simplify
LM@polyD
x5 y z4
4- 4 Greatest common divisor of multivariate polynomials
In that case the normal Euclidean algorithm does not work. Let
g1 = x y;
g2 = x + y;
then
PolynomialGCD@g1, g2D
1
It would mean, that g1 and g2 are relativ primes. However they are not,
8G1, G2< = GroebnerBasis@8g1, g2<, 8x, y<D
9y2, x + y=where G1 and G2 represent the Groebner basis. The polynomials g1(x, y) and g2(x, y) can be expressed as the linearcombination of G1 and G2.
4 Groebner_Basis_04.nb
where G1 and G2 represent the Groebner basis. The polynomials g1(x, y) and g2(x, y) can be expressed as the linearcombination of G1 and G2.
g1 � 8-1 , y<.8G1, G2<
x y � -y2 + y Hx + yLSimplify@%D
True
and
g2 == 80, 1<.8G1, G2<
True
Formally we can consider the Groebner basis as the greatest common divisors of g1 and g2,
8g1, g2< � 88-1, y<, 80, 1<<.8G1, G2< �� Simplify
True
4- 5 Employing Groebner basis for solving polynomial system
The Grobner basis of the polynomial system, {G1(x,y), G2(x,y)} can be considered as another but equivalent representationof {g1 (x, y), g2 (x, y)}, in sense of the roots of the system, since g1 and g2 can be expressed as linear combination of themembers of the Groebner basis.
Consider F (x, y) = {f1, f2}, where
f1 = x y - 2 y;
f2 = 2 y2 - x2;
Now we seek a simplified representation, G(x, y), where one of the polynomials is an univariate one, see Section 2- 11- 2!
G = GroebnerBasis@8f1, f2<, 8y, x<D
9-2 x2 + x3, -2 y + x y, -x2 + 2 y2=then G(1) can be solved numerically,
Roots@G@@1DD � 0, xD
x � 2 ÈÈ x � 0 ÈÈ x � 0
and substituting them in the third element of the set G to solve for y,
Roots@HG@@3DD �. x ® 2L � 0, yD
y � 2 ÈÈ y � - 2
and
Roots@HG@@3DD �. x ® 0L � 0, yD
y � 0 ÈÈ y � 0
Solving the system directly, we get the same pairs of roots,
Groebner_Basis_04.nb 5
Solve@8f1 � 0, f2 � 0<, 8x, y<D
:8x ® 0, y ® 0<, 8x ® 0, y ® 0<, :y ® - 2 , x ® 2>, :y ® 2 , x ® 2>>
4- 6 Ideal of polynomials
The systems of G(x, y) and F(x,y) can be considered as two different bases or generators of the same ideal I. We learnt thatpolynomials are elements of a ring and they satisfy the ring axioms of addition and substruction. The computation of theGroebner basis is achieved by the capability to manipulate the polynomials to generate ideals.
It is easy to test whether a polynomial belongs to the ideal generated by a set of polynomials. If f is a polynomial and pi is a
set of polynomials generating an ideal, then f can be expressed as
f = âci pi + r
where r is the minimal remainder modulo. If this remainder modulo is zero, then f belongs to the ideal.Now let us check whether f1 and f2 belong to the ideal generated by the Groebner basis, G.
8c, r< = PolynomialReduce@f1, G, 8x, y<D
880, 1, 0<, 0<f1 � c.G + r
True
and
r
0
Similarly,
8c, r< = PolynomialReduce@f2, G, 8x, y<D
880, 0, 1<, 0<Vice versa,
PolynomialReduce@G@@1DD, 8f1, f2<, 8x, y<D
882 y, 2 - x<, 0<and
PolynomialReduce@G@@2DD, 8f1, f2<, 8x, y<D
881, 0<, 0<It means that the elements of G belong to the ideal F = {f1, f2}. Consequently F and G generate the same ideal.
4- 7 Buchberger algorithm
The algorithm for computing Groebner basis uses S polynomial function. Let consider two polynomials, f and g, then
Clear@SD
S@f_, g_D := PolynomialLCM@LM@fD, LM@gDDf
LT@fD-
g
LT@gD�� Simplify
For example, let
6 Groebner_Basis_04.nb
For example, let
p1 = x2 + y; p2 = x + y;
This S polynomial function will reduce p1 to p3, employing p2.
p3 = S@p1, p2D
y - x y
Now, on one hand
p3 = c1 p1 + c2 p2
where
c1 = 1 and c2 = - x
p3 � 1 p1 + H-xL p2 �� Simplify
True
therefore p3 belongs to the same ideal, which generated by p1 and p2. On the other hand
p1 = p3 - c2 p2
p1 � p3 - H-xL p2 �� Simplify
True
which means that the ideal I = X p1 , p2 \ is the same as I = X p2 , p3 \, but in different representation.
The new basis is,
X p2 , p3 \ = X x + y, y - x y\Because, the leading monomials are LM(p2) = x and LM( p3) = x y, further reduction is possible,
LM@p2D
x
LM@p3D
x y
p4 = S@p2, p3D �� Expand
y + y2
The new basis is,
8p2 , p4< = 9x + y, y + y2=
Now, because
LM@p2D
x
and
LM@p4D
y2
no further reduction is possible. Using built-in function
Groebner_Basis_04.nb 7
no further reduction is possible. Using built-in function
GroebnerBasis@8p1, p2<, 8x, y<D
9y + y2, x + y=But of course
GroebnerBasis@8p2, p3<, 8x, y<D
9y + y2, x + y=is also true.
4- 8 Mathematica computation of Groebner basis
In Mathematica Groebner basis can be easily computed,
eqs = 9x2 + 3 x + 4 y, 2 y2 + 4 x + 5 y + 9=;
GroebnerBasis@eqs, 8x, y<D
9-27 + 94 y + 37 y2 + 20 y3 + 4 y4, 9 + 4 x + 5 y + 2 y2=By Hilbert’ s Nullstellensatz, if the ideal is {1} then the polynomials have no common zero,
GroebnerBasis@8x + y, x^2 - 1, y^2 - 2 x<, 8x, y<D
81<The default options of this function are,
Options@GroebnerBasisD
8CoefficientDomain ® Automatic, Method ® Automatic, Modulus ® 0,
MonomialOrder ® Lexicographic, ParameterVariables ® 8<, Sort ® False, Tolerance ® 0<eqs = {2 x^4 y + y^3 x^3 - x z^2 + 1, x^2 + y^2 z^3 - 1, x^2 y - 7 y^3 z^2 + y^2 z^3};
The default method is the Groebner - Walk, which sometimes works faster than the Buchberger algorithm
(gb = GroebnerBasis[eqs, {x, y, z}]); // Timing
80.203, Null<(gb = GroebnerBasis[eqs, {x, y, z},Method-> "Buchberger"]); // Timing
80.235, Null<The basis consists of 3 polynomials, where the exponents of the variables x, y and z respectively
Exponent@ð, 8x, y, z<D & �� gb
880, 0, 44<, 80, 1, 43<, 81, 0, 43<<The first polynomial in the basis is an univariate polynomial of degree 44,
8 Groebner_Basis_04.nb
gb@@1DD
117 649 - 46 236 057 z4 - 6 595 547 z5 - 80 707 214 z6 + 51 059 666 z7 + 4 571 604 842 z8 +
1 298 818 549 z9 - 20 298 041 848 z10 - 24 001 149 914 z11 + 1 455 250 216 z12 + 30 811 711 266 z13 +
31 232 547 766 z14 + 20 170 837 063 z15 - 36 237 809 370 z16 - 85 757 329 609 z17 - 51 785 684 006 z18 -
11 507 822 346 z19 + 41 012 782 674 z20 + 73 248 097 707 z21 + 54 340 160 189 z22 + 20 824 284 830 z23 -
9 324 213 804 z24 - 19 647 822 019 z25 - 13 785 492 799 z26 - 5 796 697 370 z27 - 1 536 300 404 z28 +
26 559 267 z29 + 372 895 414 z30 + 258 968 812 z31 + 104 738 883 z32 + 26 589 276 z33 + 4 329 844 z34 +
518 264 z35 + 65 037 z36 - 28 911 z37 - 7542 z38 + 939 z39 + 330 z40 + 21 z41 + 196 z42 + 56 z43 + 4 z44
Changing the coeffient domain from infinite precision to number with finite precision, the computation time can be reduced,
HgbN = GroebnerBasis@N@eqs, 300D, 8x, y, z<,CoefficientDomain -> InexactNumbersDL; �� Timing
80.187, Null<The result is practically the same
NSolve@gb@@1DD � 0, zD
88z ® -7.1865<, 8z ® -6.80836<, 8z ® -2.27987 - 1.12953 ä<, 8z ® -2.27987 + 1.12953 ä<,8z ® -2.07184 - 1.76484 ä<, 8z ® -2.07184 + 1.76484 ä<, 8z ® -1.96926<,8z ® -1.77133 - 1.28682 ä<, 8z ® -1.77133 + 1.28682 ä<, 8z ® -1.24096<, 8z ® -1.<,8z ® -0.954096 - 2.28913 ä<, 8z ® -0.954096 + 2.28913 ä<, 8z ® -0.555164<,8z ® -0.548026 - 0.540556 ä<, 8z ® -0.548026 + 0.540556 ä<, 8z ® -0.400539<,8z ® -0.367271 - 1.31691 ä<, 8z ® -0.367271 + 1.31691 ä<, 8z ® -0.233676<,8z ® -0.0367005 - 0.25117 ä<, 8z ® -0.0367005 + 0.25117 ä<, 8z ® 0. - 1. ä<, 8z ® 0. + 1. ä<,8z ® 0.0428975 - 0.247826 ä<, 8z ® 0.0428975 + 0.247826 ä<, 8z ® 0.230852<,8z ® 0.241211 - 1.06447 ä<, 8z ® 0.241211 + 1.06447 ä<, 8z ® 0.370407 - 0.0998822 ä<,8z ® 0.370407 + 0.0998822 ä<, 8z ® 0.444639 - 3.29218 ä<, 8z ® 0.444639 + 3.29218 ä<,8z ® 0.698402 - 2.0687 ä<, 8z ® 0.698402 + 2.0687 ä<, 8z ® 0.722791 - 0.321214 ä<,8z ® 0.722791 + 0.321214 ä<, 8z ® 1.<, 8z ® 1.285<, 8z ® 2.14356<, 8z ® 2.18865 - 2.9481 ä<,8z ® 2.18865 + 2.9481 ä<, 8z ® 3.68765 - 1.18149 ä<, 8z ® 3.68765 + 1.18149 ä<<
and
NSolve@gbN@@1DD � 0, z, 6D
88z ® -7.18650<, 8z ® -6.80836<, 8z ® -2.27987 - 1.12953 ä<, 8z ® -2.27987 + 1.12953 ä<,8z ® -2.07184 - 1.76484 ä<, 8z ® -2.07184 + 1.76484 ä<, 8z ® -1.96926<,8z ® -1.77133 - 1.28682 ä<, 8z ® -1.77133 + 1.28682 ä<, 8z ® -1.24096<,8z ® -1.00000<, 8z ® -0.95410 - 2.28913 ä<, 8z ® -0.95410 + 2.28913 ä<,8z ® -0.555164<, 8z ® -0.548026 - 0.540556 ä<, 8z ® -0.548026 + 0.540556 ä<,8z ® -0.400539<, 8z ® -0.367271 - 1.316906 ä<, 8z ® -0.367271 + 1.316906 ä<,8z ® -0.233676<, 8z ® -0.036700 - 0.251170 ä<, 8z ® -0.036700 + 0.251170 ä<,8z ® -1.00000 ä<, 8z ® 1.00000 ä<, 8z ® 0.042897 - 0.247826 ä<,8z ® 0.042897 + 0.247826 ä<, 8z ® 0.230852<, 8z ® 0.241211 - 1.064471 ä<,8z ® 0.241211 + 1.064471 ä<, 8z ® 0.370407 - 0.099882 ä<, 8z ® 0.370407 + 0.099882 ä<,8z ® 0.44464 - 3.29218 ä<, 8z ® 0.44464 + 3.29218 ä<, 8z ® 0.69840 - 2.06870 ä<,8z ® 0.69840 + 2.06870 ä<, 8z ® 0.722791 - 0.321214 ä<, 8z ® 0.722791 + 0.321214 ä<,8z ® 1.00000<, 8z ® 1.28500<, 8z ® 2.14356<, 8z ® 2.18865 - 2.94810 ä<,8z ® 2.18865 + 2.94810 ä<, 8z ® 3.68765 - 1.18149 ä<, 8z ® 3.68765 + 1.18149 ä<<
However, we need to use high precision,
(gbN = GroebnerBasis[N[eqs, 200], {x, y, z}, CoefficientDomain -> InexactNumbers]); // Timing
GroebnerBasis::fltgb: Excessive loss of precision during computation. �
80.172, Null<The order of the variables has influence on the form of the basis,
Groebner_Basis_04.nb 9
The order of the variables has influence on the form of the basis,
GroebnerBasis@8x + y + z, x - 2 y + z^3, x^2 - 2 y^3 + z<, 8x, y, z<D
9-27 z - 12 z2 - 2 z3 - 12 z4 + 6 z5 - 3 z6 - 6 z7 + 2 z9, 3 y + z - z3, 3 x + 2 z + z3=or
GroebnerBasis@8x + y + z, x - 2 y + z^3, x^2 - 2 y^3 + z<, 8z, y, x<D
9-27 x + 18 x2 - 342 x3 + 306 x4 - 186 x5 + 229 x6 - 18 x7 + 12 x8 + 8 x9,
-3 469 149 x + 826 587 x2 - 297 774 x3 + 1 547 550 x4 + 1 141 206 x5 + 33 316 x6 +
169 480 x7 + 48 784 x8 + 1 194 237 y, 4 663 386 x - 826 587 x2 + 297 774 x3 -
1 547 550 x4 - 1 141 206 x5 - 33 316 x6 - 169 480 x7 - 48 784 x8 + 1 194 237 z=Computation time may be reduced by using reverse lexicographic order,
Timing@HgbLex = GroebnerBasis@8x^4 + y + z, x - 2 y^3 + 5 z^3, x^2 - 7 y^3 + z^4<, 8z, y, x<,
MonomialOrder -> LexicographicDL;D80.094, Null<Timing@
HgbDegRevLex = GroebnerBasis@8x^4 + y + z, x - 2 y^3 + 5 z^3, x^2 - 7 y^3 + z^4<,8z, y, x<, MonomialOrder -> DegreeReverseLexicographic DL;D
80., Null<Both basis have 4 polynomials,
Map[Length, {gbLex,gbDegRevLex}]
84, 4<The order of the polynomials are considerably lower in the second case,
Map[Length, {gbLex, gbDegRevLex}, {2}]
8828, 46, 46, 3<, 83, 3, 4, 8<<However, in case of the reverse lexicographic order our system is not triangular,
(Exponent[#, {x, y, z}]& /@ #)& /@ {gbLex, gbDegRevLex}
88846, 0, 0<, 845, 1, 0<, 845, 3, 0<, 84, 1, 1<<, 881, 3, 3<, 84, 1, 1<, 82, 3, 1<, 82, 6, 2<<<gbDegRevLex
9x - 2 y3 + 5 z3, x4 + y + z, 5 x2 - 35 y3 - x z + 2 y3 z,
30 629 x2 - 214 375 y3 - 16 x y3 + 16 y6 - 6125 x z + 1750 x2 z - 350 x z2 + 100 x2 z2=Let us set ordering option to elimination order for an interesting example: What is the largest area that a hexagon of unitdiameter can have? Interestingly, the largest area is not the one of a regular hexagon. It can be shown that the hexagon weare looking for must have mirror symmetry and be of the following form, see Fig.5.1. Without loss of generality we can usethe following parametrization of the hexagon,
Clear["x*", "y*"];p1 = {0, 0}; p2 = { x2, y2}; p3 = { x3, y3};p4 = {0, 1}; p5 = {-x3, y3}; p6 = {-x2, y2};
10 Groebner_Basis_04.nb
Block[{x2 = 0.5, y2 = 0.402, x3 = 0.343, y3 = 0.939}, Show[Graphics[{{Hue[0], Thickness[0.01], (* outline *) Line[{p1, p2, p3, p4, p5, p6, p1}]}, {GrayLevel[0], Thickness[0.002], (* diagonals *) Line[{p1, p3}], Line[{p1, p5}], Line[{p2, p5}], Line[{p3, p6}], Line[{p1, p4}], Line[{p2, p5}]}}], PlotRange -> All, Frame -> True, AspectRatio -> Automatic]]
-0.4 -0.2 0.0 0.2 0.4
0.0
0.2
0.4
0.6
0.8
1.0
Fig. 5 .1 Optimal hexagon of unit diameter
The above hexagon has four degrees freedom, the coordinates of the points p2 and p3. It follows from elementary geometrythat the area of the hexagon is given by x3 - x3 y2 + x2 y3. We take the unit diameter conditions into account using Λ1, Λ2,
and Λ3 Lagrange multipliers,
area = x3 - x3 y2 + x2 y3;L = area + Λ1 (#.#&[p1 - p3] - 1) + Λ2 (#.#&[p2 - p5] - 1) + Λ3 (#.#&[p2 - p6] - 1)
x3 - x3 y2 + x2 y3 + I-1 + x32 + y32M Λ1 + I-1 + Hx2 + x3L2+ Hy2 - y3L2M Λ2 + I-1 + 4 x22M Λ3
The maximum values of the area is represented with the variable area . In order to get this value, we eliminate all of the othervariables from the Groebner basis, we call it as reduced Groebner basis, see also in Section 2- 11- 2. The variables {area , x2,y2, x3, y3, Λ1, Λ2, Λ3} will be eliminated and in addition the option for elimination order is MonomialOrder ® Elimina-
tionOrder,
GroebnerBasis[ {area - area, D[L, x2], D[L, y2], D[L, x3], D[L, y3], D[L, Λ1], D[L, Λ2], D[L, Λ3]}, {area}, {x2, y2, x3, y3, Λ1, Λ2, Λ3}, MonomialOrder -> EliminationOrder] // Factor
9I11 993 + 78 488 area + 144 464 area2 - 1232 area
3 - 221 360 area4 -
146 496 area5 + 21 056 area
6 + 30 848 area7 - 3008 area
8 - 8192 area9 + 4096 area
10MI11 993 - 78 488 area + 144 464 area
2 + 1232 area3 - 221 360 area
4 + 146 496 area5 +
21 056 area6 - 30 848 area
7 - 3008 area8 + 8192 area
9 + 4096 area10M=
Remark: In this case, the variables to be eliminated are represented by the third list in the function. For example, computingthe reduced Groebner basis for the variable area , the variables {x2, y2, x3, y3, Λ1, Λ2, Λ3} should be eliminated.
The root which is real and larger than the area of a regular hexagon,
Groebner_Basis_04.nb 11
Select[NSolve[%[[1]] == 0, area], Im[(area /. #)] == 0 && (* larger than regular hexagon *) 3 Sqrt[3]/8 < (area /. #)&][[1]]
8area ® 0.674981<The area of the regular hexagon is,
3 Sqrt@3D � 8.
0.649519
It is nearly 4 % smaller the the area of our hexagon above.
Here we present a function, which is useful if one wants to study the effect of
- the order of variables- the type of elimination order- the type of the coeffient domain
and other options of the GroebnerBasis function implemented in Mathematica
GroebnerBasisStatistics @polys_, vars_, opts___D :=
Module@8time, gb, numberPolys, numberTerms, totalDegrees, w, maxcoeffs<,time = First@Timing@gb = GroebnerBasis@polys, vars, optsDDD;numberPolys = Length@gbD; numberTerms = Length �� gb; totalDegrees =
HExponent@ð1, wD &L �� Hgb �. Thread@vars -> Table@Random@D, 8Length@varsD<D wDL;maxcoeffs = HMax@Abs@List �� ð1 �. Thread@Variables@polysD -> 1DDD &L �� gb;
TableForm@88" ", " ", " "<, 8" ", " ", " "<, 8time, numberPolys "polys", " "<,8" ", " ", " "<, 8"terms", "total", "max"<, 8"in poly", "degrees", "coeffs"<,8" ", " ", " "<, 8numberTerms, totalDegrees, maxcoeffs<<DD
Let us consider the following polynomial system,
polys = 9x6 + y4 + z3 - 1, x5 + y3 + z2 - 1=;
GroebnerBasisStatistics @polys, 8y, z, x<D
0.109 7 polys
terms total max
in poly degrees coeffs
2219019062041994
202928628285
1276168130969721
Let us change the order of the variables,
12 Groebner_Basis_04.nb
GroebnerBasisStatistics @polys, 8z, y, x<D
0.016 5 polys
terms total max
in poly degrees coeffs
141329164
15201665
615511
This result is better. Let us give another variable order,
GroebnerBasisStatistics @polys, 8x, y, z<D
0.578 11 polys
terms total max
in poly degrees coeffs
4446045664704854965055095154
20333243232323232325
9092 15831 845 473 36011 142 984 893 32546 422 823 129 589 450463 975 321 160 615 58475 399 319 152 268 460 053824 803 805 400 478 498 421373 123 721 045 048 098 6541
Now we got the best result. Let us change the monomial order,
GroebnerBasisStatistics @polys, 8x, y, z<, MonomialOrder ® DegreeReverseLexicographic D
0. 3 polys
terms total max
in poly degrees coeffs
6437
458
114
The result could be improved. Let us consider the variable z as constant and change the coefficient domain,
GroebnerBasisStatistics @polys, 8x, y<, CoefficientDomain ® RationalFunctionsD
0.25 2 polys
terms total max
in poly degrees coeffs
1947
2019
3041 884
Now the basis consists of only two polynomials.
4- 9 Examples
Groebner_Basis_04.nb 13
4- 9 Examples
4- 9- 1 3D Resection
Let us solve the Grunert’s distance equations (see the text book),
p1 = x12 - x1 x2 + x22 - d � 0;
p2 = x22 - x2 x3 + x32 - d � 0;
p3 = x32 - x1 x3 + x12 - d � 0;
The Groebner basis
Gb = GroebnerBasis@8p1, p2, p3<, 8x1, x2, x3<, ParameterVariables ® 8d<D; TableForm@GbD
-d x3 + x33
-d + x22 - x2 x3 + x32
-d x1 + d x2 + x1 x32 - x2 x32
-d + x1 x2 - x1 x3 - x2 x3 + 2 x32
-d + x12 - x1 x3 + x32
This is a triangular system. Let us solve it,
Solve@Map@ð � 0 &, GbD, 8x1, x2, x3<D
::x1 ® 0, x2 ® - d , x3 ® - d >, :x1 ® 0, x2 ® d , x3 ® d >,:x1 ® - d , x2 ® 0, x3 ® - d >, :x1 ® - d , x2 ® - d , x3 ® 0>,:x1 ® - d , x2 ® - d , x3 ® - d >, :x1 ® - d , x2 ® - d , x3 ® - d >,:x1 ® d , x2 ® 0, x3 ® d >, :x1 ® d , x2 ® d , x3 ® 0>,:x1 ® d , x2 ® d , x3 ® d >, :x1 ® d , x2 ® d , x3 ® d >>
From geometric point of view, only the positive solutions should be considered,
Last@%D
:x1 ® d , x2 ® d , x3 ® d >The full symmetry of the problem can be revealed, when reduced Groebner Basis is computed,
Gbx1 = GroebnerBasis@8p1, p2, p3<, 8x1, x2, x3<, 8x2, x3<D
9-d x1 + x13=Gbx2 = GroebnerBasis@8p1, p2, p3<, 8x1, x2, x3<, 8x1, x3<D
9-d x2 + x23=Gbx3 = GroebnerBasis@8p1, p2, p3<, 8x1, x2, x3<, 8x1, x2<D
9-d x3 + x33=In general
Clear@XD
14 Groebner_Basis_04.nb
SolveA-d X + X3 � 0, XE
:8X ® 0<, :X ® - d >, :X ® d >>
4-9-2 2D Helmert transformation
Transformation from one system of coordinates to another is a very useful operation that is used frequently in photogramme-
try, geodesy, and surveying. Considering two dimensional space, the transformation from one cartesian coordinate system to
another with rotation and scale
X
Y=
x s cos HWL -y s sin HWLx s sin HWL y s cos HWL
or
X
Y= s
cos HWL - sin HWLsin HWL cos HWL
x
y=
Α - Β
Β Α
x
y
Let us suppose, that we have measurements for three corresponding data pairs (xi, yi) ® (Xi, Yi), i = 1,2,3, respectively, see
Table 5.1
Table 5.1
Measured data pairs in the two systems
i xi yi Xi Yi
a 0.0 1.0 -2.1 1.1
b 1.0 0.0 1.0 2.0
c 1.0 1.0 -0.9 2.8
We require the least square estimates of the transformation parameters, Α and Β and simultaneously the adjustment of thecoordinates, namely xa, xb, xc,Xa, Xb,and Xc.
Applying the two equations of the transformation for each of the three point - pairs with the adjusted values, we get,
fa = Α Hxa + dxaL - Β ya - HXa + dXaL;
ga = Β Hxa + dxaL + Α ya - Ya;
fb = Α Hxb + dxbL - Β yb - HXb + dXbL;
gb = Β Hxb + dxbL + Α yb - Yb;
fc = Α Hxc + dxcL - Β yc - HXc + dXcL;
gc = Β Hxc + dxcL + Α yc - Yc;
In these 6 equations there are 8 unknowns, the adjustments (dxa, dxb, dxc,dXa, dXb, dXc) and the two parameters (Α , Β) to beestimated. This underdetermined system can be transformed into a constrained minimization problem formulated withLagrange multipliers, Λ1, ..., Λ6
F = dxa2 + dxb2 + dxc2 + dXa2 + dXb2 + dXc2 + 8Λ1, Λ2, Λ3, Λ4, Λ5, Λ6<.8fa, ga, fb, gb, fc, gc<;
Now, we have 14 unknowns,
d = 8dxa, dxb, dxc, dXa, dXb, dXc, Α, Β, Λ1, Λ2, Λ3, Λ4, Λ5, Λ6<;
The necessary condition for the existence of the optimum provides the following polynomials,
Groebner_Basis_04.nb 15
eq = Table@D@F, d@@iDDD, 8i, 1, 14<D
82 dxa + Α Λ1 + Β Λ2, 2 dxb + Α Λ3 + Β Λ4, 2 dxc + Α Λ5 + Β Λ6, 2 dXa - Λ1, 2 dXb - Λ3,
2 dXc - Λ5, Hdxa + xaL Λ1 + ya Λ2 + Hdxb + xbL Λ3 + yb Λ4 + Hdxc + xcL Λ5 + yc Λ6,
-ya Λ1 + Hdxa + xaL Λ2 - yb Λ3 + Hdxb + xbL Λ4 - yc Λ5 + Hdxc + xcL Λ6,
-dXa - Xa + Hdxa + xaL Α - ya Β, -Ya + ya Α + Hdxa + xaL Β, -dXb - Xb + Hdxb + xbL Α - yb Β,
-Yb + yb Α + Hdxb + xbL Β, -dXc - Xc + Hdxc + xcL Α - yc Β, -Yc + yc Α + Hdxc + xcL Β<Using rational data providing infinite precision,
xa = 0; ya = 1; Xa = -21 � 10; Ya = 11 � 10;
xb = 1; yb = 0; Xb = 1; Yb = 2;
xc = 1; yc = 1; Xc = -9 � 10; Yc = 28 � 10;
then
eq
:2 dxa + Α Λ1 + Β Λ2, 2 dxb + Α Λ3 + Β Λ4, 2 dxc + Α Λ5 + Β Λ6,
2 dXa - Λ1, 2 dXb - Λ3, 2 dXc - Λ5, dxa Λ1 + Λ2 + H1 + dxbL Λ3 + H1 + dxcL Λ5 + Λ6,
-Λ1 + dxa Λ2 + H1 + dxbL Λ4 - Λ5 + H1 + dxcL Λ6,21
10- dXa + dxa Α - Β, -
11
10+ Α + dxa Β,
-1 - dXb + H1 + dxbL Α, -2 + H1 + dxbL Β,9
10- dXc + H1 + dxcL Α - Β, -
14
5+ Α + H1 + dxcL Β>
Let us compute the Groebner basis,
gr = GroebnerBasis@eq, dD; �� Timing
80.203, Null<This basis consists of 14 polynomials,
Length@grD
14
and they represent a triangular system,
Table@Exponent@gr@@iDD, dD, 8i, 1, 14<D
880, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6<, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 5<,80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 5<, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 5<,80, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 5<, 80, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 5<,80, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 5<, 80, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 5<,80, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 5<, 80, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 5<,80, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5<, 80, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5<,80, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5<, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5<<
The first basis is a monomial of the variable Λ6, namely
gr@@1DD
-7 630 949 955 162 482 528 767 108 340 +
42 959 839 227 889 682 667 793 048 133 Λ6 - 48 918 108 637 327 112 393 858 971 361 Λ62+
10 461 095 486 070 027 991 388 157 780 Λ63+ 10 401 874 932 371 574 116 079 405 000 Λ64
-
3 829 299 680 266 483 288 767 890 625 Λ65+ 349 089 071 788 949 996 689 453 125 Λ66
This is a polynomial with degree of six for Λ6. The solutions are
16 Groebner_Basis_04.nb
solΛ6 = NSolve@gr@@1DD � 0, Λ6D
88Λ6 ® -2.14502<, 8Λ6 ® 0.238268<, 8Λ6 ® 1.10343 - 0.462287 ä<,8Λ6 ® 1.10343 + 0.462287 ä<, 8Λ6 ® 5.33465 - 1.19353 ä<, 8Λ6 ® 5.33465 + 1.19353 ä<<
Let us consider the positive, real solution,
Λ6 = Λ6 �. solΛ6@@2DD
0.238268
Then the values of the other variables can be easily computed via successive elimination.
d
8dxa, dxb, dxc, dXa, dXb, dXc, Α, Β, Λ1, Λ2, Λ3, Λ4, Λ5, 0.238268<We are interested in the first 8 variables,
Table@d@@iDD �. Solve@Reverse@grD@@iDD � 0, d@@iDDD, 8i, 1, 8<D �� Flatten
80.0218895, 0.0215372, -0.109804, 0.165307, 0.0799118, -0.116768, 1.05714, 1.95783<or with
dr = Take@d, 81, 8<D
8dxa, dxb, dxc, dXa, dXb, dXc, Α, Β<MapThread@ð1 ® ð2 &, 8dr, %%<D
8dxa ® 0.0218895, dxb ® 0.0215372, dxc ® -0.109804,
dXa ® 0.165307, dXb ® 0.0799118, dXc ® -0.116768, Α ® 1.05714, Β ® 1.95783<In order to check our result, we solve this constrained optimization problem by direct global minimization with the built infunction NMinimize of Mathematica, too.
NMinimizeA9dxa2 + dxb2 + dxc2 + dXa2 + dXb2 + dXc2,
fa � 0, fb � 0, fc � 0, ga � 0, gb � 0, gc � 0=, drE �� Timing
80.328, 80.0603469, 8dxa ® 0.0218895, dxb ® 0.0215372, dxc ® -0.109804,
dXa ® 0.165307, dXb ® 0.0799118, dXc ® -0.116768, Α ® 1.05714, Β ® 1.95783<<<So we have got the same result, but the computation time is longer than in case of Groebner basis solution.
Groebner_Basis_04.nb 17
top related