axiom-math
[Top][All Lists]
Advanced

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

[Axiom-math] Re: Advantage of Types and different representations


From: Martin Rubey
Subject: [Axiom-math] Re: Advantage of Types and different representations
Date: 28 Mar 2007 14:58:25 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

"Ondrej Certik" <address@hidden> writes:

> So how are you comparing x^2-1 and (x+1)(x-1) in Axiom? Is it the same, or
> not?

Of course it is. But the point is, you can choose the representation. If you
know that your polynomials will have lots and lots of factors, and if you
mainly multiply your polynomials, you will be better off to work in the domain
Factored Polynomial Integer. Otherwise, you will probably prefer to work in
Polynomial Integer.

> In SymPy, every expression is converted to a canonical form and then assigned
> a hash. Then we just need to compare the hashes, thus resulting in O(1)
> operation.

And how does the user tell the system which canonical form is suitable?

> > Another point for Axiom: in axiom, you define the gcd once. Of course, you
> > are free to define more efficient versions for certain domains, but you
> > have a default version that works for any Eucledian Domain.
> 
> The same with SymPy, we also implement each algorithm exactly once. 

Oh, I misinterpreted:

> > > The same is with polynomials, like polynomial gcd is an algorithm, that
> > > only works for polynomials.

ALthough I do not see how your gcd algorithm will work with *any* Euclidian
Domain... (Note that multiplication and addition do not necessarily have to be
compatible with the usual multiplication and addition of, say, integers, I
guess. Well, maybe they have to, I'm not sure right now.)

> > > Currently, in SymPy, the input to gcd is just an expression tree and it
> > > checks, if it is a polynomial (and computes gcd), otherwise raises an
> > > exception.
> >
> > And in Axiom, you do not need to check.
> 
> Well, you need to check at some point, when converting from the expression
> tree to the higher level rep. 

But what if I don't start at all with an expression tree?

> I probably know what you mean - in Aldor, you need to specify a type of each
> variable in advance, but in Python, the type of the variable is inferred from
> the right hand side.

For Axiom, you have to distinguish between the extension language (say, for
example, Aldor) and the interpreter. The interpreter tries hard to infer a
sensible type for the things you type in.

> > Note that Axiom uses the product in the ring of symmetric functions to 
> > compute
> > the determinant. To check, by Jacobi-Trudi the result should coincide with 
> > the
> > Schur function corresponding to the partition $(1,1)$:
> >
> > (4) -> SFunction [1,1]
> >
> >           1       1   2
> >    (4)  - - (2) + - (1 )
> >           2       2
> >                                    Type: SymmetricPolynomial Fraction 
> > Integer
> 
> Maybe I am wrong, but it seems to me, that the advantage of doing it this way
> in Axiom is that it allows you to implement each mathematical algorithm
> exactly once, and possibly specifying a faster/better algorithm in special
> cases. 

That's one advantage, but certainly not the only one. I still do not know how
to implement a non-standard multiplication (as, for example, for symmetric
functions) in Mathematica, Maple, or Python.  Would it be possible to implement
it in SymPy *without* modifying "Mul"? I.e., I want to write

powerSum 3 * powerSum 5 

and obtain the symmetric function correponding to the partition (3, 5). And, of
course, I want to compute the determinant of a matrix of symmetric functions,
also. Maybe more precisely, if you create a new class "P", how do you tell
SymPy what

Mul(P(3), P(5))

means?

Martin





reply via email to

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