When writing in math, do you use a comma or colon preceding an equation? This is a general question about mathematical writing especially for writing research papers and the like.

Question: Do you precede an equation with a comma or colon?

Example A:


*

*The following equation is the Yosida-Hawking-Penrose-Dantzig function
\begin{equation}
f(x) = \frac{1}{2} D_\alpha(x,y)
\end{equation} 

*The following equation is the Yosida-Hawking-Penrose-Dantzig function,
\begin{equation}
f(x) = \frac{1}{2} D_\alpha(x,y)
\end{equation} 

*The following equation is the Yosida-Hawking-Penrose-Dantzig function:
\begin{equation}
f(x) = \frac{1}{2} D_\alpha(x,y)
\end{equation} 


Example B:


*

*In fact, we can express the earlier function using a much simpler expression
\begin{equation}
f(x) = \varphi(x,y) 
\end{equation} 
where $\varphi(x,y)$ is the Demiane functional

*In fact, we can express the earlier function using a much simpler expression,
\begin{equation}
f(x) = \varphi(x,y) 
\end{equation} 
where $\varphi(x,y)$ is the Demiane functional

*In fact, we can express the earlier function using a much simpler expression:
\begin{equation}
f(x) = \varphi(x,y) 
\end{equation} 
where $\varphi(x,y)$ is the Demiane functional


Can anyone comment on which one is the best practice?
 A: No punctuation should be used between the word "function" and an immediately following expression that defines it, unless "the function" has already been defined and its expression in the text is just a convenient reminder of its definition. Exactly the same applies in ordinary Language. Compare, for example the following two sentences:
My sister Laura lives in London.
My sister, Laura, lives in London.
The second sentence implies that "my sister" has already been defined, perhaps as the only sister or the sister who was previously discussed. In contrast, the first sentence makes no such implication: Laura, as far as we can tell from the sentence, might be any one of many sisters; but the sentence does specify which sister is being considered.
In general, the punctuation of mathematical writing should follow that of the corresponding natural language. In particular, a mathematical expression that ends a sentence should be followed by a full stop.
A: For papers, it always depends on what is specified in the style guide for the publication or journal. Having said that, however, the guide is often not so specific as to whether the sentence with the equation should be punctuated with commas, colons or little flags.
For example, from the Monthly Notices of the Royal Astronomical Society

Mathematics
...
Equations should be punctuated as part of the sentence. Displayed equations are ranged left (i.e. no indent). Numbering of equations should follow the convention (1), (2)… throughout the whole paper, or (2.1), (2.2)… by section. Equations in appendices should be numbered (A1), (A2), (B1), etc.

This is indented, but still accepted:
image from paper at https://arxiv.org/pdf/1401.2593.pdf 
edit: added picture 

Much seems to depend how particular/pedantic a reviewer is in relation to the style guide (which they may not know in such detail for specifics like this), and grammar conventions are not universal. 
Check the style guide, read some of the published papers from the journal in question, and be consistent in application of grammar rules when inserting equations.
A: This is what I remember from my technical writing class of twenty years ago.
The most important thing is that a colon must only be used at the end of a complete sentence.
For example
A line can be excpressed as: $$y=mx + b.$$
is incorrect, and
A line can be expressed as $$y=mx + b$$
and
The following equation is the slope-intercept equation of a line: $$y = mx + b$$
are correct
A: Equations should be included as part of the sentence, as in the following.

Consider the Yosida-Hawking-Penrose-Dantzig function
  $$
f(x) = \frac{1}{2}D_\alpha(x,y).
$$
It can also be expressed as
  $$f(x)=\phi(x,y),$$
  where $\phi(x,y)$ is the Demiane functional.

In example B, if you don't want to change the sentence:

In fact, we can express the earlier function using the much simpler expression
  $$f(x)=\phi(x,y),$$
  where $\phi(x,y)$ is the Demiane functional.

I use this style example. Milnor's book, referenced in the comments below, follows the same rules, as do all the references and publications in my bookshelf (Polya's Problems and Theorems in Analysis, Rudin's Real and Complex analysis, etc.)
Standard guides


*

*Knuth's Mathematical Writing.

*How to Write Mathematics, by P. Halmos. 
A: Generally, I would treat the equation as if it were any ordinary noun phrase, and use the usual rules for comma, colon, or no punctuation.
A colon is used if the equation is an elaboration, or an item.  So, just as you might write

Lips are characterized by the following properties: fleshy, paired, red.

you would write

An ellipse is characterized by the following equation:
$$ \frac{x^2}{a^2}+\frac{y^2}{b^2} = 1 $$

A comma precedes a non-restrictive clause (one that describes rather than identifies the noun phrase), so by analogy with

The line can be assigned to a simpler character, Polonius.

we might write

A line can be described with a simpler equation,
$$ y = mx+b $$

In comparison, with a restrictive clause, we use no comma, so just as we would write

From this, the oiler obtained the formula CH$_3$C$_6$H$_4$C$_2$H$_5$.

we would also write

From this, Euler obtained the formula
$$ e^{i\pi}+1 = 0 $$

I suspect there aren't any hard and fast rules for this, however.  Whatever you choose to do, be consistent and reasonable.

ETA (2017-09-10): You'll notice that I have no periods at the ends of these equations.  The papers I have generally (though not universally) observe this pattern.  However, in other fields, equations may have ending punctuation depending on how they occur within a sentence.  It may be useful for a writer to consult the publication's style guide, if applicable, or at least examine previous articles within the same publication or outlet.

ETA (2022-05-01): Somewhat coincidentally, on the same day (today), I both (a) received a straggling upvote on this rather middle-aged answer, and (b) found the following in the foreword to the third edition of Ian Stewart's classic book, Galois Theory (2004):

[after discussing the need for punctuation for formulas in the main body of the text] But I have come to the conclusion that eliminating visual junk from the printed page is more important than punctuatory pedantry, so that when the same formula is displayed, for example
$$ t^2+1 $$
then it looks silly if the comma is included, like this,
$$ t^2+1, $$
and everything is much cleaner and less ambiguous without punctuation.
Purists will hate this, though many of them would not have noticed had I not pointed it out here. Until recently, I would have agreed. But I think it is time we accepted that the act of displaying a formula equips it with implicit (invisible) punctuation. This is the $21$st century, and typography has moved on.

A: I was told to use correct punctuation as defined by grammatical rules, but to always place the equation or formula on a line of its own, even if this meant starting a line with a punctuation mark. Even though the layout may look a little odd there can be no confusion as to the meaning. While it would be very rare for a comma to be misconstrued imagine the confusion an exclamation mark would cause.
