SymPy.jl icon indicating copy to clipboard operation
SymPy.jl copied to clipboard

errors in the integrate function

Open AmplitudeGravity opened this issue 5 years ago • 4 comments

WeChat6847d52f2ba72c3d51bff3cb1992ff23

AmplitudeGravity avatar Mar 09 '20 14:03 AmplitudeGravity

It looks like you are missing a * before (1+x).

In the future, could you please post code, not screenshots, to make it easier for others to reproduce your report?

mzaffalon avatar Mar 09 '20 14:03 mzaffalon

Thanks. That seems more errors. integrate(x^(1/2)*(1+x)^(-23/10),(x,0,1)) PyError ($(Expr(:escape, :(ccall(#= /Users/gangchen/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:44 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'sympy.integrals.meijerint._CoeffExpValueError'> _CoeffExpValueError('expr not of form ax**b: 0.857109621959463') File "/Users/gangchen/.julia/conda/3/lib/python3.7/site-packages/sympy/integrals/integrals.py", line 1477, in integrate return integral.doit(**doit_flags) File "/Users/gangchen/.julia/conda/3/lib/python3.7/site-packages/sympy/integrals/integrals.py", line 541, in doit function, xab[0], **eval_kwargs) File "/Users/gangchen/.julia/conda/3/lib/python3.7/site-packages/sympy/integrals/integrals.py", line 1012, in _eval_integral h = meijerint_indefinite(g, x) File "/Users/gangchen/.julia/conda/3/lib/python3.7/site-packages/sympy/integrals/meijerint.py", line 1621, in meijerint_indefinite res = _meijerint_indefinite_1(f.subs(x, x + a), x) File "/Users/gangchen/.julia/conda/3/lib/python3.7/site-packages/sympy/integrals/meijerint.py", line 1646, in _meijerint_indefinite_1 gs = _rewrite1(f, x) File "/Users/gangchen/.julia/conda/3/lib/python3.7/site-packages/sympy/integrals/meijerint.py", line 1569, in _rewrite1 g = _rewrite_single(g, x, recursive) File "/Users/gangchen/.julia/conda/3/lib/python3.7/site-packages/sympy/integrals/meijerint.py", line 1472, in _rewrite_single exponents_only=True), x) File "/Users/gangchen/.julia/conda/3/lib/python3.7/site-packages/sympy/integrals/meijerint.py", line 337, in _get_coeff_exp raise _CoeffExpValueError('expr not of form ax**b: %s' % expr)

Stacktrace: [1] pyerr_check at /Users/gangchen/.julia/packages/PyCall/ttONZ/src/exception.jl:60 [inlined] [2] pyerr_check at /Users/gangchen/.julia/packages/PyCall/ttONZ/src/exception.jl:64 [inlined] [3] macro expansion at /Users/gangchen/.julia/packages/PyCall/ttONZ/src/exception.jl:84 [inlined] [4] __pycall!(::PyCall.PyObject, ::Ptr{PyCall.PyObject_struct}, ::PyCall.PyObject, ::Ptr{Nothing}) at /Users/gangchen/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:44 [5] _pycall!(::PyCall.PyObject, ::PyCall.PyObject, ::Tuple{Sym,Tuple{Sym,Int64,Int64}}, ::Int64, ::Ptr{Nothing}) at /Users/gangchen/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:29 [6] _pycall!(::PyCall.PyObject, ::PyCall.PyObject, ::Tuple{Sym,Tuple{Sym,Int64,Int64}}, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/gangchen/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:11 [7] #call#111(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::PyCall.PyObject, ::Sym, ::Vararg{Any,N} where N) at /Users/gangchen/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:89 [8] (::PyCall.PyObject)(::Sym, ::Vararg{Any,N} where N) at /Users/gangchen/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:89 [9] #integrate#212(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Sym, ::Tuple{Sym,Int64,Int64}) at /Users/gangchen/.julia/packages/SymPy/tgSHx/src/importexport.jl:102 [10] integrate(::Sym, ::Tuple{Sym,Int64,Int64}) at /Users/gangchen/.julia/packages/SymPy/tgSHx/src/importexport.jl:102 [11] top-level scope at In[4]:1

AmplitudeGravity avatar Mar 09 '20 14:03 AmplitudeGravity

Although the int power function works.

integrate(x^(2)*(1+x)^(-3),(x,0,1)) −5/8+log(2)

AmplitudeGravity avatar Mar 09 '20 14:03 AmplitudeGravity

In general, you should use rational exponents to avoid floating point round off. However, in this case once doing so, the integral takes forever to compute. Even on sympygamma it fails. The integration with Wolfram Alpha is just better.

jverzani avatar Jun 01 '20 13:06 jverzani