/usr/share/axiom-20170501/src/algebra/D01WGTS.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 | )abbrev package D01WGTS d01WeightsPackage
++ Author: Brian Dupee
++ Date Created: July 1994
++ Date Last Updated: January 1998
++ Description:
++ \axiom{d01WeightsPackage} is a package for functions used to investigate
++ whether a function can be divided into a simpler function and a weight
++ function. The types of weights investigated are those giving rise to
++ end-point singularities of the algebraico-logarithmic type, and
++ trigonometric weights.
d01WeightsPackage() : SIG == CODE where
LEDF ==> List Expression DoubleFloat
KEDF ==> Kernel Expression DoubleFloat
LKEDF ==> List Kernel Expression DoubleFloat
EDF ==> Expression DoubleFloat
PDF ==> Polynomial DoubleFloat
FI ==> Fraction Integer
LDF ==> List DoubleFloat
DF ==> DoubleFloat
SOCDF ==> Segment OrderedCompletion DoubleFloat
OCDF ==> OrderedCompletion DoubleFloat
NIA ==> Record(var:Symbol,fn:EDF,range:SOCDF,abserr:DF,relerr:DF)
INT ==> Integer
BOP ==> BasicOperator
URBODF ==> Union(Record(op:BasicOperator,w:DF),"failed")
LURBODF ==> List(Union(Record(op:BasicOperator,w:DF), "failed"))
SIG ==> with
exprHasWeightCosWXorSinWX : NIA -> URBODF
++ \axiom{exprHasWeightCosWXorSinWX} looks for trigonometric
++ weights in an expression of the form \axiom{cos \omega x} or
++ \axiom{sin \omega x}, returning the value of \omega
++ (\notequal 1) and the operator.
exprHasAlgebraicWeight : NIA -> Union(LDF,"failed")
++ \axiom{exprHasAlgebraicWeight} looks for algebraic weights
++ giving rise to singularities of the function at the end-points.
exprHasLogarithmicWeights : NIA -> INT
++ \axiom{exprHasLogarithmicWeights} looks for logarithmic weights
++ giving rise to singularities of the function at the end-points.
CODE ==> add
score:(EDF,EDF) -> FI
kernelIsLog:KEDF -> Boolean
functionIsPolynomial?:EDF -> Boolean
functionIsNthRoot?:(EDF,EDF) -> Boolean
functionIsQuotient:EDF -> Union(EDF,"failed")
findCommonFactor:LEDF -> Union(LEDF,"failed")
findAlgebraicWeight:(NIA,EDF) -> Union(DF,"failed")
exprHasListOfWeightsCosWXorSinWX:(EDF,Symbol) -> LURBODF
exprOfFormCosWXorSinWX:(EDF,Symbol) -> URBODF
bestWeight:LURBODF -> URBODF
weightIn?:(URBODF,LURBODF) -> Boolean
inRest?:(EDF,LEDF)->Boolean
factorIn?:(EDF,LEDF)->Boolean
voo?:(EDF,EDF)->Boolean
kernelIsLog(k:KEDF):Boolean ==
(name k = (log :: Symbol))@Boolean
factorIn?(a:EDF,l:LEDF):Boolean ==
for i in 1..# l repeat
(a = l.i)@Boolean => return true
false
voo?(b:EDF,a:EDF):Boolean ==
(voo:=isTimes(b)) case LEDF and factorIn?(a,voo)
inRest?(a:EDF,l:LEDF):Boolean ==
every?(x+->voo?(x,a) ,l)
findCommonFactor(l:LEDF):Union(LEDF,"failed") ==
empty?(l)$LEDF => "failed"
f := first(l)$LEDF
r := rest(l)$LEDF
(t := isTimes(f)$EDF) case LEDF =>
pos:=select(x+->inRest?(x,r),t)
empty?(pos) => "failed"
pos
"failed"
exprIsLogarithmicWeight(f:EDF,Var:EDF,a:EDF,b:EDF):INT ==
ans := 0$INT
k := tower(f)$EDF
lf := select(kernelIsLog,k)$LKEDF
empty?(lf)$LKEDF => ans
for i in 1..# lf repeat
arg := argument lf.i
if (arg.1 = (Var - a)) then
ans := ans + 1
else if (arg.1 = (b - Var)) then
ans := ans + 2
ans
exprHasLogarithmicWeights(args:NIA):INT ==
ans := 1$INT
a := getlo(args.range)$d01AgentsPackage :: EDF
b := gethi(args.range)$d01AgentsPackage :: EDF
Var := args.var :: EDF
(l := isPlus numerator args.fn) case LEDF =>
(cf := findCommonFactor l) case LEDF =>
for j in 1..# cf repeat
ans := ans + exprIsLogarithmicWeight(cf.j,Var,a,b)
ans
ans
ans := ans + exprIsLogarithmicWeight(args.fn,Var,a,b)
functionIsQuotient(expr:EDF):Union(EDF,"failed") ==
(k := mainKernel expr) case KEDF =>
expr = inv(f := k :: KEDF :: EDF)$EDF => f
(numerator expr = 1) => denominator expr
"failed"
"failed"
functionIsPolynomial?(f:EDF):Boolean ==
(retractIfCan(f)@Union(PDF,"failed"))$EDF case PDF
functionIsNthRoot?(f:EDF,e:EDF):Boolean ==
(m := mainKernel f) case "failed" => false
((# (kernels f)) = 1)
and (name operator m = (nthRoot :: Symbol))@Boolean
and (((argument m).1 = e)@Boolean)
score(f:EDF,e:EDF):FI ==
ans := 0$FI
(t := isTimes f) case LEDF =>
for i in 1..# t repeat
ans := ans + score(t.i,e)
ans
(q := functionIsQuotient f) case EDF =>
ans := ans - score(q,e)
functionIsPolynomial? f =>
g:EDF := f/e
if functionIsPolynomial? g then
ans := 1+score(g,e)
else
ans
(l := isPlus f) case LEDF =>
(cf := findCommonFactor l) case LEDF =>
factor := 1$EDF
for i in 1..# cf repeat
factor := factor*cf.i
ans := ans + score(f/factor,e) + score(factor,e)
ans
functionIsNthRoot?(f,e) =>
(p := isPower f) case "failed" => ans
exp := p.exponent
m := mainKernel f
m case KEDF =>
arg := argument m
a:INT := (retract(arg.2)@INT)$EDF
exp / a
ans
ans
findAlgebraicWeight(args:NIA,e:EDF):Union(DF,"failed") ==
zero?(s := score(args.fn,e)) => "failed"
s :: DF
exprHasAlgebraicWeight(args:NIA):Union(LDF,"failed") ==
(f := functionIsContinuousAtEndPoints(args)$d01AgentsPackage)
case continuous =>"failed"
Var := args.var :: EDF
a := getlo(args.range)$d01AgentsPackage :: EDF
b := gethi(args.range)$d01AgentsPackage :: EDF
A := Var - a
B := b - Var
f case lowerSingular =>
(h := findAlgebraicWeight(args,A)) case "failed" => "failed"
[h,0]
f case upperSingular =>
(g := findAlgebraicWeight(args,B)) case "failed" => "failed"
[0,g]
h := findAlgebraicWeight(args,A)
g := findAlgebraicWeight(args,B)
r := (h case "failed")
s := (g case "failed")
(r) and (s) => "failed"
r => [0,coerce(g)@DF]
s => [coerce(h)@DF,0]
[coerce(h)@DF,coerce(g)@DF]
exprOfFormCosWXorSinWX(f:EDF,var:Symbol): URBODF ==
l:LKEDF := kernels(f)$EDF
# l = 1 =>
a:LEDF := argument(e:KEDF := first(l)$LKEDF)$KEDF
empty?(a) => "failed"
m:Union(LEDF,"failed") := isTimes(first(a)$LEDF)$EDF
m case LEDF => -- if it is a list, it will have at least two elements
is?(second(m)$LEDF,var)$EDF =>
omega:DF := retract(first(m)$LEDF)@DF
o:BOP := operator(n:Symbol:=name(e)$KEDF)$BOP
(n = cos@Symbol)@Boolean => [o,omega]
(n = sin@Symbol)@Boolean => [o,omega]
"failed"
"failed"
"failed"
"failed"
exprHasListOfWeightsCosWXorSinWX(f:EDF,var:Symbol): LURBODF ==
(e := isTimes(f)$EDF) case LEDF =>
[exprOfFormCosWXorSinWX(u,var) for u in e]
empty?(k := kernels f) => ["failed"]
((first(k)::EDF) = f) =>
[exprOfFormCosWXorSinWX(f,var)]
["failed"]
bestWeight(l:LURBODF): URBODF ==
empty?(l)$LURBODF => "failed"
best := first(l)$LURBODF -- best is first in list
empty?(rest(l)$LURBODF) => best
for i in 2..# l repeat -- unless next is better
r:URBODF := l.i
if r case "failed" then leave
else if best case "failed" then
best := r
else if r.w > best.w then
best := r
best
weightIn?(weight:URBODF,listOfWeights:LURBODF):Boolean ==
n := # listOfWeights
for i in 1..n repeat -- cycle through list
(weight = listOfWeights.i)@Boolean => return true -- return when found
false
exprHasWeightCosWXorSinWX(args:NIA):URBODF ==
ans := empty()$LURBODF
f:EDF := numerator(args.fn)$EDF
(t:Union(LEDF,"failed") := isPlus(f)) case "failed" =>
bestWeight(exprHasListOfWeightsCosWXorSinWX(f,args.var))
if t case LEDF then
e1 := first(t)$LEDF
le1:LURBODF := exprHasListOfWeightsCosWXorSinWX(e1,args.var)
le1 := [u for u in le1 | (not (u case "failed"))]
empty?(le1)$LURBODF => "failed"
test := true
for i in 1..# le1 repeat
le1i:URBODF := le1.i
for j in 2..# t repeat
if test then
tj:LURBODF := exprHasListOfWeightsCosWXorSinWX(t.j,args.var)
test := weightIn?(le1i,tj)
if test then
ans := concat([le1i],ans)
bestWeight ans
else "failed"
|