# Why does the theoretical value of the difference between these 2 stochastic integrals differ from the observed value in r?

Consider the stochastic integral $$2 \int_0^1 W_t \hspace{2mm} dW_t$$

Using r, this may be evaluated using one of the following summations $$S_1 = 2 \sum_{j=0}^{n-1} \left[ W_\frac{j}{n} \left( W_\frac{j+1}{n} - W_\frac{j}{n} \right) \right] \\ S_2 = 2 \sum_{j=0}^{n-1} \left[ W_\frac{j+1}{n} \left( W_\frac{j+1}{n} - W_\frac{j}{n} \right) \right] \\$$ where $S_1$ evaluates the integral from the lhs of each interval and $S_2$ evaluates the integral from the rhs of each interval.

My question is: how would you expect the value of $S_1 - S_2$ to change as $n \rightarrow \infty$?

Intuitively, I would expect $(S_1 - S_2) \rightarrow 0$ as $n \rightarrow \infty$, since $S_1$ and $S_2$ would get closer and closer to the true value of the integral as more intervals were considered.

However, I have a program in r which:

1. Generates a vector of $n$ values representing a standard Brownian motion
2. Based on this vector, evaluates the summations $S_1$ and $S_2$.

Using this program, I have tested the value of $S_1 - S_2$ for $n = 1, \dots 5000$. Based on the results of these tests, the value of $S_1 - S_2$ seems to be tending to $-1$ (from above).

Can anyone see why this might be?

Edit: Upon further thought, perhaps the reason why $S_1 - S_2$ might tend to a non-zero value is because, if we take $$W_\frac{j}{n} - W_\frac{j-1}{n} = W_\frac{j+1}{n} - W_\frac{j}{n}$$ (which should be true 'on average', since both sides of the above have the same distribution) then $$S_1 - S_2 = 2 \sum_{j=0}^{n-1} \left[ W_\frac{j}{n} \left( W_\frac{j+1}{n} - W_\frac{j}{n} \right) \right] - 2 \sum_{j=1}^{n} \left[ W_\frac{j}{n} \left( W_\frac{j+1}{n} - W_\frac{j}{n} \right) \right] = 2W_0 - 2W_1 = -2W_1$$ and the expected value of $W_1$ is 1.

However, this is still not equal to $-1$. Furthermore, if this is the case then I cannot understand why my initial analysis, that $S_1 - S_2 \rightarrow 0$ would be incorrect?

$$\int_0^1W_tdW_t=\lim_{n\to\infty}\sum_{j=0}^{n-1}W_{\frac{j}{n}}\left(W_{\frac{j+1}{n}}-W_{\frac{j}{n}}\right),$$
where the limit is understood in the $L_2$ sense. As the following calculation shows, the lhs of the interval is important (see also the difference between Itô and Stratonovich integral, which is also about where the integrand is evaluated). We have
$$\begin{split} \sum_{j=0}^{n-1}W_{\frac{j+1}{n}}\left(W_{\frac{j+1}{n}}-W_{\frac{j}{n}}\right)&=\sum_{j=0}^{n-1}\left(W_{\frac{j}{n}}+W_{\frac{j+1}{n}}-W_{\frac{j}{n}}\right)\left(W_{\frac{j+1}{n}}-W_{\frac{j}{n}}\right) \\ &=\sum_{j=0}^{n-1}W_{\frac{j}{n}}\left(W_{\frac{j+1}{n}}-W_{\frac{j}{n}}\right)+\sum_{j=0}^{n-1}\left(W_{\frac{j+1}{n}}-W_{\frac{j}{n}}\right)^2 \\ &\to \int_0^1W_tdW_t+\int_0^1d[W]_t \\ &=\int_0^1W_tdW_t+[W]_1-[W]_0, \quad n\to\infty. \end{split}$$
Since the quadratic variation of the Wiener process is $[W]_t=t$, we obtain
$$\sum_{j=0}^{n-1}W_{\frac{j+1}{n}}\left(W_{\frac{j+1}{n}}-W_{\frac{j}{n}}\right)\to \int_0^1W_tdW_t+1, \quad n\to\infty.$$