If a+b*sqrtK is the square of, say, c+d*sqrtK, then a-b*sqrtK is the square of c-d*sqrtK. So a pretest is to see if the product a^2 - K b^2 is an integer or rational square. Assuming this condition is passed, then 2c = sqrt(a+b*sqrtK) +- sqrt(a-b*sqrtK). In the integer case, this calculation can be done in floating point, and generates two possible candidate c values. C must be an integer or integer+1/2. The corresponding d value must meet a = c^2 - K d^2 and b = 2cd. One equation gives candidate d's, and the other checks them. For the rational case, either deal with it directly (since the denominator of c must divide 2 * den(a) * den(b), the floating point c value can be multiplied by 2 den(a) den(b) and must be an integer) or convert the initial problem to integers by multiplying by (den(a)den(b))^2. I'm not sure if this qualifies as "easy", and it's got some annoying branches in the algorithm. Rich -----Original Message----- From: Bill & Rosemary Cordwell To: math-fun Sent: 7/7/2004 5:16 PM Subject: [math-fun] perfect squares Is there an easy way to tell when a + b*sqrt(k) is a perfect square in the extension field Q(sqrt(k))? For example, 3 + 2*sqrt(2) is the square of 1 + sqrt(2). I'm particularly interested in when a, b, k are integers, but a and b rationals would be OK, too. Thanks, Kristin Cordwell _______________________________________________ math-fun mailing list math-fun@mailman.xmission.com http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
participants (1)
-
Schroeppel, Richard