[pstricks] Thomae's Function

Jean-Côme Charpentier jean-come.charpentier at wanadoo.fr
Sun Jun 8 11:19:34 CEST 2008

Herbert Voss a écrit :
> sebastian perez schrieb:
>> I'd like to know if it is possible to use pstricks to make the graph of Thomae's function
>> http://en.wikipedia.org/wiki/Thomae's_function
> not yet possible

... with a direct way. Otherwise, we can cheat :-)


  \def\reserved at a{#1}%
  \def\reserved at b{#2}%
  \loop\ifnum\reserved at b>0
    \pst at mod\reserved at a\reserved at b\reserved at c
    \let\reserved at a\reserved at b
    \let\reserved at b\reserved at c
  \ifnum\reserved at a=1
    \def\reserved at c{#3}%
    \def\reserved at c{#4}%
  \reserved at c\ignorespaces

  \psset{unit=4cm,dotsize=1pt 0}
        \unless\ifnum\ip>\numexpr2*\iq % for x \in [0,2]
            \psdots(!\ip\space \iq\space div 1 \iq\space div)

Attention! The two loops can't be extended. For instance, with


I obtain a beautiful

Runaway text?
" tx at Dict begin STP newpath 0.8 SLW 0  setgray  [ 41 147 div 1 147 di\ETC.
! TeX capacity exceeded, sorry [main memory size=1500000].
\pst at code ...r .5 add exch itransform Dot } repeat

l.36     }
No pages of output.

I suppose (I'm not sure) that it's working with recursive macro rather
multido but I'm too lasy to test it :-)

  Jean-Côme Charpentier

More information about the PSTricks mailing list