axiom-math
[Top][All Lists]
Advanced

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

Re: [Axiom-math] if-expression and variables


From: Bill Page
Subject: Re: [Axiom-math] if-expression and variables
Date: Mon, 2 May 2011 20:36:24 -0400

What you want is probably better called a "piecewise expression" - not
a function in Axiom's sense. Unfortunately as far as I know piecewise
expressions like "(if y < 10 then 2*y else 5*y**2)" are not
implemented in any version of Axiom so they can not be returned as the
result of a function application like "test1(y)".

To explain the results that you get, it is important to know that in
older versions of Axiom (in particular in the original Axiom open
source project), the expression

  y<10

is evaluated as a comparison of polynomials in lexicographical order.
As such "y<10" is "false". In other versions of Axiom to avoid such
confusion lexicographical ordering is no longer expressed by the "<"
function so the expression "y<10" is not evaluated at all. In FriCAS
you would write: "smaller?(x,10)", in OpenAxiom it is written:
"before?(10,x)". But like in the original Axiom, both of these
functions are always fully evaluated as a boolean value, true or
false.  They cannot be used like "unevaluated functions" or
expressions.

I hope that helps.

Regards,
Bill Page.


On Sat, Apr 30, 2011 at 2:40 PM, Stefan Karrmann <address@hidden> wrote:
> Dear all,
>
> I'm new to axiom and have a problem with piecewise functions.
>
> test1 (x | x < 10) == 2*x
> test1 (x | x < 10) == 5*x^2
> test1
> ->
>   test1 (x | x < 10) == 2x
>   test1 (x | ^ x < 10) == 5x
>                                                   Type: FunctionCalled
> test1 y
> ->
>     2
>   5y
>
> I expected something like (if y < 10 then 2*y else 5*y**2).
>
> How is it possible to pass a Variable to a piecewise function respecting
> the pieces?
>
> PS: Using a block and => or explicit if-then-else does not help.
>
> --
> Kind regards,
> Stefan
>
>
> _______________________________________________
> Axiom-math mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/axiom-math
>



reply via email to

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