aboutsummaryrefslogtreecommitdiff
path: root/src/algebra/liouv.spad.pamphlet
blob: 587f8b231f857a66dc68abe95c813ddddd64abb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
\documentclass{article}
\usepackage{axiom}
\begin{document}
\title{\$SPAD/src/algebra liouv.spad}
\author{Manuel Bronstein}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
\section{package LF LiouvillianFunction}
<<package LF LiouvillianFunction>>=
)abbrev package LF LiouvillianFunction
++ Author: Manuel Bronstein
++ Date Created: 1987
++ Date Last Updated: 10 August 1994
++ Keywords: liouvillian, function, primitive, exponential.
++ Examples:  )r LF INPUT
++ Description:
++   This package provides liouvillian functions over an integral domain.
LiouvillianFunction(R, F): Exports == Implementation where
  R:Join(OrderedSet, IntegralDomain)
  F:Join(FunctionSpace R,RadicalCategory,TranscendentalFunctionCategory)

  OP  ==> BasicOperator
  PR  ==> Polynomial R
  K   ==> Kernel F
  SE  ==> Symbol
  O   ==> OutputForm
  INP ==> InputForm
  INV ==> error "Invalid argument"

  SPECIALDIFF ==> "%specialDiff"
  SPECIALDISP ==> "%specialDisp"
  SPECIALINPUT ==> "%specialInput"
  SPECIALEQUAL ==> "%specialEqual"

  Exports ==> with
    belong? : OP -> Boolean
      ++ belong?(op) checks if op is Liouvillian
    operator: OP -> OP
      ++ operator(op) returns the Liouvillian operator based on op
    Ei      : F  -> F
      ++ Ei(f) denotes the exponential integral
    Si      : F  -> F
      ++ Si(f) denotes the sine integral
    Ci      : F  -> F
      ++ Ci(f) denotes the cosine integral
    li      : F  -> F
      ++ li(f) denotes the logarithmic integral
    erf     : F  -> F
      ++ erf(f) denotes the error function
    dilog   : F  -> F
      ++ dilog(f) denotes the dilogarithm
    integral: (F, SE) -> F
      ++ integral(f,x) indefinite integral of f with respect to x.
    integral: (F, SegmentBinding F) -> F
      ++ integral(f,x = a..b) denotes the definite integral of f with
      ++ respect to x from \spad{a} to b.

  Implementation ==> add
    iei        : F  -> F
    isi        : F  -> F
    ici        : F  -> F
    ierf       : F  -> F
    ili        : F  -> F
    ili2       : F  -> F
    iint       : List F -> F
    eqint      : (K,K) -> Boolean
    dvint      : (List F, SE) -> F
    dvdint     : (List F, SE) -> F
    ddint      : List F -> O
    integrand  : List F -> F

    dummy := new()$SE :: F

    opint  := operator('integral)$CommonOperators
    opdint := operator('%defint)$CommonOperators
    opei   := operator('Ei)$CommonOperators
    opli   := operator('li)$CommonOperators
    opsi   := operator('Si)$CommonOperators
    opci   := operator('Ci)$CommonOperators
    opli2  := operator('dilog)$CommonOperators
    operf  := operator('erf)$CommonOperators

    Si x                == opsi x
    Ci x                == opci x
    Ei x                == opei x
    erf x               == operf x
    li  x               == opli x
    dilog x             == opli2 x

    belong? op     == has?(op, 'prim)
    isi x          == kernel(opsi, x)
    ici x          == kernel(opci, x)
    ierf x         == (zero? x => 0; kernel(operf, x))
    ili2 x         == (one? x => INV; kernel(opli2, x))
    integrand l    == eval(first l, retract(second l)@K, third l)
    integral(f:F, x:SE) == opint [eval(f, k:=kernel(x)$K, dummy), dummy, k::F]

    iint l ==
      zero? first l => 0
      kernel(opint, l)

    ddint l ==
      int(integrand(l)::O * hconcat('d::O, third(l)::O),
                                    third(rest l)::O, third(rest rest l)::O)

    eqint(k1,k2) == 
      a1:=argument k1
      a2:=argument k2
      res:=operator k1 = operator k2
      if not res then return res
      res:= a1 = a2
      if res then return res
      res:= (a1.3 = a2.3) and (subst(a1.1,[retract(a1.2)@K],[a2.2]) = a2.1)

    dvint(l, x) ==
      k  := retract(second l)@K
      differentiate(third l, x) * integrand l
          + opint [differentiate(first l, x), second l, third l]


    dvdint(l, x) ==
      x = retract(y := third l)@SE => 0
      k := retract(d := second l)@K
      differentiate(h := third rest rest l,x) * eval(f := first l, k, h)
        - differentiate(g := third rest l, x) * eval(f, k, g)
             + opdint [differentiate(f, x), d, y, g, h]

    integral(f:F, s: SegmentBinding F) ==
      x := kernel(variable s)$K
      opdint [eval(f,x,dummy), dummy, x::F, lo segment s, hi segment s]

    ili x ==
      x = 1 => INV
      is?(x,'exp) => Ei first argument(retract(x)@K)
      kernel(opli, x)

    iei x ==
      x = 0 => INV
      is?(x,'log) => li first argument(retract(x)@K)
      kernel(opei, x)

    operator op ==
      is?(op,'integral)   => opint
      is?(op,'%defint)    => opdint
      is?(op,'Ei)         => opei
      is?(op,'Si)         => opsi
      is?(op,'Ci)         => opci
      is?(op,'li)         => opli
      is?(op,'erf)        => operf
      is?(op,'dilog)      => opli2
      error "Not a Liouvillian operator"

    evaluate(opei,   iei)$BasicOperatorFunctions1(F)
    evaluate(opli,   ili)
    evaluate(opsi,   isi)
    evaluate(opci,   ici)
    evaluate(operf,  ierf)
    evaluate(opli2,  ili2)
    evaluate(opint,  iint)
    derivative(opsi, sin(#1) / #1)
    derivative(opci, cos(#1) / #1)
    derivative(opei, exp(#1) / #1)
    derivative(opli, inv log(#1))
    derivative(operf, 2 * exp(-(#1**2)) / sqrt(pi()))
    derivative(opli2, log(#1) / (1 - #1))
    setProperty(opint,SPECIALEQUAL,eqint@((K,K) -> Boolean) pretend None)
    setProperty(opint,SPECIALDIFF,dvint@((List F,SE) -> F) pretend None)
    setProperty(opdint,SPECIALDIFF,dvdint@((List F,SE)->F) pretend None)
    setProperty(opdint, SPECIALDISP, ddint@(List F -> O) pretend None)

    if R has ConvertibleTo INP then
      inint : List F -> INP
      indint: List F -> INP
      pint  : List INP -> INP


      pint l  == convert concat(convert('integral)@INP, l)
      inint l == 
        r2:= convert([convert("::"::SE)@INP,convert(third l)@INP,convert("Symbol"::SE)@INP]@List INP)@INP
        pint [convert(integrand l)@INP, r2]

      indint l ==
        pint [convert(integrand l)@INP,
              convert concat(convert("="::SE)@INP,
                            [convert(third l)@INP,
                             convert concat(convert("SEGMENT"::SE)@INP,
                                            [convert(third rest l)@INP,
                                             convert(third rest rest l)@INP])])]

      setProperty(opint, SPECIALINPUT, inint@(List F -> INP) pretend None)
      setProperty(opdint, SPECIALINPUT, indint@(List F -> INP) pretend None)

@
\section{License}
<<license>>=
--Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
--All rights reserved.
--Copyright (C) 2007-2009, Gabriel Dos Reis.
--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.
@
<<*>>=
<<license>>

-- SPAD files for the functional world should be compiled in the
-- following order:
--
--   op  kl  fspace  algfunc elemntry LIOUV expr

<<package LF LiouvillianFunction>>
@
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}