# Weird solve() problem

I try to solve the equation $$a^2 + b^2 + 2 a^2 b^2 = c^2$$ in integers. Using

 var('a,b,c')
assume(a,'integer')
assume(b,'integer')
assume(c,'integer')
solve([a^2 + b^2 + 2*a^2*b^2 == c^2],[a,b,c],solution_dict=True)


gives Pythagorean triples:

{c: t1^2 + t2^2, b: 2*t1*t2, a: t1^2 - t2^2}


which clearly do not satisfy the equation (unless $t_1=t_2$ or $t_2t_2 = 0$). It seems that solve() does not see the term $2a^2b^2$; trying

solve([a^2 + b^2 + 2222*a^2*b^2 == c^2],[a,b,c],solution_dict=True)


gives the same (wrong) result.

UPDATE: The problem does not exist in the newest version (8.1).

edit retag close merge delete

Could not reproduce the error:

After

sage: solve([a^2 + b^2 + 2*a^2*b^2 == c^2],[a,b,c],solution_dict=True)
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
....
/usr/lib/python2.7/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
996
....


and many further lines, sage gives the reason for the error:

NotImplementedError:
This equation is not yet recognized or else has not been simplified
sufficiently to put it in a form recognized by diop_classify().
sage: version()
'SageMath version 8.1, Release Date: 2017-12-07'
sage:


I have version 8.0, so I'll update and check if the problem persists.

Sort by » oldest newest most voted

As for me, on 8.2.beta6, i got the same NotImplementedError as @dan_fulea. Without the assume statements, i got:

sage: var('a,b,c')
(a, b, c)
sage: solve([c c^2],[a,b,c],solution_dict=True)
[{a: r1, c: sqrt((2*r2^2 + 1)*r1^2 + r2^2), b: r2},
{a: r3, c: -sqrt((2*r4^2 + 1)*r3^2 + r4^2), b: r4}]


which seems perfectly valid. That said, if you do not care about the integer nature of the solution, there is no benefit in using of a computer algebra system to solve such an equation since the variable c is isolated, it is clear that for each a and each b, there are two solutions sqrt(a^2 + b^2 + 2*a^2*b^2) and sqrt(a^2 + b^2 + 2*a^2*b^2).

The question is when a^2 + b^2 + 2*a^2*b^2) is a square. You can try to guess some pattern for the integer solutions as follows (try with size=10,100,1000,10000):

sage: from itertools import product
sage: p = product(range(size),range(size))
sage: L = []
sage: for a,b in p:
....:     if (a^2 + b^2 + 2*a^2*b^2).is_square():
....:         L.append((a,b))
sage: points(L, aspect_ratio=1)


Given those pictures, no obvious paterns seems to appear, and i would bet that there is no simple formula (like a fnite union of discrete hyperbolas or so) to describe such solution set.

more