# Computing the decomposition of this semimartingale

I am asked to show that the process $$X_t = f(B_t) \exp\left(-\int_0^t g(B_s) ds\right)$$ is a semimartingale, and to calculate its decomposition as the sum of a continuous local martingale and a finite variation process. Here $B_t$ is a one-dimensional Brownian motion started at $0$, $f$ is twice differentiable and $g$ is continuous. I know I need to use Ito's lemma but I'm having trouble getting it to work out.

First I try to deal with the integral term. Let $G$ be such that $G'' = g$ and $G(0) = G'(0) = 0$. Then an application of Ito's lemma gives $$\int_0^t g(B_s) ds = 2G(B_t) - 2\int_0^t G'(B_s) dB_s.$$

Denote $A_t := \int_0^t G'(B_s) dB_s$, so we can rewrite $$X_t = f(B_t) \exp(-2G(B_t) - 2A_t).$$ Since $A_t$ is a continuous local martingale, we can prepare to apply Ito's lemma again with $B_t$ and $A_t$. However this will lead to something messy and doesn't seem to give anything useful. I think my first step was not really useful so I'm stuck on how to proceed.

You need Itô's formula for diffusion processes. Suppose that $$dY_t = b(Y_t) \, dt + \sigma(Y_t) \, dB_t$$ and $$dZ_t = c(Z_t) \, dt + \varrho(Z_t) \, dB_t$$ are two one-dimensional diffusion processes, then Itô's formula states that
\begin{align*} &\quad h(Y_t,Z_t)-h(Y_0,Z_0) \\ &= \int_0^t \partial_y h(Y_s,Z_s) dY_s + \int_0^t \partial_z h(Y_s,Z_s) \, dZ_s \\&\quad+ \frac{1}{2} \int_0^t \left( \sigma^2(Y_s) \partial_{yy} h(Y_s,Z_s) + 2 \sigma(Y_s) \varrho(Z_s) \partial_{yz} h(Y_s,Z_s) + \varrho^2(Z_s) \partial_{zz} h(Y_s,Z_s) \right) \, ds. \end{align*}
In your framework, $$Y_t := B_t \qquad Z_t := \int_0^t g(B_s) \, ds \qquad h(y,z) := f(y) e^{-z},$$ i.e. $b=\varrho=0$, $\sigma=1$, $c=g$. Applying the above formula we find
$$f(B_t) e^{-Z_t} - f(0) = \underbrace{\int_0^t f'(B_s) e^{-Z_s} \, dB_s}_{\text{martingale}} \underbrace{ - \int_0^t f(B_s) e^{-Z_s} g(B_s) \, ds + \frac{1}{2} \int_0^t f''(B_s) e^{-Z_s} \, ds}_{\text{bounded variation}}.$$