There is not always a solution. Whether or not there is a solution is
the contents of the Hasse-Minkowski theorem. I couldn't find a
function in sage that immediately tells you whether there is a
rational solution. There is a function that tells you whether there is
a local solution at a prime p, namely hilbert_symbol(-N, d, p) (this
is 1 when there is a solution, otherwise -1), and the Hasse-Minkowski
theorem actually states that there is a global (rational) solution if
and only if there is a local solution at every prime p including
infinity (in sage you have to pass p = -1). In fact this only has to
be checked for primes that divide N or d, for 2 and for infinity.

In sage you could write a function like this, in one line if you use
some fancy python constructs (using the N and d as in your equation
(2), check just in case I made a mistake):
def has_rational_solution(N,d):
     return reduce(lambda P,Q: P and Q, [prod([hilbert_symbol(a,b,p)
for a in [-N.numerator(), N.denominator()] for b in [d.numerator(),
d.denominator()]]) == 1 for p in prime_divisors(2*N*d) + [-1]])

If you have magma installed (accessible from sage in that case), then
this function will actually give you a rational point (in homogeneous
coordinates) if it exists:
f := func<N,d| HasRationalPoint(Conic(P2, P2.1^2 - d*P2.2^2 +
N*P2.3^2))> where P2 is ProjectiveSpace(Rationals(),2);

Hope you find this useful.
Greetings,

Utpal


On Sep 20, 9:40 pm, David Stahl <[EMAIL PROTECTED]> wrote:
> I have a non-SAGE question and am hoping someone can point me to a
> source that discusses the solution.  I am trying to find a rational
> solution for x and y to the equation:
>
> Ax^2 + Bxy + Cy^2 + Dx + Ey + F =0    (1)
>
> where the coefficients are rational.  This can be transformed to:
>
> xprm^2 - d*yprm^2 + N = 0                  (2)
>
> There are alot of websites that talk about finding integer solutions
> to these equations with integer coefficients.  I do not think an
> integer solution always exists when the coefficients of (2) are
> rational but I do think a rational solution always does exist and I am
> perfectly happy with a rational solution.  Any guidance would be
> appreciated.  Thank you.
>
> David


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to