Mathematica Mathematica: Convolution between Lorentzian and Gaussian

Click For Summary
The discussion centers around the performance issue encountered when using Mathematica to convolve a Lorentzian function with a Gaussian function. The original code provided for the convolution is noted to take an excessively long time to compute. One participant mentions that the computation takes only 15 seconds on their laptop, but the output is likely not what the user intended. They suggest considering the use of ListConvolve for a numerical approach, which may yield faster results. The conversation highlights potential inefficiencies in symbolic convolution in Mathematica and offers a practical alternative for improved performance.
Niles
Messages
1,834
Reaction score
0
Hi

I have the following code:

Code:
lorentz[A_, Ox_, Oy_, FWHM_, x_] := 
  A (1/3.14) FWHM/((x - Ox)^2 + FWHM^2) + Oy;
gauss[A_, Ox_, Oy_, x_, C_] := A Exp[-(x - Ox)^2 C] + Oy;

Convolve[lorentz[1, 0, 0, 1, x], gauss[1, 0, 0, x, 1], x, y]

It takes extremely long time for this to finish -- is it just an example, where Mathematica is the wrong tool?Niles.
 
Physics news on Phys.org
It only takes 15 seconds on my laptop, but the result probably is not what you want:

0.318471 Convolve[1/(1 + x^2), E^-x^2, x, y]

You may want to use ListConvolve and do it numerically.
 
Last edited:

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 0 ·
Replies
0
Views
617
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K