axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] Questions


From: m.rubey
Subject: [Axiom-developer] Questions
Date: Mon, 17 May 2004 11:40:29 +0200 (CEST)

I'm trying to port Christian Krattenthaler's Mathematica program rate (= 
german for "guess!"), which guesses formulas for sequences of numbers 
given the first few terms, however, I failed somehow. 

Here are my questions, which proved to be obstacles: (I tried to be as 
concise as possible)

--------------------- first obstacle ------------------------


it seems that I need an own version of product:

(1) -> f == n +-> product(product(i,i=1..j),j=1..n)
                                                                   Type: 
Void
(2) -> f(n)

          n      j
        ++-++  ++-++
   (2)   | |    | |   i
         | |    | |
        j= 1   i= 1
                                                     Type: Expression 
Integer
(3) -> f(3)
   Loading /home/rubey/axiom/mnt/linux/algebra/PI.o for domain 
      PositiveInteger 
   Compiling function f with type PositiveInteger -> Expression Integer
      
 
   >> Error detected within library code:
   not a kernel

protected-symbol-warn called with (NIL)

Note that I would want my program to spit out a sum as in (2), but 
certainly I would want it to be evaluable.

Furthermore, I'm having a problem spitting out something like

product(x^i,i=1..n)

where x is a fractional polynomial over PF 2, for example... What's the
type of this thing, EXPR PF 2 does not work, of course. I cannot simply
take EXPR INT, since my factors can be functions from INT into any
(infinite) field.

I tried 

 g(i:INT):FRAC UP(x,PF 2) == x^i+1

however, this does not work, of course:

f(n:INT):FRAC UP(x,PF 2) == product(g(i),i=1..n)

a little better is

 f(n:INT):FRAC UP(x,PF 2) == reduce(*,[g(i) for i in 1..n])

in which case I don't get f(n) for symbolic n however...

In fact, it seems to me that I'd need a EXPR domain which does not need 
OrderedSet...

Any ideas?

----------------------------------------------------------------
--------------------- second question --------------------------

why don't these functions compile ???

Tst(xx, F): Exports == Implementation  where
    xx: Symbol
    F: Field 
    UP  ==> UnivariatePolynomial

    Exports == with
          tst: (UP(xx, F)) -> Polynomial F

    Implementation == add
          tst(poly) == poly::Polynomial F

-- ((|::| |poly| (|Polynomial| F)))
-- ****** level 1  ******
-- $x:= (:: poly (Polynomial F))
-- $m:= (Polynomial F)
-- $f:=
-- ((((|poly| # #) (|$Information| #) (~= # # #) (= # # #) ...)))
--  
--    >> Apparent user error:
--    Cannot coerce poly 
--       of mode (UnivariatePolynomial xx F) 
--       to mode (Polynomial F)

Tst1(xx, F): Exports == Implementation  where
    xx: Symbol
    F: Field 
    UP  ==> UnivariatePolynomial

    Exports == with
          tst: () -> UP(xx, F)

    Implementation == add
          tst() ==
            xy: UP(xx, F) := monomial(1,1)$UP(xx, F)

            (1+xy*xy) 
-- works

Tst2(xx, F): Exports == Implementation  where
    xx: Symbol
    F: Field 
    UP  ==> UnivariatePolynomial

    Exports == with
          tst: () -> UP(xx, F)

    Implementation == add
          tst() == (1+xy^2)

-- (+ 1 (IF | << xy >> | |false| |true|))
-- ****** level 3  ******
-- $x:= xy
-- $m:= (Boolean)
-- $f:=
-- ((((|$Information| #) (~= # # #) (= # # #) (|coerce| # # #) ...)))
--  
--    >> Apparent user error:
--    cannot compile (+ (One) (IF xy false true)) 
-- 

Tst3(xx, F): Exports == Implementation  where
    xx: Symbol
    F: Field 
    UP  ==> UnivariatePolynomial

    Exports == with
          tst: () -> UP(xx, F)

    Implementation == add
          tst() == xx::UP(xx, F)

-- ((|::| |xx| (|UnivariatePolynomial| |xx| F)))
-- ****** level 1  ******
-- $x:= (:: xx (UnivariatePolynomial xx F))
-- $m:= (UnivariatePolynomial xx F)
-- $f:=
-- ((((|$Information| #) (~= # # #) (= # # #) (|coerce| # # #) ...)))
--  
--    >> Apparent user error:
--    Cannot coerce xx 
--       of mode (Symbol) 
--       to mode (UnivariatePolynomial xx F)







reply via email to

[Prev in Thread] Current Thread [Next in Thread]