First, we should represent the function under the integral as a sum of partial fractions. Then it will integrate easily using arctangent and/or logarithm.
The decomposition should exist in the form
`( 3x^3 - x^2 + 6x - 4 ) / ( ( x^2 + 1 ) ( x^2 + 2 ) ) = ( Ax + B ) / ( x^2 + 1 ) + ( Cx + D ) / ( x^2 + 2 ) .`
To find the constants, multiply by the denominator:
`3x^3 - x^2 + 6x - 4 = ( Ax + B ) ( x^2 + 2 ) + ( Cx + D ) ( x^2 + 1 ) , ` i.e.
`3x^3 - x^2 + 6x - 4 = ( A + C ) x^3 + ( B + D ) x^2 + ( 2A + C ) x + ( 2B + D ) .`
This gives the system of equations
`A + C = 3 , ` `B + D = -1 , ` `2A + C = 6 , ` `2B + D = -4,`
which clearly has only one solution `A = 3 , ` `C = 0 , ` `B = -3 , ` `D = 2 .`
Then the indefinite integral is equal to
`3 int x / (x^2+1) dx - 3 int (dx) / (x^2+1) dx + 2 int (dx)/(x^2+2) , `
which is simple and is equal to
`3/2 ln(x^2+1) - 3 arctan (x) + sqrt(2) arctan(x/sqrt(2)) + C .`