[pstricks] graph like-Thomae function
Michael Sharpe
msharpe at ucsd.edu
Sun Sep 25 22:39:04 CEST 2011
On Sep 24, 2011, at 2:27 PM, Hamed Al-Sulami wrote:
> Hi all,
>
> I try to imetate the code for Thomae function to graph like Thomae function F(p/q)=sin(1/sqrt(q)).
> What I got does not look right and I'm not sure what did I do wrong.
>
> Here is my try
>
> \documentclass{article}
> \usepackage{pstricks-add}
> \usepackage{multido}
> \makeatletter
> \def\psThomae{\pst at object{psThomae}}
> \def\psThomae at i(#1,#2)#3{%
> \addbefore at par{dotsize=1pt}
> \begin at ClosedObj
> \addto at pscode{
> 1 1 #3 {
> dup
> /ipSave ED % save loop value
> /ip ED % dito
> 1 1 #3 {
> dup
> /iqSave ED % sabve loop value
> /iq ED % dito
> {
> iq 0 le { exit } if
> ip iq mod
> /ip iq def
> /iq ED
> } loop
> ip 1 eq {
> /xVal ipSave iqSave div def
> xVal #1 ge { xVal #2 le {
> \psk at dotsize
> \@nameuse{psds@\psk at dotstyle}
> \pst at usecolor\pslinecolor xVal 1 iqSave sqrt div RadtoDeg sin \tx at ScreenCoor
> 2 copy moveto Dot } if } if
> } 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){300}
> \end{pspicture}
> \end{center}
> \end{document}
>
>
> Thanks a lot
>
I don't see any problem with this. With your variant, the smallest non-zero value the function can take is close to 1/\sqrt{300} \approx 0.06, and the graph bears this out.
Michael
More information about the PSTricks
mailing list