[pstricks] Thomae's Function

Herbert Voss Herbert.Voss at FU-Berlin.DE
Sun Jun 8 20:41:56 CEST 2008


Jean-Côme Charpentier schrieb:
> 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 :-)

ok ok, you'd won ... :-)

\documentclass{article}
\usepackage{pstricks-add}
\usepackage{multido}

\makeatletter
\def\psThomae{\pst at object{psThomae}}
\def\psThomae at i(#1,#2){%
   \begin at ClosedObj
   \addto at pscode{
     \psk at dotsize
     1 1 500 {
       dup
       /ipSave ED
       /ip ED
       1 1 500 {
         dup
         /iqSave ED
         /iq ED
         {
           iq 0 le { exit } if
           ip iq mod
           /ip iq def
           /iq ED
         } loop
         ip 1 eq {
           \psk at dotsize
           \@nameuse{psds@\psk at dotstyle}
           \pst at usecolor\pslinecolor ipSave iqSave div 1 iqSave div 
\tx at ScreenCoor
           2 copy moveto Dot
         } if
       } for
     } for
   }%
   \end at ClosedObj%
}

\makeatother

\begin{document}
\begin{center}
   \psset{unit=4cm,dotsize=1pt 0}
   \begin{pspicture}(2.5,1.5)
     \psaxes{->}(0,0)(2.5,1.5)
     \psThomae(0,2)
   \end{pspicture}
\end{center}

\end{document}

Herbert



More information about the PSTricks mailing list