File:Temporal coherence tutorial.webm

Summary

Description
English: Side by side comparison of the spectral and time domain representation of a signal with different bandwidths, and different phase profile, used to explain the basic idea of temporal coherence.
Date
Source https://mathstodon.xyz/@j_bertolotti/112908325918433504
Author Berto
Permission
(Reusing this file)
https://mathstodon.xyz/@j_bertolotti/111363365323269417

Mathematica 14.0 code

\[Omega]0 = 20;
amplitude[\[Omega]_, \[Sigma]_] := E^(-((\[Omega] - \[Omega]0)^2/(2 \[Sigma]^2)))/(Sqrt[2 \[Pi]] \[Sigma]);
rpgenerator = Total[Table[ RandomReal[{-1, 1}]*Sin[j/5 \[Omega] + 2 \[Pi] RandomReal[{0, 1}]], {j, 1, 80}]];
randomphase[\[Omega]_, flag_] := flag*I rpgenerator;
phase[\[Omega]_, flag_] := Exp[randomphase[\[Omega], flag]];
argphase = randomphase[\[Omega] - \[Omega]0, 1];
spectrum[\[Omega]_, \[Sigma]_, flag_] := amplitude[\[Omega], \[Sigma]]*phase[\[Omega], flag]

plot[\[Sigma]_, flag_, string_] := (
  \[Delta]\[Omega] = \[Sigma]/150;
  hsamples = Total@Table[ spectrum[\[Omega], \[Sigma], flag]*E^(I \[Omega] t), {\[Omega], \[Omega]0 - 10 \[Sigma], \[Omega]0 + 10 \[Sigma], \[Delta]\[Omega]}];
  tplot = Re@hsamples/FindMaximum[Abs@hsamples, {t, 0}][[1]];
  Grid[{{Text[Style[string, Purple, Bold, FontSize -> 18]], 
     SpanFromLeft}, {},
    {
     Show[
      Plot[ Abs[amplitude[\[Omega], \[Sigma]]/amplitude[\[Omega]0, \[Sigma]]], {\[Omega], 10, 30}, PlotRange -> {-1.1, 1.2}, Ticks -> None, Axes -> {True, False}, AxesStyle -> Thick, PlotStyle -> Directive[Thick, Black], PlotLegends -> Placed[LineLegend[{Black, Orange}, {"Amplitude", "Phase"},  LegendFunction -> (Framed[#, RoundingRadius -> 5, Background -> White] &), LegendMargins -> 5], {Right, Top}], PlotLabel -> "Frequency domain", LabelStyle -> Directive[Bold, Black, FontSize -> 14], ImageSize -> Large, PlotPoints -> 200]
      ,
      Plot[ Evaluate@(Im[randomphase[\[Omega] - \[Omega]0, flag]]/(4 \[Pi])), {\[Omega], 10, 30}, PlotStyle -> {Thick, Orange}, Axes -> False]
      ]
     ,
     Show[
      Plot[Cos[\[Omega]0 t], {t, -5, 5}, PlotRange -> {-1.1, 1.2}, Ticks -> None, Axes -> {True, False}, AxesStyle -> Thick, PlotStyle -> Directive[LightGray], PlotLegends -> Placed[LineLegend[{Black, LightGray}, {"Signal", "Carrier"}, LegendFunction -> (Framed[#, RoundingRadius -> 5, Background -> White] &), LegendMargins -> 5], {Right, Top}], LabelStyle -> Directive[Bold, Black, FontSize -> 14]]
      ,
      Plot[tplot, {t, -5, 5}, PlotRange -> {-1.1, 1.2}, PlotStyle -> Directive[Thick, Black]], ImageSize -> Large, PlotLabel -> "Time domain", LabelStyle -> Directive[Bold, Black, FontSize -> 14]]
     }}]
  )

frame1 = plot[0.01, 0, "Time coherence tells us how much our signal looks like a perfect sinusoidal"];
frame2 = plot[0.01, 0, "A signal with a very narrow bandwidth is almost exactly a sinusoidal"];
sinstep[t_] := Sin[\[Pi]/2 t]^2;
frame3 = Table[plot[N[0.01 + sinstep[k]*(3 - 0.01)], 0, "A signal with a large bandwidth stops looking like a simple sinusoidal"], {k, 0, 1, 0.01}];
frame4 = plot[3, 0, "If the phase of the spectrum is flat, all sinusoidal components add constructively at t=0, and we get a pulse"];
frame5 = Table[plot[3, sinstep[k], "But if the phase is random, the result doesn't look like a sinusoidal at all (short time coherence)"], {k, 0, 1, 0.01}];
frame6 = Table[plot[3 - (3 - 0.01)*sinstep[k], 1, "If the bandwidth is small, the randomness of the phase doesn't matter, and we recover a nice sinusoidal"], {k, 0, 1, 0.01}];
frame7 = Table[plot[0.01, 1 - sinstep[k], "If the bandwidth is small, the randomness of the phase doesn't matter, and we recover a nice sinusoidal"], {k, 0, 1, 0.01}];

ListAnimate[Join[Table[frame1, {100}],  Table[frame2, {100}], frame3, Table[frame3[[-1]], {30}], Table[frame4, {100}], frame5, able[frame5[[-1]], {30}], frame6, Table[frame6[[-1]], {30}], frame7, Table[frame7[[-1]], {30}]  ]]

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Category:CC-Zero#Temporal%20coherence%20tutorial.webm
Category:Self-published work Category:WebM videos Category:Concepts in physics Category:Optics Category:Images with Mathematica source code
Category:CC-Zero Category:Concepts in physics Category:Images with Mathematica source code Category:Optics Category:Self-published work Category:WebM videos