integral of differences of vector I have a vector function $f: \mathbb{R}^n \to \mathbb{R}^n$ defined with components
$$
f_i(a) = \sum_{j=1}^n \sin(a_i - a_j)
$$
which I want to integrate from ${\bf{\alpha}}^0$ to ${\bf{\alpha}}^1$ where ${\bf{\alpha}}^k = [\alpha^k_1, \ldots, \alpha^k_n]$ for $k \in \{1,2\}$.
So the problem looks like
$$
\int_{{\bf{\alpha}}^0}^{{\bf{\alpha}}^1} f(a)^{\top} {\rm d}\, a.
$$
I thought that I could integrate as below
$$
\int_{\alpha^0}^{\alpha^1} \sum_{i=1}^n \left\{ \sum_{j=1}^n \sin(a_i - a_j)\right\} {\rm d}a_i 
$$
by expanding the inner product in the integrand. I think that I can then write the integral as
$$
\int_{(\alpha_1^0, \ldots, \alpha_n^0)}^{(\alpha_1^1, \ldots, \alpha_n^1)} \sum_{i=1}^n \left\{ \sum_{j=1}^n \sin(a_i - a_j)\right\} {\rm d}a_i = \sum_{i=1}^n \int_{\hat{\alpha}_i^0}^{\hat{\alpha}_i^1} \left\{ \sum_{j=1}^n \sin(a_i - a_j)\right\} {\rm d}a_i
$$
where $\hat{\alpha}_i^0$ treats every component of $a$ as fixed $\alpha_j^0$ for $j \neq i$, which I think would give
$$
\sum_{i=1}^n \sum_{j=1}^n \left[ \cos(\alpha_i^1 - \alpha_j^1) - \cos(\alpha_i^0 - \alpha_j^0) \right].
$$
Is this correct?
 A: We are asked to compute the line integral 
$$\int_{\alpha^0}^{\alpha^1}f(a)\cdot da, $$
where
$$f_i(a)=\sum_{j=1}^{n}\sin(a_i-a_j).$$
Ideally, this line integral is path-independent. We would need $f=\nabla g$ for some scalar field $g(a).$ That is, we would need
$$\sum_{j=1}^{n}\sin(a_i-a_j)=\frac{\partial}{\partial a_i}\,g(a).$$
This would force
$$\int\sum_{j=1}^{n}\sin(a_i-a_j)\,da_i=g(a),$$
or
$$g(a)=-\sum_{j=1}^{n}\cos(a_i-a_j).$$
But this needs to be true of all the $a_i,$ so let's modify this to
$$g(a)=-\sum_{i=1}^n\sum_{j=1}^n\cos(a_i-a_j).$$
When $i=j,$ we're going to pick up a number of $-1$'s, but that should be immaterial. The point is, that if we differentiate this $g(a)$ w.r.t. $a_i,$ we'll get $f_i.$ Let's double-check that this works by computing:
\begin{align*}
\frac{\partial g(a)}{\partial a_1}&=-\frac{\partial}{\partial a_1}\sum_{i=1}^n\sum_{j=1}^n\cos(a_i-a_j)\\
&=-\sum_{i=1}^n\sum_{j=1}^n\frac{\partial}{\partial a_1}\,\cos(a_i-a_j).
\end{align*}
Now we see here that if neither $i$ nor $j$ is $1,$ the derivative annihilates the $\cos$. So, which terms have $a_1$ in them? Well, we have a number of terms. If $i=1,$ and $j\not=1,$ those will contribute. Also, if $i\not=1$ but $j=1,$ those will also contribute. If $i=j,$ then, as before mentioned, the term is $\cos(0)=1,$ which disappears under differentiation. Therefore, the expression above becomes the following:
\begin{align*}
\frac{\partial g(a)}{\partial a_1}&=
-\sum_{j=2}^n\frac{\partial}{\partial a_1}\,\cos(a_1-a_j)-\sum_{i=2}^n\frac{\partial}{\partial a_1}\,\cos(a_i-a_1).
\end{align*}
Since $\cos$ is even, these sums will actually turn out to be identical, which means we double-counted initially. That is:
\begin{align*}
\frac{\partial g(a)}{\partial a_1}&=
-\sum_{j=2}^n\frac{\partial}{\partial a_1}\,\cos(a_j-a_1)-\sum_{i=2}^n\frac{\partial}{\partial a_1}\,\cos(a_i-a_1) \\
&=-\sum_{i=2}^n\frac{\partial}{\partial a_1}\,\cos(a_i-a_1)-\sum_{i=2}^n\frac{\partial}{\partial a_1}\,\cos(a_i-a_1) \\
&=-2\sum_{i=2}^n\frac{\partial}{\partial a_1}\,\cos(a_i-a_1) \\
&=2\sum_{i=2}^n\sin(a_i-a_1).
\end{align*}
This means we need to adjust our $g$ by a factor of $1/2:$
$$g(a)=-\frac12 \sum_{i=1}^n\sum_{j=1}^n\cos(a_i-a_j).$$
Once we do this, we can see that the proof above goes through, and it is indeed the case that $\partial_{a_1}g(a)=f_1,$ since in $f_1,$ when $j=1,$ we see that $\sin(a_1-a_1)=\sin(0)=0.$
Whew! We have path independence on account of the form of $f$. It remains to calculate the line integral itself, but we've actually done all the hard work because we know what $g$ is. Since the integral is path-independent, we'll choose the straight line from $\alpha^0$ to $\alpha^1,$ parametrized as 
$$\gamma(t)=t\alpha^1+(1-t)\alpha^0,\quad t\in[0,1],$$
as it has all the nice properties we need to use the Fundamental Theorem for Line Integrals:
\begin{align*}
\int_{\alpha^0}^{\alpha^1}f(a)\cdot da &=\int_{\alpha^0}^{\alpha^1}(\nabla g(a))\cdot da \\
&=g(\alpha^1)-g(\alpha^0) \\
&=\frac12 \sum_{i=1}^n\sum_{j=1}^n\cos(\alpha_i^0-\alpha_j^0)-\frac12 \sum_{i=1}^n\sum_{j=1}^n\cos(\alpha_i^1-\alpha_j^1) \\
&=\frac12 \sum_{i=1}^n\sum_{j=1}^n[\cos(\alpha_i^0-\alpha_j^0)-\cos(\alpha_i^1-\alpha_j^1)].
\end{align*}
You could use
$$\cos(\theta)-\cos(\varphi)=-2\sin\left(\frac{\theta+\varphi}{2}\right)\sin\left(\frac{\theta-\varphi}{2}\right)$$
to combine the cosines in the last expression, but that might or might not be simpler. 
