Open rburing opened 6 months ago
The following code works in python
but not in sage -python
:
from sympy import symbols, Float, integrate
x, t = symbols('x t')
y = Float('2.66778786276411e493')*t**3*x - Float('1.93258971534823e247')*x
integrate(y, (t, Float('0'), Float('1')))
Traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/integrals/integrals.py", line 1567, in integrate
return integral.doit(**doit_flags)
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/integrals/integrals.py", line 499, in doit
did = self.xreplace(reps).doit(**hints)
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/integrals/integrals.py", line 612, in doit
antideriv = self._eval_integral(
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/integrals/integrals.py", line 951, in _eval_integral
return poly.integrate().as_expr()
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/polytools.py", line 2355, in integrate
return f.per(f.rep.integrate(m=1))
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/polyclasses.py", line 606, in integrate
return f.per(dmp_integrate_in(f.rep, m, j, f.lev, f.dom))
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/densetools.py", line 135, in dmp_integrate_in
return _rec_integrate_in(f, m, u, 0, j, K)
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/densetools.py", line 109, in _rec_integrate_in
return dmp_integrate(g, m, v, K)
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/densetools.py", line 88, in dmp_integrate
return dup_integrate(f, m, K)
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/densetools.py", line 66, in dup_integrate
g.insert(0, K.exquo(c, K(n)))
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/domains/domain.py", line 381, in __call__
return self.new(*args)
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/domains/fractionfield.py", line 38, in new
return self.field.field_new(element)
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/fields.py", line 230, in field_new
return self.ground_new(element)
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/fields.py", line 181, in ground_new
return self.new(self.ring.ground_new(element))
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/rings.py", line 320, in ground_new
return self.term_new(self.zero_monom, coeff)
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/rings.py", line 323, in term_new
coeff = self.domain_new(coeff)
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/rings.py", line 317, in domain_new
return self.domain.convert(element, orig_domain)
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/domains/domain.py", line 423, in convert
return self.convert_from(ZZ(element), ZZ)
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/domains/domain.py", line 396, in convert_from
result = _convert(element, base)
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/sympy/polys/domains/realfield.py", line 76, in from_ZZ
return self.dtype(element)
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/mpmath/ctx_mp_python.py", line 79, in __new__
v._mpf_ = mpf_pos(cls.mpf_convert_arg(val, prec, rounding), prec, rounding)
File "/home/rburing/mambaforge/envs/sage/lib/python3.10/site-packages/mpmath/ctx_mp_python.py", line 98, in mpf_convert_arg
raise TypeError("cannot create mpf from " + repr(x))
TypeError: cannot create mpf from mpz(1)
Steps To Reproduce
It fails with
algorithm=a
for eacha
in['maxima', 'sympy', 'mathematica_free', 'fricas', 'giac', 'libgiac']
.Expected Behavior
Get the integral.
Actual Behavior
For
algorithm='giac'
oralgorithm='libgiac'
: returnsundef
.For
algorithm='sympy'
:For
algorithm='fricas'
:For
algorithm='maxima'
:Additional Information
Originally reported at https://ask.sagemath.org/question/77253/what-does-undef-mean/.
Workaround for polynomials:
Environment
Checklist