November 27, 2011

Harking Back

After my recent spate of “you can do mathematics in your blog” posts (I am no mathematician, but I do know computers) I remembered that some time ago I did a post about Euler's identity, and at the time the best I could do was a graphic with the equation in it. I reproduce the graphic in large format below, to demonstrate how clearly unsatisfactory the graphic truly was at higher resolution (you may notice that at this size the pixellation of the font has become clearly visible, though some browsers make valiant efforts to disguise it):

Of course I could have taken more care, and produced a higher-resolution graphic, but the fact remains that ultimately this representation cannot be copied and pasted as part of another expression, because the bitmap representation is completely unrelated to the structure of the equation. And eventually, no matter how high the resolution at which you generate, someone will come up with an application that demands more resolution. More of everything cheaper is kind of a clarion call in the computing world, and by and large the engineers have done their best to deliver.

Now, though, with the magic of TeX at my blogging fingertips, I can display the same equation (or at least the same identity: most people seem to prefer the zero identity as the canonical form, but I am persisting in my original bloody-minded mistake for backwards compatibility reasons) with ease using the TeX formula

\(e^{\pi i} = -1\)

which renders (using standard font sizes) as:
e^{\pi i} = -1
Thanks to MathJax, when I blow the TeX formula up it renders without the unpleasant pixellation effects of my previous attempt:
e^{\pi i} = -1

To me this is clearly an improvement over my original method (though I must confess that I cannot remember at this distance how I produced the graphic for the original blog entry).

Access to TeX Source

If you hover the cursor over the MathJax equation you will get a context menu from it (Windows and Ubuntu users use your right mouse button, recent Mac users use a two-finger click) and ask to see the equation source code using the Show Source option:
The first time I used this feature it was in TeX mode, and what I saw was the TeX code I used to create the expression.  On my Mac that window looked like this:
So now your mathematics can be copied by others, for example to paste into their own blogs or other papers. People can now copy and paste mathematics freely. I think that's exciting news! Of course you can also repay the favor by copying TeX source from other blogs (as well as the many excellent TeX web papers and articles) into your own blogs.

MathML Too

If, like me, you are an inveterate tinkerer then you might wonder whether it's worth learning MathML. If you already know TeX then it would appear that the answer is “no,” because MathJax can translate between TeX and MathML format for you. If you want to see the mathML equivalent you first have to change MathJax's display format. This is again just a matter of using the MathJax context menu:

If you repeat your request to see the equation source you will now see the MathML equivalent to the TeX source I wrote in the first place. This neatly gives you the answer to your question “is mathML representation much more long-winded than TeX markup,” to which the answer is “yes, and then some” but you don't need to worry about that. Just be happy that MathJax can take care of them both:

I know it is equally possible to author for MathJax in MathML, so I would assume (but have not verified) that translation to TeX would similarly be possible. You'll have to switch back to TeX mode to start seeing TeX sources again, by the way.


Someone wanted to know if superscripts can have superscripts. The answer, naturally, is yes. You can use the context menu to examine the source.

\(e^{{\pi i}^{\pi i}}\)

How did that work for you? Welcome to the world of copy and paste mathematics!

No comments: