       Re: Partial fraction expansion

• To: mathgroup at smc.vnet.net
• Subject: [mg30469] Re: Partial fraction expansion
• From: "Allan Hayes" <hay at haystack.demon.co.uk>
• Date: Thu, 23 Aug 2001 02:15:33 -0400 (EDT)
• References: <9lvh6b\$4oc\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Lee, Andrzej

Here are some functions for factorizing and putting into partial fractions.
The methods are different from Andrzej's and sometimes give
different results.

FactorC[p_, x_] :=              (*over complex numbers*)
Times @@ Cases[Roots[p == 0, x,
Cubics -> False], u_ == v_ -> x - v]

FactorR[p_, x_] :=              (*over real numbers*)
(Times @@ Join[Cases[#1, u_ == v_ /; Im[v] == 0 :>
x - v], Cases[#1, u_ == v_ /; Im[v] > 0 :>
x^2 - x*2*Re[v] + Abs[v]^2]] & )[
Roots[p == 0, x, Cubics -> False]]

PartialFractionsC[p_, x_] := (*over complex numbers*)
(Apart[Numerator[#1]/FactorC[Denominator[#1], x], x] & )[Together[p]]

PartialFractionsR[p_, x_] := (*over real numbers*)
(Apart[Numerator[#1]/FactorR[Denominator[#1], x], x] & )[Together[p]]

PROGRAMMING NOTES

The option Cubics->False is used to keep roots of cubics in Root[....] form.
This more effIcient for computation.
Re[v] and  Abs[v]^2 are  used rather than  v+Conjugate[v] and v*Conjugate[v]
to prevent Apart from factorising  x^2 - x*2*Re[v] + Abs[v]^2] back to
complex form.

EXAMPLES

pol = Expand[(x - 1)*(x + 1)^2*(x^2 + x + 1)^2*(x^2 + 4)];

f1 = FactorC[pol, x]

(-1 + x)*(-2*I + x)*(2*I + x)*(1 + x)^2*((-1)^(1/3) + x)^2*
(-(-1)^(2/3) + x)^2

f2 = FactorR[pol, x]

(-1 + x)*(1 + x)^2*(4 + x^2)*(1 + x + x^2)^2

f3 = FactorR[x^3 + x + 1, x]

(x - Root[1 + #1 + #1^3 & , 1])*
(x^2 - 2*x*Root[-1 + 2*#1 + 8*#1^3 & , 1] +
Root[-1 - #1^4 + #1^6 & , 2]^2)

Root objects appear because of the option Cubics->False in Roots.
We can sometimes get radical forms, but notice the complication.

((2/(3*(-9 + Sqrt)))^(1/3) -
((1/2)*(-9 + Sqrt))^(1/3)/3^(2/3) + x)*
(1/3 + (1/3)*(29/2 - (3*Sqrt)/2)^(1/3) +
(1/3)*((1/2)*(29 + 3*Sqrt))^(1/3) -
2*(((1/2)*(9 + Sqrt))^(1/3)/(2*3^(2/3)) -
1/(2^(2/3)*(3*(9 + Sqrt))^(1/3)))*x + x^2)

Inexact forms can be found, from f3 :

N[f3]

(0.6823278038280193 + x)*(1.4655712318767682 -
0.6823278038280193*x + x^2)

or directly

f3 = FactorR[x^3 + x + 1//N, x]

(0.6823278038280193 + x)*(1.4655712318767682 -
0.6823278038280193*x + x^2)

Partial fractions

pf1 = PartialFractionsR[(2 + x)/pol, x]

1/(60*(-1 + x)) - 1/(10*(1 + x)^2) - 39/(100*(1 + x)) +
(-54 - 31*x)/(4225*(4 + x^2)) +
(-1 + 3*x)/(13*(1 + x + x^2)^2) +
(44 + 193*x)/(507*(1 + x + x^2))

pf2 = PartialFractionsR[(1 + x)/(1 - 3*x + x^2), x]

(-5 - Sqrt)/(Sqrt*(3 + Sqrt - 2*x)) +
(-5 + Sqrt)/(Sqrt*(-3 + Sqrt + 2*x))

Partial fractions will often involve Root objects (I delete the output for
brevity)

pf3 = PartialFractionsR[(1 + x)/(x^3 - x + 1), x]

This ressult can in fact be put into radical form

We could have found the inexact form directly.

PartialFractionsR[(1+x)/(x^3-x+1)//N,x]

-(0.07614206365252976/(1.324717957244746 + 1.*x)) +
(0.7982664819556426 + 0.07614206365252976*x)/
(0.754877666246693 - 1.324717957244746*x + 1.*x^2)

--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Lee Lin Yap" <kendallyap at hotmail.com> wrote in message
news:9ki2fp\$kcu\$1 at smc.vnet.net...
> Hi,
>
> I'm currently doing a software programming for my final year project. I
need
> to solve a partial fraction expansion in my program. I have a numerator
and
> I got the roots for it. But I can't solve the problem to get the answer
that
> I need.
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>

```

• Prev by Date: Re: Re: Re: Rotation3D, MatrixRotation3D ?
• Next by Date: [Technical] Filters like GIMP?
• Previous by thread: Re: Partial fraction expansion
• Next by thread: Importing Graphics into Mathematica notebooks?