/usr/share/axiom-20170501/src/algebra/HACKPI.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 | )abbrev domain HACKPI Pi
++ Author: Manuel Bronstein
++ Date Created: 21 Feb 1990
++ Date Last Updated: 12 Mai 1992
++ Description:
++ Symbolic fractions in %pi with integer coefficients;
++ The point for using Pi as the default domain for those fractions
++ is that Pi is coercible to the float types, and not Expression.
Pi() : SIG == CODE where
PZ ==> Polynomial Integer
UP ==> SparseUnivariatePolynomial Integer
RF ==> Fraction UP
SIG ==> Join(Field, CharacteristicZero, RetractableTo Integer,
RetractableTo Fraction Integer, RealConstant,
CoercibleTo DoubleFloat, CoercibleTo Float,
ConvertibleTo RF, ConvertibleTo InputForm) with
pi: () -> %
++ pi() returns the symbolic %pi.
CODE ==> RF add
Rep := RF
sympi := "%pi"::Symbol
p2sf: UP -> DoubleFloat
p2f : UP -> Float
p2o : UP -> OutputForm
p2i : UP -> InputForm
p2p: UP -> PZ
pi() == (monomial(1, 1)$UP :: RF) pretend %
convert(x:%):RF == x pretend RF
convert(x:%):Float == x::Float
convert(x:%):DoubleFloat == x::DoubleFloat
coerce(x:%):DoubleFloat == p2sf(numer x) / p2sf(denom x)
coerce(x:%):Float == p2f(numer x) / p2f(denom x)
p2o p == outputForm(p, sympi::OutputForm)
p2i p == convert p2p p
p2p p ==
ans:PZ := 0
while p ^= 0 repeat
ans := ans + monomial(leadingCoefficient(p)::PZ, sympi, degree p)
p := reductum p
ans
coerce(x:%):OutputForm ==
(r := retractIfCan(x)@Union(UP, "failed")) case UP => p2o(r::UP)
p2o(numer x) / p2o(denom x)
convert(x:%):InputForm ==
(r := retractIfCan(x)@Union(UP, "failed")) case UP => p2i(r::UP)
p2i(numer x) / p2i(denom x)
p2sf p ==
map((x:Integer):DoubleFloat+->x::DoubleFloat, p)_
$SparseUnivariatePolynomialFunctions2(Integer, DoubleFloat)
(pi()$DoubleFloat)
p2f p ==
map((x:Integer):Float+->x::Float,p)_
$SparseUnivariatePolynomialFunctions2(Integer, Float)
(pi()$Float)
|