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

Francois Maltey wrote:


Subject: [Axiom-developer] about Expression Integer
   Date: 16 Feb 2006 21:33:45 +0100
   From: Francois Maltey <<span class=fmaltey@nerim.fr> To: axiom-developer@nongnu.org, fmaltey@nerim.fr

I play with expressions and I have these questions :

1/ Can I (or cannot) remain Expressions as

x+1/(y+1) y+1/(x+1)

and do not have a single denominator. " title=" Subject: Axiom-developer about Expression Integer Date: 16 Feb 2006 21:33:45 +0100 From: Francois Maltey <fmaltey@nerim.fr> To: axiom-developer@nongnu.org, fmaltey@nerim.fr

I play with expressions and I have these questions :

1/ Can I (or cannot) remain Expressions as

x+1/(y+1) y+1/(x+1)

and do not have a single denominator. " class="equation" src="images/4888188823115559482-16.0px.png" width="433" height="248"/>

You can use Fraction Polynomial Integer as their common domain.

axiom
a:=x + 1/(y+1)

\label{eq1}{{x \  y}+ x + 1}\over{y + 1}(1)
Type: Fraction(Polynomial(Integer))
axiom
b:=y + 1/(x+1)

\label{eq2}{{{\left(x + 1 \right)}\  y}+ 1}\over{x + 1}(2)
Type: Fraction(Polynomial(Integer))


 2/ Can I go back from (xy+x+1)/(y+1) to x+1/(y+1) ?
 Other cas have normal or partfrac function, or remain fraction as.

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

axiom
c:=partialFraction(a,y)$PFRPAC(INT)

\label{eq3}x +{1 \over{y + 1}}(3)
Type: PartialFraction(UnivariatePolynomial(y,Fraction(Polynomial(Integer))))
axiom
d:=partialFraction(b,x)$PFRPAC(INT)

\label{eq4}y +{1 \over{x + 1}}(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)

\label{eq5}x +{1 \over{y + 1}}(5)
Type: PartialFraction(UnivariatePolynomial(y,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)

\label{eq6}{{x \  y}+ x + 1}\over{y + 1}(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))

\label{eq7}x +{1 \over{y + 1}}(7)
Type: PartialFraction(UnivariatePolynomial(x,Fraction(UnivariatePolynomial(y,Fraction(Integer)))))
axiom
f:= b:: PFR UP(y, FRAC UP(x, FRAC INT))

\label{eq8}y +{1 \over{x + 1}}(8)
Type: PartialFraction(UnivariatePolynomial(y,Fraction(UnivariatePolynomial(x,Fraction(Integer)))))


 3/ When I expand a trig formula I cut x+1/(y+1) in x and 1/(y+1)
 not in xy/(y+1) and x/(y+1) and 1/(y+1).<p> But perhaps my ideas aren't right ?

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.


 4/ I'm not sure that the results (xy+x+1)/(y+1) and ((x+1)y+1)/(x+1)
 are fine :<p> First the order of the variable is important,
 and the user (almost) can't force it, if he uses "n" and "x" variables.</p>
<p> Second the result is longer if the denominator is big.</p>
<p> 5/ Of course there is no problem in expand (cos (4<em>x+5y)),
 but small problems appear with     expand (cos (4</em>x+5<em>y/2))
 and a lot with                     expand (cos (4</em>x+5*y/(2+t+t^2+t^3))).</p>
<p> What is the better expand in the 3 cases.
 Perhaps cos^4 x ... cos^5 y ...
         cos^4 x ... cos^5 (y/2) ...
         cos^4 x ... cos^5 (y/(2+t+t^2+t^3)) ... but I'm not sure.</p>
<p> I will be very happy if you can give me your advice, and tell me if
 one or an other way of computation is impossible/not natural/too complex
 with axiom.

You can try something like this:

axiom
)clear all
All user variables and function definitions have been cleared. fraction:=FRAC POLY INT

\label{eq9}\hbox{\axiomType{Fraction}\ } (\hbox{\axiomType{Polynomial}\ } (\hbox{\axiomType{Integer}\ }))(9)
Type: Domain
axiom
dom:=UP(y,fraction)

\label{eq10}\hbox{\axiomType{UnivariatePolynomial}\ } (y , \hbox{\axiomType{Fraction}\ } (\hbox{\axiomType{Polynomial}\ } (\hbox{\axiomType{Integer}\ })))(10)
Type: Domain
axiom
bdom:=PFR dom

\label{eq11}\hbox{\axiomType{PartialFraction}\ } (\hbox{\axiomType{UnivariatePolynomial}\ } (y , \hbox{\axiomType{Fraction}\ } (\hbox{\axiomType{Polynomial}\ } (\hbox{\axiomType{Integer}\ }))))(11)
Type: Domain
axiom
a:=x + 1/(y+1)

\label{eq12}{{x \  y}+ x + 1}\over{y + 1}(12)
Type: Fraction(Polynomial(Integer))
axiom
b:=partialFraction(a,y)$PFRPAC(INT)

\label{eq13}x +{1 \over{y + 1}}(13)
Type: PartialFraction(UnivariatePolynomial(y,Fraction(Polynomial(Integer))))
axiom
c:=b::bdom

\label{eq14}x +{1 \over{y + 1}}(14)
Type: PartialFraction(UnivariatePolynomial(y,Fraction(Polynomial(Integer))))
axiom
cw:=(wholePart c)::EXPR INT

\label{eq15}x(15)
Type: Expression(Integer)
axiom
m:=numberOfFractionalTerms(c)

\label{eq16}1(16)
Type: PositiveInteger
axiom
crList:= [nthFractionalTerm(c,i) for i in 1..m]

\label{eq17}\left[{1 \over{y + 1}}\right](17)
Type: List(PartialFraction(UnivariatePolynomial(y,Fraction(Polynomial(Integer)))))
axiom
cc:=reduce(+,crList)

\label{eq18}1 \over{y + 1}(18)
Type: PartialFraction(UnivariatePolynomial(y,Fraction(Polynomial(Integer))))
axiom
ccx:=cc::(FRAC dom)::(EXPR INT)

\label{eq19}1 \over{y + 1}(19)
Type: Expression(Integer)
axiom
sin(cw)*cos(ccx)+sin(ccx)*cos(cw)

\label{eq20}{{\cos \left({1 \over{y + 1}}\right)}\ {\sin \left({x}\right)}}+{{\cos \left({x}\right)}\ {\sin \left({1 \over{y + 1}}\right)}}(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:   Be Bold !!
  ( 7 subscribers )  
Please rate this page: