Introducing algebraic expressions

9 views
Skip to first unread message

Pearu Peterson

unread,
Jan 6, 2008, 4:41:25 AM1/6/08
to sympy, symp...@googlegroups.com
Hi,

In sympycore we have found a very efficient way to perform
arithmetic operations. This turned out to have a general
implementation that seems to be applicable to any (commutative)
algebraic structure. So, the idea is to introduce classes
such as AlgebraicExpression and AlgebraicNumberExpression
that implement operations + and * in an abstract way but using
very efficient representation from sympycore.

The specification of these classes can be found in
http://sympycore.googlecode.com/svn/trunk/sympycore/algebra/basic.py

Comments and ideas about the above are welcome. I'd like to settle
down the specs before starting implementing it.

Regards,
Pearu

Ondrej Certik

unread,
Jan 6, 2008, 7:49:15 AM1/6/08
to sy...@googlegroups.com, symp...@googlegroups.com

From the technical point of view, anything is fine with me, as long as it works
and it's efficient.

But is it possible to use the current easy to understand structure in
sympy, i.e.

Add, Mul, Pow, Function, ....

classes?

I.e. is it just an implementation detail, how Add/Mul/Pow classes work
internally?
Or is it necessary to change this paradigm completely?

Ondrej

Ondrej Certik

unread,
Jan 6, 2008, 7:53:12 AM1/6/08
to sy...@googlegroups.com, symp...@googlegroups.com

And also a general note:

You have already investigated quite a lot of approaches. Please
document them all in the wiki.
We should also investigate how other CAS systems are doing this.

In sympy, we just did the simplest possible approach, so no
investigation was necessary, but now,
when we try to optimize it, we need to know the "state of the art".

Ondrej

Pearu Peterson

unread,
Jan 6, 2008, 8:19:27 AM1/6/08
to Sympy Core


On Jan 6, 12:49 pm, "Ondrej Certik" <ond...@certik.cz> wrote:

> From the technical point of view, anything is fine with me, as long as it works
> and it's efficient.
>
> But is it possible to use the current easy to understand structure in
> sympy, i.e.
>
> Add, Mul, Pow, Function, ....
>
> classes?

Function will not change, Pow is still needed. Add, Mul will be
functions/classes that construct AlgebraicExpression instance
but otherwise there should be no need to these wrapper classes
that Add, Mul basically are in sympycore. For example, not
using the Add, Mul classes in the 3*(a*x+..) benchmark, the
timings are 4.7x better.

> I.e. is it just an implementation detail, how Add/Mul/Pow classes work
> internally?

It can be an implementation detail for Add/Mul to ease transition.

> Or is it necessary to change this paradigm completely?

Not immidiately but if there will be no surprises then Add/Mul
wrappers can be dropped. In fact, in sympycore the BasicSymbol,
SetSymbol, Boolean, Symbol could be unified to one class,
the algebra where symbols are used as elements,
will define the nature of a symbol.

Note that numbers in AlgebraicExpression can also be algebraic
expressions that is essential when dealing with polynomials over
algebraic numbers.

Pearu

Pearu Peterson

unread,
Jan 6, 2008, 8:20:24 AM1/6/08
to Sympy Core


On Jan 6, 12:53 pm, "Ondrej Certik" <ond...@certik.cz> wrote:

> And also a general note:
>
> You have already investigated quite a lot of approaches. Please
> document them all in the wiki.
> We should also investigate how other CAS systems are doing this.
>
> In sympy, we just did the simplest possible approach, so no
> investigation was necessary, but now,
> when we try to optimize it, we need to know the "state of the art".

Yes, good idea.

Pearu
Reply all
Reply to author
Forward
0 new messages