How can I can solve integrals of rational functions of polynomials in $x$? I would like to know a way to solve integrals such as this one:
$$\int \frac{x}{3x - 4}dx$$
Also, I assume similar integrals where x is squared are solved in a similar manner. (If the answer is yes then don't also show me how to solve this second one, I want to see if I can do it myself. :) )
$$\int \frac{x^2}{x^2 - 1}dx$$
(I haven't included the conditions that x must meet in order for those to be valid expressions.)
 A: For your two examples my first lines would be
$$ \int \frac{x}{3x-4} \text{d}x = \int \frac{ \frac{1}{3}(3x-4) +4/3}{3x-4} \text{d}x $$
and
$$ \int \frac{x^2}{x^2-1} \text{d}x = \int \frac{ (x^2-1) + 1}{x^2-1} \text{d}x . $$
You can easily extend this technique, for example
$$ \int \frac{x^3}{x^2-1} \text{d}x = \int \frac{ x(x^2-1) + x}{x^2-1} \text{d}x . $$
A: Whenever you are trying to integrate a rational function, the first step is to do the division so that the numerator is of degree strictly smaller than the numerator (this is what Eugene Bulkin and J.M. are saying in the comments). For example, for
$$\int \frac{x}{3x-4}\,dx$$
you should do the division of $x$ by $3x-4$ with remainder. This is
$$x = \frac{1}{3}(3x-4) + \frac{4}{3}$$
which means that
$$\frac{x}{3x-4} = \frac{1}{3} + \frac{4/3}{3x-4}.$$
So the integral can be rewritten as
$$\int \frac{x}{3x-4}\,dx = \int\left(\frac{1}{3} + \frac{4/3}{3x-4}\right)\,dx = \int\frac{1}{3}\,dx + \frac{4}{3}\int \frac{1}{3x-4}\,dx.$$
The first integral is immediate. The second integral yields to a change of variable $u=3x-4$. We get
$$\begin{align*}
\int\frac{x}{3x-4}\,dx &= \int\frac{1}{3}\,dx + \frac{4}{3}\int\frac{1}{3x-4}\,dx\\
&= \frac{1}{3}x + \frac{4}{9}\int\frac{du}{u}\\
&= \frac{1}{3}x + \frac{4}{9}\ln|u| + C\\
&= \frac{1}{3}x + \frac{4}{9}\ln|3x-4| + C.
\end{align*}$$
In general, if you have a denominator of degree $1$, by doing the long division you can always express it as a polynomial plus a rational function of the form
$$\frac{k}{ax+b}$$
with $k$, $a$, and $b$ constants. The polynomial is easy to integrate, and the fraction can be integrated with a change of variable.
The same is true for your second integral. Doing the long division gives, as you note, that
$$\int \frac{x^2}{x^2-1}\,dx = \int\left(1 + \frac{1}{x^2-1}\right)\,dx = \int\,dx + \int\frac{1}{x^2-1}\,dx.$$
The first integral is easy. The second is as well, using partial fractions:
$$\frac{1}{x^2-1} = \frac{1}{(x+1)(x-1)} = \frac{1/2}{x-1} - \frac{1/2}{x+1}$$
so:
$$\int\frac{1}{x^2-1}\,dx = \frac{1}{2}\int\frac{dx}{x-1} - \frac{1}{2}\int\frac{dx}{x+1} = \frac{1}{2}\ln|x-1| - \frac{1}{2}\ln|x+1|+C.$$
See also some of the comments in this answer on solving integrals by partial fractions.
