[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-mail] comparison operators and %pi
From: |
Martin Rubey |
Subject: |
Re: [Axiom-mail] comparison operators and %pi |
Date: |
24 May 2007 18:06:33 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 |
"Sumant S.R. Oemrawsingh" <address@hidden> 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
- [Axiom-mail] comparison operators and %pi, Sumant S.R. Oemrawsingh, 2007/05/24
- Re: [Axiom-mail] comparison operators and %pi, Themos Tsikas, 2007/05/24
- Re: [Axiom-mail] comparison operators and %pi,
Martin Rubey <=
- Re: [Axiom-mail] comparison operators and %pi, Sumant S.R. Oemrawsingh, 2007/05/24
- Re: [Axiom-mail] comparison operators and %pi, Martin Rubey, 2007/05/24
- Re: [Axiom-mail] comparison operators and %pi, Alasdair McAndrew, 2007/05/25
- Re: [Axiom-mail] comparison operators and %pi, Martin Rubey, 2007/05/25
- Re: [Axiom-mail] comparison operators and %pi, Alasdair McAndrew, 2007/05/25
- Re: [Axiom-mail] comparison operators and %pi, Sumant S.R. Oemrawsingh, 2007/05/25
- Re: [Axiom-mail] comparison operators and %pi, Themos Tsikas, 2007/05/25