% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved. % !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk. \newcommand{\PartialFractionXmpTitle}{PartialFraction} \newcommand{\PartialFractionXmpNumber}{9.61} % % ===================================================================== \begin{page}{PartialFractionXmpPage}{9.61 PartialFraction} % ===================================================================== \beginscroll %% %% pfr.htex %% A {\it partial fraction} is a decomposition of a quotient into %-% \HDindex{partial fraction}{PartialFractionXmpPage}{9.61}{PartialFraction} a sum %-% \HDindex{fraction!partial}{PartialFractionXmpPage}{9.61}{PartialFraction} of quotients where the denominators of the summands are powers of primes.\footnote{Most people first encounter partial fractions when they are learning integral calculus. For a technical discussion of partial fractions, see, for example, Lang's {\it Algebra.}} For example, the rational number \spad{1/6} is decomposed into \spad{1/2 -1/3}. You can compute partial fractions of quotients of objects from domains belonging to the category \spadtype{EuclideanDomain}. For example, \spadtype{Integer}, \spadtype{Complex Integer}, and \spadtype{UnivariatePolynomial(x, Fraction Integer)} all belong to \spadtype{EuclideanDomain}. In the examples following, we demonstrate how to decompose quotients of each of these kinds of object into partial fractions. Issue the system command \spadcmd{)show PartialFraction} to display the full list of operations defined by \spadtype{PartialFraction}. It is necessary that we know how to factor the denominator when we want to compute a partial fraction. Although the interpreter can often do this automatically, it may be necessary for you to include a call to \spadfun{factor}. In these examples, it is not necessary to factor the denominators explicitly. % \xtc{ The main operation for computing partial fractions is called \spadfunFrom{partialFraction}{PartialFraction} and we use this to compute a decomposition of \spad{1 / 10!}. The first argument to \spadfunFrom{partialFraction}{PartialFraction} is the numerator of the quotient and the second argument is the factored denominator. }{ \spadpaste{partialFraction(1,factorial 10) \bound{prev1}} } \xtc{ Since the denominators are powers of primes, it may be possible to expand the numerators further with respect to those primes. Use the operation \spadfunFrom{padicFraction}{PartialFraction} to do this. }{ \spadpaste{f := padicFraction(\%) \free{prev1}\bound{f}} } % % \xtc{ The operation \spadfunFrom{compactFraction}{PartialFraction} returns an expanded fraction into the usual form. The compacted version is used internally for computational efficiency. }{ \spadpaste{compactFraction(f) \free{f}} } % \xtc{ You can add, subtract, multiply and divide partial fractions. In addition, you can extract the parts of the decomposition. \spadfunFrom{numberOfFractionalTerms}{PartialFraction} computes the number of terms in the fractional part. This does not include the whole part of the fraction, which you get by calling \spadfunFrom{wholePart}{PartialFraction}. In this example, the whole part is just \spad{0}. }{ \spadpaste{numberOfFractionalTerms(f) \free{f}} } \xtc{ The operation \spadfunFrom{nthFractionalTerm}{PartialFraction} returns the individual terms in the decomposition. Notice that the object returned is a partial fraction itself. \spadfunFrom{firstNumer}{PartialFraction} and \spadfunFrom{firstDenom}{PartialFraction} extract the numerator and denominator of the first term of the fraction. }{ \spadpaste{nthFractionalTerm(f,3) \free{f}} } % % \xtc{ Given two gaussian integers (see \downlink{`Complex'}{ComplexXmpPage}\ignore{Complex}), you can decompose their quotient into a partial fraction. }{ \spadpaste{partialFraction(1,- 13 + 14 * \%i) \bound{prev2}} } % \xtc{ To convert back to a quotient, simply use a conversion. }{ \spadpaste{\% :: Fraction Complex Integer \free{prev2}} } To conclude this section, we compute the decomposition of \texht{\narrowDisplay{1 \over {{(x + 1)}{(x + 2)}^2{(x + 3)}^3{(x + 4)}^4}}}{ \begin{verbatim} 1 ------------------------------- 2 3 4 (x + 1)(x + 2) (x + 3) (x + 4) \end{verbatim} } The polynomials in this object have type \spadtype{UnivariatePolynomial(x, Fraction Integer)}. % \xtc{ We use the \spadfunFrom{primeFactor}{Factored} operation (see \downlink{`Factored'}{FactoredXmpPage}\ignore{Factored}) to create the denominator in factored form directly. }{ \spadpaste{u : FR UP(x, FRAC INT) := reduce(*,[primeFactor(x+i,i) for i in 1..4]) \bound{u}} } % % \xtc{ These are the compact and expanded partial fractions for the quotient. }{ \spadpaste{partialFraction(1,u) \free{u}\bound{prev3}} } \xtc{ }{ \spadpaste{padicFraction \% \free{prev3}} } All see \downlink{`FullPartialFractionExpansion'}{FullPartialFractionExpansionXmpPage}\ignore{FullPartialFractionExpansion} for examples of factor-free conversion of quotients to full partial fractions. \endscroll \autobuttons \end{page} %