login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Francois Maltey wrote:

LatexWiki Image

You can use Fraction Polynomial Integer as their common domain.

axiom
a:=x + 1/(y+1)
LatexWiki Image(1)
Type: Fraction Polynomial Integer
axiom
b:=y + 1/(x+1)
LatexWiki Image(2)
Type: Fraction Polynomial Integer

LatexWiki Image

Axiom also has a package called PartialFractionPackage (PFRPAC), but you should package call it.

axiom
c:=partialFraction(a,y)$PFRPAC(INT)
LatexWiki Image(3)
Type: PartialFraction? UnivariatePolynomial(y,Fraction Polynomial Integer)
axiom
d:=partialFraction(b,x)$PFRPAC(INT)
LatexWiki Image(4)
Type: PartialFraction? UnivariatePolynomial(x,Fraction Polynomial Integer)

The reason for the package call is that Axiom Interpreter will find the wrong partialFraction from the domain PartialFraction (PFR) otherwise, giving a seemingly wrong answer:

axiom
partialFraction(a,y)
LatexWiki Image(5)
Type: PartialFraction? Fraction Polynomial Integer

This is NOT a bug, but rather a wrong use. The routine partialFraction from PFR expects two arguments: the first is the numerator, and the second the factored denominator! Unfortunately, the function requires the numerator domain to be a EuclideanDomain, and POLY INT does not have this property. So we are forced to use FRAC POLY INT, but there, partial fraction decomposition does not make much sense:

axiom
partialFraction(numerator a, factor denominator a)
LatexWiki Image(6)
Type: PartialFraction? Fraction Polynomial Integer

Partial fraction can only be done with respect to a single variable at a time, with all other variables considered in a coefficient domain. So in this sense, it is not possible to retain the two expresssions c, d in partial fraction form within the same domain. That is one reason why the target domain where c and d live is ANY. An alternative way could be (but this coercion is really not a true partial fraction decomposition):

axiom
e:= a:: PFR UP(x, FRAC UP(y, FRAC INT))
LatexWiki Image(7)
Type: PartialFraction? UnivariatePolynomial(x,Fraction UnivariatePolynomial(y,Fraction Integer))
axiom
f:= b:: PFR UP(y, FRAC UP(x, FRAC INT))
LatexWiki Image(8)
Type: PartialFraction? UnivariatePolynomial(y,Fraction UnivariatePolynomial(x,Fraction Integer))

LatexWiki Image

At present the codomain of partialFraction is ANY, which does not have ORDSET. Even the actual domain PFR UP(y, FRAC POLY INT) of c does not have ORDSET. So it is not possible to form EXPR over these two domains to apply trigonometric functions. Since FRAC POLY INT has ORDSET, it should be possible to modify PFR R to give it ORDSET if R has ORDSET, since mathematically speaking, PFR R is the same as FRAC R. However, even after modifying pfr.spad to make it into ORDSET if R has ORDSET, the interpreter would not allow computations in EXPR PFR R when R is UP(y, FRAC POLY INT). My guess is it would be quite difficult to add trigonometric functions to PFR R in general.

LatexWiki Image

You can try something like this:

axiom
)clear all
All user variables and function definitions have been cleared. fraction:=FRAC POLY INT
LatexWiki Image(9)
Type: Domain
axiom
dom:=UP(y,fraction)
LatexWiki Image(10)
Type: Domain
axiom
bdom:=PFR dom
LatexWiki Image(11)
Type: Domain
axiom
a:=x + 1/(y+1)
LatexWiki Image(12)
Type: Fraction Polynomial Integer
axiom
b:=partialFraction(a,y)$PFRPAC(INT)
LatexWiki Image(13)
Type: PartialFraction? UnivariatePolynomial(y,Fraction Polynomial Integer)
axiom
c:=b::bdom
LatexWiki Image(14)
Type: PartialFraction? UnivariatePolynomial(y,Fraction Polynomial Integer)
axiom
cw:=(wholePart c)::EXPR INT
LatexWiki Image(15)
Type: Expression Integer
axiom
m:=numberOfFractionalTerms(c)
LatexWiki Image(16)
axiom
crList:= [nthFractionalTerm(c,i) for i in 1..m]
LatexWiki Image(17)
Type: List PartialFraction? UnivariatePolynomial(y,Fraction Polynomial Integer)
axiom
cc:=reduce(+,crList)
LatexWiki Image(18)
Type: PartialFraction? UnivariatePolynomial(y,Fraction Polynomial Integer)
axiom
ccx:=cc::(FRAC dom)::(EXPR INT)
LatexWiki Image(19)
Type: Expression Integer
axiom
sin(cw)*cos(ccx)+sin(ccx)*cos(cw)
LatexWiki Image(20)
Type: Expression Integer

I would like to add that attempting to create a sin function with source bdom was not successful. The call ends up with an error message:

  >> Error detected within library code:
     reducing over an empty list needs the 3 argument form

axiom
sin(f:bdom):EXPR INT == fw:=(wholePart f)::EXPR INT n:=numberOfFractionalTerms(f) frList:= [nthFractionalTerm(f,i) for i in 1..n] ff:=reduce(+,frList) ffx:=ff::(FRAC dom)::(EXPR INT) sin(fw)*cos(ffx)+sin(ffx)*cos(fw)
Function declaration sin : PartialFraction UnivariatePolynomial(y, Fraction Polynomial Integer) -> Expression Integer has been added to workspace.
Type: Void
axiom
sin(c)
axiom
Compiling function sin with type PartialFraction 
      UnivariatePolynomial(y,Fraction Polynomial Integer) -> Expression
      Integer 
>> Error detected within library code: reducing over an empty list needs the 3 argument form

William




subject:
  ( 7 subscribers )  
Please rate this page: