$SPAD/src/input distexpr.input

Francois Maltey, Bill Page, Martin Rubey

December 3, 2016

Abstract

Contents

2

— distexpr.spad —

)abbrev domain DEXPR DistributedExpression
DistributedExpression(R:Join(Ring,OrderedSet)): Exports == Implementation where
EXPRR ==> Expression R
AN    ==> AlgebraicNumber
SUP   ==> SparseUnivariatePolynomial
Exports == FunctionSpace R with
if R has IntegralDomain then
AlgebraicallyClosedFunctionSpace R
TranscendentalFunctionCategory
CombinatorialOpsCategory
LiouvillianFunctionCategory
SpecialFunctionCategory
reduce: % -> %
  ++ reduce(f) simplifies all the unreduced algebraic quantities
  ++ present in f by applying their defining relations.
number?: % -> Boolean
  ++ number?(f) tests if f is rational
simplifyPower: (%,Integer) -> %
  ++ simplifyPower(f,n) \undocumented
if R has GcdDomain then
  factorPolynomial: SUP % -> Factored SUP %
    ++ factorPolynomial(p) \undocumented
  squareFreePolynomial: SUP % -> Factored SUP %
    ++ squareFreePolynomial(p) \undocumented
if R has RetractableTo Integer then RetractableTo AN
coerce: EXPRR -> %
Implementation == EXPRR add
Rep := EXPRR
out: (Polynomial R, List %, List %) -> OutputForm
-- coerces the polynomial to OutputForm completely expanded and
-- replaces the variables in vl with the kernels in kl
out(p,kl,vl) ==
ex := leadingMonomial(p)::%
if reductum p = 0
then coerce(eval(ex,vl,kl))$Rep
else coerce(eval(ex,vl,kl))$Rep + out(reductum p, kl, vl)
coerce(ex:%):OutputForm ==
kl:=kernels ex
vl:List %:=[subscript('x,[i::OutputForm])::Symbol::% for i in 1..#kl]
exl:%:=subst(ex,kl,vl)$%
kll:=map(coerce(#1)$%,kl)$ListFunctions2(Kernel %,%)
if R has IntegralDomain then

        if denominator exl = 1 then
          out(retract(numerator exl)@Polynomial(R), kll,vl)
        else
          out(retract(numerator exl)@Polynomial(R), kll,vl)
           /out(retract(denominator exl)@Polynomial(R), kll,vl)
      else
        out(retract(exl)@Polynomial(R),kll,vl)
    coerce(p:EXPRR):% == p

———-

— * —

)set break resume
)sys rm -f distexpr.output
)spool distexpr.output
)set message test on
)set message auto off
)clear all
)sys cp $AXIOM/../../src/input/distexpr.input.pamphlet .
)lisp (tangle "distexpr.input.pamphlet" "distexpr.spad" "distexpr.spad")
)co distexpr
--S 1 of 6
ex1:=(2*log(x)+3*exp(y))*(4*sin(z)+2*log(x))
--R
--R
--R                       y                 2      y
--R   (1)  (8log(x) + 12%e )sin(z) + 4log(x)  + 6%e log(x)
--R                                                    Type: Expression(Integer)
--E 1
--S 2 of 6
ex2:=8*log(x)*sin(z)+4*log(x)^2+12*exp(y)*sin(z)+6*exp(y)*log(x)
--R
--R
--R                       y                 2      y
--R   (2)  (8log(x) + 12%e )sin(z) + 4log(x)  + 6%e log(x)
--R                                                    Type: Expression(Integer)
--E 2
--S 3 of 6
subst(ex1, kernels ex1, [x1,x2,x3])::DMP([x1,x2,x3],INT)
--R
--R
--R                              2
--R   (3)  8x1 x2 + 12x1 x3 + 4x2  + 6x2 x3
--R                  Type: DistributedMultivariatePolynomial([x1,x2,x3],Integer)

--E 3
--S 4 of 6
ex1::DistributedExpression(Integer)
--R
--R
--R           y             y                2
--R   (4)  6%e log(x) + 12%e sin(z) + 4log(x)  + 8log(x)sin(z)
--R                                         Type: DistributedExpression(Integer)
--E 4
--S 5 of 6
((1+2*a+3*b)*(4*c+5*d))::DEXPR INT
--R
--R
--R   (5)  8a c + 10a d + 12b c + 15b d + 4c + 5d
--R                                         Type: DistributedExpression(Integer)
--E 5
--S 6 of 6
((1+2*a+3*b)*(4*c+5*d))::POLY INT
--R
--R
--R   (6)  (15b + 10a + 5)d + (12b + 8a + 4)c
--R                                                    Type: Polynomial(Integer)
--E 6
)spool
)lisp (bye)

———-

References

[1] http://axiom-wiki.newsynthesis.org/SandBoxDistributedExpression