/usr/share/axiom-20170501/src/algebra/INTEF.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | )abbrev package INTEF ElementaryIntegration
++ 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
++ elementary functions.
ElementaryIntegration(R, F) : SIG == CODE where
R : Join(GcdDomain, OrderedSet, 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)
PSOL ==> Record(ans:F, right:F, sol?:Boolean)
FAIL ==> error "failed - cannot handle that integrand"
ALGOP ==> "%alg"
OPDIFF ==> "%diff"::SE
SIG ==> 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).
CODE ==> add
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"::SE) or has?(operator k, "prim")
tanint(f, x, k) ==
eta' := differentiate(eta := first argument k, x)
r1 :=
tanintegrate(univariate(f, k),
(x1:UP):UP +-> differentiate(x1,
(x2:F):F +-> differentiate(x2, x),
monomial(eta', 2) + eta'::UP),
(x3:Integer,x4:F,x5:F):Union(List F,"failed") +->
rischDEsys(x3, 2 * eta, x4, x5, x,
(x6:F,x7:List F):U3 +-> lflimitedint(x6, x, x7),
(x8:F,x9:F):U2 +-> lfextendedint(x8, x, x9)))
map((x1:RF):F+->multivariate(x1, 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"::SE) => 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((x1:F):F +-> eval(x1, 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"::SE) or is?(kx, "log"::SE) => 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((x1:F):F+->eval(x1,[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"::SE) or is?(kx, "log"::SE) => 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((x1:RF):F +-> multivariate(x1, k), integrate univariate(f, k))
is?(k, "tan"::SE) => addx(tanint(f, x, k), xf)
is?(k, "exp"::SE) => 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((x1:F):F+->eval(x1, 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,
(x1:UP):UP +-> differentiate(x1,
(x2:F):F +-> differentiate(x2, 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,
(x1:UP):UP +-> differentiate(x1,
(x2:F):F +-> differentiate(x2, 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 =>
g1 :=
empty?(l1 := varselect(kernels g,x)) => 0::F
kmax(l1) = k => g
0::F
map((x1:RF):F +-> multivariate(x1, k),
extendedint(univariate(f, k),
univariate(g1, k)))
is?(k, "exp"::SE) => 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((x1:RF):F +-> multivariate(x1, k),
limitedint(univariate(f, k),
[univariate(u, k) for u in lu]))
is?(k, "exp"::SE) => 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"::SE)], x)
(u1 := primextendedint(univariate(f, k),
(x1:UP):UP +-> differentiate(x1,
(x2:F):F +-> differentiate(x2, x), differentiate(k::F, x)::UP),
(x3:F):U2+->lfextlimint(x3,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),
(x1:UP):UP +-> differentiate(x1,
(x2:F):F +-> differentiate(x2, x),
monomial(differentiate(first argument k, x), 1)),
(x3:Integer,x4:F):PSOL+->rischDE(x3, first argument k, x4, x,
(x5:F,x6:List F):U3 +-> lflimitedint(x5, x, x6),
(x7:F,x8:F):U2+->lfextendedint(x7, x, x8)), 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"::SE)], x)
r1 := primintegrate(univariate(f, k),
(x1:UP):UP +-> differentiate(x1,
(x2:F):F +-> differentiate(x2, x), differentiate(k::F, x)::UP),
(x3:F):U2 +-> lfextlimint(x3, x, k, lk))
map((x1:RF):F+->multivariate(x1, 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"::SE) =>
(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),
(x1:UP):UP +-> differentiate(x1,
(x2:F):F +-> differentiate(x2, x),
monomial(differentiate(eta, x), 1)),
(x3:Integer,x4:F):PSOL+->rischDE(x3, eta, x4, x,
(x5:F,x6:List F):U3 +-> lflimitedint(x5, x, x6),
(x7:F,x8:F):U2+->lfextendedint(x7, x, x8)))
map((x1:RF):F+->multivariate(x1, 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"::SE)], x)
(u1 :=
primlimitedint(univariate(f, k),
(x1:UP):UP+->differentiate(x1,
(x2:F):F+->differentiate(x2, x), differentiate(k::F, x)::UP),
(x3:F):U2+->lfextlimint(x3,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),
(x1:UP):UP+->differentiate(x1,
(x2:F):F+->differentiate(x2,x), monomial(differentiate(eta,x), 1)),
(x3:Integer,x4:F):PSOL+->rischDE(x3, eta, x4, x,
(x5:F,x6:List F):U3+->lflimitedint(x5, x, x6),
(x7:F,x8:F):U2+->lfextendedint(x7, x, x8)),
[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)]
|