For scientific programmers, it has long been a goal to have mathematical equations in their programs displayed as they would normally write them, with superscripts and subscripts in the right places, and that sort of thing.

One early attempt was the HAL/S language, developed in the 1970s for the NASA Space Shuttle program.

An equation like this:

X = A ** 2 + B$(I) ** 2

would be displayed like this:

E       2     2
M  X = A  + B
S            I

The letters E, and S at the left margin indicated exponent and subscript lines. The line marked M was the main line. (I'm not sure if M stood for main or not.) C was used for comment lines.

That was a start, but the fixed line spacing available in 1970s line printers violated the norms of mathematical printing and make the resulting equations difficult to read accurately. But today, half a century later, we have the technology to do a much better job of this. (By the way, if I am understanding what I have been reading about HAL/S correctly, it was also possible to enter the lines that way, putting E, M, S or C in column one. Since punch cards were still the prevalent form of input at that time, that seems a bit brutal. since any change to a line might require re-punching three cards.)

This could be done much more smoothly today. Once the language parser has figured out the line, it could generate MathML to display it properly. For example, the above line, would generate the following MathML:

<m:math display='block'>
 <m:mrow>
  <m:mi>X</m:mi><m:mo>=</m:mo><m:msup>
   <m:mi>A</m:mi>
   <m:mn>2</m:mn>
  </m:msup>
  <m:mo>+</m:mo><m:msubsup>
   <m:mi>B</m:mi>
   <m:mi>I</m:mi>
   <m:mn>2</m:mn>
  </m:msubsup>
  </m:mrow>
</m:math>

and would display like this:

upper-case equation: X equals A squared plus B sub I squared

Actually, since lower-case letters, which were not available in the keypunch days are possible, it would probably be re-coded like this,

lower-case equation: x equals a squared plus b sub i squared

which would be more in keeping with norms of mathematical notation.

The generated MathML can be easily displayed using the MathJax browser plugin.

 

Even if we have to wait for someone to augment a compiler to produce MathML-enhanced output, we can still get nice looking equations in the Doxygen pages that describe our programs. By specifying USE_MATHJAX in the Doxygen configuration, you can include equations in LaTex form in your Doxygen prologue comments by surrounding them with \f tags. This is the preferred method for people who work with LaTex a lot and are comfortable with its syntax. If you prefer to insert your equations as MathMl, you can surround them with \htmlonly and \endhtmlonly tags. It will be included verbatim in the HTML output, to be interpreted by MathJax.

Either way, you do not have to know LaTex or MathML syntax. You can use a tool like MathType, by Wirris, to build your equations, and them paste the resulting LaTex or MathML into your prologue.