)abbrev domain GSERIES GeneralUnivariatePowerSeries
++ Author: Clifton J. Williamson
++ Date Created: 22 September 1993
++ Basic Operations:
++ Related Domains:
++ Also See:
++ AMS Classifications:
++ Keywords: series, Puiseux
++ Examples:
++ References:
++ Description:
++   This is a category of univariate Puiseux series constructed
++   from univariate Laurent series.  A Puiseux series is represented
++   by a pair \spad{[r, f(x)]}, where r is a positive rational number and
++   \spad{f(x)} is a Laurent series.  This pair represents the Puiseux
++   series \spad{f(x\^r)}.
GeneralUnivariatePowerSeries(Coef, var, cen) : Exports == Implementation where
  Coef : Ring
  var  : Symbol
  cen  : Coef
  I      ==> Integer
  UTS    ==> UnivariateTaylorSeries
  ULS    ==> UnivariateLaurentSeries
  UPXS   ==> UnivariatePuiseuxSeries

  Exports ==> UnivariatePuiseuxSeriesCategory Coef with
    coerce : Variable(var) -> %
      ++ coerce(var) converts the series variable \spad{var} into a
      ++ Puiseux series.
    coerce : UPXS(Coef, var, cen) -> %
      ++ coerce(f) converts a Puiseux series to a general power series.
    differentiate : (%, Variable(var)) -> %
      ++ \spad{differentiate(f(x), x)} returns the derivative of
      ++ \spad{f(x)} with respect to \spad{x}.
    if Coef has Algebra Fraction Integer then
      integrate : (%, Variable(var)) -> %
        ++ \spad{integrate(f(x))} returns an anti-derivative of the power
        ++ series \spad{f(x)} with constant coefficient 0.
        ++ We may integrate a series when we can divide coefficients
        ++ by integers.

  Implementation ==> UnivariatePuiseuxSeries(Coef, var, cen) add

    coerce(upxs : UPXS(Coef, var, cen)) == upxs pretend %

    puiseux : % -> UPXS(Coef, var, cen)
    puiseux f == f pretend UPXS(Coef, var, cen)

    if Coef has Algebra Fraction Integer then

      differentiate f ==
        str1 : String := "'differentiate' unavailable on this domain;  "
        str2 : String := "use 'approximate' first"
        error concat(str1, str2)

      differentiate(f : %, v : Variable(var)) == differentiate f

      if Coef has PartialDifferentialRing(Symbol) then
        differentiate(f : %, s : Symbol) ==
          (s = variable(f)) =>
            str1 : String := "'differentiate' unavailable on this domain;  "
            str2 : String := "use 'approximate' first"
            error concat(str1, str2)
          dcds := differentiate(center f, s)
          deriv := differentiate(puiseux f) :: %
          map(x +-> differentiate(x, s), f) - dcds * deriv

      integrate f ==
        str1 : String := "'integrate' unavailable on this domain;  "
        str2 : String := "use 'approximate' first"
        error concat(str1, str2)

      integrate(f : %, v : Variable(var)) == integrate f

      if Coef has integrate : (Coef, Symbol) -> Coef and _
         Coef has variables : Coef -> List Symbol then

        integrate(f : %, s : Symbol) ==
          (s = variable(f)) =>
            str1 : String := "'integrate' unavailable on this domain;  "
            str2 : String := "use 'approximate' first"
            error concat(str1, str2)
          not entry?(s, variables center f) => map(x +-> integrate(x, s), f)
          error "integrate: center is a function of variable of integration"

      if Coef has TranscendentalFunctionCategory and _
         Coef has PrimitiveFunctionCategory and _
         Coef has AlgebraicallyClosedFunctionSpace Integer then

        integrateWithOneAnswer : (Coef, Symbol) -> Coef
        integrateWithOneAnswer(f, s) ==
          res := integrate(f, s)$FunctionSpaceIntegration(Integer, Coef)
          res case Coef => res :: Coef
          first(res :: List Coef)

        integrate(f : %, s : Symbol) ==
          (s = variable(f)) =>
            str1 : String := "'integrate' unavailable on this domain;  "
            str2 : String := "use 'approximate' first"
            error concat(str1, str2)
          not entry?(s, variables center f) =>
            map(x +-> integrateWithOneAnswer(x, s), f)
          error "integrate: center is a function of variable of integration"

--Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
--All rights reserved.
--
--Redistribution and use in source and binary forms, with or without
--modification, are permitted provided that the following conditions are
--met:
--
--    - Redistributions of source code must retain the above copyright
--      notice, this list of conditions and the following disclaimer.
--
--    - Redistributions in binary form must reproduce the above copyright
--      notice, this list of conditions and the following disclaimer in
--      the documentation and/or other materials provided with the
--      distribution.
--
--    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
--      names of its contributors may be used to endorse or promote products
--      derived from this software without specific prior written permission.
--
--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
--IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
--TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
--PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
--OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
--EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
--PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
--PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
--LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
--NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
