0
$\begingroup$

In my code I solved a differential equation system, then I made a fourier transform of the solution in differents times, this is my code

Clear["Global`*"]

dt = 4;

Nmax = 64; (*Number of sites*)

tini = 0; (*initial time*)

tmax = 80; (*maximal time*)

n0 = Nmax/2;(*initial condition*)

\[Psi]ini = Sqrt[2/Nmax] Table[Sin[\[Pi] (n0 n)/Nmax], {n, 1, Nmax}];

Z = Table[
   1. (KroneckerDelta[i - j + 1] + KroneckerDelta[i - j - 1]), {i, 1, 
    Nmax}, {j, 1, Nmax}];

Clear[\[Psi]]

usol = NDSolveValue[{I D[\[Psi][t], t] == 
     Z.\[Psi][t], \[Psi][0] == \[Psi]ini}, \[Psi], {t, tini, tmax}];

tt = Range[tini, tmax, dt];

FF = Table[FourierDST[usol[i], 1], {i, tini, tmax, dt}];

Table[ListLinePlot[Abs[FF[[i]]]^2, PlotRange -> All, 
   PlotLabel -> tt[[i]], PlotTheme -> "Scientific"], {i, 
   Length[tt]}] // Chop

this is the result that I´m expected, a pick in n0 in all the times but I don´t know why the amplitude of pick is not 1. And if I change n0 like n0=1 or n0=64 the amplitude of pick is equal to 1. Do I have a problem with normalization? I expected that for all n0 the amplitude of pick is equal to 1

In fact, I made the manual fourier transform

Ur = Table[usol[t], {t, tini, tmax, dt}];

S = Sqrt[2/Nmax]
    Table[Sin[\[Pi]/(Nmax + 1) r n], {r, 1, Nmax}, {n, 1, Nmax}];

Table[ListLinePlot[(Re[S.Ur[[i]]]^2 + Im[S.Ur[[i]]]^2), 
   PlotRange -> All, PlotLabel -> tt[[i]], 
   PlotTheme -> "Scientific"], {i, Length[tt]}] // Chop

but the result is the same.

$\endgroup$
2
  • 1
    $\begingroup$ Mathematica's Fourier convention is not by default unitary. Luckily, FourierDSTaccepts a second parameter, m which is used for DST and DCT, rather than the FourierParameters option. Both m=1 and m=4 are their own inverses, meaning they must be unitary. Which you want depends on your application, but I think it's m=1. $\endgroup$
    – evanb
    Jun 7 at 7:41
  • $\begingroup$ In the line "FF" I used FourierDST with m=1, I know that I´m using the correct form of fourier transform but I don´t why when I change n0 the pick is not equal to 1 $\endgroup$ Jun 7 at 15:35
1
$\begingroup$

First consider that your "peak" has a certain width:

ListLinePlot[tf = (Abs[FF[[1]]]^2)[[30 ;; 35]], PlotRange -> All, 
 PlotLabel -> tt[[1]], PlotTheme -> "Scientific"]

enter image description here

This is because you have a finite sequence. Therefore, what matters is the area, not the height.

Further, the absolute values are not important, they are a conventions, but the relative values matter. But what really matters is that the inverse gives back the original data. In your case, you are implicitly using convention: 2, then convention: 3 gives the inverse:

test = usol[0] // Chop;
test1 = FourierDST[test, 2] // Chop;
test2 = FourierDST[test1, 3] // Chop;
test2 == test

(* True*)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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