axiom-developer
[Top][All Lists]

## RE: [Axiom-developer] RE: How can I get every term of an expression ?

 From: Page, Bill Subject: RE: [Axiom-developer] RE: How can I get every term of an expression ? Date: Tue, 20 Sep 2005 02:45:28 -0400

```On Tuesday, September 20, 2005 1:36 AM Tim Daly wrote:
> ...
> Bill writes:
>
> > How can I persuade Axiom to write out
> >
> > (1) -> (2*log(x)+3*exp(y))*(4*sin(z)+2*log(x))
> >
> > as a "sum of products"? E.g.
> >
> > (2) -> 8*log(x)*sin(z)+4*log(x)^2+12*exp(y)*sin(z)+6*exp(y)*log(x)
>
> so you're asking for a domain whose print representation is a
> "factored" form, something like asking axiom:
>
> n:= 345
>        Type: PositiveInteger
>
> Now Factored(Integer) has a print representation of:
>
> n::Factored(Integer)
>
>     3 5 23
>        Type: Factored Integer
>

No, I don't see what this has to do with factoring integers
(except by analogy). The factored form of the Francois' example
polynomial is shown in Axiom output (2) below. That is not
the problem.

>
> I'm unaware of any existing domain that has a print representation
> as a "sum of products" although one could be written.

The polynomial domains that contain the word 'distributed' have
such a representation.

>
> Bill writes
> > Why can't Axiom factor and expand such expressions?
>
> Axiom can factor and expand such expressions. However when the
> results get printed (in Expression(Integer)) they get printed in
> the form shown.

No. So far as I can tell the "factored" form of Francois' Expression
and the original form are identical. See below.

>
> Instead of "Distributed" perhaps you wanted "Factored" such as
>
>   Factored(Expression(Integer))
>
> however factored currently does not know how to print anything in
> factored from other than integers it seems.

I would like *both* Factored and Distributed as valid types over
Expression Integer. This works for polynomial domains (see below)
except the way of forming the Distributed form is irregular.

(1) -> p1:=(2*x+3*y)*(4*z+2*x)

2
(1)  (12y + 8x)z + 6x y + 4x
Type: Polynomial
Integer
(2) -> p1::Factored POLY INT

(2)  2(3y + 2x)(2z + x)
Type: Factored Polynomial
Integer
(3) -> p1::DMP([x,y,z],INT)

2
(3)  4x  + 6x y + 8x z + 12y z
Type:
DistributedMultivariatePolynomial([x,y,z],Integer)
(4) ->

> Since this is a valid type clearly the print representation could
> be expanded to cover the Expression(Integer) values.
>

Isn't there is more to the difference between for example
MP([x,y,z], INT) and DMP([x,y,z], INT) then just the print
representation?

For example, Francois' Expression is

(5) -> p2:=(2*log(x)+3*exp(y))*(4*sin(z)+2*log(x))

y                 2      y
(5)  (8log(x) + 12%e )sin(z) + 4log(x)  + 6%e log(x)
Type: Expression Integer

And the factored form of the polynomial example is:

(6) -> p1::Factored POLY INT::InputForm

(6)
(*  (nilFactor (:: 2 (Polynomial (Integer))) 1)

(*  (primeFactor (:: (+ (* 3 y) (* 2 x)) (Polynomial (Integer))) 1)
(primeFactor (:: (+ (* 2 z) x) (Polynomial (Integer))) 1))
)
Type: InputForm

InputForm shows some detail of the internal representation.

On the other hand doing this with Expression Integer appaentely
does not produce a factored form at all.

(16) -> p2::Factored EXPR INT::InputForm

(16)
(+  (* (+ (* 8 (log x)) (* 12 (exp y))) (sin z))
(+ (* 4 (** (log x) 2)) (* (* 6 (exp y)) (log x))))
Type: InputForm

Regards,
Bill Page.

```