Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!

Fourier Animation

By: Matthen on Feb 2nd, 2013  |  syntax: None  |  size: 0.71 KB  |  views: 3,515  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. FourierF[a_, t_] := a.Table[Sin[2 Pi i t], {i, Length[a]}];
  2. FourierAnim[a_, t_] :=
  3.   Module[{A = Accumulate[a*Table[Cos[2 Pi i t], {i, Length[a]}]],
  4.     B = Accumulate[a*Table[Sin[2 Pi i t], {i, Length[a]}]]}
  5.    , PrependTo[A, 0]; PrependTo[B, 0];
  6.    Show[Graphics[
  7.      Table[{Circle[{A[[i]], B[[i]]}, a[[i]]], Darker[Red],
  8.        If[i != Length@a,
  9.         Line[{{A[[i]], B[[i]]}, {A[[i + 1]], B[[i + 1]]}}], {Red,
  10.          Dashed, Line[{{A[[i]], B[[i]]}, {2, B[[i]]}}]}]}, {i,
  11.        Length@a}], PlotRange -> {{-1.5, 3}, {-1, 1}}],
  12.     Plot[FourierF[a[[;; -2]], t - \[Tau]], {\[Tau], 2, 3}]]];
  13. a = Table[(1 - (-1)^i)/i, {i, 16}]/Pi;
  14.  
  15. Manipulate[FourierAnim[a[[;; j]], t], {t, 0, 1}, {j, 1, Length@a, 1}]