axiom-math
[Top][All Lists]
Advanced

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

Re: [Axiom-math] How reads axiom Expressions ?


From: root
Subject: Re: [Axiom-math] How reads axiom Expressions ?
Date: Mon, 13 Oct 2003 13:06:23 -0400

> > Can you tell me what result you were expecting?
> > It is hard to guess what result you wanted so
> > I don't know if this is considered a bug or not.
> > 
> > >Hello, 
> > >
> > >I type this example in axiom :
> > >
> > >(4) ->  (sin (x)+1/2)*(cos(x)+1/2)
> > >        (4cos(x) + 2)sin(x) + 2cos(x) + 1
> > >   (4)  ---------------------------------
> > >                        4
> > >
> > >I don't understand the result : 
> > >it's _not_ an expanded product, and it's _not_ a factorised product.
> > >What does axiom ?
> 
> Of corse the result is right, but because I'm a 4M user and I didn't wait
> this result. 
> 
> Mupad keeps theses products factorised, so they remain short.
> And the expand or normal command gives the result in Q[cos(x),sin(x)]
> The collect command computes as axiom, but I almost don't use it.
> 
> It seems that axiom computes in fraction (Z[cos(x)][sin(x)]),
> and It's surprising for my eyes. 
> 
> Today I prefer the mupad way, but I can't explain why :
> A really more pretty way as we do over paper, or only my long use of mupad.
> Of corse I don't know if internal simplifications are more easy in 
> Q[cos(x),sin(x)] (for mupad) or in fraction (Z[cos(x)][sin(x)]) (for axiom).
> 

The issue appears to be that mupad is using a tree representation.
I can't prove this but it appears likely given the results. In a
tree representation one of the "simplification" rules would be that
multiplication is "simpler" than division. (See: Cohen, Joel
"Computer Algebra and Symbolic Computation, Mathematical Methods" (2003)
A.K. Peters, Ltd, Natick MA. ISBN 1-56881-159-4 Chapter 1)

Thus given a product of two terms A * B as in:

(4) ->  (sin (x)+1/2)*(cos(x)+1/2)

where A=cos(x) and B=sin(x)

you would leave the "result" in "simplified" form, that is, as a product
rather than a fraction.

In Axiom the result depends on the type analysis. The simple term

(1) -> sin(x)
            Type: Expression Integer

is an expression over integer. cos(x) is the same type. To see the
effect try declaring variables of the same type and ask for a result:

(2) -> A:EXPR(INT)
(3) -> B:EXPR(INT)
(4) -> (A + 1/2)*(B+1/2)

   (4 A + 2)B + 2 A + 1
   --------------------
            4
             Type: Expression Integer

substitution of A=cos(x) and B=sin(x) in the above expression yields 
your result. The output depends on the type. Axiom does not use a tree 
representation in general although particular types might.

You can get the form you want if you coerce it to the correct type, thus:
(note that "%" means the last result)

(5) -> %:Fraction(POLY(INT))

   (4 A + 2)B + 2 A + 1
   --------------------
            4
             Type: Fraction Polynomial Integer

Now we want to switch the type tower so that we convert from
Fraction(Polynomial(Integer)) to Polynomial(Fraction(Integer)) thus:

(6) -> %:POLY(FRAC(INT))

      1     1     1
 (A + -)B + - A + -
      2     2     2
         Type: Polynomial Fraction Integer

Now we want the factored form so we extend the type tower to include
a type which keeps its results in factored form thus:

(7) -> %:Factored(POLY(FRAC(INT)))

       1       1
  (A + _) (B + _)
       2       2
         Type: Factored Polynomial Fraction Integer

Note I've deliberately kept the A and B so the results are clearer.

So what you wanted was a factored expression (the outer type)
where the terms are polynomials (the next layer of the type tower)
whose coefficients are fractions (the next layer of the type tower)
over the integers (the bottom of the type tower).

But you didn't tell Axiom that. You told it you wanted to multiply
two expressions (the top of the type tower) over integers (the bottom
of the type tower) and Axiom found a multiply operator in EXPR(INT),
did the multiplication, and returned the result in EXPR(INT).

You can get what you want but you have to pick the right type.

Hope this helps.

Tim
address@hidden
address@hidden






reply via email to

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