Some Issues with Partial Fractions and Integration of Rational Functions.

Many partial fractions decompositions taken out of calculus texts can be easily done with Apart

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

1/(x + 3) + 2/(x - 5)

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

31/(x + 2) - 26/(x + 1) + 12/(x + 1)^2

Making a slight change in the denominator can become a problem since the denominator may not factor without identifying the extension of the rationals that is needed to factor the denominator.

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

(3 x + 1)/(x^2 - 2 x - 14)

Solve[y_2[[2, 1]] == 0, x]

{{x→1 - 15^(1/2)}, {x→1 + 15^(1/2)}}

Why y2[[2,1]]?  Evaluate  FullForm[y2[[2,1]]] to find out.

Apart[(3x + 1)/Factor[x^2 - 2x - 14, Extension→Sqrt[15]]]

(-4 + 3 15^(1/2))/(2 15^(1/2) (x + 15^(1/2) - 1)) + (-4 - 3 15^(1/2))/(2 15^(1/2) (-x + 15^(1/2) + 1))

Fortunately, you don't need to use Apart to integrate a rational function, but another problem emerges.  Mathematica doesn't assume that you are only interested in real valued functions.

Y_1 = Integrate[y_1, x]

2 log(x - 5) + log(x + 3)

Y_2 = Integrate[y_2, x]

1/30 (45 + 4 15^(1/2)) log(-x + 15^(1/2) + 1) + 1/30 (45 - 4 15^(1/2)) log(x + 15^(1/2) - 1)

Y_1/.{x→4}

2  π + log(7)

This makes plotting an antiderivative like Y_1a problem when the argument to a log term become negative.

Plot[Y_1, {x, -10, 10}]

Plot :: plnr : Y  is not a machine-size real number at x = -10. .  More…                 1

Plot :: plnr : Y  is not a machine-size real number at x = -9.18866 .  More…                 1

Plot :: plnr : Y  is not a machine-size real number at x = -8.30382 .  More…                 1

General :: stop : Further output of  Plot :: plnr will be suppressed during this calculation. More…

[Graphics:HTMLFiles/partial_fractions_25.gif]

-Graphics -

Here is one way to transform the integration result into the one we expect to see in calculus.

Z_1 = Y_1/.{Log[arg_] →Log[Abs[arg]]}

2 log({x - 5}) + log({x + 3})

Z_1/.{x→4}

log(7)

Plot[Z_1, {x, -10, 10}]

[Graphics:HTMLFiles/partial_fractions_32.gif]

-Graphics -

The graph doesn't show it, but Z_2 dirverges to -∞ as x approaches either -3 or 5.

Limit[Z_1, x→ -3, Direction→ -1]

-∞

There is a package called RealOnly that puts you into a real-only environment, but loading it doesn't solve the problem we ran into above.

<<Miscellaneous`RealOnly`

W_1 = Integrate[y_1, x]

2 log(x - 5) + log(x + 3)

W_1/.{x→4}

Nonreal :: warning : Nonreal number encountered.

Nonreal

This package can be useful in other calculus contexts.  For example, the cube root of a negative real number is complex and so plotting y=x^(1/3) can be a problem

Quit[]   (* This restarts the kernel to see what happens when RealOnly isn ' t loaded *)

(-8)^(1/3)

2 (-1)^(1/3)

Plot[x^(1/3), {x, -8, 8}]

                1/3 Plot :: plnr : x    is not a machine-size real number at x = -8. .  More…

                1/3 Plot :: plnr : x    is not a machine-size real number at x = -7.35093 .  More…

                1/3 Plot :: plnr : x    is not a machine-size real number at x = -6.64306 .  More…

General :: stop : Further output of  Plot :: plnr will be suppressed during this calculation. More…

[Graphics:HTMLFiles/partial_fractions_52.gif]

-Graphics -

<<Miscellaneous`RealOnly`

Now the cube root of -8 will be -2:

(-8)^(1/3)

-2

Plot[x^(1/3), {x, -8, 8}]

[Graphics:HTMLFiles/partial_fractions_58.gif]

-Graphics -


Created by Mathematica  (March 9, 2006) Valid XHTML 1.1!