# Symbolic Integration works only with second dummy variable

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:

 var('y') psi = function('psi')(y) f = function('f')(y) integrate(psi(x-y)*f(y),y) 

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:

 var('t') psi = function('psi')(t,y) f = function('f')(t,y) integrate(psi(t,x-y)*f(t,y),y) 

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 integrate(psi(y)*f(y),y) return an error?

What am I missing here ?

edit retag close merge delete

Sort by » oldest newest most voted

I think that's a bug in the Sage-to-maxima interface. Compare :

sage: var('y')
....: psi = function('psi')(y)
....: f = function('f')(y)
....:
y
sage: (psi(x-y)*f(y)).maxima_methods().integrate(y)
integrate(f(y)*psi(x - y), y)
sage: (psi(x-y)*f(y)).maxima_methods().integrate(y).diff(x)
integrate(f(y)*D[0](psi)(x - y), y)


with :

sage: (psi(x-y)*f(y)).integrate(y)
---------------------------------------------------------------------------


[ Long backtrace ]

RuntimeError: ECL says: Error executing code in Maxima:


BTW :

sage: integrate(psi(x-y)*f(y),y, algorithm="sympy")
integrate(f(y)*psi(x - y), y)
sage: integrate(psi(x-y)*f(y),y, algorithm="sympy").diff(x)
integrate(f(y)*D[0](psi)(x - y), y)
sage: integrate(psi(x-y)*f(y),y, algorithm="giac")
integrate(f(y)*psi(x - y), y)
sage: integrate(psi(x-y)*f(y),y, algorithm="giac").diff(x)
integrate(f(y)*D[0](psi)(x - y), y)


Another exemple of this quirk (against an old saw by Leibnitz, IIRC) :

sage: foo=arctan(x).diff(x).subs(x^2==-p).maxima_methods().powerseries(p,0).subs
....: (p==-x^2).simplify(); foo
sum((-1)^i5*x^(2*i5), i5, 0, +Infinity)
sage: foo.maxima_methods().integrate(x)
sum((-1)^i5*x^(2*i5 + 1)/(2*i5 + 1), i5, 0, +Infinity)
sage: foo.integrate(x)
---------------------------------------------------------------------------


[ Long backtrace again... ]

RuntimeError: Encountered operator mismatch in maxima-to-sr translation


and integrate(foo, x) gives the same final error message.

I encounter the same problem (and the same "solution") in Trac#13071. Other integration Trac tickets may have a similar origin, (but I lack the time needed to check them...).

more

This is definitely a bug, which seems to originate from the name psi for one of the two functions: it is confused with Maxima's special function psi, see http://maxima.sourceforge.net/docs/ma...

If you replace psi by another name, everything works:

sage: f = function('f')
sage: g = function('g')
sage: y = var('y')
sage: integrate(g(x-y)*f(y), y)
integrate(f(y)*g(x - y), y)

more