<s>[INST] Determine continuous function from piecewise derivative I'm having trouble solving this issue.

Determine a continuous function $f$ on the interval $[-2,2]$ whose derived function on $[-2,2] \setminus \{0\}$ is known to be the function:
$$
f(x)=
\left\lbrace
\begin{array}{lll}
\dfrac{x^2+4x+7}{2x^3-x^2+18x-9} & \text{ if} -2 \leq x < 0 \\ 
& \\
x^2 \sin^2 (x) & \text{ if } 0 < x \leq 2
\end{array}
\right.
$$

I tried to calculate the integral of the function in each definition interval, add a constant and impose conditions to determine the constant. I have the problem in the first interval. I can't integrate the function. How do I solve this problem? Thanks!
 [/INST] You can use partial fractions. First, factorize the denominator as $$2x^3-x^2+18x-9 = (2x-1)(x^2+9) = (2x-1)(x+3i)(x-3i) $$ Now, set $$\frac{x^2+4x+7}{(2x-1)(x-3i)(x+3i)} = \frac{P}{2x-1} + \frac{Q}{x+3i} +\frac{R}{x-3i} \\ \implies  x^2+4x+7 = P(x^2+9) +Q(2x-1)(x-3i) +R(2x-1)(x+3i)$$
Letting $x=\frac 12, 3i, -3i$ will give you $P=1, Q=\frac i3, R= -\frac i3 $. Hence, the integral is $$\int \frac{dx}{2x-1} +\frac i3 \int \frac{dx}{x+3i} -\frac i3 \int \frac{dx}{x-3i} \\ =\ln|2x-1| +\frac i3 \ln(x+3i) -\frac i3 \ln(x-3i) + C \\ =\ln(1-2x) +\frac i3  \left[ \ln \sqrt{x^2+9} +i(\pi +\tan^{-1} \frac 3x) \right] -\frac i3 \left[ \ln\sqrt{x^2+9} +i(-\pi -\tan^{-1}\frac 3x ) \right] + C \hspace{0.1 cm} (*) \\ = \ln(1-2x)-\frac 23 (\pi+\tan^{-1} \frac 3x ) + C \\ = \ln(1-2x)-\frac 23 \tan^{-1} \frac 3x +C’$$
$ \begin{align} (*) \ln(z) = \ln |z| +i\arg z \end{align}$
</s>