/usr/share/axiom-20170501/src/algebra/TRIGMNIP.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 | )abbrev package TRIGMNIP TrigonometricManipulations
++ Author: Manuel Bronstein
++ Date Created: 4 April 1988
++ Date Last Updated: 14 February 1994
++ Description:
++ \spadtype{TrigonometricManipulations} provides transformations from
++ trigonometric functions to complex exponentials and logarithms, and back.
TrigonometricManipulations(R, F) : SIG == CODE where
R : Join(GcdDomain, OrderedSet, RetractableTo Integer,
LinearlyExplicitRingOver Integer)
F : Join(AlgebraicallyClosedField, TranscendentalFunctionCategory,
FunctionSpace R)
Z ==> Integer
SY ==> Symbol
K ==> Kernel F
FG ==> Expression Complex R
SIG ==> with
complexNormalize : F -> F
++ complexNormalize(f) rewrites \spad{f} using the least possible number
++ of complex independent kernels.
complexNormalize : (F, SY) -> F
++ complexNormalize(f, x) rewrites \spad{f} using the least possible
++ number of complex independent kernels involving \spad{x}.
complexElementary : F -> F
++ complexElementary(f) rewrites \spad{f} in terms of the 2 fundamental
++ complex transcendental elementary functions: \spad{log, exp}.
complexElementary : (F, SY) -> F
++ complexElementary(f, x) rewrites the kernels of \spad{f} involving
++ \spad{x} in terms of the 2 fundamental complex
++ transcendental elementary functions: \spad{log, exp}.
trigs : F -> F
++ trigs(f) rewrites all the complex logs and exponentials
++ appearing in \spad{f} in terms of trigonometric functions.
real : F -> F
++ real(f) returns the real part of \spad{f} where \spad{f} is a complex
++ function.
imag : F -> F
++ imag(f) returns the imaginary part of \spad{f} where \spad{f}
++ is a complex function.
real? : F -> Boolean
++ real?(f) returns \spad{true} if \spad{f = real f}.
complexForm : F -> Complex F
++ complexForm(f) returns \spad{[real f, imag f]}.
CODE ==> add
import ElementaryFunctionSign(R, F)
import InnerTrigonometricManipulations(R,F,FG)
import ElementaryFunctionStructurePackage(R, F)
import ElementaryFunctionStructurePackage(Complex R, FG)
s1 := sqrt(-1::F)
ipi := pi()$F * s1
K2KG : K -> Kernel FG
kcomplex : K -> Union(F, "failed")
locexplogs : F -> FG
localexplogs : (F, F, List SY) -> FG
complexKernels: F -> Record(ker: List K, val: List F)
K2KG k == retract(tan F2FG first argument k)@Kernel(FG)
real? f == empty?(complexKernels(f).ker)
real f == real complexForm f
imag f == imag complexForm f
-- returns [[k1,...,kn], [v1,...,vn]] such that ki should be replaced by vi
complexKernels f ==
lk:List(K) := empty()
lv:List(F) := empty()
for k in tower f repeat
if (u := kcomplex k) case F then
lk := concat(k, lk)
lv := concat(u::F, lv)
[lk, lv]
-- returns f if it is certain that k is not a real kernel and k = f,
-- "failed" otherwise
kcomplex k ==
op := operator k
is?(k, "nthRoot"::SY) =>
arg := argument k
even?(retract(n := second arg)@Z) and ((u := sign(first arg)) case Z)
and (u::Z < 0) => op(s1, n / 2::F) * op(- first arg, n)
"failed"
is?(k, "log"::SY) and ((u := sign(a := first argument k)) case Z)
and (u::Z < 0) => op(- a) + ipi
"failed"
complexForm f ==
empty?((l := complexKernels f).ker) => complex(f, 0)
explogs2trigs locexplogs eval(f, l.ker, l.val)
locexplogs f ==
any?(x +-> has?(x, "rtrig"),
operators(g := realElementary f))$List(BasicOperator) =>
localexplogs(f, g, variables g)
F2FG g
complexNormalize(f, x) ==
any?(y +-> has?(operator y, "rtrig"),
[k for k in tower(g := realElementary(f, x))
| member?(x, variables(k::F))]$List(K))$List(K) =>
FG2F(rischNormalize(localexplogs(f, g, [x]), x).func)
rischNormalize(g, x).func
complexNormalize f ==
l := variables(g := realElementary f)
any?(x +-> has?(x, "rtrig"), operators g)$List(BasicOperator) =>
h := localexplogs(f, g, l)
for x in l repeat h := rischNormalize(h, x).func
FG2F h
for x in l repeat g := rischNormalize(g, x).func
g
complexElementary(f, x) ==
any?(y +-> has?(operator y, "rtrig"),
[k for k in tower(g := realElementary(f, x))
| member?(x, variables(k::F))]$List(K))$List(K) =>
FG2F localexplogs(f, g, [x])
g
complexElementary f ==
any?(x +-> has?(x, "rtrig"),
operators(g := realElementary f))$List(BasicOperator) =>
FG2F localexplogs(f, g, variables g)
g
localexplogs(f, g, lx) ==
trigs2explogs(F2FG g, [K2KG k for k in tower f
| is?(k, "tan"::SY) or is?(k, "cot"::SY)], lx)
trigs f ==
real? f => f
g := explogs2trigs F2FG f
real g + s1 * imag g
|