Stochastic Integration: Riemann Sums I am reading this book:
Introduction to Stochastic Differential Equations
On page 63, in the lemma in the middle of the page the author has the following

$\displaystyle \sum_{k=0}^{m_n - 1}W(\tau_k^n)(W(t_{k+1}^n) - W(t_k^n)) = \frac{W^2(T)}{2} - \frac{1}{2}\sum_{k=0}^{m_n - 1}(W(t_{k+1}^n) - W(t_k^n))^2 + \sum_{k=0}^{m_n - 1}(W(\tau_{k}^n) - W(t_k^n))^2 + \sum_{k=0}^{m_n - 1}(W(t_{k+1}^n) - W(\tau_k^n))(W(\tau_{k}^n) - W(t_k^n))$

$\tau_k$ is a midpoint in $[t_k, t_{k+1}]$
WLOG we can assume $W(t_0) = 0$ as it is a standard Brownian motion. Let $m_n = 2$ then we get the following:
NOTE: I will omit the exponent $n$ and $W(t_2) = W(T)$ as this is on $[0,T]$
The LHS becomes :
$W(\tau_0)(W(t_1) - 0) + W(\tau_1)(W(T) - W(t_1))$
The RHS side is then:
$\frac{1}{2}W^2(T) - \frac{1}{2}[W^2(t_1) + W^2(T) - 2W(T)W(t_1) + W^2(t_1)] + [W^2(\tau_0) + W^2(\tau_1) - 2W(\tau_1)W(t_1) + W^2(t_1)] + ...$
$= W(\tau_0)(W(t_1) - 0) + W(\tau_1)(W(T) - W(t_1)) + \bigg ((W^2(t_1) - \frac{1}{2}W^2(t_1) \bigg )$
So they are almost similar except the term $\bigg ((W^2(t_1) - \frac{1}{2}W^2(t_1) \bigg )$. And it seems there would be more of these terms left over for $m_n = j, j > 2$.
Possibly I made a mistake in my algebra, easy to misplace terms in expanding. If I did not make a mistake though could someone clarify because as it stands it seems incorrect.
 A: For ease of notation we replace $m_n,t_k^n,\tau_k^n$ with $m,t_k,\tau_k$ respectively. Starting on the right, we have the following:
\begin{align}
\text{RHS } & = \frac{W(t_m)^2}{2} +\sum_{k=0}^{m-1} -\frac{1}{2}W(t_{k+1})^2 + W(t_{k+1})W(t_k) - \frac{1}{2}W(t_k)^2 + W(\tau_k)^2 - 2 W(\tau_k)W(t_k)+W(t_k)^2 + W(t_{k+1})W(\tau_k) - W(t_{k+1})W(t_k) - W(\tau_k)^2 + W(\tau_k)W(t_k) \\
\end{align}
We cancel $W(t_{k+1})W(t_k) - W(t_{k+1})W(t_k)$ to get
\begin{equation}
\frac{W(t_m)^2}{2} +\sum_{k=0}^{m-1} -\frac{1}{2}W(t_{k+1})^2 - \frac{1}{2}W(t_k)^2 + W(\tau_k)^2 - 2 W(\tau_k)W(t_k)+W(t_k)^2 + W(t_{k+1})W(\tau_k) - W(\tau_k)^2 + W(\tau_k)W(t_k).
\end{equation}
Then we cancel $W(\tau_k)^2 - W(\tau_k)^2$ to get
\begin{equation}
\frac{W(t_m)^2}{2} +\sum_{k=0}^{m-1} -\frac{1}{2}W(t_{k+1})^2 - \frac{1}{2}W(t_k)^2 - 2 W(\tau_k)W(t_k)+W(t_k)^2 + W(t_{k+1})W(\tau_k)  + W(\tau_k)W(t_k).
\end{equation}
Then $W(\tau_k)W(t_k) - 2W(\tau_k)W(t_k) = -W(\tau_k)W(t_k)$, and we have
\begin{equation}
\frac{W(t_m)^2}{2} +\sum_{k=0}^{m-1} -\frac{1}{2}W(t_{k+1})^2 - \frac{1}{2}W(t_k)^2 - W(\tau_k)W(t_k)+W(t_k)^2 + W(t_{k+1})W(\tau_k) .
\end{equation}
We then combine $W(t_k)^2 - \frac{1}{2}W(t_k)^2 = \frac{1}{2}W(t_k)^2 $ to get
\begin{equation}
\frac{W(t_m)^2}{2} +\sum_{k=0}^{m-1} -\frac{1}{2}W(t_{k+1})^2 + \frac{1}{2}W(t_k)^2 - W(\tau_k)W(t_k) + W(t_{k+1})W(\tau_k) .
\end{equation}
Some slight rearranging yields the following:
\begin{equation}
\frac{W(t_m)^2}{2} +\sum_{k=0}^{m-1} \frac{1}{2}W(t_k)^2 -\frac{1}{2}W(t_{k+1})^2  + W(\tau_k)(W(t_{k+1}) - W(t_k)).
\end{equation}
Note that $\sum_{k=0}^{m-1} \frac{1}{2}W(t_k)^2 -\frac{1}{2}W(t_{k+1})^2$ is a telescoping sum, so we have
\begin{equation}
\frac{W(t_m)^2}{2} +(\frac{1}{2}W(t_0)^2 -\frac{1}{2}W(t_{m})^2)  + \sum_{k=0}^{m-1} W(\tau_k)(W(t_{k+1}) - W(t_k)).
\end{equation}
As you noted, we have standard Brownian motion, so $W(t_0)^2 = 0$, and we obtain the left hand side:
\begin{equation}
\text{RHS } = \frac{1}{2}W(t_0)^2 + \sum_{k=0}^{m-1} W(\tau_k)(W(t_{k+1}) - W(t_k)) = \sum_{k=0}^{m-1} W(\tau_k)(W(t_{k+1}) - W(t_k)) = \text{LHS}.
\end{equation}
