0

Having imported the following:

from sympy.solvers.diophantine.diophantine import diop_ternary_quadratic
from sympy.abc import x,y,z,d,h,c

Running the code diop_ternary_quadratic(-7938*x**2+14436*x*y-98*y**2-z**2) returns (761, 441, 15120), however running diop_ternary_quadratic(-7938*d**2+14436*d*h-98*h**2-c**2), which is equivilent to the first line, the only difference being the symbols used, returns (None,None,None). Why does this happen? Furthermore how would one remedy this?

I've found that this issue only happens for some expressions, for example diop_ternary_quadratic(d**2+h**2-c**2) spits out (1,0,1) as expected.

This problem is not on my end as running it in SymPy's online shell produses the same results.

A possible fix could be exchanging d,h,c for x,y,z, however that would make my code harder to parse by humans, and introduce other "icky" problems, as well as not assuage my question.

Any help would be appreciated, and thanks in advance.

  • The docs could be clearer about this but the function you are using is not intended for end users: https://docs.sympy.org/latest/modules/solvers/diophantine.html#user-functions – Oscar Benjamin Mar 14 '23 at 09:42
  • I suspect there is a bug at play. If you try to run the c,d,h form first in a new SymPy session, do you get an answer? (I am getting a recursion error when I try to solve this equation whether I use the x,y,z or c,d,h form.) – smichr Mar 14 '23 at 12:55
  • @OscarBenjamin Thank you, I'll try useing the user-facing `diophantine` function and see if that works. (Although I'd still like to know why my problem arises, if not for anything but for knowledge's sake.) – Benjamin Vakil Mar 14 '23 at 17:01
  • @smichr I worried as much. For me, the problem still arises whether I run the cdh form first, or even alone, not even importing the variables xyz. – Benjamin Vakil Mar 14 '23 at 17:04
  • @OscarBenjamin, I just tried your suggestion, and unfortunately, the discrepancy still persists. – Benjamin Vakil Mar 14 '23 at 17:16

0 Answers0