axiom-developer
[Top][All Lists]
Advanced

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

RE: [Axiom-developer] about Expression Integer


From: Bill Page
Subject: RE: [Axiom-developer] about Expression Integer
Date: Fri, 17 Feb 2006 18:25:51 -0500

On February 16, 2006 3:34 PM Francois Maltey wrote:
> ... 
> I play with expressions and I have theses questions :
>

In contrast to most other computer algebra systems, in Axiom
the concept of an 'expression' is not a fundamental idea.
Rather the concept of 'domain' comes first. I think some of
your questions are related to this different point of view.
 
> 1/ Can I (or cannot) remain Expressions as 
> 
> x+1/(y+1)             
> y+1/(x+1)             
> 
> and do not have a single denominator.
>

It is possible to do this in several ways. If you do not tell
Axiom anything else, it will interpret your expression as
a member of the domain 'Fraction Polynomial Integer'. That
is why it appears like this:

(1) -> (x+1/(y+1))

        x y + x + 1
   (1)  -----------
           y + 1
   Type: Fraction Polynomial Integer

This is the first domain that the interpreter finds in which
it can accurately represent your expression, so the expression
is converted to this domain and the result is displayed as you
see above. But notice that your original expression is not a
member of this domain.

There are however more complex domains which do include
expressions of the same form as you wrote above. The interpreter
is not able to find these automatically, but you can help by
specifying more exactly what you want. In the compiler you must
always provide this additional information. For example:

(2) -> (x+1/(y+1))$DMP([x,y],EXPR INT)

              1
   (2)  x + -----
            y + 1
   Type: DistributedMultivariatePolynomial([x,y],Expression Integer)

(3) -> (y+1/(x+1))$DMP([x,y],EXPR INT)

              1
   (3)  y + -----
            x + 1
   Type: DistributedMultivariatePolynomial([x,y],Expression Integer)

DMP is the abbreviation for DistributedMultivariatePolynomial. EXPR
is the abbreviation for Expression and of course INT is the abbreviation
for Integer.

In this case your expression is a member of the specified domain and
no conversion is necessary, but notice that the 2nd term is a monomial
of degree 0 since this domain has coefficients that can be expressions.
You might consider this result ambiguous since the entire expression
could be consider a term degree 0, but apparently the domain DMP
attempts construct a polynomial of highest degree? To know for sure
we would probably have to consult the source code for DMP.

I am not sure if this is exactly what you want or what you need as I
will explain below. 
 
> 2/ Can I go back from (xy+x+1)/(y+1) to x+1/(y+1) ?
> Other cas have normal or partfrac fuction, or remain fraction as.
>

Yes. For example:

(4) -> (%%(1)::EXPR INT)::DMP([x,y],EXPR INT)

               1
   (4)  x + -----
             y + 1
   Type: DistributedMultivariatePolynomial([x,y],Expression Integer)
 
> 3/ When I expand a trig formula I cut x+1/(y+1) in x and 1/(y+1) 
> not in xy/(y+1) and x/(y+1) and 1/(y+1). 
> 
> But perhaps my ideas aren't right ?

I am not sure I understand your use of English. Perhaps you mean
you would like to write:

   sin(%%(2))

but unfortunately there is not domain in Axiom right now of which
this expression would be a member. The command ')di op sin' shows
that 'sin' is only defined over domains in the category TRIGCAT.

But this does not mean that you cannot write a function which
performs this expansion. E.g.

(5) -> monomials((%%(1)::EXPR INT)::DMP([x,y],EXPR INT))

              1
   (5)  [x,-----]
            y + 1
   Type: List DistributedMultivariatePolynomial([x,y],Expression Integer)

> 
> 4/ I'm not sure that the results (xy+x+1)/(y+1) and
> ((x+1)y+1)/(x+1) are fine :
> 
> First the order of the variable is important, and the user
> (almost) can't force it, if he uses "n" and "x" variables.
> 
> Second the result is longer if the denominator is big.
>

Obviously these results are "fine" in the sense that the expressions
belong to the domain 'Fraction Polynomial Integer' which is the
domain that the Axiom interpreter chooses by default. Other results
are possible, as I showed above.
 
> 5/ Of course there is no problem in expand (cos (4*x+5y)),
> but small problems appear with     expand (cos (4*x+5*y/2)) 
> and a lot with                     expand (cos 
> (4*x+5*y/(2+t+t^2+t^3))).
> 
> What is the better expand in the 3 cases.
> Perhaps cos^4 x ... cos^5 y ... 
>         cos^4 x ... cos^5 (y/2) ... 
>         cos^4 x ... cos^5 (y/(2+t+t^2+t^3)) ... but I'm not sure.
> 

Yes, I agree with this.

> 
> I will be very happy if you can give me your advice, and tell
> me if one or an other way of computation is impossible/not
> natural/too complex with axiom. 
> 

I certainly don't think it is too complicated for axiom. To
understand how to use and especially how to program in Axiom
it is necessary to take a quite different view than in most
other computer algebra systems.

Fundamentally, Axiom is "object-oriented". This means that we
must think not about the objects (expressions) themselves but
rather about to what domain they belong. The domain determines
what operations can be performed on it's members. So if you
just write:

  x+1/(y+1)

you do not yet have something on which you can operate because
you have not said to which domain it belongs.

One of the important operations defined for almost all domains
is the coercion from that domain to the special domain called
OutputForm. This is the operation that determines how the members
of the domain will appear as output. But keep in mind that how
something appears in output does not directly relate to how it
is represented internally.

Conversions and coercions are very important in Axiom because
they allow you to find equivalent members of other domains that
may include operations of the type that you wish to perform.

To make these operations more "natural" in Axiom it is sometimes
necessary to create new domains. Martin Rubey's reply presents
this idea in more detail.

I hope this is some help.

Regards,
Bill Page.






reply via email to

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