/usr/share/axiom-20170501/src/algebra/ESCONT.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 | )abbrev package ESCONT ExpertSystemContinuityPackage
++ Author: Brian Dupee
++ Date Created: May 1994
++ Date Last Updated: June 1995
++ Description:
++ ExpertSystemContinuityPackage is a package of functions for the use of
++ domains belonging to the category \axiomType{NumericalIntegration}.
ExpertSystemContinuityPackage() : SIG == CODE where
EF2 ==> ExpressionFunctions2
FI ==> Fraction Integer
EFI ==> Expression Fraction Integer
PFI ==> Polynomial Fraction Integer
DF ==> DoubleFloat
LDF ==> List DoubleFloat
EDF ==> Expression DoubleFloat
VEDF ==> Vector Expression DoubleFloat
SDF ==> Stream DoubleFloat
SS ==> Stream String
EEDF ==> Equation Expression DoubleFloat
LEDF ==> List Expression DoubleFloat
KEDF ==> Kernel Expression DoubleFloat
LKEDF ==> List Kernel Expression DoubleFloat
PDF ==> Polynomial DoubleFloat
FPDF ==> Fraction Polynomial DoubleFloat
OCDF ==> OrderedCompletion DoubleFloat
SOCDF ==> Segment OrderedCompletion DoubleFloat
NIA ==> Record(var:Symbol,fn:EDF,range:SOCDF,abserr:DF,relerr:DF)
UP ==> UnivariatePolynomial
BO ==> BasicOperator
RS ==> Record(zeros: SDF,ones: SDF,singularities: SDF)
SIG ==> with
getlo : SOCDF -> DF
++ getlo(u) gets the \axiomType{DoubleFloat} equivalent of
++ the first endpoint of the range \axiom{u}
gethi : SOCDF -> DF
++ gethi(u) gets the \axiomType{DoubleFloat} equivalent of
++ the second endpoint of the range \axiom{u}
functionIsFracPolynomial? : NIA -> Boolean
++ functionIsFracPolynomial?(args) tests whether the function
++ can be retracted to \axiomType{Fraction(Polynomial(DoubleFloat))}
problemPoints : (EDF,Symbol,SOCDF) -> List DF
++ problemPoints(f,var,range) returns a list of possible problem points
++ by looking at the zeros of the denominator of the function \spad{f}
++ if it can be retracted to \axiomType{Polynomial(DoubleFloat)}.
zerosOf : (EDF,List Symbol,SOCDF) -> SDF
++ zerosOf(e,vars,range) returns a list of points
++ (\axiomType{Doublefloat}) at which a NAG fortran version of \spad{e}
++ will most likely produce an error.
singularitiesOf : (EDF,List Symbol,SOCDF) -> SDF
++ singularitiesOf(e,vars,range) returns a list of points
++ (\axiomType{Doublefloat}) at which a NAG fortran
++ version of \spad{e} will most likely produce
++ an error. This includes those points which evaluate to 0/0.
singularitiesOf : (Vector EDF,List Symbol,SOCDF) -> SDF
++ singularitiesOf(v,vars,range) returns a list of points
++ (\axiomType{Doublefloat}) at which a NAG fortran
++ version of \spad{v} will most likely produce
++ an error. This includes those points which evaluate to 0/0.
polynomialZeros : (PFI,Symbol,SOCDF) -> LDF
++ polynomialZeros(fn,var,range) calculates the real zeros of the
++ polynomial which are contained in the given interval. It returns
++ a list of points (\axiomType{Doublefloat}) for which the univariate
++ polynomial \spad{fn} is zero.
df2st : DF -> String
++ df2st(n) coerces a \axiomType{DoubleFloat} to \axiomType{String}
ldf2lst : LDF -> List String
++ ldf2lst(ln) coerces a List of \axiomType{DoubleFloat} to
++ \axiomType{List}(\axiomType{String})
sdf2lst : SDF -> List String
++ sdf2lst(ln) coerces a Stream of \axiomType{DoubleFloat} to
++ \axiomType{List}(\axiomType{String})
CODE ==> ExpertSystemToolsPackage add
import ExpertSystemToolsPackage
functionIsPolynomial?(args:NIA):Boolean ==
-- tests whether the function can be retracted to a polynomial
(retractIfCan(args.fn)@Union(PDF,"failed"))$EDF case PDF
isPolynomial?(f:EDF):Boolean ==
-- tests whether the function can be retracted to a polynomial
(retractIfCan(f)@Union(PDF,"failed"))$EDF case PDF
isConstant?(f:EDF):Boolean ==
-- tests whether the fn can be retracted to a constant (DoubleFloat)
(retractIfCan(f)@Union(DF,"failed"))$EDF case DF
denominatorIsPolynomial?(args:NIA):Boolean ==
-- tests if the denominator can be retracted to polynomial
a:= copy args
a.fn:=denominator(args.fn)
(functionIsPolynomial?(a))@Boolean
denIsPolynomial?(f:EDF):Boolean ==
-- tests if the denominator can be retracted to polynomial
(isPolynomial?(denominator f))@Boolean
listInRange(l:LDF,range:SOCDF):LDF ==
-- returns a list with only those elements internal to the range range
[t for t in l | in?(t,range)]
loseUntil(l:SDF,a:DF):SDF ==
empty?(l)$SDF => l
f := first(l)$SDF
(abs(f) <= abs(a)) => loseUntil(rest(l)$SDF,a)
l
retainUntil(l:SDF,a:DF,b:DF,flag:Boolean):SDF ==
empty?(l)$SDF => l
f := first(l)$SDF
(in?(f)$ExpertSystemContinuityPackage1(a,b)) =>
concat(f,retainUntil(rest(l),a,b,false))
flag => empty()$SDF
retainUntil(rest(l),a,b,true)
streamInRange(l:SDF,range:SOCDF):SDF ==
-- returns a stream with only those elements internal to the range range
a := getlo(range := dfRange(range))
b := gethi(range)
explicitlyFinite?(l) =>
select(in?$ExpertSystemContinuityPackage1(a,b),l)$SDF
negative?(a*b) => retainUntil(l,a,b,false)
negative?(a) =>
l := loseUntil(l,b)
retainUntil(l,a,b,false)
l := loseUntil(l,a)
retainUntil(l,a,b,false)
getStream(n:Symbol,s:String):SDF ==
import RS
entry?(n,bfKeys()$BasicFunctions)$(List(Symbol)) =>
c := bfEntry(n)$BasicFunctions
(s = "zeros")@Boolean => c.zeros
(s = "singularities")@Boolean => c.singularities
(s = "ones")@Boolean => c.ones
empty()$SDF
polynomialZeros(fn:PFI,var:Symbol,range:SOCDF):LDF ==
up := unmakeSUP(univariate(fn)$PFI)$UP(var,FI)
range := dfRange(range)
r:Record(left:FI,right:FI) := [df2fi(getlo(range)), df2fi(gethi(range))]
ans:List(Record(left:FI,right:FI)) :=
realZeros(up,r,1/1000000000000000000)$RealZeroPackageQ(UP(var,FI))
listInRange(dflist(ans),range)
functionIsFracPolynomial?(args:NIA):Boolean ==
-- tests whether the function can be retracted to a fraction
-- where both numerator and denominator are polynomial
(retractIfCan(args.fn)@Union(FPDF,"failed"))$EDF case FPDF
problemPoints(f:EDF,var:Symbol,range:SOCDF):LDF ==
(denIsPolynomial?(f))@Boolean =>
c := retract(edf2efi(denominator(f)))@PFI
polynomialZeros(c,var,range)
empty()$LDF
zerosOf(e:EDF,vars:List Symbol,range:SOCDF):SDF ==
(u := isQuotient(e)) case EDF =>
singularitiesOf(u,vars,range)
k := kernels(e)$EDF
((nk := # k) = 0)@Boolean => empty()$SDF -- constant found.
(nk = 1)@Boolean => -- single expression found.
ker := first(k)$LKEDF
n := name(operator(ker)$KEDF)$BO
entry?(n,vars) => -- polynomial found.
c := retract(edf2efi(e))@PFI
coerce(polynomialZeros(c,n,range))$SDF
a := first(argument(ker)$KEDF)$LEDF
(not (n = log :: Symbol)@Boolean) and ((w := isPlus a) case LEDF) =>
var:Symbol := first(variables(a))
c:EDF := w.2
c1:EDF := w.1
entry?(c1,[b::EDF for b in vars]) and ((# vars) = 1) =>
c2:DF := edf2df c
c3 := c2 :: OCDF
varEdf := var :: EDF
varEqn := equation(varEdf,c1-c)$EEDF
range2 := (lo(range)+c3)..(hi(range)+c3)
s := zerosOf(subst(e,varEqn)$EDF,vars,range2)
st := map(t1 +-> t1-c2,s)$StreamFunctions2(DF,DF)
streamInRange(st,range)
zerosOf(a,vars,range)
(t := isPlus(e)$EDF) case LEDF => -- constant + expression
# t > 2 => empty()$SDF
entry?(a,[b::EDF for b in vars]) => -- finds entries like sqrt(x)
st := getStream(n,"ones")
o := edf2df(second(t)$LEDF)
(o = 1) or (-o = 1) => -- is it like (f(x) -/+ 1)
st := map(t2 +-> -t2/o,st)$StreamFunctions2(DF,DF)
streamInRange(st,range)
empty()$SDF
empty()$SDF
entry?(a,[b::EDF for b in vars]) => -- finds entries like sqrt(x)
st := getStream(n,"zeros")
streamInRange(st,range)
(n = tan :: Symbol)@Boolean =>
concat([zerosOf(a,vars,range),singularitiesOf(a,vars,range)])
(n = sin :: Symbol)@Boolean =>
concat([zerosOf(a,vars,range),singularitiesOf(a,vars,range)])
empty()$SDF
(t := isPlus(e)$EDF) case LEDF => empty()$SDF -- INCOMPLETE!!!
(v := isTimes(e)$EDF) case LEDF =>
concat([zerosOf(u,vars,range) for u in v])
empty()$SDF
singularitiesOf(e:EDF,vars:List Symbol,range:SOCDF):SDF ==
(u := isQuotient(e)) case EDF =>
zerosOf(u,vars,range)
(t := isPlus e) case LEDF =>
concat([singularitiesOf(u,vars,range) for u in t])
(v := isTimes e) case LEDF =>
concat([singularitiesOf(u,vars,range) for u in v])
(k := mainKernel e) case KEDF =>
n := name(operator k)
entry?(n,vars) => coerce(problemPoints(e,n,range))$SDF
a:EDF := (argument k).1
(not (n = log :: Symbol)@Boolean) and ((w := isPlus a) case LEDF) =>
var:Symbol := first(variables(a))
c:EDF := w.2
c1:EDF := w.1
entry?(c1,[b::EDF for b in vars]) and ((# vars) = 1) =>
c2:DF := edf2df c
c3 := c2 :: OCDF
varEdf := var :: EDF
varEqn := equation(varEdf,c1-c)$EEDF
range2 := (lo(range)+c3)..(hi(range)+c3)
s := singularitiesOf(subst(e,varEqn)$EDF,vars,range2)
st := map(t3 +-> t3-c2,s)$StreamFunctions2(DF,DF)
streamInRange(st,range)
singularitiesOf(a,vars,range)
entry?(a,[b::EDF for b in vars]) =>
st := getStream(n,"singularities")
streamInRange(st,range)
(n = log :: Symbol)@Boolean =>
concat([zerosOf(a,vars,range),singularitiesOf(a,vars,range)])
singularitiesOf(a,vars,range)
empty()$SDF
singularitiesOf(v:VEDF,vars:List Symbol,range:SOCDF):SDF ==
ls := [singularitiesOf(u,vars,range) for u in entries(v)$VEDF]
concat(ls)$SDF
|