1
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ 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? $\endgroup$
    – user64494
    Apr 21 at 8:02
  • 1
    $\begingroup$ 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. $\endgroup$
    – Hugh
    Apr 21 at 11:11
  • $\begingroup$ The value of xrange is 40. $\endgroup$
    – Aschoolar
    Apr 21 at 12:35
3
$\begingroup$

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}]

Abs value of Laplace transform

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?

$\endgroup$
1
  • $\begingroup$ Yes. You did it. $\endgroup$
    – Aschoolar
    Apr 21 at 20:30

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