Karim Belabas on Sat, 23 Jun 2012 19:14:17 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Converting t_QUADs |
* Dirk Laurie [2012-06-23 08:17]: > It is easy to find two t_QUADs that generate the same subset of the > algebraic numbers, e.g. phi=quadgen(5) and sqrt5=quadgen(20). > > Is there a function that can convert one kind of QUAD into another > when possible? No. For general algebraic numbers -- a much more difficult problem! --, you have nfisisom(). Here's a straightforward (unoptimized, mostly untested) implementation: \\ x a t_QUAD. Express x as a t_QUAD of discriminant D quad2quad(x, D) = { my (a,b,c, d = x.disc); if (!issquare(D/d, &c), error("impossible conversion")); a = real(x); b = imag(x); /* x = a + b w, w = ((d%2) + sqrt(d)) / 2 */ if (d % 2, a += b/2); b /= 2; /* x = a + b Ñqrt(d), D = d c^2 */ b /= c; /* x = a + b Ñqrt(D) */ b *= 2; if (D % 2, a -= b/2); /* x = a + b (D%2 + Ñqrt(D))/2 */ a + b * quadgen(D); } phi = quadgen(5); sqrt5 = quadgen(20); ? quad2quad(phi, sqrt5.disc) %3 = 1/2 + 1/2*w ? quad2quad(sqrt5, phi.disc) %4 = -1 + 2*w Cheers, K.B. -- Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17 Universite Bordeaux 1 Fax: (+33) (0)5 40 00 69 50 351, cours de la Liberation http://www.math.u-bordeaux1.fr/~belabas/ F-33405 Talence (France) http://pari.math.u-bordeaux1.fr/ [PARI/GP] `