These are chat archives for symengine/symengine

28th
Mar 2015
Isuru Fernando
@isuruf
Mar 28 2015 03:30
@certik, the issue is what gcd(x, 4) is supposed to do. If x is treated as a polynomial it is gcd(x,4) is 1. If we consider it as a symbol that can take on any value, we have to keep it as it is.
Ondřej Čertík
@certik
Mar 28 2015 04:11
I see --- if you substitute some number for "x", then you can essentially get anything, e.g. gcd(2, 4) == 2, gcd(8, 4) == 4 etc.
Isuru Fernando
@isuruf
Mar 28 2015 04:12
yep
Ondřej Čertík
@certik
Mar 28 2015 04:12
Well, I would just check if "x" is a Polynomial, then we can do polynomial gcd, and if "x" is a symbol, then we would just keep it unevaluated.
Otherwise, we can also not introduce gcd, and just have polynomial_gcd and integer_gcd, which are two different things.
Isuru Fernando
@isuruf
Mar 28 2015 04:13
there are many more gcds. rational_gcd etc.
Ondřej Čertík
@certik
Mar 28 2015 04:14
Sure. If they are not compatible with each other, as it seems they are not, then we just have to keep them separate.
Isuru Fernando
@isuruf
Mar 28 2015 04:16
Okay. What about something like gcd((x+4)*(x+1), 4), (x+4)*(x+1) can be a polynomial or a symbolic expression
Ondřej Čertík
@certik
Mar 28 2015 04:17
It's either represented as Mul, or as Polynomial (not yet in CSymPy)
So you can choose between integer_gcd and polynomial_gcd.
Isuru Fernando
@isuruf
Mar 28 2015 04:19
Sure, we'll handle it when Polynomials are implemented. Btw, this issue is there in SymPy as well.
Shivam Vats
@shivamvats
Mar 28 2015 04:51
I agree with @certik . We define a Polynomial over a ring. So, for comparing with a Polynomial x , the value, 4, in this case, should also belong to a ring, i.e, both should be polynomials. Which means, (x+4)*(x+1) should be a polynomial only if every variable is a ring element (PolyElement in SymPy)
Sumith Kulal
@Sumith1896
Mar 28 2015 06:47
What if we define gcd function taking Basic arguments and do the checks internally?
Sumith Kulal
@Sumith1896
Mar 28 2015 06:54
This is useful when we are comparing between integer and rational gcd. But the above will fail if user wants polynomial gcd of x and 4 or integer gcd of x and 4 and hence two different function may be needed.
Ondřej Čertík
@certik
Mar 28 2015 17:43
Let's check what Mathematica, Maple and other systems do in this case.