Re: What’s the equivalent of Mathematica ’s Solve[] Function in Pari/Gp ?

Laël Cellier <[email protected]>
Newsgroups gmane.comp.mathematics.pari.user
Message-ID <[email protected]>
Hi,

and what would be the code to solve
a×x + sqrt(b×y²) = c in {x,y} integers

instead ? The aim is to have b×y being a perfect square and if possible have a value lower than a…
Cordialement,

Le 12/01/2025 à 11:58, Karim Belabas a écrit :
> Hi Laël,
>
>    Bill's question was about the algorithm used, not the result.
>
> To solve a*x + b*y = c in {x,y} integers (given a,b,c integers) in GP:
>
> Solve(a,b,c) =
> { my([u, v, d] = gcdext(a, b));
>
>    if (c % d, return ([]));  \\ no solution
>    my(x = c/d * u % (b/d));
>    [x, (c - a*x) / b];
> }
>
> ? Solve(300001,4139891237,5)
> %1 = [1952821586, -141513]
> ? 1952821586 * 300001 - 141513*4139891237
> %2 = 5
>
> Cheers,
>
>      K.B.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.