Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica: Convolution between Lorentzian and Gaussian

  1. Jun 7, 2012 #1

    I have the following code:

    Code (Text):

    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?

  2. jcsd
  3. Jun 10, 2012 #2


    Staff: Mentor

    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: Jun 10, 2012
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook