sympy_gamma icon indicating copy to clipboard operation
sympy_gamma copied to clipboard

Cannot multiply integral by constant

Open MarsEdge opened this issue 11 years ago • 7 comments

It seems that when I multiply an integral by a constant, it only calculates the integral part and ignores the constant. If I put the constant in the integral, it works fine.

It shows the the proper calculation at the top of the first ("SymPy") box, but the formatted version below does not show the constant. The answer it shows in the "Antiderivative forms" section does not account for the constant and the full answer is not shown anywhere.

SymPy Live does not seem to have this issue.

works: http://www.sympygamma.com/input/?i=integral%281%2F2*x%29

doesn't work: http://www.sympygamma.com/input/?i=1%2F2*integral%28x%29

MarsEdge avatar Apr 04 '14 16:04 MarsEdge

@lidavidm It works for me. This issue can be closed.

debugger22 avatar Apr 28 '14 17:04 debugger22

@debugger22 are you sure? This is still broken:

image

That should be \frac12 * \int x dx not just \int x dx.

lidavidm avatar Apr 29 '14 00:04 lidavidm

Sorry I was wrong.

But it's interesting that it works in case of post multiplication. http://www.sympygamma.com/input/?i=integral%28x%29*1%2F2

debugger22 avatar Apr 29 '14 02:04 debugger22

has anyone solved this issue?

nicodjimenez avatar Dec 19 '15 06:12 nicodjimenez

@nicodjimenez https://github.com/sympy/sympy_gamma/pull/60 contains a fix, you should take a look. I think it wasn't merged because I was testing something related to deployment, but it's been a rather long time.

lidavidm avatar Dec 19 '15 18:12 lidavidm

Thanks @lidavidm. However I am still seeing that expressions are not being parsed correctly, for example: http://60.sympy-gamma-li.appspot.com/input/?i=integrate%28x%29+%2B+integrate%28x%29

Sympy seems to know the answer is x**2 but why doesn't this show up in the SymPy box on top?

nicodjimenez avatar Dec 19 '15 19:12 nicodjimenez

@nicodjimenez Understand that the parsing and stuff in Gamma is extremely basic - it's stuff I did as a sophomore or junior in high school. If you're looking for something more sophisticated, you won't find it pre-written (in Gamma at least). Gamma sees the "integrate" (I think via TopCallVisitor) and converts the input to just integrate(x) in this case, I think. SymPy itself can parse all of this perfectly - it's the postprocessing Gamma does that is causing problems. If you just want the parsing, you should stick with parse_expr and maybe treat Gamma as a source of examples.

lidavidm avatar Dec 19 '15 19:12 lidavidm