# How to differentiate Ito's integral and correctly apply Ito's formula

I came across the following problem and below is my approach. I am not sure how to proceed.
Problem: suppose
$$M(t)=\int_0^t W(s)dW(s)$$ where $$W(s)$$ is a standard Brownian motion, find $$f=f(t,x)$$ such that $$E(t)=e^{M(t)-\int_0^tf(s,W(s))ds}$$ is a martingale.
What I did was to let $$g(t,W(t))=E(t)$$ and then by Ito's formula, $$dg(t,W(t))=\partial_tg(t,W(t))dt+\partial_xg(t,W(t))dW(t)+\frac{1}{2}\partial_x^2g(t,W(t))dt$$

## Edit:

My question now is how do we compute those partial derivatives of $$g$$? I tried the following: $$\partial_tg(t,W(t))=E(t)(-f(t,W(t))$$ $$\partial_xg(t,W(t))=E(t)W(t)$$ $$\partial_x^2g(t,W(t))=E(t)W(t)^2+E(t)$$ Could someone tell me what I did wrong here?

We know that $$d\bigg(\int_0^t W(s)dW(s)\bigg) = W(t)dW(t)$$ by definition. Now let $$N(t) := M(t)- \int_0^t f(s,W(s))ds$$, then $$d(N(t)) = dM(t)-d(\int_0^t f(s,W(s))ds) = W(t)dW(t)-d(\int_0^t f(s,W(s))ds) = W(t)dW(t) -f(t,W(t))dt$$ since $$\int_0^t f(s,W(s))ds$$ is a "regular" integral, and $$d[N](t) = W^2(t)dt.$$ By Ito we have $$d(E(t))= d(e^{N(t)}) = e^{N(t)}dN(t)+\frac12e^{N(t)} d[N](t) = e^{N(t)}(W(t)dW(t)-f(t,W(t)dt+\frac{W^2(t)}{2}dt).$$ In order for this to be a martingale the $$dt$$ term has to be 0, thus choose $$f(t,W(t)) = \frac12 W^2(t)$$, i.e. $$f(t,x) = \frac{x^2}2$$.
Note that $$\int_0^t W^2(s)ds = [M](t)$$ is actually the quadratic variation of $$M(t)$$. This means that given any $$L^2$$ martingale $$M(t)$$ in the filtration of $$(W(t))_{t\geq 0}$$, the process $$\mathcal E(M)(t) = \exp\bigg( M(t)-\frac12 [M](t) \bigg)$$ is a(n exponential) martingale.
• Thanks very much! This approach makes a lot of sense. However, I am trying to proceed from where I was stuck before. I obtained that $\partial_tg(t,W(t))=E(t)(-f(s,W(s))$, $\partial_xg(t,W(t))=E(t)W(t)$, $\partial_x^2g(t,W(t))=E(t)W^2(t)+E(t)$. This does not seem to be the same as the correct answer above with an extra $E(t)$ term. Could you help me understand what I did wrong here? Mar 17, 2020 at 19:46
• The problem is with defining $g(t,x)$, since technically if you set $g(t,W(s)) = \int_0^t W(s)dW(s)$, then how would you define $g(t,x)$? You cleary can't just set $g(t,x)= \int_0^t xdx$. You have to express $\int_0^t W(s)dW(s)$ as a function of $W(s)$, or you go around it like I did.
• Typo: express $\int_0^t W(s)dW(s)$ as a fct of $W(t)$ and not $W(s)$.