Mathematical diagrams

There’s no excuse for any authors to be satisfied with less than perfection in their diagrams – for simple diagrams at least. Software, both commercial and open-source, can now produce diagrams of extraordinarily high quality. But I keep coming across published books where the excellence of the exposition is let down by the poor quality of the diagrams. In one book (which I will not name), a graph claiming to be a sine curve seemed to be made up of half ellipses. As a pretty figure it was quite attractive, but as a “sine curve” it was atrocious. Since when did a sine curve allow a vertical tangent?

Lately I’ve been reading some books and articles about elliptic curves and their application to public-key cryptography. And again, some books, excellent in every other way, get sloppy with their diagrams. I have one book where the numbers and labels on the figures are in such a big ugly font as to ruin the graphs, and in another book one of the figures, purporting to be of an elliptic curve y^2=x^3+ax+b, is not even symmetrical about the x-axis.

One of the best graph drawing software (for 2-dimensional graphs, although there are extensions to 3-dimensions) is the PStricks package of LaTeX. This allows for plotting, of the placement of all sorts of curves, lines, arrows, and text on a figure, all nicely integrated into the LaTeX environment. Now, elliptic curves, being defined implicitly, are not particularly well suited to being plotted as graphs of the form y=f(x). But implicit plotting, as provided by every mathematical software I know, is clumsy and memory intensive. Generally implicit plotting of, say, f(x,y)=0 works by creating the three dimensional structure z=f(x,y), and then plotting the plane z=0.

However, an elliptic curve can be easily plotted by considering the intervals for which x^3+ax+b is positive, and graphing y=sqrt{x^3+ax+b} and y=-sqrt{x^3+ax+b}. Using PStricks, I produced the following diagram illustrating addition on an elliptic curve:

Addition law on an elliptic curve

This diagram was created with the following LaTeX code:

     {x dup mul 2 sub x mul sqrt}
     {x dup mul 2 sub x mul sqrt}
     {x dup mul 2 sub x mul sqrt neg}
     {x dup mul 2 sub x mul sqrt neg}
  rput(-1,-1.2){large P}
  rput(.2,-.2){large Q}
  rput[l](2.2,-2){large R=P+Q}

I cheated slightly here: the elliptic curve used was y^2=x^3-2x which has the nice property that on the curve (-1,-1)+(0,0)=(2,-2); that is, all the coordinates are integers. The plot shown simply shifts the x-axis a bit. The problem is learning PStricks, and for plotting, as you see, learning some PostScript, which uses a stack system. Thus

x dup mul 2 sub x mul sqrt

has the following meaning:

  1. Take a value x.
  2. Duplicate it
  3. Multiply the last two values
  4. Subtract 2 from the result
  5. Multiply by x
  6. Take the square root

At the cost of a little work, superb diagrams can be produced.

Read about PostScript mathematics at and about pstricks at

2 thoughts on “Mathematical diagrams

Leave a Reply

Your email address will not be published. Required fields are marked *