File: dixon.gi

package info (click to toggle)
gap-polycyclic 2.17-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 2,796 kB
  • sloc: xml: 3,018; javascript: 155; makefile: 124
file content (178 lines) | stat: -rw-r--r-- 5,374 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#############################################################################
##
#W  dixon.gi                                                     Bettina Eick
##
##  Determine Dixon's Bound for torsion free semisimple matrix groups.
##

#############################################################################
##
#F PadicValue( rat, p )
##
BindGlobal( "PadicValue", function( rat, p )
    local a1, a2;
    a1 := AbsInt( NumeratorRat(rat) );
    a2 := DenominatorRat(rat);
    a1 := Length( Filtered( FactorsInt(a1), x -> x = p ) );
    a2 := Length( Filtered( FactorsInt(a2), x -> x = p ) );
    return a1 - a2;
end );

#############################################################################
##
#F LogAbsValueBound( rat )
##
BindGlobal( "LogAbsValueBound", function( rat )
    local a1, a2, a;
    a1 := LogInt( AbsInt( NumeratorRat(rat) ), 2 );
    a2 := LogInt( DenominatorRat(rat), 2 );
    a  := Maximum( AbsInt( a1 - a2 + 1 ), AbsInt( a1 - a2 - 1) );
    return QuoInt( a * 3, 4 );
end );

#############################################################################
##
#F ConsideredPrimes( rats )
##
BindGlobal( "ConsideredPrimes", function( rats )
    local pr, r, a1, a2, tmp;
    pr := [];
    for r in rats do
        a1 := AbsInt( NumeratorRat(r) );
        a2 := DenominatorRat(r);
        if a1 <> 1 then
            tmp := FactorsInt( a1: RhoTrials := 1000000 );
            pr := Union( pr, tmp );
        fi;
        if a2 <> 1 then
            tmp := FactorsInt( a2: RhoTrials := 1000000 );
            pr := Union( pr, tmp );
        fi;
    od;
    return pr;
end );

#############################################################################
##
#F CoefficientsByBase( base, vec )
##
BindGlobal( "CoefficientsByBase", function( base, vec )
    local sol;
    sol := MemberBySemiEchelonBase( vec, base.vectors );
    if IsBool( sol ) then return fail; fi;
    return sol * base.coeffs;
end );

#############################################################################
##
#F FullDixonBound( gens, prim )
##
BindGlobal( "FullDixonBound", function( gens, prim )
    local c, f, j, n, d, minp, sub, max, cof, deg, base, cofs, dofs,
          g, pr, t1, p, s, i, a, b, t2, t;

    # set up
    c := prim.elem;
    f := prim.poly;
    n := Length( gens );
    d := Degree(f);
    cof := CoefficientsOfUnivariatePolynomial( f );
    if cof[1] <> 1 or cof[d+1] <> 1 then return fail; fi;

    # get prim-basis
    # Print("compute prim-base \n");
    base := List([0..d-1], x -> Flat(c^x));
    base := SemiEchelonMatTransformation( base );

    # get coeffs of gens in prim-base
    Print("compute coefficients \n");
    cofs := [];
    dofs := [];
    for g in gens do
        Add( cofs, CoefficientsByBase( base, Flat( g ) ) );
        Add( dofs, CoefficientsByBase( base, Flat( g^-1 ) ) );
    od;

    Print("compute relevant primes \n");
    pr := ConsideredPrimes( Flat( Concatenation(  cofs, dofs ) ) );

    # first consider p-adic case
    Print("p-adic valuations \n");
    t1 := 0;
    for p in pr do
        s := 0;
        for i in [1..n] do
            a := AbsInt( Minimum( List( cofs[i], x -> PadicValue(x,p) ) ) );
            b := AbsInt( Minimum( List( dofs[i], x -> PadicValue(x,p) ) ) );
            s := s + Maximum( a, b );
        od;
        t1 := Maximum( t1, s );
    od;
    t1 := d * t1;
    Print("non-archimedian: ", t1,"\n");

    # then the log-value
    Print("logarithmic valuations \n");
    t := Maximum( List( cof, x -> LogAbsValueBound( 1+AbsInt(x) ) ) );
    t2 := 0;
    for i in [1..n] do
        if gens[i] = c then
            t2 := t2 + t;
        else
            a := LogAbsValueBound( Sum( AbsInt( cofs[i] ) ) );
            b := LogAbsValueBound( Sum( AbsInt( dofs[i] ) ) );
            t2 := t2 + (d-1) * t + Maximum( a, b );
        fi;
    od;
    t2 := QuoInt( 3 * 7 * d^2 * t2, 2 * LogInt(d,2) );
    Print("archimedian: ", t2,"\n");

    t := Maximum( t1, t2 );
    return QuoInt( t^n + 1, t );
end );

#############################################################################
##
#F LogDixonBound( gens, prim )
##
BindGlobal( "LogDixonBound", function( gens, prim )
    local c, f, d, base, cofs, dofs, g, t, s, i, a, b;

    # set up
    c := prim.elem;
    f := CoefficientsOfUnivariatePolynomial( prim.poly );
    d := Length( f ) - 1;
    if f[1] <> 1 or f[d+1] <> 1 then return fail; fi;

    # get prim-basis
    # Print("compute prim-base \n");
    base := List([0..d-1], x -> Flat(c^x));
    base := SemiEchelonMatTransformation( base );

    # get coeffs of gens in prim-base
    # Print("compute coefficients \n");
    cofs := [];
    dofs := [];
    for g in gens do
        Add( cofs, CoefficientsByBase( base, Flat( g ) ) );
        Add( dofs, CoefficientsByBase( base, Flat( g^-1 ) ) );
    od;

    # get log-value
    # Print("logarithmic valuation \n");
    t := Maximum( List( f, x -> LogAbsValueBound( 1+AbsInt(x) ) ) );
    s := 0;
    for i in [1..Length(gens)] do
        if gens[i] = c then
            s := s + t;
        else
            a := LogAbsValueBound( Sum( AbsInt( cofs[i] ) ) );
            b := LogAbsValueBound( Sum( AbsInt( dofs[i] ) ) );
            s := s + (d-1) * t + Maximum( a, b );
        fi;
    od;

    # now determine final value
    t := 7 * d^2 * s / QuoInt( 2 * LogInt(d,2), 3 );
    return QuoInt( t^Length(gens) + 1, t );
end );