/usr/share/axiom-20170501/src/algebra/SOLVERAD.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 | )abbrev package SOLVERAD RadicalSolvePackage
++ Author: P.Gianni
++ Date Created: Summer 1990
++ Date Last Updated: October 1991
++ References:
++ Description:
++ This package tries to find solutions
++ expressed in terms of radicals for systems of equations
++ of rational functions with coefficients in an integral domain R.
RadicalSolvePackage(R) : SIG == CODE where
R : Join(EuclideanDomain, OrderedSet, CharacteristicZero)
PI ==> PositiveInteger
NNI==> NonNegativeInteger
Z ==> Integer
B ==> Boolean
ST ==> String
PR ==> Polynomial R
UP ==> SparseUnivariatePolynomial PR
LA ==> LocalAlgebra(PR, Z, Z)
RF ==> Fraction PR
RE ==> Expression R
EQ ==> Equation
SY ==> Symbol
SU ==> SuchThat(List RE, List Equation RE)
SUP==> SparseUnivariatePolynomial
L ==> List
P ==> Polynomial
SOLVEFOR ==> PolynomialSolveByFormulas(SUP RE, RE)
UPF2 ==> SparseUnivariatePolynomialFunctions2(PR,RE)
SIG ==> with
radicalSolve : (RF,SY) -> L EQ RE
++ radicalSolve(rf,x) finds the solutions expressed in terms of
++ radicals of the equation rf = 0 with respect to the symbol x,
++ where rf is a rational function.
++
++X b:Fraction(Polynomial(Integer)):=(3*x^3+7)/(5*x^2-13)
++X radicalSolve(b,x)
radicalSolve : RF -> L EQ RE
++ radicalSolve(rf) finds the solutions expressed in terms of
++ radicals of the equation rf = 0, where rf is a
++ univariate rational function.
++
++X b:Fraction(Polynomial(Integer)):=(3*x^3+7)/(5*x^2-13)
++X radicalSolve(b)
radicalSolve : (EQ RF,SY) -> L EQ RE
++ radicalSolve(eq,x) finds the solutions expressed in terms of
++ radicals of the equation of rational functions eq
++ with respect to the symbol x.
++
++X b:Fraction(Polynomial(Integer)):=(3*x^3+7)/(5*x^2-13)
++X radicalSolve(b=0,x)
radicalSolve : EQ RF -> L EQ RE
++ radicalSolve(eq) finds the solutions expressed in terms of
++ radicals of the equation of rational functions eq
++ with respect to the unique symbol x appearing in eq.
++
++X b:Fraction(Polynomial(Integer)):=(3*x^3+7)/(5*x^2-13)
++X radicalSolve(b=0)
radicalSolve : (L RF,L SY) -> L L EQ RE
++ radicalSolve(lrf,lvar) finds the solutions expressed in terms of
++ radicals of the system of equations lrf = 0 with
++ respect to the list of symbols lvar,
++ where lrf is a list of rational functions.
++
++X b:Fraction(Polynomial(Integer)):=(3*x^3+7)/(5*x^2-13)
++X c:Fraction(Polynomial(Integer)):=(y^2+4)/(y+1)
++X radicalSolve([b,c],[x,y])
radicalSolve : L RF -> L L EQ RE
++ radicalSolve(lrf) finds the solutions expressed in terms of
++ radicals of the system of equations lrf = 0, where lrf is a
++ system of univariate rational functions.
++
++X b:Fraction(Polynomial(Integer)):=(3*x^3+7)/(5*x^2-13)
++X c:Fraction(Polynomial(Integer)):=(y^2+4)/(y+1)
++X radicalSolve([b,c])
radicalSolve : (L EQ RF,L SY) -> L L EQ RE
++ radicalSolve(leq,lvar) finds the solutions expressed in terms of
++ radicals of the system of equations of rational functions leq
++ with respect to the list of symbols lvar.
++
++X b:Fraction(Polynomial(Integer)):=(3*x^3+7)/(5*x^2-13)
++X c:Fraction(Polynomial(Integer)):=(y^2+4)/(y+1)
++X radicalSolve([b=0,c=0],[x,y])
radicalSolve : L EQ RF -> L L EQ RE
++ radicalSolve(leq) finds the solutions expressed in terms of
++ radicals of the system of equations of rational functions leq
++ with respect to the unique symbol x appearing in leq.
++
++X b:Fraction(Polynomial(Integer)):=(3*x^3+7)/(5*x^2-13)
++X c:Fraction(Polynomial(Integer)):=(y^2+4)/(y+1)
++X radicalSolve([b=0,c=0])
radicalRoots : (RF,SY) -> L RE
++ radicalRoots(rf,x) finds the roots expressed in terms of radicals
++ of the rational function rf with respect to the symbol x.
++
++X b:Fraction(Polynomial(Integer)):=(3*x^3+7)/(5*x^2-13)
++X radicalRoots(b,x)
radicalRoots : (L RF,L SY) -> L L RE
++ radicalRoots(lrf,lvar) finds the roots expressed in terms of
++ radicals of the list of rational functions lrf
++ with respect to the list of symbols lvar.
++
++X b:Fraction(Polynomial(Integer)):=(3*x^3+7)/(5*x^2-13)
++X c:Fraction(Polynomial(Integer)):=(y^2+4)/(y+1)
++X radicalRoots([b,c],[x,y])
contractSolve : (EQ RF,SY) -> SU
++ contractSolve(eq,x) finds the solutions expressed in terms of
++ radicals of the equation of rational functions eq
++ with respect to the symbol x. The result contains new
++ symbols for common subexpressions in order to reduce the
++ size of the output.
++
++X b:Fraction(Polynomial(Integer)):=(3*x^3+7)/(5*x^2-13)
++X contractSolve(b=0,x)
contractSolve : (RF,SY) -> SU
++ contractSolve(rf,x) finds the solutions expressed in terms of
++ radicals of the equation rf = 0 with respect to the symbol x,
++ where rf is a rational function. The result contains new
++ symbols for common subexpressions in order to reduce the
++ size of the output.
++
++X b:Fraction(Polynomial(Integer)):=(3*x^3+7)/(5*x^2-13)
++X contractSolve(b,x)
CODE ==> add
import DegreeReductionPackage(PR, R)
import SOLVEFOR
SideEquations: List EQ RE := []
ContractSoln: B := false
---- Local Function Declarations ----
solveInner:(PR, SY, B) -> SU
linear: UP -> List RE
quadratic: UP -> List RE
cubic: UP -> List RE
quartic: UP -> List RE
rad: PI -> RE
wrap: RE -> RE
New: RE -> RE
makeEq : (List RE,L SY) -> L EQ RE
select : L L RE -> L L RE
isGeneric? : (L PR,L SY) -> Boolean
findGenZeros : (L PR,L SY) -> L L RE
findZeros : (L PR,L SY) -> L L RE
New s ==
s = 0 => 0
S := new()$Symbol ::PR::RF::RE
SideEquations := append([S = s], SideEquations)
S
linear u == [(-coefficient(u,0))::RE /(coefficient(u,1))::RE]
quadratic u == quadratic(map(coerce,u)$UPF2)$SOLVEFOR
cubic u == cubic(map(coerce,u)$UPF2)$SOLVEFOR
quartic u == quartic(map(coerce,u)$UPF2)$SOLVEFOR
rad n == n::Z::RE
wrap s == (ContractSoln => New s; s)
---- Exported Functions ----
-- find the zeros of components in "generic" position --
findGenZeros(rlp:L PR,rlv:L SY) : L L RE ==
pp:=rlp.first
v:=first rlv
rlv:=rest rlv
res:L L RE:=[]
res:=append([reverse cons(r,[eval(
(-coefficient(univariate(p,vv),0)::RE)/
(leadingCoefficient univariate(p,vv))::RE,
kernel(v)@Kernel(RE),r) for vv in rlv for p in rlp.rest])
for r in radicalRoots(pp::RF,v)],res)
res
findZeros(rlp:L PR,rlv:L SY) : L L RE ==
parRes:=[radicalRoots(p::RF,v) for p in rlp for v in rlv]
parRes:=select parRes
res:L L RE :=[]
res1:L RE
for par in parRes repeat
res1:=[par.first]
lv1:L Kernel(RE):=[kernel rlv.first]
rlv1:=rlv.rest
p1:=par.rest
while p1^=[] repeat
res1:=cons(eval(p1.first,lv1,res1),res1)
p1:=p1.rest
lv1:=cons(kernel rlv1.first,lv1)
rlv1:=rlv1.rest
res:=cons(res1,res)
res
radicalSolve(pol:RF,v:SY) ==
[equation(v::RE,r) for r in radicalRoots(pol,v)]
radicalSolve(p:RF) ==
zero? p =>
error "equation is always satisfied"
lv:=removeDuplicates
concat(variables numer p, variables denom p)
empty? lv => error "inconsistent equation"
#lv>1 => error "too many variables"
radicalSolve(p,lv.first)
radicalSolve(eq: EQ RF) ==
radicalSolve(lhs eq -rhs eq)
radicalSolve(eq: EQ RF,v:SY) ==
radicalSolve(lhs eq - rhs eq,v)
radicalRoots(lp: L RF,lv: L SY) ==
parRes:=triangularSystems(lp,lv)$SystemSolvePackage(R)
parRes= list [] => []
-- select the components in "generic" form
rlv:=reverse lv
rpRes:=[reverse res for res in parRes]
listGen:= [res for res in rpRes|isGeneric?(res,rlv)]
result:L L RE:=[]
if listGen^=[] then
result:="append"/[findGenZeros(res,rlv) for res in listGen]
for res in listGen repeat
rpRes:=delete(rpRes,position(res,rpRes))
-- non-generic components
rpRes = [] => result
append("append"/[findZeros(res,rlv) for res in rpRes],
result)
radicalSolve(lp:L RF,lv:L SY) ==
[makeEq(lres,lv) for lres in radicalRoots(lp,lv)]
radicalSolve(lp: L RF) ==
lv:="setUnion"/[setUnion(variables numer p,variables denom p)
for p in lp]
[makeEq(lres,lv) for lres in radicalRoots(lp,lv)]
radicalSolve(le:L EQ RF,lv:L SY) ==
lp:=[rhs p -lhs p for p in le]
[makeEq(lres,lv) for lres in radicalRoots(lp,lv)]
radicalSolve(le: L EQ RF) ==
lp:=[rhs p -lhs p for p in le]
lv:="setUnion"/[setUnion(variables numer p,variables denom p)
for p in lp]
[makeEq(lres,lv) for lres in radicalRoots(lp,lv)]
contractSolve(eq:EQ RF, v:SY)==
solveInner(numer(lhs eq - rhs eq), v, true)
contractSolve(pq:RF, v:SY) == solveInner(numer pq, v, true)
radicalRoots(pq:RF, v:SY) == lhs solveInner(numer pq, v, false)
-- test if the ideal is radical in generic position --
isGeneric?(rlp:L PR,rlv:L SY) : Boolean ==
"and"/[degree(f,x)=1 for f in rest rlp for x in rest rlv]
---- select the univariate factors
select(lp:L L RE) : L L RE ==
lp=[] => list []
[:[cons(f,lsel) for lsel in select lp.rest] for f in lp.first]
---- Local Functions ----
-- construct the equation
makeEq(nres:L RE,lv:L SY) : L EQ RE ==
[equation(x :: RE,r) for x in lv for r in nres]
solveInner(pq:PR,v:SY,contractFlag:B) ==
SideEquations := []
ContractSoln := contractFlag
factors:= factors
(factor pq)$MultivariateFactorize(SY,IndexedExponents SY,R,PR)
constants: List PR := []
unsolved: List PR := []
solutions: List RE := []
for f in factors repeat
ff:=f.factor
^ member?(v, variables (ff)) =>
constants := cons(ff, constants)
u := univariate(ff, v)
t := reduce u
u := t.pol
n := degree u
l: List RE :=
n = 1 => linear u
n = 2 => quadratic u
n = 3 => cubic u
n = 4 => quartic u
unsolved := cons(ff, unsolved)
[]
for s in l repeat
if t.deg > 1 then s := wrap s
T0 := expand(s, t.deg)
for i in 1..f.exponent repeat
solutions := append(T0, solutions)
re := SideEquations
[solutions, SideEquations]$SU
|