Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Recently discovered what InterpolatingFunction's are in Mathematica...really amazing/useful. As I understand it, it's basically a curve fitter....sorta.

So how would I use Convolve with a unit triangle or some other analytical-esque function, to convolve over a InterpolatingFunction??

In the image, the red triangle is UnitTriangle[x] (well, it's height and width are off, but you get the gist of it). So ideallly, I'd like to do something like Convolve[ UnitTriangle[x], InterpolatedFunction, ?, ?]

But that won't work of course, since I don't know what the domains are (hence the ? ?) for the interpolated function.

share|improve this question
I think Convolve works only symbolically. You might have to use NIntegrate to do the convolution integral directly. – Michael E2 Mar 15 '14 at 22:41
Yes, as Michael said you need to integrate numerically. Not only does Convolve require symbolic input, it also integrates over the whole real line, which won't work for an interpolating function with a restricted domain. – Szabolcs Mar 15 '14 at 23:12
Hmm. Well, if you use NIntegrate you just get a number out right? Is there a way, for example, to use NIntegreate to get the same graph output, as this would do --> Convolve[UnitBox[x], UnitBox[x], x, t] Really I just need the graph output of what the convolution of the unit triangle with an interpolation function would look like. – Christopher Brittain Mar 16 '14 at 5:28
If you specifically want to use Convolve, you have to construct a different kind of interpolation function to work with. For instance, you can use Piecewise, InterpolatingPolynomial or construct the function using your own basis functions. I must say I'm a bit saddened by the fact Interpolation, BezierFunction and BSPlineFunction don't produce suitable output, but instead you have to trouble yourself to get all this done. – kirma Mar 16 '14 at 9:51

There is nothing to stop you from using NIntegrate with a parameter and have it evaluated for a given value of that parameter, e.g.

Plot[ NIntegrate[ f[x] UnitTriangle[ x - x0], {x, 1, 6}], {x0, 1, 6}]

Now, this is somewhat slow and can be made significantly faster by telling NIntegrate not to bother with any symbolic preprocessing:

 Plot[ NIntegrate[ f[x] UnitTriangle[ x - x0], {x, 1, 6}, Method -> {Automatic, "SymbolicProcessing" -> 0}], {x0, 1, 6}]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.