# Getting divergence-free vector field

Let $v$ be a $C^\infty$ vector field on $\mathbb{R}^n$. Show that $v$ can be written as a sum $v=f\dfrac{\partial}{\partial x_1}+w$, where $w$ is a divergence-free vector field.

Suppose $v=v_1\dfrac{\partial}{\partial x_1}+v_2\dfrac{\partial}{\partial x_2}+\ldots+v_n\dfrac{\partial}{\partial x_n}$, where $v_i:\mathbb{R}^n\rightarrow\mathbb{R}$ are $C^\infty$ functions.

Then we want to choose $f$ so that $$v-f\dfrac{\partial}{\partial x_1}=(v_1-f)\dfrac{\partial}{\partial x_1}+v_2\dfrac{\partial}{\partial x_2}+\ldots+v_n\dfrac{\partial}{\partial x_n}$$ is divergence-free, i.e. this quantity is zero when we actually take these partial derivatives (rather than using them as just symbols).

How can we choose such $f$?

By requiring $v = f\frac{\partial }{\partial x^1} + w$ and $div(w)=0$,
$$div(v) = div \bigg( f\frac{\partial }{\partial x^1}\bigg) = \frac{\partial f}{\partial x^1}.$$
Then $f(x^1, \cdots, x^n) =\int_a^{x^1} div(v)(t, x^2, \cdots, x^n) dt \ .$