Ask Your Question

A symbolic convolution of arbitrary functions

asked 2011-11-23 17:01:36 -0500

ADuC812 gravatar image

updated 2011-11-25 14:25:25 -0500

kcrisman gravatar image

In this manual it is described how to get a symbolic result of "the convolution of any piecewise defined function with another". However, when I try this with functions like exponent, this does not work:

x = PolynomialRing(QQ, 'x').gen()
f = Piecewise([[(0,1),exp(x)]])

I get an error "RuntimeError: Symbolic Ring still using old coercion framework"

If I use a 'RR' ring instead of 'QQ', Piecewise() returns another error "TypeError: cannot coerce arguments: __call__() takes exactly 1 positional argument (0 given)"

I have 2 questions:

  1. Is there a way to get a function, which represent convolution of a gaussian function and a decaying exponent (and, generally, any functions)? I want to fit my data with such a function.
  2. How to get a symbolical convolution of functions with parameters (they should be assumed to be constants during convolution computation)?
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2011-12-02 21:55:41 -0500

ADuC812 gravatar image

The possible way is to use convolution definition and to find symbolically the corresponding integral. This may be done without piecewise definition:

var('t, x_0, FWHM, y_0, S_1, tau_1')
assume (t>0)

However, the resulting function works rather slow for fitting purposes

edit flag offensive delete link more


I wonder how to make it faster. I tried fast_callable(), but it does not seem to help.

ADuC812 gravatar imageADuC812 ( 2011-12-02 21:58:31 -0500 )edit

answered 2011-11-25 14:48:18 -0500

kcrisman gravatar image

updated 2015-02-16 11:52:59 -0500

I can't fix this for you (yet?), but I see why this wasn't detected before - the example you reference uses

f = Piecewise([[(0,1),1*x^0]])

which becomes

sage: f
Piecewise defined function with 1 parts, [[(0, 1), 1]]

so the variables don't come into play. Also, the example (and yours) uses a polynomial variable, which of course (?) becomes non-polynomial once e^x is involved. So there are two strikes against this.

It's not clear to me that there is an easy way to get around this, because there isn't an obvious way to turn the polynomial generator x into an exponential, but the code for convolution relies pretty heavily on having those polynomial generators.

Stock disclaimer: all piecewise material dates from before Sage had any true symbolic capabilities. It has since languished. See the piecewise tag here and questions under it, such as this one.

I'm hoping someone more familiar with some of the numerical tools in Sage can help you with your underlying questions. You can certainly get some convolutions, e.g. discrete ones in Numpy, but your use case might be a little trickier.

Maxima used directly might be of help, or perhaps using its integration as at this Maxima feature request or using its piecewise capabilities.

edit flag offensive delete link more


The last link (now) leads to a spam page.

rws gravatar imagerws ( 2015-02-16 02:10:46 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-11-23 17:01:36 -0500

Seen: 1,117 times

Last updated: Feb 16 '15