\numberwithin makes the first equation unnumbered

I might be doing something stupid, but the following code produces a document with the first equation unnumbered (only an empty set of parentheses is given). The second equation is correctly numbered as 1.1.2. If I remove the change to \theequation, then everything is counted normally.

\documentclass[draft,fleqn,openany]{book}
\usepackage[tbtags]{amsmath}
\usepackage{amssymb}
\usepackage[no-math]{fontspec}
\usepackage{xkeyval}
\usepackage{polyglossia}
\setmainfont[BoldFont={* Bold},ItalicFont={* Italic},BoldItalicFont={* Bold Italic},SlantedFont={Linux Libertine Slanted O}]{Linux Libertine O}
\usepackage[letterpaper]{geometry}
\renewcommand{\theequation}{\numberwithin{equation}{section}}
\allowdisplaybreaks[1]
\setdefaultlanguage[variant=british]{english}
\begin{document}
\frontmatter
\title{A test document}
\author{AstroPig7}
\date{}
\maketitle
\tableofcontents
\mainmatter
\chapter{One}
Test document.
\section{Two}
Test document.
$$\text{Test.}$$
\subsection{Three}
$$\text{Test.}$$
\end{document}


I’ve also tried removing various non-essential declarations from the preamble with no success.

-
Thank you for pointing out my moment of illiteracy. That did it. :) –  AstroPig7 Dec 7 '12 at 20:45

amsmath's \numberwithin{<slave>}{<master>} does a couple of things. It:

1. checks whether the counters <slave> and <master> exist. If they do, then it
2. redefines the presentation of the <slave> counter to include the master using the format <master>.<slave>; and
3. adds <slave> to the reset list of <master>. That is, <slave> will reset to 0 whenever <master> is incremented.

Here it is, in super high definition, from amsmath.sty:

\newcommand{\numberwithin}[3][\arabic]{%
\@ifundefined{c@#2}{\@nocounterr{#2}}{%
\@ifundefined{c@#3}{\@nocnterr{#3}}{%

\numberwithin{equation}{section}