Ask Your Question

Weird solve() problem

asked 2018-03-02 04:26:55 -0500

zhoraster gravatar image

updated 2018-03-02 13:56:38 -0500

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

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 flag offensive close merge delete


Could not reproduce the error:


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)

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

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'
dan_fulea gravatar imagedan_fulea ( 2018-03-02 05:36:10 -0500 )edit

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

zhoraster gravatar imagezhoraster ( 2018-03-02 05:58:39 -0500 )edit

Yes, the same in 8.1. Thanks.

zhoraster gravatar imagezhoraster ( 2018-03-02 13:55:42 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-03-02 15:38:29 -0500

tmonteil gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2018-03-02 04:26:55 -0500

Seen: 111 times

Last updated: Mar 02