Fourier Transforms of Various Functions

Clear["Global`*"]

Fourier Transform of a Sinusoidal Function

f[x_, λ_] := Cos[2 π x / λ] (* If you pick Sin[ ], the transform is imaginary *)
Plot[f[x, 5], {x, -30, 30}, PlotRange -> All]

g[k_, λ_] = FourierTransform[f[x, λ], x, k]

(* We can't actually plot the DiracDelta, so visually simulate it with a skinny triangle. *)g[k_, λ_] := UnitTriangle[(k - 2π/λ)/0.2] + UnitTriangle[(k + 2π/λ)/0.2]

fxplot[λ_] := Plot[f[x, λ], {x, -10, 10}, PlotRange -> All, AxesLabel->{"x", "f[x]"}, LabelStyle->Larger ,PlotLabel -> StringForm["λ = ``", λ]]
gkplot[λ_] := Plot[Abs[g[k, λ]], {k, -10, 10}, PlotRange -> All, AxesLabel->{"k", "g[k]"}, PlotStyle -> Red,  LabelStyle->Larger ,PlotPoints-> 200, PlotLabel -> StringForm["λ = ``", λ]]

Manipulate[GraphicsRow[{fxplot[λ], gkplot[λ]}, ImageSize->800], {{λ, 2π}, 0.1, 10, 0.1, Appearance -> "Open"}  ]

Fourier Transform of a Windowed Finite Wave Train

window[x_, w_]:= HeavisideTheta[w - Abs[x]] * (1+Cos[π x / w])/2
fwt[x_, λ_, w_]:= window[x, w] * Cos[2 π x / λ]

Plot[fwt[x, 4, 20], {x, -30, 30}, PlotRange -> All, PlotStyle -> Thick]

gwt[k_, λ_, w_] = FourierTransform[fwt[x, λ, w], x, k]

fwtxplot[λ_, w_] := Plot[fwt[x, λ, w], {x, -30, 30}, PlotRange -> All, AxesLabel->{"x", "f[x]"}, LabelStyle->Larger ,PlotLabel -> StringForm[" λ= ``  w = ``", λ, w], PlotStyle -> Thick]
gwtkplot[λ_, w_] := Plot[Abs[gwt[k, λ, w]], {k, -10, 10}, PlotPoints -> 200, PlotRange -> All, AxesLabel->{"k", "g[k]"}, PlotStyle -> Red,  LabelStyle->Larger ,PlotLabel -> StringForm[" λ = ``  w = ``", λ, w]]

Manipulate[GraphicsRow[{fwtxplot[λ, w], gwtkplot[λ, w]}, ImageSize->800], {{λ, 2}, 0.2, 10, 0.2, Appearance -> "Open"}, {{w, 20}, 1, 30, 1, Appearance -> "Open"}  ]

Fourier Transform of a Gaussian

fg[x_, σ_] := Exp[-(x^2)/(2 (σ^2))]
Plot[f[x, 5], {x, -30, 30}, PlotRange -> All]

gg[k_, σ_] = FourierTransform[f[x, σ], x, k]

fgxplot[σ_] := Plot[fg[x, σ], {x, -10, 10}, PlotRange -> All, AxesLabel->{"x", "f[x]"}, LabelStyle->Larger ,PlotLabel -> StringForm["σ = ``", σ]]
ggkplot[σ_] := Plot[gg[k, σ], {k, -10, 10}, PlotRange -> All, AxesLabel->{"k", "g[k]"}, PlotStyle -> Red,  LabelStyle->Larger ,PlotLabel -> StringForm["σ = ``", σ]]

Manipulate[GraphicsRow[{fgxplot[σ], ggkplot[σ]}, ImageSize->800], {{σ, 1}, 0.1, 10, 0.1, Appearance -> "Open"}  ]

Fourier Transform of a Single Pulse

fss[x_, a_]:=UnitStep[a/2-x] UnitStep[a/2+x]

Plot[fss[x, 8], {x, -30, 30}, PlotRange -> All, PlotStyle -> Thick]

gss[k_, a_] = FourierTransform[fss[x, a], x, k]

fssxplot[a_] := Plot[fss[x, a], {x, -10, 10}, PlotRange -> All, AxesLabel->{"x", "f[x]"}, LabelStyle->Larger ,PlotLabel -> StringForm[" a= ``", a], PlotStyle -> Thick]
gsskplot[a_] := Plot[gss[k, a], {k, -10, 10}, PlotRange -> All, AxesLabel->{"k", "g[k]"}, PlotStyle -> Red,  LabelStyle->Larger ,PlotLabel -> StringForm[" a = ``", a]]
gssk2plot[a_] := Plot[Abs[gss[k, a]]^2, {k, -10, 10}, PlotRange -> All, AxesLabel->{"k", "g[k]"}, PlotStyle -> Red,  LabelStyle->Larger ,PlotLabel -> StringForm[" a = ``", a]]

Manipulate[GraphicsRow[{fssxplot[a], gsskplot[a]}, ImageSize->800], {{a, 3}, 0.1, 10, 0.1, Appearance -> "Open"}  ]

Power Spectrum

Manipulate[GraphicsRow[{fssxplot[a], gssk2plot[a]}, ImageSize->800], {{a, 3}, 0.1, 10, 0.1, Appearance -> "Open"}  ]

Fourier Transform of a Double Pulse

fds[x_, a_, d_]:=UnitStep[a/2-(x-d/2)] UnitStep[a/2+(x-d/2)] +
UnitStep[a/2-(x+d/2)] UnitStep[a/2+(x+d/2)]

gds[k_, a_, d_] = FourierTransform[fds[x, a, d], x, k]

fdsxplot[a_, d_] := Plot[fds[x, a, d], {x, -20, 20}, PlotRange -> All, AxesLabel->{"x", "f[x]"}, LabelStyle->Larger ,PlotLabel -> StringForm[" a= ``  d = ``", a, d], PlotStyle -> Thick]
gdskplot[a_, d_] := Plot[gds[k, a, d], {k, -20, 20}, PlotPoints -> 200, PlotRange -> All, AxesLabel->{"k", "g[k]"}, PlotStyle -> Red,  LabelStyle->Larger ,PlotLabel -> StringForm[" a = ``  d = ``", a, d]]
gdsk2plot[a_, d_] := Plot[Abs[gds[k, a, d]]^2, {k, -20, 20}, PlotPoints -> 200, PlotRange -> All, AxesLabel->{"k", "g[k]"}, PlotStyle -> Red,  LabelStyle->Larger ,PlotLabel -> StringForm[" a = ``  d = ``", a, d]]

Manipulate[GraphicsRow[{fdsxplot[a, d], gdskplot[a, d]}, ImageSize->800], {{a, 1}, 0.1, 10, 0.1, Appearance -> "Open"}, {{d, 10}, 2, 20, 0.2, Appearance -> "Open"}  ]

Power Spectrum

Manipulate[GraphicsRow[{fdsxplot[a, d], gdsk2plot[a, d]}, ImageSize->800], {{a, 1}, 0.1, 10, 0.1, Appearance -> "Open"}, {{d, 10}, 2, 20, 0.2, Appearance -> "Open"}  ]