Re: comparison operators and %pi

Martin Rubey <[email protected]>
Newsgroups gmane.comp.mathematics.axiom.user
Message-ID <[email protected]>
"Sumant S.R. Oemrawsingh" <[email protected]> writes:

> I just tried axiom today for the first time, since it appears quite
> powerful. This of course means I'm a total newbie, so I've tried searching
> for the problem that I have through the archives, without luck.

welcome, and do not hesitate to ask!  I highly recommend the axiom book by
Jenks and Sutor as first reading, by the way.  What

> I'm trying to define a piecewise function, and I didn't manage. I could track
> the problem down to this expression in the predicate: x < %pi.

Note that (unfortunately) if you are dealing with things like trigonometry %pi,
you are often confined to the domain "Expression Integer", which is currently
not very powerful in axiom.

Most importantly:

 the operation "<" does not use the "mathematical" ordering in Expression
 Integer!  In fact, it wouldn't make sense anyway, think of "cos x < 0", and
 currently we do not have a domain for "constant" expressions, I believe. (But
 we certainly should).  In particular, in Expression Integer, you have "%pi <
 %e" evaluate to true:

(1) -> %pi < %e

   (1)  true
                                                                Type: Boolean
 What you want is to compare numerically:

(2) -> %pi::Float < %e

   (2)  false

(3) -> 1::Float < %pi

   (3)  true
                                                                Type: Boolean
(4) -> 1.0 < %pi

   (4)  true
                                                                Type: Boolean

> However, Float (1.1 < %pi) and AlgebraicNumber (sqrt(2) < %pi) work
> properly. Nevertheless, I want to evaluate the function at any point and get
> a symbolic answer instead of Float->Float. What can I do?

maybe you want something like

(9) ->   less(a, b) == a::Expression Float::Float < b::Expression Float::Float
   Compiled code for less has been cleared.
   1 old definition(s) deleted for function or rule less 
                                                                   Type: Void
(10) -> less(sin %e, %pi)
   Compiling function less with type (Expression Integer,Pi) -> Boolean
      
   (10)  true
                                                                Type: Boolean

?

(The additional coercion to Expression Float is necessary, since the
interpreter is too stupid to convert %e directly to float, unfortunately.)


Martin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.