Graphing the Thomae Function
up vote
1
down vote
favorite
Could someone please give me guidance on how to plot this special function? I honestly have no idea where even to start (I've never actually done a tikzpicture from scratch).
[
f(x) = left{begin{array}{lr}
0, &x text{irrational}\
frac{1}{q}, &x = frac{p}{q} text{in lowest form}\[10pt]
end{array}right}
]
It should look something like this:

tikz-pgf
New contributor
Miguel Cumming-Romo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
1
down vote
favorite
Could someone please give me guidance on how to plot this special function? I honestly have no idea where even to start (I've never actually done a tikzpicture from scratch).
[
f(x) = left{begin{array}{lr}
0, &x text{irrational}\
frac{1}{q}, &x = frac{p}{q} text{in lowest form}\[10pt]
end{array}right}
]
It should look something like this:

tikz-pgf
New contributor
Miguel Cumming-Romo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Do you want a cartoon as your this screen shot?AFAIK there are infinitely many rational numbers in the interval [0,1] so drawing the dots requires the specification of a cut-off forq, I think.
– marmot
4 hours ago
This is Thomae's function, sometimes called the popcorn function. It is built into thepst-funcpackage, located here on CTAN. See page 66.
– DJP
4 hours ago
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Could someone please give me guidance on how to plot this special function? I honestly have no idea where even to start (I've never actually done a tikzpicture from scratch).
[
f(x) = left{begin{array}{lr}
0, &x text{irrational}\
frac{1}{q}, &x = frac{p}{q} text{in lowest form}\[10pt]
end{array}right}
]
It should look something like this:

tikz-pgf
New contributor
Miguel Cumming-Romo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Could someone please give me guidance on how to plot this special function? I honestly have no idea where even to start (I've never actually done a tikzpicture from scratch).
[
f(x) = left{begin{array}{lr}
0, &x text{irrational}\
frac{1}{q}, &x = frac{p}{q} text{in lowest form}\[10pt]
end{array}right}
]
It should look something like this:

tikz-pgf
tikz-pgf
New contributor
Miguel Cumming-Romo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Miguel Cumming-Romo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 1 hour ago
New contributor
Miguel Cumming-Romo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 4 hours ago
Miguel Cumming-Romo
112
112
New contributor
Miguel Cumming-Romo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Miguel Cumming-Romo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Miguel Cumming-Romo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Do you want a cartoon as your this screen shot?AFAIK there are infinitely many rational numbers in the interval [0,1] so drawing the dots requires the specification of a cut-off forq, I think.
– marmot
4 hours ago
This is Thomae's function, sometimes called the popcorn function. It is built into thepst-funcpackage, located here on CTAN. See page 66.
– DJP
4 hours ago
add a comment |
Do you want a cartoon as your this screen shot?AFAIK there are infinitely many rational numbers in the interval [0,1] so drawing the dots requires the specification of a cut-off forq, I think.
– marmot
4 hours ago
This is Thomae's function, sometimes called the popcorn function. It is built into thepst-funcpackage, located here on CTAN. See page 66.
– DJP
4 hours ago
Do you want a cartoon as your this screen shot?AFAIK there are infinitely many rational numbers in the interval [0,1] so drawing the dots requires the specification of a cut-off for
q, I think.– marmot
4 hours ago
Do you want a cartoon as your this screen shot?AFAIK there are infinitely many rational numbers in the interval [0,1] so drawing the dots requires the specification of a cut-off for
q, I think.– marmot
4 hours ago
This is Thomae's function, sometimes called the popcorn function. It is built into the
pst-func package, located here on CTAN. See page 66.– DJP
4 hours ago
This is Thomae's function, sometimes called the popcorn function. It is built into the
pst-func package, located here on CTAN. See page 66.– DJP
4 hours ago
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
Here's a sagetex solution using the computer algebra system, SAGE, to do the computations.
documentclass[border=3pt]{standalone}
usepackage{sagetex}
usepackage{pgfplots}
pgfplotsset{compat=1.15}
begin{document}
begin{sagesilent}
xvalue =
yvalue =
for q in range(1,101):
for p in range(1,q):
xvalue += [(p*1.0/q*1.).n(digits=2)]
yvalue += [(1/(q/gcd(p,q))).n(digits=2)]
output = r""
output += r"begin{tikzpicture}"
output += r"begin{axis}["
output += r"title={Thomae's function},"
output += r"xlabel=$x$,"
output += r"ylabel=$f(x)$,"
output += r"]"
output += r"addplot[only marks,mark options={mark size=.5pt}] coordinates {"
for i in range(0,len(xvalue)):
output += r"(%s, %s)"%(xvalue[i],yvalue[i])
output += r"};"
output += r"end{axis}"
output += r"end{tikzpicture}"
end{sagesilent}
sagestr{output}
end{document}
The result running in Cocalc is shown below:

By changing the value of q from 101 to something more, you'll get more points. SAGE is not part of the LaTeX distribution, so you would need to install it on your computer or, to avoid that, get a free Cocalc account. The documentation for SAGE is here and the documentation for sagetex is here on CTAN. The SAGE programming involves a mixture of SAGE commands mixed into Python code. If your work involves mathematics, then this is a very convenient package to learn.
add a comment |
up vote
1
down vote
Welcome to TeX.SE! Here is a proposal. Of course, this is just a cartoon because I had to cut off q, as is done in your screen shot.
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[scale=8]
draw [-stealth] (-0.1,0) -- (1.1,0);
draw [-stealth] (0,-0.1) -- (0,1.1);
foreach X in {1,...,7}
{ifnumX=1
draw (0.02,1/X) -- (-0.02,1/X) node[left]{$1$};
else
draw (0.02,1/X) -- (-0.02,1/X) node[left,xshift={(-(1+pow(-1,X)))*3pt}]{$frac{1}{X}$};
fi
}
foreach X [evaluate=X as Ymax using {int(X-1)}]in {5,4,...,2}
{foreach Y in {1,...,Ymax}
{draw (Y/X,0.02) -- (Y/X,-0.02) node[below,fill=white]{$frac{Y}{X}$};
fill ({Y/X},1/X) circle(0.2pt);
}
}
end{tikzpicture}
end{document}

ADDENDUM: Without external programs, compiles in below 1sec on a 4 years old MacBook pro.
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[scale=8]
draw [-stealth] (-0.1,0) -- (1.1,0);
draw [-stealth] (0,-0.1) -- (0,0.6);
foreach X in {1,...,7}
{ifnumX=1
else
draw (0.02,1/X) -- (-0.02,1/X) node[left,xshift={(-(1+pow(-1,X)))*3pt}]{$frac{1}{X}$};
fi
}
foreach X [evaluate=X as Ymax using {int(X-1)}]in {25,24,...,2}
{foreach Y in {1,...,Ymax}
{ifnumX<6
draw (Y/X,0.02) -- (Y/X,-0.02) node[below,fill=white]{$frac{Y}{X}$};
else
draw[ultra thin] (Y/X,0.01) -- (Y/X,-0.01);
fi
fill ({Y/X},1/X) circle(0.2pt);
}
}
foreach X in {0,1,...,80}
{fill (X/80,0) circle(0.2pt); }
end{tikzpicture}
end{document}

Your answer are excellent. Have you take the "virus" of the best users of LaTeX? :-):-). +1
– Sebastiano
4 hours ago
@Sebastiano Such a virus does not exist and I am certainly not the best user of LaTeX.
– marmot
4 hours ago
I hope you understand my line. I was joking; you're a very good, useless person to deny it.
– Sebastiano
4 hours ago
How would you suggest putting in dots on the x-axis? As shown in the screenshot
– Miguel Cumming-Romo
2 hours ago
@MiguelCumming-Romo Just addforeach X in {0,1,...,80} {fill (X/80,0) circle(0.2pt); }(you may replace80by some other number) as I did in my second example. To make the numbers irrational, you could shift the circles by a tiny irrational amount, but in the end none of the computer-generated numbers are irrational).
– marmot
2 hours ago
|
show 2 more comments
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Here's a sagetex solution using the computer algebra system, SAGE, to do the computations.
documentclass[border=3pt]{standalone}
usepackage{sagetex}
usepackage{pgfplots}
pgfplotsset{compat=1.15}
begin{document}
begin{sagesilent}
xvalue =
yvalue =
for q in range(1,101):
for p in range(1,q):
xvalue += [(p*1.0/q*1.).n(digits=2)]
yvalue += [(1/(q/gcd(p,q))).n(digits=2)]
output = r""
output += r"begin{tikzpicture}"
output += r"begin{axis}["
output += r"title={Thomae's function},"
output += r"xlabel=$x$,"
output += r"ylabel=$f(x)$,"
output += r"]"
output += r"addplot[only marks,mark options={mark size=.5pt}] coordinates {"
for i in range(0,len(xvalue)):
output += r"(%s, %s)"%(xvalue[i],yvalue[i])
output += r"};"
output += r"end{axis}"
output += r"end{tikzpicture}"
end{sagesilent}
sagestr{output}
end{document}
The result running in Cocalc is shown below:

By changing the value of q from 101 to something more, you'll get more points. SAGE is not part of the LaTeX distribution, so you would need to install it on your computer or, to avoid that, get a free Cocalc account. The documentation for SAGE is here and the documentation for sagetex is here on CTAN. The SAGE programming involves a mixture of SAGE commands mixed into Python code. If your work involves mathematics, then this is a very convenient package to learn.
add a comment |
up vote
1
down vote
Here's a sagetex solution using the computer algebra system, SAGE, to do the computations.
documentclass[border=3pt]{standalone}
usepackage{sagetex}
usepackage{pgfplots}
pgfplotsset{compat=1.15}
begin{document}
begin{sagesilent}
xvalue =
yvalue =
for q in range(1,101):
for p in range(1,q):
xvalue += [(p*1.0/q*1.).n(digits=2)]
yvalue += [(1/(q/gcd(p,q))).n(digits=2)]
output = r""
output += r"begin{tikzpicture}"
output += r"begin{axis}["
output += r"title={Thomae's function},"
output += r"xlabel=$x$,"
output += r"ylabel=$f(x)$,"
output += r"]"
output += r"addplot[only marks,mark options={mark size=.5pt}] coordinates {"
for i in range(0,len(xvalue)):
output += r"(%s, %s)"%(xvalue[i],yvalue[i])
output += r"};"
output += r"end{axis}"
output += r"end{tikzpicture}"
end{sagesilent}
sagestr{output}
end{document}
The result running in Cocalc is shown below:

By changing the value of q from 101 to something more, you'll get more points. SAGE is not part of the LaTeX distribution, so you would need to install it on your computer or, to avoid that, get a free Cocalc account. The documentation for SAGE is here and the documentation for sagetex is here on CTAN. The SAGE programming involves a mixture of SAGE commands mixed into Python code. If your work involves mathematics, then this is a very convenient package to learn.
add a comment |
up vote
1
down vote
up vote
1
down vote
Here's a sagetex solution using the computer algebra system, SAGE, to do the computations.
documentclass[border=3pt]{standalone}
usepackage{sagetex}
usepackage{pgfplots}
pgfplotsset{compat=1.15}
begin{document}
begin{sagesilent}
xvalue =
yvalue =
for q in range(1,101):
for p in range(1,q):
xvalue += [(p*1.0/q*1.).n(digits=2)]
yvalue += [(1/(q/gcd(p,q))).n(digits=2)]
output = r""
output += r"begin{tikzpicture}"
output += r"begin{axis}["
output += r"title={Thomae's function},"
output += r"xlabel=$x$,"
output += r"ylabel=$f(x)$,"
output += r"]"
output += r"addplot[only marks,mark options={mark size=.5pt}] coordinates {"
for i in range(0,len(xvalue)):
output += r"(%s, %s)"%(xvalue[i],yvalue[i])
output += r"};"
output += r"end{axis}"
output += r"end{tikzpicture}"
end{sagesilent}
sagestr{output}
end{document}
The result running in Cocalc is shown below:

By changing the value of q from 101 to something more, you'll get more points. SAGE is not part of the LaTeX distribution, so you would need to install it on your computer or, to avoid that, get a free Cocalc account. The documentation for SAGE is here and the documentation for sagetex is here on CTAN. The SAGE programming involves a mixture of SAGE commands mixed into Python code. If your work involves mathematics, then this is a very convenient package to learn.
Here's a sagetex solution using the computer algebra system, SAGE, to do the computations.
documentclass[border=3pt]{standalone}
usepackage{sagetex}
usepackage{pgfplots}
pgfplotsset{compat=1.15}
begin{document}
begin{sagesilent}
xvalue =
yvalue =
for q in range(1,101):
for p in range(1,q):
xvalue += [(p*1.0/q*1.).n(digits=2)]
yvalue += [(1/(q/gcd(p,q))).n(digits=2)]
output = r""
output += r"begin{tikzpicture}"
output += r"begin{axis}["
output += r"title={Thomae's function},"
output += r"xlabel=$x$,"
output += r"ylabel=$f(x)$,"
output += r"]"
output += r"addplot[only marks,mark options={mark size=.5pt}] coordinates {"
for i in range(0,len(xvalue)):
output += r"(%s, %s)"%(xvalue[i],yvalue[i])
output += r"};"
output += r"end{axis}"
output += r"end{tikzpicture}"
end{sagesilent}
sagestr{output}
end{document}
The result running in Cocalc is shown below:

By changing the value of q from 101 to something more, you'll get more points. SAGE is not part of the LaTeX distribution, so you would need to install it on your computer or, to avoid that, get a free Cocalc account. The documentation for SAGE is here and the documentation for sagetex is here on CTAN. The SAGE programming involves a mixture of SAGE commands mixed into Python code. If your work involves mathematics, then this is a very convenient package to learn.
answered 2 hours ago
DJP
6,90921629
6,90921629
add a comment |
add a comment |
up vote
1
down vote
Welcome to TeX.SE! Here is a proposal. Of course, this is just a cartoon because I had to cut off q, as is done in your screen shot.
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[scale=8]
draw [-stealth] (-0.1,0) -- (1.1,0);
draw [-stealth] (0,-0.1) -- (0,1.1);
foreach X in {1,...,7}
{ifnumX=1
draw (0.02,1/X) -- (-0.02,1/X) node[left]{$1$};
else
draw (0.02,1/X) -- (-0.02,1/X) node[left,xshift={(-(1+pow(-1,X)))*3pt}]{$frac{1}{X}$};
fi
}
foreach X [evaluate=X as Ymax using {int(X-1)}]in {5,4,...,2}
{foreach Y in {1,...,Ymax}
{draw (Y/X,0.02) -- (Y/X,-0.02) node[below,fill=white]{$frac{Y}{X}$};
fill ({Y/X},1/X) circle(0.2pt);
}
}
end{tikzpicture}
end{document}

ADDENDUM: Without external programs, compiles in below 1sec on a 4 years old MacBook pro.
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[scale=8]
draw [-stealth] (-0.1,0) -- (1.1,0);
draw [-stealth] (0,-0.1) -- (0,0.6);
foreach X in {1,...,7}
{ifnumX=1
else
draw (0.02,1/X) -- (-0.02,1/X) node[left,xshift={(-(1+pow(-1,X)))*3pt}]{$frac{1}{X}$};
fi
}
foreach X [evaluate=X as Ymax using {int(X-1)}]in {25,24,...,2}
{foreach Y in {1,...,Ymax}
{ifnumX<6
draw (Y/X,0.02) -- (Y/X,-0.02) node[below,fill=white]{$frac{Y}{X}$};
else
draw[ultra thin] (Y/X,0.01) -- (Y/X,-0.01);
fi
fill ({Y/X},1/X) circle(0.2pt);
}
}
foreach X in {0,1,...,80}
{fill (X/80,0) circle(0.2pt); }
end{tikzpicture}
end{document}

Your answer are excellent. Have you take the "virus" of the best users of LaTeX? :-):-). +1
– Sebastiano
4 hours ago
@Sebastiano Such a virus does not exist and I am certainly not the best user of LaTeX.
– marmot
4 hours ago
I hope you understand my line. I was joking; you're a very good, useless person to deny it.
– Sebastiano
4 hours ago
How would you suggest putting in dots on the x-axis? As shown in the screenshot
– Miguel Cumming-Romo
2 hours ago
@MiguelCumming-Romo Just addforeach X in {0,1,...,80} {fill (X/80,0) circle(0.2pt); }(you may replace80by some other number) as I did in my second example. To make the numbers irrational, you could shift the circles by a tiny irrational amount, but in the end none of the computer-generated numbers are irrational).
– marmot
2 hours ago
|
show 2 more comments
up vote
1
down vote
Welcome to TeX.SE! Here is a proposal. Of course, this is just a cartoon because I had to cut off q, as is done in your screen shot.
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[scale=8]
draw [-stealth] (-0.1,0) -- (1.1,0);
draw [-stealth] (0,-0.1) -- (0,1.1);
foreach X in {1,...,7}
{ifnumX=1
draw (0.02,1/X) -- (-0.02,1/X) node[left]{$1$};
else
draw (0.02,1/X) -- (-0.02,1/X) node[left,xshift={(-(1+pow(-1,X)))*3pt}]{$frac{1}{X}$};
fi
}
foreach X [evaluate=X as Ymax using {int(X-1)}]in {5,4,...,2}
{foreach Y in {1,...,Ymax}
{draw (Y/X,0.02) -- (Y/X,-0.02) node[below,fill=white]{$frac{Y}{X}$};
fill ({Y/X},1/X) circle(0.2pt);
}
}
end{tikzpicture}
end{document}

ADDENDUM: Without external programs, compiles in below 1sec on a 4 years old MacBook pro.
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[scale=8]
draw [-stealth] (-0.1,0) -- (1.1,0);
draw [-stealth] (0,-0.1) -- (0,0.6);
foreach X in {1,...,7}
{ifnumX=1
else
draw (0.02,1/X) -- (-0.02,1/X) node[left,xshift={(-(1+pow(-1,X)))*3pt}]{$frac{1}{X}$};
fi
}
foreach X [evaluate=X as Ymax using {int(X-1)}]in {25,24,...,2}
{foreach Y in {1,...,Ymax}
{ifnumX<6
draw (Y/X,0.02) -- (Y/X,-0.02) node[below,fill=white]{$frac{Y}{X}$};
else
draw[ultra thin] (Y/X,0.01) -- (Y/X,-0.01);
fi
fill ({Y/X},1/X) circle(0.2pt);
}
}
foreach X in {0,1,...,80}
{fill (X/80,0) circle(0.2pt); }
end{tikzpicture}
end{document}

Your answer are excellent. Have you take the "virus" of the best users of LaTeX? :-):-). +1
– Sebastiano
4 hours ago
@Sebastiano Such a virus does not exist and I am certainly not the best user of LaTeX.
– marmot
4 hours ago
I hope you understand my line. I was joking; you're a very good, useless person to deny it.
– Sebastiano
4 hours ago
How would you suggest putting in dots on the x-axis? As shown in the screenshot
– Miguel Cumming-Romo
2 hours ago
@MiguelCumming-Romo Just addforeach X in {0,1,...,80} {fill (X/80,0) circle(0.2pt); }(you may replace80by some other number) as I did in my second example. To make the numbers irrational, you could shift the circles by a tiny irrational amount, but in the end none of the computer-generated numbers are irrational).
– marmot
2 hours ago
|
show 2 more comments
up vote
1
down vote
up vote
1
down vote
Welcome to TeX.SE! Here is a proposal. Of course, this is just a cartoon because I had to cut off q, as is done in your screen shot.
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[scale=8]
draw [-stealth] (-0.1,0) -- (1.1,0);
draw [-stealth] (0,-0.1) -- (0,1.1);
foreach X in {1,...,7}
{ifnumX=1
draw (0.02,1/X) -- (-0.02,1/X) node[left]{$1$};
else
draw (0.02,1/X) -- (-0.02,1/X) node[left,xshift={(-(1+pow(-1,X)))*3pt}]{$frac{1}{X}$};
fi
}
foreach X [evaluate=X as Ymax using {int(X-1)}]in {5,4,...,2}
{foreach Y in {1,...,Ymax}
{draw (Y/X,0.02) -- (Y/X,-0.02) node[below,fill=white]{$frac{Y}{X}$};
fill ({Y/X},1/X) circle(0.2pt);
}
}
end{tikzpicture}
end{document}

ADDENDUM: Without external programs, compiles in below 1sec on a 4 years old MacBook pro.
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[scale=8]
draw [-stealth] (-0.1,0) -- (1.1,0);
draw [-stealth] (0,-0.1) -- (0,0.6);
foreach X in {1,...,7}
{ifnumX=1
else
draw (0.02,1/X) -- (-0.02,1/X) node[left,xshift={(-(1+pow(-1,X)))*3pt}]{$frac{1}{X}$};
fi
}
foreach X [evaluate=X as Ymax using {int(X-1)}]in {25,24,...,2}
{foreach Y in {1,...,Ymax}
{ifnumX<6
draw (Y/X,0.02) -- (Y/X,-0.02) node[below,fill=white]{$frac{Y}{X}$};
else
draw[ultra thin] (Y/X,0.01) -- (Y/X,-0.01);
fi
fill ({Y/X},1/X) circle(0.2pt);
}
}
foreach X in {0,1,...,80}
{fill (X/80,0) circle(0.2pt); }
end{tikzpicture}
end{document}

Welcome to TeX.SE! Here is a proposal. Of course, this is just a cartoon because I had to cut off q, as is done in your screen shot.
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[scale=8]
draw [-stealth] (-0.1,0) -- (1.1,0);
draw [-stealth] (0,-0.1) -- (0,1.1);
foreach X in {1,...,7}
{ifnumX=1
draw (0.02,1/X) -- (-0.02,1/X) node[left]{$1$};
else
draw (0.02,1/X) -- (-0.02,1/X) node[left,xshift={(-(1+pow(-1,X)))*3pt}]{$frac{1}{X}$};
fi
}
foreach X [evaluate=X as Ymax using {int(X-1)}]in {5,4,...,2}
{foreach Y in {1,...,Ymax}
{draw (Y/X,0.02) -- (Y/X,-0.02) node[below,fill=white]{$frac{Y}{X}$};
fill ({Y/X},1/X) circle(0.2pt);
}
}
end{tikzpicture}
end{document}

ADDENDUM: Without external programs, compiles in below 1sec on a 4 years old MacBook pro.
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[scale=8]
draw [-stealth] (-0.1,0) -- (1.1,0);
draw [-stealth] (0,-0.1) -- (0,0.6);
foreach X in {1,...,7}
{ifnumX=1
else
draw (0.02,1/X) -- (-0.02,1/X) node[left,xshift={(-(1+pow(-1,X)))*3pt}]{$frac{1}{X}$};
fi
}
foreach X [evaluate=X as Ymax using {int(X-1)}]in {25,24,...,2}
{foreach Y in {1,...,Ymax}
{ifnumX<6
draw (Y/X,0.02) -- (Y/X,-0.02) node[below,fill=white]{$frac{Y}{X}$};
else
draw[ultra thin] (Y/X,0.01) -- (Y/X,-0.01);
fi
fill ({Y/X},1/X) circle(0.2pt);
}
}
foreach X in {0,1,...,80}
{fill (X/80,0) circle(0.2pt); }
end{tikzpicture}
end{document}

edited 2 hours ago
answered 4 hours ago
marmot
77.7k487166
77.7k487166
Your answer are excellent. Have you take the "virus" of the best users of LaTeX? :-):-). +1
– Sebastiano
4 hours ago
@Sebastiano Such a virus does not exist and I am certainly not the best user of LaTeX.
– marmot
4 hours ago
I hope you understand my line. I was joking; you're a very good, useless person to deny it.
– Sebastiano
4 hours ago
How would you suggest putting in dots on the x-axis? As shown in the screenshot
– Miguel Cumming-Romo
2 hours ago
@MiguelCumming-Romo Just addforeach X in {0,1,...,80} {fill (X/80,0) circle(0.2pt); }(you may replace80by some other number) as I did in my second example. To make the numbers irrational, you could shift the circles by a tiny irrational amount, but in the end none of the computer-generated numbers are irrational).
– marmot
2 hours ago
|
show 2 more comments
Your answer are excellent. Have you take the "virus" of the best users of LaTeX? :-):-). +1
– Sebastiano
4 hours ago
@Sebastiano Such a virus does not exist and I am certainly not the best user of LaTeX.
– marmot
4 hours ago
I hope you understand my line. I was joking; you're a very good, useless person to deny it.
– Sebastiano
4 hours ago
How would you suggest putting in dots on the x-axis? As shown in the screenshot
– Miguel Cumming-Romo
2 hours ago
@MiguelCumming-Romo Just addforeach X in {0,1,...,80} {fill (X/80,0) circle(0.2pt); }(you may replace80by some other number) as I did in my second example. To make the numbers irrational, you could shift the circles by a tiny irrational amount, but in the end none of the computer-generated numbers are irrational).
– marmot
2 hours ago
Your answer are excellent. Have you take the "virus" of the best users of LaTeX? :-):-). +1
– Sebastiano
4 hours ago
Your answer are excellent. Have you take the "virus" of the best users of LaTeX? :-):-). +1
– Sebastiano
4 hours ago
@Sebastiano Such a virus does not exist and I am certainly not the best user of LaTeX.
– marmot
4 hours ago
@Sebastiano Such a virus does not exist and I am certainly not the best user of LaTeX.
– marmot
4 hours ago
I hope you understand my line. I was joking; you're a very good, useless person to deny it.
– Sebastiano
4 hours ago
I hope you understand my line. I was joking; you're a very good, useless person to deny it.
– Sebastiano
4 hours ago
How would you suggest putting in dots on the x-axis? As shown in the screenshot
– Miguel Cumming-Romo
2 hours ago
How would you suggest putting in dots on the x-axis? As shown in the screenshot
– Miguel Cumming-Romo
2 hours ago
@MiguelCumming-Romo Just add
foreach X in {0,1,...,80} {fill (X/80,0) circle(0.2pt); } (you may replace 80 by some other number) as I did in my second example. To make the numbers irrational, you could shift the circles by a tiny irrational amount, but in the end none of the computer-generated numbers are irrational).– marmot
2 hours ago
@MiguelCumming-Romo Just add
foreach X in {0,1,...,80} {fill (X/80,0) circle(0.2pt); } (you may replace 80 by some other number) as I did in my second example. To make the numbers irrational, you could shift the circles by a tiny irrational amount, but in the end none of the computer-generated numbers are irrational).– marmot
2 hours ago
|
show 2 more comments
Miguel Cumming-Romo is a new contributor. Be nice, and check out our Code of Conduct.
Miguel Cumming-Romo is a new contributor. Be nice, and check out our Code of Conduct.
Miguel Cumming-Romo is a new contributor. Be nice, and check out our Code of Conduct.
Miguel Cumming-Romo is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461603%2fgraphing-the-thomae-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you want a cartoon as your this screen shot?AFAIK there are infinitely many rational numbers in the interval [0,1] so drawing the dots requires the specification of a cut-off for
q, I think.– marmot
4 hours ago
This is Thomae's function, sometimes called the popcorn function. It is built into the
pst-funcpackage, located here on CTAN. See page 66.– DJP
4 hours ago