How would you describe math in comments?

I just use multiple lines to do it thus:

// Work out average as:  sum (values)
//                      --------------
//                      count (values)
//
// and distance between points as:
//           _______________________
//          /         2            2
//    d = \/ (x1 - x0)  + (y1 - y0)
//
// and the following function:
//
//             3     2   
//    f(x) = ax  + bx  + cx + d

No magic required for that at all. Don't you just love ASCII art?


Following up on @pax's answer to use ascii-art/plain text to render your equations (+1 by the way, pax):

Here's a quick list of shortcut keys for math-related characters:

° (degree) - Alt+0176

± (plus/minus) - Alt+0177

² (squared) - Alt+0178

³ (cubed) - Alt+0179

¼ (1/4) - Alt+0188

½ (1/2) - Alt+0189

¾ (3/4) - Alt+0190


I use latex: if it's simple you can see it anyway, and if it's complicated - cut and paste it in the nearest wordpress window, most times they parse correctly.