<s>[INST] Evaluate integral: $\int\frac{C^2}{P^3-P^2C-QC^3} dC$, given $P,Q > 0$ I was trying to get a closed form solution of the integral
$$\int\frac{C^2}{P^3-P^2C-QC^3} dC$$
with $ P,Q > 0 $.
I went through the following steps:
$$\frac{C^2}{P^3-P^2C-QC^3} = \frac{-3QC^2}{-3Q(P^3-P^2C-QC^3)} \\+ \frac{-P^2}{-3Q(P^3-P^2C-QC^3)} + \frac{P^2}{-3Q(P^3-P^2C-QC^3)}$$
$$\int\frac{C^2}{P^3-P^2C-QC^3} \\= \int(\frac{-3QC^2-P^2}{-3Q(P^3-P^2C-QC^3)}+ \frac{P^2}{-3Q(P^3-P^2C-QC^3)}) dC$$
The first integral evaluates to:
$$\int(\frac{-3QC^2-P^2}{-3Q(P^3-P^2C-QC^3)}=\frac{-1}{3Q}\int(\frac{dz}{z}) =\frac{-1}{3Q}\log{z} $$
I am lost in evaluating the second integral :
$$\int\frac{P^2}{-3Q(P^3-P^2C-QC^3)} dC$$
Is there a closed form solution for this at all?
 [/INST] Rewrite the integral as
$$I= -\frac1q \int\frac{x^2}{x^3 + \frac{p^2}q x-\frac{p^3}q}dx$$
and factorize  $x^3 + \frac{p^2}q x-\frac{p^3}q=(x-r)(x^2+rx+\frac{p^3}{qr})$,
with
$$r=\frac p{\sqrt[3]{2q}} \bigg( \sqrt[3]{\sqrt{1+\frac4{27q}}+1}-\sqrt[3]{\sqrt{1+\frac4{27q}}-1}\bigg)
$$
Then, integrate per partial fractions to obtain the close-form below
\begin{align}
I=& -\frac1q \int\frac{x^2}{(x-r)(x^2+rx+\frac{p^3}{qr})}dx\\
 =&\ -\frac1{p^3+2qr^3}
\int \frac{r^3}{x-r}+\frac{(p^3+qr^3)(2x+r)+ p^2r^2}{2q\ (x^2+rx+\frac{p^3}{qr})}\ dx\\
= &\ -\frac1{p^3+2qr^3}\bigg(
r^3\ln(x-r)+\frac{p^3+qr^3}{2q}\ln(x^2+rx+\frac{p^3}{qr})\\
&\hspace{35mm}+\frac{p r^2}q\sqrt{\frac{qr}{3p+r}}
\tan^{-1}\frac{p\sqrt{3p+r}\ (x+\frac r2)}{2\sqrt{qr}}
\bigg)
\end{align}
</s>