Fri Dec 12 05:09:29 MET 1997 anne % axiom Axiom Computer Algebra System (Release 2.1) Digital Unix on DEC Alpha (AXIOM Sockets) The AXIOM server number is undefined. ----------------------------------------------------------------------------- Issue )copyright to view copyright notices. Issue )summary for a summary of useful system commands. Issue )quit to leave AXIOM and return to shell. ----------------------------------------------------------------------------- initial (1) -> -- ----------[ A x i o m ]---------- -- ---------- Initialization ---------- )set messages autoload off )set messages time on )set quit unprotected -- ---------- Numerical Analysis ---------- -- This number should immediately simplify to 0.0 0.0/sqrt(2) (1) 0.0 Type: Expression Float Time: 0.40 (IN) + 0.20 (EV) + 0.22 (OT) + 0.18 (GC) = 1.0 sec -- This number normally produces an underflow => 3.29683e-434295 exp(-1000000.0) (2) 0.3296831478 088558579 E -434294 Type: Float Time: 0.02 (IN) + 0.02 (OT) = 0.03 sec -- Arbitrary precision floating point numbers digits(50); Type: PositiveInteger Time: 0.02 (IN) = 0.02 sec -- This number is nearly an integer: -- 26253741 2640768743.9999999999 9925007259 7198185688 ... exp(sqrt(163.)*%pi) (4) 26253741 2640768743.9999999999 9925007259 7198185688 9 Type: Float Time: 0.20 (IN) + 0.03 (OT) + 0.03 (GC) = 0.27 sec digits(20); Type: PositiveInteger Time: 0 sec -- => [-2, -1] [floor(-5/3), ceiling(-5/3)] (6) [- 2,- 1] Type: List Integer Time: 0.02 (IN) + 0.02 (OT) = 0.03 sec -- Generate a cubic natural spline s from x = [1, 2, 4, 5] and y = [1, 4, 2, 3] -- and then compute s(3) => 27/8 [[1, 2, 4, 5], [1, 4, 2, 3]] (7) [[1,2,4,5],[1,4,2,3]] Type: List List PositiveInteger Time: 0.02 (OT) = 0.02 sec -- Translation a:= operator('a); Type: BasicOperator Time: 0.05 (IN) + 0.02 (OT) = 0.07 sec p:= sum(a(i)*x**i, i = 1..n) n --+ i (9) > a(i)x --+ i= 1 Type: Expression Integer Time: 0.77 (IN) + 0.68 (EV) + 0.15 (OT) + 0.07 (GC) = 1.67 sec -- Convert into FORTRAN syntax outputAsFortran('p = p) >> Fortran translation error: No corresponding Fortran structure for: n --+ i > a(i)x --+ i= 1 Type: Void Time: 0.27 (IN) + 0.03 (EV) + 0.05 (OT) = 0.35 sec -- Convert into C syntax -- Horner's rule---this is important for numerical algorithms -- => (a[1] + (a[2] + (a[3] + (a[4] + a[5] x) x) x) x) x p:= sum(a(i)*x**i, i = 1..5) 5 4 3 2 (11) a(5)x + a(4)x + a(3)x + a(2)x + a(1)x Type: Expression Integer Time: 0.07 (IN) + 0.22 (EV) + 0.03 (OT) = 0.32 sec factor(p) 5 4 3 2 (12) a(5)x + a(4)x + a(3)x + a(2)x + a(1)x Type: Factored Expression Integer Time: 0.02 (EV) + 0.02 (OT) = 0.03 sec p:= p :: MPOLY([x], Expression Integer) 5 4 3 2 (13) a(5)x + a(4)x + a(3)x + a(2)x + a(1)x Type: MultivariatePolynomial([x],Expression Integer) Time: 0.07 (IN) + 0.03 (OT) + 0.02 (GC) = 0.12 sec p:= factor(p) WARNING (genufact): No known algorithm to factor 4 a(4) 3 a(3) 2 a(2) a(1) ? + ---- ? + ---- ? + ---- ? + ----, trying square-free. a(5) a(5) a(5) a(5) 4 a(4) 3 a(3) 2 a(2) a(1) (14) a(5)x(x + ---- x + ---- x + ---- x + ----) a(5) a(5) a(5) a(5) Type: Factored MultivariatePolynomial([x],Expression Integer) Time: 0.08 (IN) + 0.32 (EV) + 0.02 (OT) + 0.05 (GC) = 0.47 sec -- Convert the result into FORTRAN syntax -- => p = (a(1) + (a(2) + (a(3) + (a(4) + a(5)*x)*x)*x)*x)*x )set fortran ints2floats off outputAsFortran('p = p) p=a(5)*x*(x**4+(a(4)/a(5))*x**3+(a(3)/a(5))*x*x+(a(2)/a(5))*x+a(1) &/a(5)) Type: Void Time: 0.48 (IN) + 0.03 (EV) + 0.12 (OT) = 0.63 sec )clear properties a p -- Convert the result into C syntax -- => p = (a[1] + (a[2] + (a[3] + (a[4] + a[5]*x)*x)*x)*x)*x ; -- Count the number of (floating point) operations needed to compute an -- expression => {[+, n - 1], [*, (n^2 - n)/2], [f, (n^2 + n)/2]} f:= operator('f); Type: BasicOperator Time: 0.03 (IN) = 0.03 sec sum(product(f(i, k), i = 1..k), k = 1..n) n k --+ ++-++ (17) > | | f(i,i) --+ | | k= 1 i= 1 Type: Expression Integer Time: 0.13 (IN) + 0.10 (EV) + 0.05 (OT) = 0.28 sec -- Interval analysis (interval polynomial example): -- ([-4, 2] x + [1, 3])^2 => [-8, 16] x^2 + [-24, 12] x + [1, 9] -- Discretize a PDE: for example, forward differencing time (explicit Euler) -- and central differencing x on the heat equation => -- (f[i, j+1] - f[i, j])/dt = (f[i+1, j] - 2 f[i, j] + f[i-1, j])/dx^2 D(f(x, t), t) = D(f(x, t), x, 2) (18) f (x,t)= f (x,t) ,2 ,1,1 Type: Equation Expression Integer Time: 0.08 (IN) + 0.07 (EV) + 0.03 (OT) = 0.18 sec )clear properties f -- ---------- Quit ---------- )quit real 7.1 user 6.2 sys 0.4