Problems on Calculating Stochastic Integral Let f be a deterministic function in $L^2[a,b]$ and $X_t=X_a+\int^t_af(s)dB(s)$.
Show that $\int^b_af(t)X_tdB(t)=\frac{1}{2}(X_b^2-X_a^2-\int^b_af(t)^2dt)$.
My attempt:
$\frac{1}{2}(X_b^2-X_a^2)=X_a\int^b_af(t)dB(t)+\frac{1}{2}(\int^b_af(t)dB(t))^2$.
On the other hand:
$\int^b_af(t)X_tdB(t)=\int^b_af(t)X_adB(t)+\int^b_af(t)(\int^t_af(s)dB(s))dB(t)$.
So it remains to show that:
$\int^b_af(t)(\int^t_af(s)dB(s))dB(t)=\frac{1}{2}(\int^b_af(t)dB(t))^2-\frac{1}{2}\int^b_af(t)^2dt$
I learn only about the basic definition of stochastic integral. Is there any suggestions or hints? Also, I am wondering why f should be deterministic. What will go wrong if f is adapted and being in $L^2$? Thank you.

I am not sure whether you know Ito's formula, which is a useful tool to prove such identity.
Let $dX_t=f(t)dB_t$ and apply Ito's formula to $X_t^2$ gives you
$$dX_t^2=2X_tdX_t+(dX_t)^2=2X_tf(t)dB_t+f^2(t)dt,$$
then integrate $dX_t^2$ from $a$ gives you the desired result.

For an elementary proof, you may refer to my comment for this post. As you can see from the above argument, if $f$ is adapted and satisfies suitable integrablity assumptions, a similar identity also holds. But for an elementary proof, if $f$ is a deterministic function, we can start first with $f$ be a indicator function of $[s,t]$, for which the identity can be established with a direct calculation. But if $f$ is $L^2(\Omega\times [a,b])$, there is no such simple function for us to start with. 
