# Numerical Laplace Transform using Fourier transform and plotting results [closed]

I would like to take a numerical transform of interpolating functions which is a solution of at least two coupled differential equations. But for this question, I am simplifying the solution to make it easier for discussion purposes. I found at least two similar questions but their solutions seem not to give the right answer.

I believe that numerical Laplace transform can be done by multiplying the solution function $$f(x)$$ with $$e^{-\alpha t}$$ where $$\alpha$$ is the frequency in real domain spectrum, and then take the numerical Fourier transform of this product. Since we have two variables $$\alpha$$ (the real part of frequency spectrum and $$\omega$$ the imaginary part of frequency spectrum, the Fourier transform is two dimensional ($$\alpha$$,$$\omega$$). The reason I am doing this is because I want to find frequencies from the solution that are only real (not imaginary).

Note: The Fourier transform is the integral of function $$f(x)$$ with kernel $$e^{-i\omega x}$$. The Laplace transform is the integral of function $$f(x)$$ with kernel $$e^{-s x}$$ where $$s=\alpha+i\omega$$. Below is my sample code,

xrange=40;
Plot[Evaluate[Sin[0.5*x]*Cos[6*x]],{x,0,xrange},PlotRange->All]

t1=Table[Evaluate[Sin[0.5*x]*Cos[6*x]],{x,0,xrange,1/20}];
Spectrogram[t1]

tmax=40;sr=20;
set=Round[tmax*10];
data1=Table[Evaluate[Sin[0.5*x]*Cos[6*x]],{x,0,tmax,1/sr}];
ft1=Fourier[data1,FourierParameters->{-1,-1}];
ff1=Table[(n-1) sr/Length@data1,{n,Length@data1}];
ListLinePlot[Transpose[{ff1,Abs[ft1]}][[1;;set]],PlotRange->All,ImageSize->   {300,300},Frame->True,FrameLabel->{"Frequency/Hz","Spectral Level"},PlotLabel->"Frequency Spectrum"]

(* Laplace transform attempt*)
data1=Table[Evaluate[Sin[0.5*x]*Cos[6*x]]*Exp[-s*x],{{x,0,tmax,1/sr},{s,0,tmax,1/sr}}];
ft1=Fourier[data1,FourierParameters->{-1,-1}];
ff1=Table[(n-1) sr/Length@data1,{n,Length@data1}];
Plot3D[Transpose[{ff1,Abs[ft1]}][[1;;set]],PlotRange->All,ImageSize->   {300,300},PlotLabel->"Frequency Spectrum"]


My attempt of Laplace transform fails because I am not writing the code of 2D Fourier transform properly. Any suggestions to where I am going wrong is appreciated.

• Plot[Evaluate[Sin[0.5*x]*Cos[6*x]],{x,0,xrange},PlotRange->All] t1=Table[Evaluate[Sin[0.5*x]*Cos[6*x]],{x,0,xrange,1/20}]; Spectrogram[t1] does not work, What is your xrange? Apr 21 at 8:02
• I don't think Spectrogram is what you want. I think Spectrogram gives a time evolving spectrum. If you want a numerical Laplace transform then you have to get a grid of values where each column is the Fourier transform of the real domain multiplied by Exp[- alpha t] . Each column has a different alpha. Fourier will give you the values for each column.
– Hugh
Apr 21 at 11:11
• The value of xrange is 40. Apr 21 at 12:35

My guess is you want something like this

xrange = 40;
a = Transpose@
Table[Fourier[
Table[E^(-α x) (Sin[0.5*x]*Cos[6*x]), {x, 0, xrange,
1/50}]][[1 ;; 100]], {α, 0, 2, 0.005}];
ListPlot3D[Abs[a], PlotRange -> All, BoxRatios -> {1, 2, 1}] Your function has two sine waves so you get two poles on the imaginary axis. I have plotted the absolute values. Also, I have not plotted the negative frequencies since they are conjugate to the positive ones.

Is this along the lines of what you want?

• Yes. You did it. Apr 21 at 20:30