diff options
Diffstat (limited to 'graphics/epix/samples/denom.xp')
-rw-r--r-- | graphics/epix/samples/denom.xp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/graphics/epix/samples/denom.xp b/graphics/epix/samples/denom.xp new file mode 100644 index 0000000000..015f29bb4a --- /dev/null +++ b/graphics/epix/samples/denom.xp @@ -0,0 +1,39 @@ +/* -*-ePiX-*- */ +#include "epix.h" +using namespace ePiX; + +int N(30); // maximum denominator plotted + +int main() +{ + picture(P(-2,0), P(2,1), "4x1in"); + + begin(); + tikz_format(); + + axis Ax(P(-2,0), P(2,0), 8, P(0,-6), b); + Ax.subdivide(6).frac().draw(); + + v_axis(2); + + dot_size(2); + for (int i=1; i< N; ++i) + for (int j=i*xmin(); j <= i*xmax(); ++j) + if (gcd(i, j) == 1) + ddot(P(j*1.0/i, 1.0/i)); + + font_size("scriptsize"); + + // The long label text can be written in one string, but using a + // stringstream allows the input to be formatted more readably. + std::stringstream buf; + buf << "$f(x)=\\begin{cases}%" << std::endl + << " \\frac{1}{q} & " + << "\\text{ $x=\\frac{p}{q}$ in lowest terms} \\\\" << std::endl + << " 0 & \\text{ $x$ irrational}%" << std::endl + << "\\end{cases}$"; + + label(P(0,0.75), P(2,0), buf.str(), r); + end(); +} + |