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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
|
\documentclass{article}
\usepackage{open-axiom}
\begin{document}
\title{\$SPAD/src/algebra intef.spad}
\author{Manuel Bronstein}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
\section{package INTEF ElementaryIntegration}
<<package INTEF ElementaryIntegration>>=
)abbrev package INTEF ElementaryIntegration
++ Integration of elementary functions
++ Author: Manuel Bronstein
++ Date Created: 1 February 1988
++ Date Last Updated: 24 October 1995
++ Description:
++ This package provides functions for integration, limited integration,
++ extended integration and the risch differential equation for
++ elemntary functions.
++ Keywords: elementary, function, integration.
++ Examples: )r INTEF INPUT
ElementaryIntegration(R, F): Exports == Implementation where
R : Join(GcdDomain, CharacteristicZero,
RetractableTo Integer, LinearlyExplicitRingOver Integer)
F : Join(AlgebraicallyClosedField, TranscendentalFunctionCategory,
FunctionSpace R)
SE ==> Symbol
K ==> Kernel F
P ==> SparseMultivariatePolynomial(R, K)
UP ==> SparseUnivariatePolynomial F
RF ==> Fraction UP
IR ==> IntegrationResult F
FF ==> Record(ratpart:RF, coeff:RF)
LLG ==> List Record(coeff:F, logand:F)
U2 ==> Union(Record(ratpart:F, coeff:F), "failed")
U3 ==> Union(Record(mainpart:F, limitedlogs:LLG), "failed")
ANS ==> Record(special:F, integrand:F)
FAIL==> error "failed - cannot handle that integrand"
Exports ==> with
lfextendedint: (F, SE, F) -> U2
++ lfextendedint(f, x, g) returns functions \spad{[h, c]} such that
++ \spad{dh/dx = f - cg}, if (h, c) exist, "failed" otherwise.
lflimitedint : (F, SE, List F) -> U3
++ lflimitedint(f,x,[g1,...,gn]) returns functions \spad{[h,[[ci, gi]]]}
++ such that the gi's are among \spad{[g1,...,gn]}, and
++ \spad{d(h+sum(ci log(gi)))/dx = f}, if possible, "failed" otherwise.
lfinfieldint : (F, SE) -> Union(F, "failed")
++ lfinfieldint(f, x) returns a function g such that \spad{dg/dx = f}
++ if g exists, "failed" otherwise.
lfintegrate : (F, SE) -> IR
++ lfintegrate(f, x) = g such that \spad{dg/dx = f}.
lfextlimint : (F, SE, K, List K) -> U2
++ lfextlimint(f,x,k,[k1,...,kn]) returns functions \spad{[h, c]}
++ such that \spad{dh/dx = f - c dk/dx}. Value h is looked for in a field
++ containing f and k1,...,kn (the ki's must be logs).
Implementation ==> add
macro ALGOP == '%alg
macro OPDIFF == '%diff
import IntegrationTools(R, F)
import ElementaryRischDE(R, F)
import RationalIntegration(F, UP)
import AlgebraicIntegration(R, F)
import AlgebraicManipulations(R, F)
import ElementaryRischDESystem(R, F)
import TranscendentalIntegration(F, UP)
import PureAlgebraicIntegration(R, F, F)
import IntegrationResultFunctions2(F, F)
import IntegrationResultFunctions2(RF, F)
import FunctionSpacePrimitiveElement(R, F)
import PolynomialCategoryQuotientFunctions(IndexedExponents K,
K, R, P, F)
alglfint : (F, K, List K, SE) -> IR
alglfextint : (F, K, List K, SE, F) -> U2
alglflimint : (F, K, List K, SE, List F) -> U3
primextint : (F, SE, K, F) -> U2
expextint : (F, SE, K, F) -> U2
primlimint : (F, SE, K, List F) -> U3
explimint : (F, SE, K, List F) -> U3
algprimint : (F, K, K, SE) -> IR
algexpint : (F, K, K, SE) -> IR
primint : (F, SE, K) -> IR
expint : (F, SE, K) -> IR
tanint : (F, SE, K) -> IR
prim? : (K, SE) -> Boolean
isx? : (F, SE) -> Boolean
addx : (IR, F) -> IR
cfind : (F, LLG) -> F
lfintegrate0: (F, SE) -> IR
unknownint : (F, SE) -> IR
unkextint : (F, SE, F) -> U2
unklimint : (F, SE, List F) -> U3
tryChangeVar: (F, K, SE) -> Union(IR, "failed")
droponex : (F, F, K, F) -> Union(F, "failed")
prim?(k, x) == is?(k, 'log) or has?(operator k, 'prim)
tanint(f, x, k) ==
eta' := differentiate(eta := first argument k, x)
r1 := tanintegrate(univariate(f, k), differentiate(#1,
differentiate(#1, x), monomial(eta', 2) + eta'::UP),
rischDEsys(#1, 2 * eta, #2, #3, x, lflimitedint(#1, x, #2),
lfextendedint(#1, x, #2)))
map(multivariate(#1, k), r1.answer) + lfintegrate(r1.a0, x)
-- tries various tricks since the integrand contains something not elementary
unknownint(f, x) ==
((r := retractIfCan(f)@Union(K, "failed")) case K) and
is?(k := r::K, OPDIFF) and
((ka:=retractIfCan(a:=second(l:=argument k))@Union(K,"failed"))case K)
and ((z := retractIfCan(zz := third l)@Union(SE, "failed")) case SE)
and (z::SE = x)
and ((u := droponex(first l, a, ka, zz)) case F) => u::F::IR
(da := differentiate(a := denom(f)::F, x)) ~= 0 and
zero? differentiate(c := numer(f)::F / da, x) => (c * log a)::IR
mkAnswer(0, empty(), [[f, x::F]])
droponex(f, a, ka, x) ==
(r := retractIfCan(f)@Union(K, "failed")) case "failed" => "failed"
is?(op := operator(k := r::K), OPDIFF) =>
(z := third(arg := argument k)) = a => op [first arg, second arg, x]
(u := droponex(first arg, a, ka, x)) case "failed" => "failed"
op [u::F, second arg, z]
eval(f, [ka], [x])
unklimint(f, x, lu) ==
for u in lu | u ~= 0 repeat
zero? differentiate(c := f * u / differentiate(u, x), x) => [0,[[c,u]]]
"failed"
unkextint(f, x, g) ==
zero?(g' := differentiate(g, x)) => "failed"
zero? differentiate(c := f / g', x) => [0, c]
"failed"
isx?(f, x) ==
(k := retractIfCan(f)@Union(K, "failed")) case "failed" => false
(r := symbolIfCan(k::K)) case "failed" => false
r::SE = x
alglfint(f, k, l, x) ==
xf := x::F
symbolIfCan(kx := ksec(k,l,x)) case SE => addx(palgint(f, kx, k), xf)
is?(kx, 'exp) => addx(algexpint(f, kx, k, x), xf)
prim?(kx, x) => addx(algprimint(f, kx, k, x), xf)
has?(operator kx, ALGOP) =>
rec := primitiveElement(kx::F, k::F)
y := rootOf(rec.prim)
map(eval(#1, retract(y)@K, rec.primelt),
lfintegrate(eval(f, [kx,k], [(rec.pol1) y, (rec.pol2) y]), x))
unknownint(f, x)
alglfextint(f, k, l, x, g) ==
symbolIfCan(kx := ksec(k,l,x)) case SE => palgextint(f, kx, k, g)
has?(operator kx, ALGOP) =>
rec := primitiveElement(kx::F, k::F)
y := rootOf(rec.prim)
lrhs := [(rec.pol1) y, (rec.pol2) y]$List(F)
(u := lfextendedint(eval(f, [kx, k], lrhs), x,
eval(g, [kx, k], lrhs))) case "failed" => "failed"
ky := retract(y)@K
r := u::Record(ratpart:F, coeff:F)
[eval(r.ratpart,ky,rec.primelt), eval(r.coeff,ky,rec.primelt)]
is?(kx, 'exp) or is?(kx, 'log) => FAIL
unkextint(f, x, g)
alglflimint(f, k, l, x, lu) ==
symbolIfCan(kx := ksec(k,l,x)) case SE => palglimint(f, kx, k, lu)
has?(operator kx, ALGOP) =>
rec := primitiveElement(kx::F, k::F)
y := rootOf(rec.prim)
lrhs := [(rec.pol1) y, (rec.pol2) y]$List(F)
(u := lflimitedint(eval(f, [kx, k], lrhs), x,
map(eval(#1, [kx, k], lrhs), lu))) case "failed" => "failed"
ky := retract(y)@K
r := u::Record(mainpart:F, limitedlogs:LLG)
[eval(r.mainpart, ky, rec.primelt),
[[eval(rc.coeff, ky, rec.primelt),
eval(rc.logand,ky, rec.primelt)] for rc in r.limitedlogs]]
is?(kx, 'exp) or is?(kx, 'log) => FAIL
unklimint(f, x, lu)
if R has Join(ConvertibleTo Pattern Integer, PatternMatchable Integer)
and F has Join(LiouvillianFunctionCategory, RetractableTo SE) then
import PatternMatchIntegration(R, F)
lfintegrate(f, x) == intPatternMatch(f, x, lfintegrate0, pmintegrate)
else lfintegrate(f, x) == lfintegrate0(f, x)
lfintegrate0(f, x) ==
zero? f => 0
xf := x::F
empty?(l := varselect(kernels f, x)) => (xf * f)::IR
symbolIfCan(k := kmax l) case SE =>
map(multivariate(#1, k), integrate univariate(f, k))
is?(k, 'tan) => addx(tanint(f, x, k), xf)
is?(k, 'exp) => addx(expint(f, x, k), xf)
prim?(k, x) => addx(primint(f, x, k), xf)
has?(operator k, ALGOP) => alglfint(f, k, l, x)
unknownint(f, x)
addx(i, x) ==
elem? i => i
mkAnswer(ratpart i, logpart i,
[[ne.integrand, x] for ne in notelem i])
tryChangeVar(f, t, x) ==
z := new()$Symbol
g := subst(f / differentiate(t::F, x), [t], [z::F])
freeOf?(g, x) => -- can we do change of variables?
map(eval(#1, kernel z, t::F), lfintegrate(g, z))
"failed"
algexpint(f, t, y, x) ==
(u := tryChangeVar(f, t, x)) case IR => u::IR
algint(f, t, y, differentiate(#1, differentiate(#1, x),
monomial(differentiate(first argument t, x), 1)))
algprimint(f, t, y, x) ==
(u := tryChangeVar(f, t, x)) case IR => u::IR
algint(f, t, y, differentiate(#1, differentiate(#1, x),
differentiate(t::F, x)::UP))
lfextendedint(f, x, g) ==
empty?(l := varselect(kernels f, x)) => [x::F * f, 0]
symbolIfCan(k := kmax(l))
case SE =>
map(multivariate(#1, k), extendedint(univariate(f, k),
univariate(g, k)))
is?(k, 'exp) => expextint(f, x, k, g)
prim?(k, x) => primextint(f, x, k, g)
has?(operator k, ALGOP) => alglfextint(f, k, l, x, g)
unkextint(f, x, g)
lflimitedint(f, x, lu) ==
empty?(l := varselect(kernels f, x)) => [x::F * f, empty()]
symbolIfCan(k := kmax(l)) case SE =>
map(multivariate(#1, k), limitedint(univariate(f, k),
[univariate(u, k) for u in lu]))
is?(k, 'exp) => explimint(f, x, k, lu)
prim?(k, x) => primlimint(f, x, k, lu)
has?(operator k, ALGOP) => alglflimint(f, k, l, x, lu)
unklimint(f, x, lu)
lfinfieldint(f, x) ==
(u := lfextendedint(f, x, 0)) case "failed" => "failed"
u.ratpart
primextint(f, x, k, g) ==
lk := varselect([a for a in tower f
| k ~= a and is?(a, 'log)], x)
(u1 := primextendedint(univariate(f, k), differentiate(#1,
differentiate(#1, x), differentiate(k::F, x)::UP),
lfextlimint(#1, x, k, lk), univariate(g, k))) case "failed"
=> "failed"
u1 case FF =>
[multivariate(u1.ratpart, k), multivariate(u1.coeff, k)]
(u2 := lfextendedint(u1.a0, x, g)) case "failed" => "failed"
[multivariate(u1.answer, k) + u2.ratpart, u2.coeff]
expextint(f, x, k, g) ==
(u1 := expextendedint(univariate(f, k), differentiate(#1,
differentiate(#1, x),
monomial(differentiate(first argument k, x), 1)),
rischDE(#1, first argument k, #2, x, lflimitedint(#1, x, #2),
lfextendedint(#1, x, #2)), univariate(g, k)))
case "failed" => "failed"
u1 case FF =>
[multivariate(u1.ratpart, k), multivariate(u1.coeff, k)]
(u2 := lfextendedint(u1.a0, x, g)) case "failed" => "failed"
[multivariate(u1.answer, k) + u2.ratpart, u2.coeff]
primint(f, x, k) ==
lk := varselect([a for a in tower f
| k ~= a and is?(a, 'log)], x)
r1 := primintegrate(univariate(f, k), differentiate(#1,
differentiate(#1, x), differentiate(k::F, x)::UP),
lfextlimint(#1, x, k, lk))
map(multivariate(#1, k), r1.answer) + lfintegrate(r1.a0, x)
lfextlimint(f, x, k, lk) ==
not((u1 := lfextendedint(f, x, differentiate(k::F, x)))
case "failed") => u1
twr := tower f
empty?(lg := [kk for kk in lk | not member?(kk, twr)]) => "failed"
is?(k, 'log) =>
(u2 := lflimitedint(f, x,
[first argument u for u in union(lg, [k])])) case "failed"
=> "failed"
cf := cfind(first argument k, u2.limitedlogs)
[u2.mainpart - cf * k::F +
+/[c.coeff * log(c.logand) for c in u2.limitedlogs], cf]
"failed"
cfind(f, l) ==
for u in l repeat
f = u.logand => return u.coeff
0
expint(f, x, k) ==
eta := first argument k
r1 := expintegrate(univariate(f, k), differentiate(#1,
differentiate(#1, x), monomial(differentiate(eta, x), 1)),
rischDE(#1, eta, #2, x, lflimitedint(#1, x, #2),
lfextendedint(#1, x, #2)))
map(multivariate(#1, k), r1.answer) + lfintegrate(r1.a0, x)
primlimint(f, x, k, lu) ==
lk := varselect([a for a in tower f
| k ~= a and is?(a, 'log)], x)
(u1 := primlimitedint(univariate(f, k), differentiate(#1,
differentiate(#1, x), differentiate(k::F, x)::UP),
lfextlimint(#1, x, k, lk), [univariate(u, k) for u in lu]))
case "failed" => "failed"
l := [[multivariate(lg.coeff, k),multivariate(lg.logand, k)]
for lg in u1.answer.limitedlogs]$LLG
(u2 := lflimitedint(u1.a0, x, lu)) case "failed" => "failed"
[multivariate(u1.answer.mainpart, k) + u2.mainpart,
concat(u2.limitedlogs, l)]
explimint(f, x, k, lu) ==
eta := first argument k
(u1 := explimitedint(univariate(f, k), differentiate(#1,
differentiate(#1, x), monomial(differentiate(eta, x), 1)),
rischDE(#1, eta, #2, x,
lflimitedint(#1, x, #2), lfextendedint(#1, x, #2)),
[univariate(u, k) for u in lu])) case "failed" => "failed"
l := [[multivariate(lg.coeff, k),multivariate(lg.logand, k)]
for lg in u1.answer.limitedlogs]$LLG
(u2 := lflimitedint(u1.a0, x, lu)) case "failed" => "failed"
[multivariate(u1.answer.mainpart, k) + u2.mainpart,
concat(u2.limitedlogs, l)]
@
\section{License}
<<license>>=
--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.
@
<<*>>=
<<license>>
-- SPAD files for the integration world should be compiled in the
-- following order:
--
-- intaux rderf intrf curve curvepkg divisor pfo
-- intalg intaf efstruc rdeef intpm INTEF irexpand integrat
<<package INTEF ElementaryIntegration>>
@
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}
|