ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 13 Aug 2020 18:13:05 +0200Stack overflow during symbolic manipulationshttps://ask.sagemath.org/question/52986/stack-overflow-during-symbolic-manipulations/I'm trying to evaluate this cursed integral (finite for $ 0 < a < 1 $):
$$\int_0^1 \frac{x}{\log{\left(ax+(1-x)^2\right)}}{\rm d}x$$
using Sagemath 9.0 and 9.1:
sage: a = var('a')
sage: assume(a>0)
sage: assume(a<1)
sage: f = integrate(x*log(1/(a*x+(1-x)^2)), x, 0, 1)
leads to
RuntimeError: ECL says: C-STACK overflow at size 1048576. Stack can probably be resized. Proceed with caution.
Sympy gives a result even without the assumptions (which is odd by itself):
sage: f = integrate(x*log(1/(a*x+(1-x)*(1-x))), x, 0, 1, algorithm='sympy')
$$\frac{1}{4} \{\left(a^{2} + \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 2\right)} \log\left(\frac{a^{2} + \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 4}{2 {\left(a - 2\right)}} + 1\right) - \frac{1}{4} {\left(a^{2} + \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 2\right)} \log\left(\frac{a^{2} + \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 4}{2 {\left(a - 2\right)}}\right) + \frac{1}{4} \{\left(a^{2} - \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 2\right)} \log\left(\frac{a^{2} - \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 4}{2 {\left(a - 2\right)}} + 1\right) - \frac{1}{4} {\left(a^{2} - \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 2\right)} \log\left(\frac{a^{2} - \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 4}{2 {\left(a - 2\right)}}\right) - \frac{1}{2} a + \frac{1}{2} \log\left(\frac{1}{a}\right) + \frac{3}{2}$$
But then problems continue:
sage: f.simplify_full()
RuntimeError: ECL says: C-STACK overflow at size 1048576. Stack can probably be resized. Proceed with caution.
But:
sage: f.expand().simplify_full()
$$
-\frac{1}{2} {\left(2 \pi - {\left(\pi - \arctan\left(\frac{\sqrt{-a + 4}}{\sqrt{a}}\right) + \arctan\left(\frac{\sqrt{a} \sqrt{-a + 4}}{a - 2}\right)\right)} a - 2 \arctan\left(\frac{\sqrt{-a + 4}}{\sqrt{a}}\right) + 2 \arctan\left(\frac{\sqrt{a} \sqrt{-a + 4}}{a - 2}\right)\right)} \sqrt{a} \sqrt{-a + 4} + \frac{1}{4} {\left(a^{2} - 4 a\right)} \log\left(a\right) - \frac{1}{2} a + \frac{3}{2}
$$
If I want to find the limit when $a\to 0$:
sage: f.limit(a=0)
RuntimeError: ECL says: C-STACK overflow at size 1048576. Stack can probably be resized. Proceed with caution.
and once again
sage: f.limit(a=0, algorithm="sympy")
$$-i \pi + \frac{3}{2}$$
Which is only true for $a<0$.
I previously found [this strange bug](https://ask.sagemath.org/question/48058/stack-overflow-in-boolean-test/) a while ago (fixed upstream, still present in Sagemath 9.1), this makes me think the assumption `assume(a>0)` is the root of it all, unfortunately it cannot be skipped to evaluate the integral properly.
Do you know when the updated version of Maxima will be included with Sagemath?
Do you think all these issues are linked to this old ticket or should it be investigated independently?
Florentin JaffredoThu, 13 Aug 2020 18:13:05 +0200https://ask.sagemath.org/question/52986/Indefinite integral is incorrecthttps://ask.sagemath.org/question/44077/indefinite-integral-is-incorrect/`indefinite_integral(sqrt(1+cos(x)**2), x).full_simplify()` gives `1/6*sin(x)^3`, which is incorrect.
proy87Fri, 26 Oct 2018 14:08:37 +0200https://ask.sagemath.org/question/44077/Two ways of integrating x↦xⁿsin(x) give contradictory results. Bug?https://ask.sagemath.org/question/36185/two-ways-of-integrating-x-xnsinx-give-contradictory-results-bug/**First way:**
var('x,n')
integral(x^n*sin(x),x)
gives just
integrate(x^n*sin(x), x)
not very informative, let us try to add an assumption to get nicer results.
**Second way:**
assume(n,'integer')
integral(x^n*sin(x),x)
gives
1/4*(((-1)^n - 1)*gamma(n + 1, I*x) - ((-1)^n - 1)*gamma(n + 1, -I*x))*(-1)^(-1/2*n)
Uhm, looks better, but... wait, isn't `(-1)^n-1` equal to `0` for even values of `n` ? That would make the whole thing equal to `0` for even `n`.
I = integral(x^n*sin(x),x)
for k in range(10):
print I.subs(n==2*k)
prints only `0`s. Weird, non-zero functions should not have zero integrals.
**Third way :**
Let us try to do the integration with particular values of `n`.
for n in range(5):
print integral(x^n*sin(x),x)
prints
-cos(x)
-x*cos(x) + sin(x)
-(x^2 - 2)*cos(x) + 2*x*sin(x)
-(x^3 - 6*x)*cos(x) + 3*(x^2 - 2)*sin(x)
Looks better, but is clearly different from the previous answer.
**Question:**
I am working on the cloud, with SageMath 7.4 kernel. Is this a bug or did I misunderstood the meaning of the `'integer'`assumption ?
If this is a bug, how should I report it, is posting this question here enough ?
P.S. I did read the [wiki page about reporting bugs](http://doc.sagemath.org/html/en/developer/trac.html#reporting-bugs), but, gosh, is it really necessary to have a google account in order to report a bug ? Both sage-devel and sage-support are on Google Groups. lbWed, 04 Jan 2017 21:44:16 +0100https://ask.sagemath.org/question/36185/Wrong error messagehttps://ask.sagemath.org/question/28851/wrong-error-message/The best things in Sage are 'mathematica_free'. No, no, I never would say this!
(exp(2*x)/cosh(exp(x))).integral(x,algorithm='mathematica_free')
I*(log(I*e^(-e^x) + 1) - log(-I*e^(-e^x) + 1))*e^x + I*polylog(2, I*e^(-e^x)) - I*polylog(2, -I*e^(-e^x))
BUT:
(exp(3*x)/cosh(exp(x))).integral(x,algorithm='mathematica_free')
AttributeError: 'NoneType' object has no attribute 'groups'
I think Sage wanted to say: "Mathematica could not find a formula for your integral."
Peter LuschnyMon, 17 Aug 2015 12:16:08 +0200https://ask.sagemath.org/question/28851/Plotting an integral with a variable as a limithttps://ask.sagemath.org/question/8820/plotting-an-integral-with-a-variable-as-a-limit/I want to plot a function with a variable as a limit, e.g. look at \int_0^x f(y) d y, but this seems to throw an error when Sage can't analytically integrate the function.
x,y=var('x y')
f(y)=integrate(x^x,x,1,y)
plot(f,2,10)
Returns
Traceback (click to the left of this block for traceback)
...
ValueError: free variable: x
Can anybody help with this, please? Many thanks.tom12519Wed, 28 Mar 2012 17:52:02 +0200https://ask.sagemath.org/question/8820/integral from sin at plus minus infinity seems to be badhttps://ask.sagemath.org/question/24412/integral-from-sin-at-plus-minus-infinity-seems-to-be-bad/This doesn't seem right to me
integrate(sin(x), x, -oo, +oo)
0
And this looks bad at all
integrate(sin(x), x, -oo, +2*oo)
0
Why this happening?koteTue, 07 Oct 2014 00:01:53 +0200https://ask.sagemath.org/question/24412/integral() failing with "segmentation fault"https://ask.sagemath.org/question/10966/integral-failing-with-segmentation-fault/Hi sage community
My question again arises from exercises in technical chemistry done in sage. I wanted to calculate an definite integral (number of transfer units).
var('x')
ys=0.06+2*(x-0.0275)
xs=ys/1.516
#my function
i=1/(xs/(1+xs)-x/(1+x))
#print i
#show(plot(i,x,0,0.03))
#I, the indefinite integral of i
I=integral(i,x)
#print I
#show(plot(I,x,0,0.03))
#three methods too calculate the integral
print n(I(x=0.0275)-I(x=0))
print numerical_integral(i,0,0.0275)
print integral(i,x,0,0.275)
The first two methods work fine. The last method gives me the infinite of the following messages.
;;;
;;; Detected access to protected memory, also kwown as 'bus or segmentation fault'.
;;; Jumping to the outermost toplevel prompt
;;;
This is a bug, isn't it? However, i have no idea how integrate() works.
Greetings, marvmarvMon, 27 Jan 2014 10:37:16 +0100https://ask.sagemath.org/question/10966/