Advertisement
Matthen

dropping a fourier series

Feb 21st, 2015
922
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. dx = N[Pi/30];
  2. Manipulate[
  3. Module[{n, ydrop},
  4. n = 1 + Floor[t];
  5. ydrop = 4 - 3.5 (0.5 + 0.5 Tanh[5 (Mod[t, 1] - 0.5)]);
  6. If[t >= 10, ydrop = 10];
  7. Graphics[{
  8. EdgeForm[Black], FaceForm[],
  9. Table[
  10. Module[{y = 0.5 + Sum[1/i (1 + 0.5 Sin[i x]), {i, 1, 2 n, 2}],
  11. y2},
  12. y2 = Max[y, ydrop] + 1/(2 n + 1) (1 + 0.5 Sin[(2 n + 1) x]);
  13. {
  14. FaceForm[
  15. ColorData["RedBlueTones"][
  16. 0.5 + 0.4 Sum[4/(Pi i) (Sin[i x]), {i, 1, 2 n, 2}]]],
  17. Rectangle[{x, 0}, {x + dx, y}],
  18. FaceForm[ColorData["RedBlueTones"][0.5 + 0.5 Sin[(2 n + 1) x]]],
  19. Rectangle[{x, Max[y, ydrop] }, {x + dx, y2}]
  20. }
  21. ], {x, -2 Pi, 2 Pi, dx}]
  22.  
  23. }, PlotRange -> {{-2 Pi, 2 Pi}, {0, 5}}, AspectRatio -> 0.61,
  24. ImageSize -> 500, ImagePadding -> 2]
  25. ],
  26. {t, 0, 10}
  27. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement