These are chat archives for symengine/symengine

22nd
Jun 2016
Srajan Garg
@srajangarg
Jun 22 2016 07:10
SymPy doesn't really simplify a lot of places
In [5]: Poly((x+1)**-2 + (x+1)**-1)
Out[5]: Poly(1/(x + 1) + 1/(x**2 + 2*x + 1), 1/(x + 1), 1/(x**2 + 2*x + 1), domain='ZZ')
Kalevi Suominen
@jksuom
Jun 22 2016 07:22
I believe that Poly is designed to work with expressions that can be regarded as polynomials (with no negative exponents or denominators). Otherwise the result may be unexpected.
Srajan Garg
@srajangarg
Jun 22 2016 07:23
@isuruf how can I check wether a certain Pow can be 'expanded' to an Add or not, eg.
(x+1)**2 can be
x**2 cannot be
(x+1)**-2 cannot be
(x+1)**(2/3) cannot be
@jksuom but this works, so I thought it was erratic
In [6]: Poly(x**-2 + x**-1)
Out[6]: Poly(1/x**2 + 1/x, 1/x, domain='ZZ')
Kalevi Suominen
@jksuom
Jun 22 2016 07:24
That is what I meant. Unexpected results.
Srajan Garg
@srajangarg
Jun 22 2016 07:29
Right, I see
Kalevi Suominen
@jksuom
Jun 22 2016 07:29
I think it should not be necessary to copy the behaviour of Poly in case of negative exponents. They should not be used in code anyway. Instead, one should first separate the numerator and denominator (by as_numer_denom) and then apply Poly to them.
Srajan Garg
@srajangarg
Jun 22 2016 07:33
To get two polynomials? How will that work
I mean, mathematically what does it mean
Kalevi Suominen
@jksuom
Jun 22 2016 07:42
Powers with negative exponents are considered as denominators. (So (x - 1)**-3 becomes 1/(x - 1)**3.) Then a common multiple of the denominators of all terms becomes the new denominator. It could be the lcm but I'm not sure if that is actually computed.
The whole process is recursive.
Srajan Garg
@srajangarg
Jun 22 2016 10:53
UIntPoly::from_basic(div(x, 2)) Error or Poly::(x/2, {{1,1}})?
SymPy takes it to the QQ domain
It'll be easier (and consistent) if the poly is created
Isuru Fernando
@isuruf
Jun 22 2016 10:55
Error. When determining the generators, we should also determine the domain needed
Srajan Garg
@srajangarg
Jun 22 2016 10:55
But, for now why will Poly::(x/2, {{1,1}}) be wrong
Isuru Fernando
@isuruf
Jun 22 2016 10:56
SymPy gives an error as well.
In [3]: Poly(x/2, domain="ZZ")
Srajan Garg
@srajangarg
Jun 22 2016 10:56
Hmm, I see. Will have to rethink about domains
Srajan Garg
@srajangarg
Jun 22 2016 11:16
What about UIntPoly::from_basic(pow(2, div(x, 2))). This will return a poly, with the genarator as itself, right?
In [10]: Poly(2**(x/2))
Out[10]: Poly(2**(x/2), 2**(x/2), domain='ZZ')
Isuru Fernando
@isuruf
Jun 22 2016 11:18
yes
Srajan Garg
@srajangarg
Jun 22 2016 12:32
What about UIntPoly::from_basic(sin(x+y)**2 + sin(x+y))