当我运行此代码时:
from __future__ import division
import sympy as sp
t = sp.symbols('t')
y = sp.symbols('y')
pw1 = sp.Piecewise((sp.exp(t/y), 1 <= t), (0, True))
pw2 = sp.Piecewise((2.5*t, sp.And((t >= 0), (t < 5))), (0, True))
xonInt = sp.integrate (pw1*pw2, t)
print xonInt
我收到错误(完整的错误消息在这个问题的最后):
提出DomainError(&#39;没有与%s&#39;%self关联的响铃) sympy.polys.polyerrors.DomainError:没有与RR关联的响铃
有趣的是,当我更改行
时pw2 = sp.Piecewise((2.5*t, sp.And((t >= 0), (t < 5))), (0, True))
到
pw2 = sp.Piecewise((2*t, sp.And((t >= 0), (t < 5))), (0, True))
或
行pw1 = sp.Piecewise((sp.exp(t/y), 1 <= t), (0, True))
到
pw1 = sp.Piecewise((sp.exp(t/5), 1 <= t), (0, True))
代码正确运行且没有错误。
这个错误是什么意思?我该如何更正我的代码?
完整的错误消息:
Traceback (most recent call last):
File "IntegralTest.py", line 19, in <module>
xonInt = sp.integrate (pw1*pw2, t)
File "//anaconda/lib/python2.7/site-packages/sympy/utilities/decorator.py", line 35, in threaded_func
return func(expr, *args, **kwargs)
File "//anaconda/lib/python2.7/site-packages/sympy/integrals/integrals.py", line 1232, in integrate
risch=risch, manual=manual)
File "//anaconda/lib/python2.7/site-packages/sympy/integrals/integrals.py", line 487, in doit
conds=conds)
File "//anaconda/lib/python2.7/site-packages/sympy/integrals/integrals.py", line 740, in _eval_integral
return f._eval_integral(x)
File "//anaconda/lib/python2.7/site-packages/sympy/functions/elementary/piecewise.py", line 200, in _eval_integral
return self.func(*[(integrate(e, x), c) for e, c in self.args])
File "//anaconda/lib/python2.7/site-packages/sympy/utilities/decorator.py", line 35, in threaded_func
return func(expr, *args, **kwargs)
File "//anaconda/lib/python2.7/site-packages/sympy/integrals/integrals.py", line 1232, in integrate
risch=risch, manual=manual)
File "//anaconda/lib/python2.7/site-packages/sympy/integrals/integrals.py", line 487, in doit
conds=conds)
File "//anaconda/lib/python2.7/site-packages/sympy/integrals/integrals.py", line 740, in _eval_integral
return f._eval_integral(x)
File "//anaconda/lib/python2.7/site-packages/sympy/functions/elementary/piecewise.py", line 200, in _eval_integral
return self.func(*[(integrate(e, x), c) for e, c in self.args])
File "//anaconda/lib/python2.7/site-packages/sympy/utilities/decorator.py", line 35, in threaded_func
return func(expr, *args, **kwargs)
File "//anaconda/lib/python2.7/site-packages/sympy/integrals/integrals.py", line 1232, in integrate
risch=risch, manual=manual)
File "//anaconda/lib/python2.7/site-packages/sympy/integrals/integrals.py", line 487, in doit
conds=conds)
File "//anaconda/lib/python2.7/site-packages/sympy/integrals/integrals.py", line 754, in _eval_integral
result, i = risch_integrate(f, x, separate_integral=True, conds=conds)
File "//anaconda/lib/python2.7/site-packages/sympy/integrals/risch.py", line 1678, in risch_integrate
ans, i, b = integrate_hyperexponential(fa, fd, DE, conds=conds)
File "//anaconda/lib/python2.7/site-packages/sympy/integrals/risch.py", line 1408, in integrate_hyperexponential
g1, h, r = hermite_reduce(a, d, DE)
File "//anaconda/lib/python2.7/site-packages/sympy/integrals/risch.py", line 964, in hermite_reduce
fp, fs, fn = canonical_representation(a, d, DE)
File "//anaconda/lib/python2.7/site-packages/sympy/integrals/risch.py", line 944, in canonical_representation
dn, ds = splitfactor(d, DE)
File "//anaconda/lib/python2.7/site-packages/sympy/integrals/risch.py", line 869, in splitfactor
Dp = derivation(p, DE, coefficientD=coefficientD)
File "//anaconda/lib/python2.7/site-packages/sympy/integrals/risch.py", line 824, in derivation
r += (d*pv.diff(v)).as_poly(t)
File "//anaconda/lib/python2.7/site-packages/sympy/core/decorators.py", line 77, in _sympifyit_wrapper
return func(a, b)
File "//anaconda/lib/python2.7/site-packages/sympy/polys/polytools.py", line 3865, in _mul__
return f.mul(g)
File "//anaconda/lib/python2.7/site-packages/sympy/polys/polytools.py", line 1350, in mul
_, per, F, G = f._unify(g)
File "//anaconda/lib/python2.7/site-packages/sympy/polys/polytools.py", line 358, in _unify
dom, lev = f.rep.dom.unify(g.rep.dom, gens), len(gens) - 1
File "//anaconda/lib/python2.7/site-packages/sympy/polys/domains/domain.py", line 250, in unify
return K0.unify_with_symbols(K1, symbols)
File "//anaconda/lib/python2.7/site-packages/sympy/polys/domains/domain.py", line 230, in unify_with_symbols
return K0.unify(K1)
File "//anaconda/lib/python2.7/site-packages/sympy/polys/domains/domain.py", line 274, in unify
domain = domain.get_ring()
File "//anaconda/lib/python2.7/site-packages/sympy/polys/domains/realfield.py", line 106, in get_ring
raise DomainError('there is no ring associated with %s' % self)
sympy.polys.polyerrors.DomainError: there is no ring associated with RR