"Source: Text/Basics/RngInt.text";
"Line: 4363";
"Date: Thu Sep 25 14:47:46 2025";
"Main: Fri Sep 26 14:29:19 2025";
// original file: Text/Basics/RngInt.text, line: 4363
// Example: H19E15 ()
print "Example: H19E15";
ei := GetEchoInput();
SetEchoInput(true);
n := RandomPrime(90)*RandomPrime(90);
n;
d := 4;
approx_m := Iroot( Iroot( n, d+1 ) * Iroot( n, d ) , 2 );
leading_coeff := n div approx_m^d;
leading_coeff;
m := Iroot( n div leading_coeff, d );
P<X,Y> := PolynomialRing( Integers(), 2 );
F<X,Y> := BaseMPolynomial(n,m,d);
F;
skew, als := OptimalSkewness( F );
alpha := MurphyAlphaApproximation( F, 2000 );
rating := als + alpha;
rating;

best_rating := rating;
best_m := m;
for i in [1..100] do
  leading_coeff := leading_coeff + 1;
  m := Iroot( n div leading_coeff, d );
  F<X,Y> := BaseMPolynomial(n,m,d);
  skew, als := OptimalSkewness( F );
  alpha := MurphyAlphaApproximation( F, 2000 );
  rating := als + alpha;
  if rating lt best_rating then
    best_rating := rating;
    best_m := m;
  end if;
end for;
best_rating;
best_m;
F<X,Y> := BaseMPolynomial(n,best_m,d);
F;
OptimalSkewness( F );
MurphyAlphaApproximation( F, 2000 );
SetEchoInput(ei);
