Solving for coefficients in partial fractions expansion

Expansion of (((x^3) - x + 1)/((x^2) (((x - 1))^3))) yields following equation.

eqn = ((x^3) - x + 1 == 
          A x (((x - 1))^3) + B (((x - 1))^3) + 
            C (x^2) (((x - 1))^2) + D (x^2) (x - 1) + 
            EE (x^2))

Substitute various values of x to get 5 linear equations in 5 unknowns.

eqn1  =  eqn /.  {x  ->  0}
eqn2  =  eqn /.  {x ->  1}
eqn3  =  eqn /.  {x  ->  2}
eqn4  =  eqn  /.  {x  ->  -1}
eqn5  =  eqn  /.  {x  ->  -2}

Solve the equations.

Solve[{eqn1,  eqn2,  eqn3,  eqn4,  eqn5},  {A,  B,  C,  D,  
        EE}]

Automatic method for (((x^3) - x + 1)/((x^2) (((x - 1))^3))).

Apart[(((x^3) - x + 1)/((x^2) (((x - 1))^3)))]

Expansion of (x/((((x - 2))^2) ((x^2) + 1) ((x^2) + 4))) yields following equation.

eqn=(x ==A (x - 2) ((x^2) + 1) ((x^2) + 4)+ B ((x^2) + 1) ((x^2) + 4) +(C x + D) (((x - 2))^2) ((x^2) + 4)+(EE x + F) (((x - 2))^2) ((x^2) + 1))

Substitute various values of x to get 6 linear equations in 6 unknowns.

eqn1  =  eqn /.  {x  ->  0}
eqn2  =  eqn /.  {x ->  1}
eqn3  =  eqn /.  {x  ->  3}
eqn4  =  eqn  /.  {x  ->  -1}
eqn5  =  eqn  /.  {x  ->  -2}
eqn6  =  eqn /.  {x  ->  2}

Solve the equations.

Solve[{eqn1,  eqn2,  eqn3,  eqn4,  eqn5,  
        eqn6}, 
{A,  B,  C,  D,  EE,  F}]

Automatic method for (x/((((x - 2))^2) ((x^2) + 1) ((x^2) + 4))).

Apart[(x/((((x - 2))^2) ((x^2) + 1) ((x^2) + 4)))] // 
      Expand

Expansion of ((x^3   +  5)/((((x^2) + 4))^2)) yields following equation.

eqn =  (((x^3   +  5)/((((x^2) + 4))^2)) == ((A x + B)/((x^2) + 4)) + ((C x + D)/((((x^2) + 4))^2)) )

Substitute various values of x to get 4 linear equations in 4 unknowns.

eqn1  =  eqn /.  {x  ->  0}
eqn2  =  eqn /.  { x ->  1}
eqn3  =  eqn /.  {x  ->  -1}
eqn4  =  eqn /. {x  ->  2}

Solve the equations.

Solve[{eqn1,  eqn2,  eqn3,  eqn4}, 
{A,  B,  
        C,  D}]

Automatic method for ((x^3   +  5)/((((x^2) + 4))^2)).

Apart[((x^3   +  5)/((((x^2) + 4))^2))] // Expand

∫(1/(((4 + (x^2)))^2)) \[DifferentialD]x