Changes 
http://wiki.axiom-developer.org/334MisrecognizedVariableInExpression/diff
--

??changed:
 
-  --  coefficient(p,v,n) == 
-  --       output(hconcat(["POLYCAT:", p::OutputForm, v::OutputForm, 
n::OutputForm]))$OutputPackage
-  --       output(hconcat(["POLYCAT:", 
univariate(p,v)::OutputForm]))$OutputPackage
-  --       coefficient(univariate(p,v),n)
-
-and obtained the following output::
-
-  --(2) -> coefficient(numer(sin x)^2, (sin x)::Kernel EXPR INT, 2)
-  --                 2
-  --   POLYCAT:sin(x) sin(x)2
-  --            2
-  --   POLYCAT:?
-  --
-  -- (2)  1
-  --        Type: SparseMultivariatePolynomial(Integer,Kernel Expression 
Integer)
-  --(3) -> coefficient(numer(sin x)^2, (sin x), 2)
-  --                 2
-  --   POLYCAT:sin(x) sin(x)2
-  --                 2
-[6 more lines...]
+    coefficient(p,v,n) == 
+         output(hconcat(["POLYCAT:", p::OutputForm, v::OutputForm, 
n::OutputForm]))$OutputPackage
+         output(hconcat(["POLYCAT:", 
univariate(p,v)::OutputForm]))$OutputPackage
+         coefficient(univariate(p,v),n)
+
+\begin{spad}
+)abbrev category POLYCAT PolynomialCategory
+++ Author:
+++ Date Created:
+++ Date Last Updated:
+++ Basic Functions: Ring, monomial, coefficient, differentiate, eval
+++ Related Constructors: Polynomial, DistributedMultivariatePolynomial
+++ Also See: UnivariatePolynomialCategory
+++ AMS Classifications:
+++ Keywords:
+++ References:
+++ Description:
+++ The category for general multi-variate polynomials over a ring
+++ R, in variables from VarSet, with exponents from the
+++ \spadtype{OrderedAbelianMonoidSup}.
+
+PolynomialCategory(R:Ring, E:OrderedAbelianMonoidSup, VarSet:OrderedSet):
+        Category ==
+  Join(PartialDifferentialRing VarSet, FiniteAbelianMonoidRing(R, E),
+       Evalable %, InnerEvalable(VarSet, R),
+       InnerEvalable(VarSet, %), RetractableTo VarSet,
+       FullyLinearlyExplicitRingOver R) with
+    -- operations
+    degree : (%,VarSet) -> NonNegativeInteger
+      ++ degree(p,v) gives the degree of polynomial p with respect to the 
variable v.
+    degree : (%,List(VarSet)) -> List(NonNegativeInteger)
+      ++ degree(p,lv) gives the list of degrees of polynomial p
+      ++ with respect to each of the variables in the list lv.
+    coefficient: (%,VarSet,NonNegativeInteger) -> %
+      ++ coefficient(p,v,n) views the polynomial p as a univariate
+      ++ polynomial in v and returns the coefficient of the \spad{v**n} term.
+    coefficient: (%,List VarSet,List NonNegativeInteger) -> %
+      ++ coefficient(p, lv, ln) views the polynomial p as a polynomial
+      ++ in the variables of lv and returns the coefficient of the term
+      ++ \spad{lv**ln}, i.e. \spad{prod(lv_i ** ln_i)}.
+    monomials: % -> List %
+      ++ monomials(p) returns the list of non-zero monomials of polynomial p, 
i.e.
+      ++ \spad{monomials(sum(a_(i) X^(i))) = [a_(1) X^(1),...,a_(n) X^(n)]}.
+    univariate   : (%,VarSet) -> SparseUnivariatePolynomial(%)
+      ++ univariate(p,v) converts the multivariate polynomial p
+      ++ into a univariate polynomial in v, whose coefficients are still
+      ++ multivariate polynomials (in all the other variables).
+    univariate   : % -> SparseUnivariatePolynomial(R)
+        ++ univariate(p) converts the multivariate polynomial p,
+        ++ which should actually involve only one variable,
+        ++ into a univariate polynomial
+        ++ in that variable, whose coefficients are in the ground ring.
+        ++ Error: if polynomial is genuinely multivariate
+    mainVariable  : % -> Union(VarSet,"failed")
+           ++ mainVariable(p) returns the biggest variable which actually
+           ++ occurs in the polynomial p, or "failed" if no variables are
+           ++ present.
+           ++ fails precisely if polynomial satisfies ground?
+    minimumDegree : (%,VarSet) -> NonNegativeInteger
+      ++ minimumDegree(p,v) gives the minimum degree of polynomial p
+      ++ with respect to v, i.e. viewed a univariate polynomial in v
+    minimumDegree : (%,List(VarSet)) -> List(NonNegativeInteger)
+      ++ minimumDegree(p, lv) gives the list of minimum degrees of the
+      ++ polynomial p with respect to each of the variables in the list lv
+    monicDivide : (%,%,VarSet) -> Record(quotient:%,remainder:%)
+       ++ monicDivide(a,b,v) divides the polynomial a by the polynomial b,
+       ++ with each viewed as a univariate polynomial in v returning
+       ++ both the quotient and remainder.
+       ++ Error: if b is not monic with respect to v.
+    monomial : (%,VarSet,NonNegativeInteger) -> %
+        ++ monomial(a,x,n) creates the monomial \spad{a*x**n} where \spad{a} is
+        ++ a polynomial, x is a variable and n is a nonnegative integer.
+    monomial : (%,List VarSet,List NonNegativeInteger) -> %
+        ++ monomial(a,[v1..vn],[e1..en]) returns \spad{a*prod(vi**ei)}.
+    multivariate : (SparseUnivariatePolynomial(R),VarSet) -> %
+        ++ multivariate(sup,v) converts an anonymous univariable
+        ++ polynomial sup to a polynomial in the variable v.
+    multivariate : (SparseUnivariatePolynomial(%),VarSet) -> %
+        ++ multivariate(sup,v) converts an anonymous univariable
+        ++ polynomial sup to a polynomial in the variable v.
+    isPlus: % -> Union(List %, "failed")
+        ++ isPlus(p) returns \spad{[m1,...,mn]} if polynomial \spad{p = m1 + 
... + mn} and
+        ++ \spad{n >= 2} and each mi is a nonzero monomial.
+    isTimes: % -> Union(List %, "failed")
+        ++ isTimes(p) returns \spad{[a1,...,an]} if polynomial \spad{p = a1 
... an}
+        ++ and \spad{n >= 2}, and, for each i, ai is either a nontrivial 
constant in R or else of the
+        ++ form \spad{x**e}, where \spad{e > 0} is an integer and x in a 
member of VarSet.
+    isExpt: % -> Union(Record(var:VarSet, exponent:NonNegativeInteger),_
+                       "failed")
+        ++ isExpt(p) returns \spad{[x, n]} if polynomial p has the form 
\spad{x**n} and \spad{n > 0}.
+    totalDegree : % -> NonNegativeInteger
+        ++ totalDegree(p) returns the largest sum over all monomials
+        ++ of all exponents of a monomial.
+    totalDegree : (%,List VarSet) -> NonNegativeInteger
+        ++ totalDegree(p, lv) returns the maximum sum (over all monomials of 
polynomial p)
+        ++ of the variables in the list lv.
+    variables : % -> List(VarSet)
+        ++ variables(p) returns the list of those variables actually
+        ++ appearing in the polynomial p.
+    primitiveMonomials: % -> List %
+        ++ primitiveMonomials(p) gives the list of monomials of the
+        ++ polynomial p with their coefficients removed.
+        ++ Note: \spad{primitiveMonomials(sum(a_(i) X^(i))) = 
[X^(1),...,X^(n)]}.
+    if R has OrderedSet  then OrderedSet
+    -- OrderedRing view removed to allow EXPR to define abs
+    --if R has OrderedRing then OrderedRing
+    if (R has ConvertibleTo InputForm) and
+       (VarSet has ConvertibleTo InputForm) then
+         ConvertibleTo InputForm
+    if (R has ConvertibleTo Pattern Integer) and
+       (VarSet has ConvertibleTo Pattern Integer) then
+         ConvertibleTo Pattern Integer
+    if (R has ConvertibleTo Pattern Float) and
+       (VarSet has ConvertibleTo Pattern Float) then
+         ConvertibleTo Pattern Float
+    if (R has PatternMatchable Integer) and
+       (VarSet has PatternMatchable Integer) then
+         PatternMatchable Integer
+    if (R has PatternMatchable Float) and
+       (VarSet has PatternMatchable Float) then
+         PatternMatchable Float
+    if R has CommutativeRing then
+      resultant : (%,%,VarSet) -> %
+         ++ resultant(p,q,v) returns the resultant of the polynomials
+         ++ p and q with respect to the variable v.
+      discriminant : (%,VarSet) -> %
+         ++ discriminant(p,v) returns the disriminant of the polynomial p
+         ++ with respect to the variable v.
+    if R has GcdDomain then
+      GcdDomain
+      content: (%,VarSet) -> %
+        ++ content(p,v) is the gcd of the coefficients of the polynomial p
+        ++ when p is viewed as a univariate polynomial with respect to the
+        ++ variable v.
+        ++ Thus, for polynomial 7*x**2*y + 14*x*y**2, the gcd of the
+        ++ coefficients with respect to x is 7*y.
+      primitivePart: % -> %
+        ++ primitivePart(p) returns the unitCanonical associate of the
+        ++ polynomial p with its content divided out.
+      primitivePart: (%,VarSet) -> %
+        ++ primitivePart(p,v) returns the unitCanonical associate of the
+        ++ polynomial p with its content with respect to the variable v
+        ++ divided out.
+      squareFree: % -> Factored %
+        ++ squareFree(p) returns the square free factorization of the
+        ++ polynomial p.
+      squareFreePart: % -> %
+        ++ squareFreePart(p) returns product of all the irreducible factors
+        ++ of polynomial p each taken with multiplicity one.
+
+    -- assertions
+    if R has canonicalUnitNormal then canonicalUnitNormal
+             ++ we can choose a unique representative for each
+             ++ associate class.
+             ++ This normalization is chosen to be normalization of
+             ++ leading coefficient (by default).
+    if R has PolynomialFactorizationExplicit then
+       PolynomialFactorizationExplicit
+ add
+    p:%
+    v:VarSet
+    ln:List NonNegativeInteger
+    lv:List VarSet
+    n:NonNegativeInteger
+    pp,qq:SparseUnivariatePolynomial %
+    eval(p:%, l:List Equation %) ==
+      empty? l => p
+      for e in l repeat
+        retractIfCan(lhs e)@Union(VarSet,"failed") case "failed" => 
+             error "cannot find a variable to evaluate"
+      lvar:=[retract(lhs e)@VarSet for e in l]
+      eval(p, lvar,[rhs e for e in l]$List(%))
+    monomials p ==
+--    zero? p => empty()
+--    concat(leadingMonomial p, monomials reductum p)
+--    replaced by sequential version for efficiency, by WMSIT, 7/30/90
+      ml:= empty$List(%)
+      while p ^= 0 repeat
+        ml:=concat(leadingMonomial p, ml)
+        p:= reductum p
+      reverse ml
+    isPlus p ==
+      empty? rest(l := monomials p) => "failed"
+      l
+    isTimes p ==
+      empty?(lv := variables p) or not monomial? p => "failed"
+      l := [monomial(1, v, degree(p, v)) for v in lv]
+--      one?(r := leadingCoefficient p) =>
+      ((r := leadingCoefficient p) = 1) =>
+        empty? rest lv => "failed"
+        l
+      concat(r::%, l)
+    isExpt p ==
+      (u := mainVariable p) case "failed" => "failed"
+      p = monomial(1, u::VarSet, d := degree(p, u::VarSet)) =>
+        [u::VarSet, d]
+      "failed"
+    -- coefficient(p,v,n) == coefficient(univariate(p,v),n)
+    coefficient(p,v,n) == 
+[231 more lines...]
 

--
forwarded from http://wiki.axiom-developer.org/[EMAIL PROTECTED]

Reply via email to