Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors in the integrate function #339

Open
AmplitudeGravity opened this issue Mar 9, 2020 · 4 comments
Open

errors in the integrate function #339

AmplitudeGravity opened this issue Mar 9, 2020 · 4 comments

Comments

@AmplitudeGravity
Copy link

WeChat6847d52f2ba72c3d51bff3cb1992ff23

@mzaffalon
Copy link
Contributor

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?

@AmplitudeGravity
Copy link
Author

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 a
x**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
Copy link
Author

Although the int power function works.

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

@jverzani
Copy link
Collaborator

jverzani commented Jun 1, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants