1
votes

guys! Sorry in advance about this.

Let's say I want to convolve two functions (f and g), a gaussian with a breit-wigner:

f[x_] := 1/(Sqrt[2 \[Pi]] \[Sigma])Exp[-(1/2) ((x - \[Mu])/\[Sigma])^2];
g[x_] := 1/\[Pi] (\[Gamma]/((x - \[Mu])^2 + \[Gamma]^2));

One way is to use Convolve like:

Convolve[f[x],g[x],x,y];

But that gives:

(\[Gamma] Convolve[E^(-((x - \[Mu])^2/(2 \[Sigma]^2))),1/(\[Gamma]^2 + (x - \[Mu])^2), x, y])/(Sqrt[2] \[Pi]^(3/2) \[Sigma])

,which means it couldn't do the convolution.

I then tried the integration (the definition of the convolution):

Integrate[f[x]*g[y - x], {x, 0, y}, Assuptions->{x > 0, y > 0}]

But again, it couldn't integrate. I know that there are functions that can't be integrated analytically, but it seems to me that whenever I go into convolution, I find another function that can't be integrated.

Is the numerical integration the only way to do convolution in Mathematica (besides those simple functions in the examples), or am I doing something wrong?

My target is to convolute a crystal-ball with a breit-weigner. The CB is something like:

Piecewise[{{norm*Exp[-(1/2) ((x - \[Mu])/\[Sigma])^2], (
x - \[Mu])/\[Sigma] > -\[Alpha]},
{norm*(n/Abs[\[Alpha]])^n*
 Exp[-(1/2) \[Alpha]^2]*((n/Abs[\[Alpha]] - Abs[\[Alpha]]) - (
   x - \[Mu])/\[Sigma])^-n, (x - \[Mu])/\[Sigma] <= -\[Alpha]}}]

I've done this in C++ but I thought I try it in Mathematica and use it to fit some data. So please tell me if I have to make a numerical integration routine in Mathematica or there's more to the analytic integration.

Thank you, Adrian

1
Just a side remark, I though in the definition of a convolution one integrates over all the reals. - b.gatessucks
yeah, I just put in those assumptions to help the computation (I don't know if it did, but same results w/ or w/o. - user2285967
oh, you mean integrate from -Inf to Inf...I don't know where I got this definition from... - user2285967
in the Generalization & Extensions section of Convolve there is a x^5 UnitStep[x] convoluted with a Sin[x] UnitStep[x]. That's where I saw it and applied it without thinking. In any case, my x is also positive. - user2285967
I recommend asking Mathematica-related questions here, where the vast majority of our community has moved. - Leonid Shifrin

1 Answers

0
votes

I Simplified your functions a little bit(it might look little, but its huge in the spirit). In this case I have set [Mu] to be zero.

\[Mu] = 0;

Now we have:

f[x_] := 1/(Sqrt[2 \[Pi]] \[Sigma]) Exp[-(1/2) ((x)/\[Sigma])^2];
g[x_] := 1/\[Pi] (\[Gamma]/((x)^2 + \[Gamma]^2));

Asking Mathematica to Convolve:

Convolve[f[x], g[x], x, y]
-((I E^(-((y + I \[Gamma])^2/(2 \[Sigma]^2))) (E^((2 I y \[Gamma])/\[Sigma]^2) \[Pi] Erfi[((y - I \[Gamma]) Sqrt[1/\[Sigma]^2])/Sqrt[2]] - \[Pi] Erfi[((y + I \[Gamma]) Sqrt[1/\[Sigma]^2])/Sqrt[2]] - Log[-y - I \[Gamma]] - E^((2 I y \[Gamma])/\[Sigma]^2) Log[y - I \[Gamma]] + E^((2 I y \[Gamma])/\[Sigma]^2) Log[-y + I \[Gamma]] + Log[y + I \[Gamma]]))/(2 Sqrt[2] \[Pi]^(3/2) \[Sigma]))

Although this is not precisely what you asked for, but it shows if your function was a tiny bit simpler, Mathematica would be able to do the integration. In the case of your question, unless we know some more information about [Mu], I don't think the result of Convolve has a closed form. You can probably ask math.stackexchange.com guys about your integral and see if someone comes up with a closed form.