Laël Cellier on Sun, 19 Jan 2025 20:52:54 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: What’s the equivalent of Mathematica’s Solve[] Function in Pari/Gp ? |
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.