当前位置: 首页 > 工具软件 > wxMaxima > 使用案例 >

python安装sympy失败_Sympy失败,wxMaxima n

阎伟志
2023-12-01

我试图用wxMaxima和sympy来求解以下不定积分:integrate(r^2*sqrt(R^2-r^2),r)

在马克西马,我确实得到了答案,但在同情中没有。我不明白为什么。我是Python的超级用户,我很喜欢用Python做符号数学,但是由于sympy没有解决这个问题,我仍然坚持使用Maxima。在

是我做错了什么,还是马克西姆好些了?

(我在Mathematica也解决了这个问题)

我在wxMaxima得到了以下答案:

^{pr2}$

给出了这个答案:g:(R^4*asin(r/abs(R)))/8-(r*(R^2-r^2)^(3/2))/4+(r*R^2*sqrt(R^2-r^2))/8

它看起来很难看,但别提了。这里的重点是,sympy不能解这个积分。试着用这个代码来解决同样的问题:import sympy as sy

import math

R,r = sy.symbols('R r')

g = sy.integrate(r**2*(R**2-r**2)**0.5,r)

print g

给出以下错误消息:Traceback (most recent call last):

File "E:\UD\Software\BendStiffener\calculate-moment\moment-calculation-equations\sympy-test.py", line 4, in

g = sy.integrate(r**2*(R**2-r**2)**0.5,r)

File "C:\Python27\lib\site-packages\sympy\utilities\decorator.py", line 35, in threaded_func

return func(expr, *args, **kwargs)

File "C:\Python27\lib\site-packages\sympy\integrals\integrals.py", line 1232, in integrate

risch=risch, manual=manual)

File "C:\Python27\lib\site-packages\sympy\integrals\integrals.py", line 487, in doit

conds=conds)

File "C:\Python27\lib\site-packages\sympy\integrals\integrals.py", line 876, in _eval_integral

h = meijerint_indefinite(g, x)

File "C:\Python27\lib\site-packages\sympy\integrals\meijerint.py", line 1596, in meijerint_indefinite

res = _meijerint_indefinite_1(f.subs(x, x + a), x)

File "C:\Python27\lib\site-packages\sympy\integrals\meijerint.py", line 1646, in _meijerint_indefinite_1

r = hyperexpand(r.subs(t, a*x**b))

File "C:\Python27\lib\site-packages\sympy\simplify\hyperexpand.py", line 2482, in hyperexpand

return f.replace(hyper, do_replace).replace(meijerg, do_meijer)

File "C:\Python27\lib\site-packages\sympy\core\basic.py", line 1351, in replace

rv = bottom_up(self, rec_replace, atoms=True)

File "C:\Python27\lib\site-packages\sympy\simplify\simplify.py", line 4082, in bottom_up

rv = F(rv)

File "C:\Python27\lib\site-packages\sympy\core\basic.py", line 1336, in rec_replace

new = _value(expr, result)

File "C:\Python27\lib\site-packages\sympy\core\basic.py", line 1280, in

_value = lambda expr, result: value(*expr.args)

File "C:\Python27\lib\site-packages\sympy\simplify\hyperexpand.py", line 2479, in do_meijer

allow_hyper, rewrite=rewrite)

File "C:\Python27\lib\site-packages\sympy\simplify\hyperexpand.py", line 2375, in _meijergexpand

t, 1/z0)

File "C:\Python27\lib\site-packages\sympy\simplify\hyperexpand.py", line 2335, in do_slater

resid = residue(integrand, s, b_ + r)

File "C:\Python27\lib\site-packages\sympy\series\residues.py", line 57, in residue

s = expr.series(x, n=0)

File "C:\Python27\lib\site-packages\sympy\core\expr.py", line 2435, in series

rv = self.subs(x, xpos).series(xpos, x0, n, dir, logx=logx)

File "C:\Python27\lib\site-packages\sympy\core\expr.py", line 2442, in series

s1 = self._eval_nseries(x, n=n, logx=logx)

File "C:\Python27\lib\site-packages\sympy\core\mul.py", line 1446, in _eval_nseries

terms = [t.nseries(x, n=n, logx=logx) for t in self.args]

File "C:\Python27\lib\site-packages\sympy\core\expr.py", line 2639, in nseries

return self._eval_nseries(x, n=n, logx=logx)

File "C:\Python27\lib\site-packages\sympy\functions\special\gamma_functions.py", line 168, in _eval_nseries

return super(gamma, self)._eval_nseries(x, n, logx)

File "C:\Python27\lib\site-packages\sympy\core\function.py", line 598, in _eval_nseries

term = e.subs(x, S.Zero)

File "C:\Python27\lib\site-packages\sympy\core\basic.py", line 892, in subs

rv = rv._subs(old, new, **kwargs)

File "C:\Python27\lib\site-packages\sympy\core\basic.py", line 1006, in _subs

rv = fallback(self, old, new)

File "C:\Python27\lib\site-packages\sympy\core\basic.py", line 983, in fallback

rv = self.func(*args)

File "C:\Python27\lib\site-packages\sympy\core\function.py", line 382, in __new__

return result.evalf(mlib.libmpf.prec_to_dps(pr))

File "C:\Python27\lib\site-packages\sympy\core\evalf.py", line 1317, in evalf

result = evalf(self, prec + 4, options)

File "C:\Python27\lib\site-packages\sympy\core\evalf.py", line 1217, in evalf

re, im = x._eval_evalf(prec).as_real_imag()

File "C:\Python27\lib\site-packages\sympy\core\function.py", line 486, in _eval_evalf

v = func(*args)

File "C:\Python27\lib\site-packages\sympy\mpmath\ctx_mp_python.py", line 993, in f

return ctx.make_mpf(mpf_f(x._mpf_, prec, rounding))

File "C:\Python27\lib\site-packages\sympy\mpmath\libmp\gammazeta.py", line 1947, in mpf_gamma

raise ValueError("gamma function pole")

ValueError: gamma function pole

 类似资料: