Disclaimer: This is related to physics, but the problem is essentially a mathematical one (check the mathematically reduced version below, which condenses relevant information).
In Masao Doi's Soft Matter Physics exercise 2.4 d), given $\Pi(\phi_1,\ldots,\phi_n)$, $f(\phi_1,\ldots,\phi_n)$, $\mu_i(\phi_1,\ldots,\phi_n)$, and $P,v_i,k_B,T=cte$, we know \begin{align} \sum_{i=0}^{n} \phi_{i} &= 1 \tag 0 \\ \Pi &= -f+\sum_{i=1}^{n} \phi_{i} \frac{\partial f}{\partial \phi_{i}}+f(0)\tag 1\\ \mu_{i} &= v_{i}\left[\frac{\partial f}{\partial \phi_{i}}+P-\Pi+f(0)\right] \text {, for } i=1, \ldots n \tag 2 \end{align}
In this particular case,
\begin{align}\Pi=\sum_{i=1}^{n} \frac{\phi_{i}}{v_{i}} k_{B} T+\sum_{i=1}^{n} \sum_{j=1}^{n} A_{i j} \phi_{i} \phi_{j} \tag 3 \end{align}
and we need to show
\begin{align}\mu_{i}=\mu_{i}^{0}(T)+P v_{i}+k_{B} T \ln \phi_{i}+\sum_{j=1}^{n}\left(2 v_{i} A_{i j}-\frac{v_i}{v_j}k_{B} T\right) \phi_{j} \tag 4 \end{align}
I am trying to take the same approach as in page 13 - "merge" the derivatives with $f$ in the rhs of (1), then substitute (3) in (1), and solve for $f$ (by integration) - but I am having trouble with "merging", and then integrating.
Any suggestions? $$\\ \\$$
Reduced version:
Given $f(x_1,\ldots,x_n)$, with \begin{align} -f+\sum_{i=1}^{n} x_{i} \frac{\partial f}{\partial x_{i}}+f(0)=a\sum_{i=1}^{n} \frac{x_{i}}{v_{i}}+\sum_{i=1}^{n} \sum_{j=1}^{n} A_{i j} x_{i} x_{j} \tag a \end{align}
show that, for $i=1,...,n$,
\begin{align} \frac{\partial f}{\partial x_{i}}-\big( a\sum_{k=1}^{n} \frac{x_{k}}{v_{k}}+\sum_{k=1}^{n} \sum_{j=1}^{n} A_{k j} x_{k} x_{j} \big) = \frac{a}{v_i} \ln x_{i}+\sum_{j=1}^{n}\left(2 A_{i j}-\frac{a}{v_j}\right) x_{j} \tag b \end{align}
A hint on how to get $f$ or $\frac{\partial f}{\partial x_{i}}$ would already be a tremendous help.