Guest User

Untitled

a guest
Jun 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. documentclass{article}
  2. usepackage{pgfplots}
  3. begin{document}
  4.  
  5. begin{tikzpicture}
  6. begin{axis}[xmin=0, xmax=30, ymin=2, ymax=3]
  7. addplot[samples at={1,2,...,30}, only marks] expression {<Add Fibonacci sequence here>};
  8. end{axis}
  9. end{tikzpicture}
  10.  
  11. end{document}
  12.  
  13. documentclass[tikz,border=3.14mm]{standalone}
  14. usetikzlibrary{math}
  15. begin{document}
  16.  
  17. tikzmath{
  18. % Adapted from http://www.cs.northwestern.edu/academics/courses/110/html/fib_rec.html
  19. function fibonacci(n) {
  20. if n == 0 then {
  21. return 0;
  22. } else {
  23. return fibonacci2(n, 0, 1);
  24. }; };
  25. function fibonacci2(n, p, q) {
  26. if n == 1 then {
  27. return q;
  28. } else {
  29. return fibonacci2(n-1, q, p+q);
  30. };
  31. };
  32. }
  33. begin{tikzpicture}
  34. foreach X in {0,1,...,8}{
  35. node[circle,fill,label=above:{pgfmathparse{int(fibonacci(X))}
  36. pgfmathresult}] at (X,{fibonacci(X)}) {};}
  37.  
  38. end{tikzpicture}
  39. end{document}
  40.  
  41. documentclass[tikz,border=7pt]{standalone}
  42. begin{document}
  43. tikz
  44. foreach[
  45. remember=g as h (initially 1),
  46. remember=f as g (initially 0),
  47. evaluate=f using int(g+h)
  48. ] n in {1,...,7}
  49. fill[green,draw=black] (n,0) rectangle +(1,f) node[black,scale=2,above left]{f};
  50. end{document}
  51.  
  52. documentclass[tikz,border=7pt]{standalone}
  53. usepackage{xintexpr}
  54. begin{document}
  55. begin{tikzpicture}[xscale=.35]
  56. foreach[
  57. remember=g as h (initially 1),
  58. remember=f as g (initially 0)
  59. ] n in{1,...,30}{
  60. edeff{thexintexpr g + h relax}
  61. edefff{thexintfloatexpr f/10000 relax}
  62. fill[green,draw=black] (n,0) rectangle +(1,ff);
  63. }
  64. end{tikzpicture}
  65. end{document}
Add Comment
Please, Sign In to add comment