ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 12 Sep 2020 05:50:48 -0500Triple integrals in a specific region of spacehttps://ask.sagemath.org/question/53419/triple-integrals-in-a-specific-region-of-space/Can I perform a triple integral in a region of space I define?
I'm trying to migrate from Mathematica to Sage,
and in Mathematica I could go and define a region of space
(with various limitations) and then perform the integral
of a function on it.
In Mathematica:
reg = ImplicitRegion[x + 2 y + 3 z < 2 && -1 < x < y < z < 1, {x, y, z}];
integral[{x, y, z} in reg, (x^2 + 2 y z)]
![mathematica-polyhedral-region-integrate-polynomial](/upfiles/16000472797455741.png)
Is there a way to easily perform this operation even in Sage?Teo7Sat, 12 Sep 2020 05:50:48 -0500https://ask.sagemath.org/question/53419/Error in integralhttps://ask.sagemath.org/question/53172/error-in-integral/I've got this error on the second integral. I put the code on wxMaxima and returned sucessfull. On wxMaxima, raise a question "z is positive, negative or zero?", also on sage, but on sage I can't answer that. How can I correct this?
```x,y,z = var("x y z")```
```function = x*e^(-y)```
``` integral(function,y,0,ln(x)).integral(x,0,2*z) ```gabrielromao5Tue, 25 Aug 2020 08:50:58 -0500https://ask.sagemath.org/question/53172/Integrate piecewise function with change of variablehttps://ask.sagemath.org/question/37114/integrate-piecewise-function-with-change-of-variable/I would like to integrate a piecewise defined function while operating a change of variable. I start by defining the function and another variable involved in the change of variable:
phi(x) = piecewise([([-1,1], (1-abs(x))*(1-abs(x))*(1+2*abs(x)))]);
phi(x) = phi.extension(0);
h=pi/n;
h=h.n();
What I would like to do is integrate the function `phi(x/h-1)` between `0` and `pi` so I try it and results in
integral(phi(x/h-1),x,0,pi)
ValueError: substituting the piecewise variable must result in real number
So I then try to use another variable which I try to define to be 'real'
t=var('t')
assume(t,'real');
integral(phi(t/h-1),t,0,pi)
but it results in the same error... Now I try the "lambda" method since it worked when calling the `plot` function with the same change of variable; but fail again
integral(lambda t: phi(t/h-1),t,0,pi)
TypeError: unable to convert <function <lambda> at 0x16d71f140> to a symbolic expression
Now I try to use another integration method with `definite_integral` but get the same errors, only different for the "lambda" method
definite_integral(lambda x: phi(x/h-1),x,0,pi)
TypeError: cannot coerce arguments: no canonical coercion from <type 'function'> to Symbolic Ring
Is there any way around this? I really do not know what else to try...
jrojasquTue, 28 Mar 2017 18:28:56 -0500https://ask.sagemath.org/question/37114/Is this a known bug with integral()https://ask.sagemath.org/question/30075/is-this-a-known-bug-with-integral/I've tried to compute the following integral wth integral() in a SageMathCloud worksheet: $\displaystyle \int_{-\pi/6}^{\pi/6}\frac{\cos x}{1+\sin x}dx$.
The output was an error message (saying the integral is divergent), just like the one I got in SageMathCell (see link):
https://sagecell.sagemath.org/?z=eJzzVLBVyMwrSU0vSszRSM4v1qjQ1Ncw1C7OzAOyNHUUKnQUdAsy9c10FECkJi9XcUZ-uYanJgDa5Q_i&lang=sage
So I tried with integrate() and with numerical_integral() as well. I was never able to obtain the value of this integral, which turns out to be $\ln(3)$ after an obvious substitution.
Is this a bug?
Note that replacing 1 by 1.1 yields this:
https://sagecell.sagemath.org/?z=eJzzVLBVyMwrSU0vSszRSM4v1qjQ1Ncw1DPULs7MA7I1dRQqdBR0CzL1zXQUQKQmL1dxRn65hqcmAPXGEEE=&lang=sage
while we get that when replacing 1 by 2:
https://sagecell.sagemath.org/?z=eJzzVLBVyMwrSU0vSszRSM4v1qjQ1Ncw0i7OzAOyNHUUKnQUdAsy9c10FECkJi9XcUZ-uYanJgDbCA_j&lang=sageJulienSat, 17 Oct 2015 10:01:02 -0500https://ask.sagemath.org/question/30075/Simplify result of this definite integralhttps://ask.sagemath.org/question/10503/simplify-result-of-this-definite-integral/It is well known that for $n\in\mathbb{N}$ and $n>0$ (an maybe even for more than these restrictions): $$I_n = \int_0^\infty\frac{x^n}{e^x-1}dx = \zeta(n+1)n!$$ which, analytically can be shown easily by expanding $1/(1-e^{-x})$ into a geometric series, which leads to trivial integrals, and by using $\zeta(n+1)=\sum_{l=1}^\infty l^{-(n+1)}$. So, eg.: $$I_1 = \pi^2/6$$ $$I_2 = 2\zeta(3)$$ a.s.o...
Now, if I try even the simplest case with sage, I get this 'nifty' little results
sage: integrate(x/(exp(x)-1),x,0,oo)
-1/6*pi^2 + limit(-1/2*x^2 + x*log(-e^x + 1) + polylog(2, e^x), x,
+Infinity, minus)
**Is there any trick to simplify this** down to the final result, or is this about as far as I can get with sage alone?
PS.: it is probably needless to say that (once again ... :( ...)
In[1]:= Integrate[x/(Exp[x] - 1), {x, 0, Infinity}]
Out[1]:= Pi^2/6
MarkWed, 04 Sep 2013 10:06:49 -0500https://ask.sagemath.org/question/10503/