Advertisement
kkoudas

ThomaeFunction

Jul 18th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. \documentclass{article}
  2. \usepackage{tikz}
  3.  
  4. \makeatletter
  5. \pgfmathdeclarefunction*{gcd}{2}{%
  6. \begingroup
  7. \pgfmathcontinuelooptrue
  8. \pgfmath@xa=#1pt\relax % <-
  9. \pgfmath@xb=#2pt\relax % <-
  10. \ifdim\pgfmath@xa=0pt\relax
  11. \pgfmathcontinueloopfalse
  12. \pgfmath@xa=\pgfmath@xb
  13. \fi
  14. \ifdim\pgfmath@xb=0pt\relax
  15. \pgfmathcontinueloopfalse
  16. \pgfmath@xb=\pgfmath@xa
  17. \fi
  18. \ifdim\pgfmath@xa<0pt\relax
  19. \pgfmath@xa=-\pgfmath@xa
  20. \fi
  21. \ifdim\pgfmath@xb<0pt\relax
  22. \pgfmath@xb=-\pgfmath@xb
  23. \fi
  24. \loop
  25. \ifpgfmathcontinueloop
  26. \ifdim\pgfmath@xa=\pgfmath@xb
  27. \pgfmathcontinueloopfalse
  28. \else
  29. \ifdim\pgfmath@xa>\pgfmath@xb
  30. \advance\pgfmath@xa by-\pgfmath@xb\relax
  31. \else
  32. \advance\pgfmath@xb by-\pgfmath@xa\relax
  33. \fi
  34. \fi
  35. \repeat
  36. \pgfmathparse{int(\pgfmath@xa)}%
  37. \pgfmath@smuggleone\pgfmathresult
  38. \endgroup}
  39. \makeatother
  40.  
  41. \begin{document}
  42. \begin{center}
  43. \begin{tikzpicture}[scale=8]
  44. \draw [-stealth] (-0.1,0) -- (1.1,0);
  45. \draw [-stealth] (0,-0.1) -- (0,0.6);
  46. \foreach \X in {1,...,7}
  47. {\ifnum\X=1
  48. \else
  49. \draw (0.02,1/\X) -- (-0.02,1/\X) node[left,xshift={(-(1+pow(-1,\X)))*3pt}]{$\frac{1}{\X}$};
  50. \fi
  51. }
  52. \foreach \X [evaluate=\X as \Ymax using {int(\X-1)}]in {95,94,...,2}%Το μέγεθος του πρώτου όρου καθορίζει το πλήθος των κουκκίδων, άρα και την απόσταση του «τριγώνου» από τον χ'χ.
  53. {\foreach \Y in {1,...,\Ymax}
  54. {\ifnum\X<6
  55. \draw (\Y/\X,0.02) -- (\Y/\X,-0.02) node[below,fill=white]{$\frac{\Y}{\X}$};
  56. \else
  57. \draw[ultra thin] (\Y/\X,0.01) -- (\Y/\X,-0.01);
  58. \fi
  59. \pgfmathtruncatemacro{\TST}{gcd(\X,\Y)}
  60. \ifnum\TST=1
  61. \fill ({\Y/\X},1/\X) circle(0.05pt); %μέγεθος κουκκίδων
  62. \fi
  63. }
  64. }
  65. \foreach \X in {0,1,...,80}
  66. {\fill (\X/80,0) circle(0.05pt); } %μέγεθος κουκκίδων
  67. \end{tikzpicture}
  68. \end{center}
  69. \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement