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.Wed, 08 Aug 2018 06:41:12 -0500Solved: Why does integrate(psi(y)*f(y),y) return an error but integrate(psi(t,y)*f(t,y),y) works?https://ask.sagemath.org/question/43287/solved-why-does-integratepsiyfyy-return-an-error-but-integratepsityftyy-works/Hi there,
I am trying get an symbolic expression for the convolution
$$ (\psi \star f)(x) := \int\limits_{\mathbb{R}} \psi(x-y) f(y) {d y} $$
of two functions
$
f, \psi: \mathbb{R} \to \mathbb{R}
$
as follows:
<code>
var('y') <br>
psi = function('psi')(y) <br>
f = function('f')(y) <br>
integrate(psi(x-y)*f(y),y)
</code>
upon which I get the error message
> RuntimeError: ECL says: Error executing code in Maxima:
If I add an extra argument to the two functions and define them as
$$ f, \psi : \mathbb{R} \times \mathbb{R} \to \mathbb{R} $$
as follows:
<code>
var('t') <br>
psi = function('psi')(t,y) <br>
f = function('f')(t,y) <br>
integrate(psi(t,x-y)*f(t,y),y)
</code>
there is a surprise, *it suddenly works!*
I get the desired symbolic expression on which I can run diff(..,x) and all the other built-in functions.
**TL;DR**
Why does <code>integrate(psi(y)*f(y),y)</code> return an error?
**Solution**
Use sympy backend for symbolic integration as in
<code>integrate(psi(x-y)*f(y),y, algorithm="sympy")</code>hausdorffWed, 08 Aug 2018 06:41:12 -0500https://ask.sagemath.org/question/43287/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 14:44:16 -0600https://ask.sagemath.org/question/36185/