(* K. Byczuk, 21/03/2017, ilustracje do wykladu Mechanika kwantowa*)

k=1;
(*Pakiet trojkatny fal plaskich e^{ikx} z 5 skladowymi*)
Plot[ 
{
Re[ Exp[ I k x  ]]+10 ,  0.8 Re[Exp[I 2 k x]]+8,0.6  Re[ Exp[I 3 k x]]+6, 0.4 Re[Exp[I 4 k x]]+4, Re[0.2 Exp[I 5 k x]+2]
},{x,-20,20},PlotRange->{{-20,20},{0,13}}]
Plot[ Re[Exp[ I k x  ]+  0.8 Exp[I 2 k x]+0.6 Exp[I 3 k x]+0.4 Exp[I 4 k x]+0.2 Exp[I 5 k x]],{x,-20,20},PlotRange->{{-20,20},{-1,4}}]

(* Ewolucja pakietu trojkatnego o 5 skladowych*)
k=1;
Animate[Plot[ 
Abs[
Exp[ I k (x-t)  ]+  0.8 Exp[I 2 k (x-2 t)]+0.6 Exp[I 3 k (x-3 t)]+0.4 Exp[I 4 k (x- 4 t)]+0.2 Exp[I 5 k (x-5 t) ]
],{x,-20,20},PlotRange->{{-20,20},{0,3}}],{t,0,20}]

k=1;
Animate[Plot[Abs[Exp[I k (x-t)]+0.8` Exp[I 2 k (x-2 t)]+0.6` Exp[I 3 k (x-3 t)]+0.4` Exp[I 4 k (x-4 t)]+0.2` Exp[I 5 k (x-5 t)]],{x,-20,20},PlotRange->{{-10,10},{0,3}}],{t,0,20},AnimationRunning->False]

(* Ewolucja pakietu trojkatnego o 9 skladowych, z maksimum w k=5*)
k=1;
Animate[Plot[ Abs[
0.2 Exp[ I k (x-t)  ]+  0.4 Exp[- I 2 k(x-2 t)] +
0.6 Exp[I 3 k (x-3 t)]+ 0.8 Exp[-I 4 k(x- 4 t)]+
1.0 Exp[I 5 k (x-5 t)]+ 0.8 Exp[- I 6 k (x-6 t)]+
0.6 Exp[I 7 k (x- 7 t)]+ 0.4 Exp[-I 8k (x - 8 t)] +
0.2 Exp[I 9 k (x-9 t)]
],{x,-20,20},PlotRange->{{-10,10},{0,6}}],{t,0,20}]

(* Pakiet trojkatny z imax liczba skladowych k w (0,1) *)
imax=100;
k=1;
Psi[x_,t_]:=Sum[(1-k i/imax) Exp[I k ((i+1) / imax )( x - k ((i+1) /imax) t)],{i,0,imax}];
Plot[Re[Psi[x,0]],{x,-20,20},PlotRange->{{-20,20},{-1,0.6 imax}}]
Animate[Plot[
Abs[Psi[x,t]],{x,-10,100}, PlotRange->{{-10,100},{0,0.6 imax}}],
{t,0,100}
]