axiom-mail
[Top][All Lists]
Advanced

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

[Axiom-mail] Defining piece-wise functions and drawing, integrating, ..


From: Sumant S.R. Oemrawsingh
Subject: [Axiom-mail] Defining piece-wise functions and drawing, integrating, ...
Date: Sun, 27 May 2007 00:43:44 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

Hi,

I've followed Martin's advice and started on the Axiom book. Of course, I've
quickly glanced through the whole book already and I'm amazed at most of the
examples there ("Can Axiom do *that*?!").

So, while reading, I've of course also skipped to parts that are most
relevant to me at this moment, for this problem I'm trying to solve (and
learn Axiom in the mean time), but I couldn't get Axiom to do what I wanted.
My problem is illustrated in the following simple example.

Say, I wish to define a piece-wise function,

(1) -> f(x|x<0)==-x**2
                                                                   Type: Void
(2) -> f(x)==x**2
                                                                   Type: Void
(3) -> draw(f(x),x=-1..1)
   Compiling function f with type Variable x -> Polynomial Integer 
Compiling /tmp/gazonk0.lsp.
End of Pass 1.  
End of Pass 2.  
OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3
Finished compiling /tmp/gazonk0.lsp.
   Compiling function %P with type DoubleFloat -> DoubleFloat 
   Graph data being transmitted to the viewport manager...
   AXIOM2D data being transmitted to the viewport manager...

   (3)  TwoDimensionalViewport: "x*x"
                                                 Type: TwoDimensionalViewport

Notice how the result is a graph x*x, instead of one part -x*x and one part
x*x (the viewport also actually shows one parabola, consistent with the
return value, but not what I wanted). If I now continue to integrate,

(4) -> integrate(f(x),x=-1..1)
(4) -> 
        2
   (4)  -
        3
                    Type: Union(f1: OrderedCompletion Expression Integer,...)

However, when I evaluate the function at specific points,

(5) -> f(-1/2)
   Compiling function f with type Fraction Integer -> Fraction Integer 

          1
   (5)  - -
          4
                                                       Type: Fraction Integer
(6) -> f(1/2)
(6) -> 
        1
   (6)  -
        4
                                                       Type: Fraction Integer

I'm lost here... Other odd functions, such as sin(x) behave as they're
supposed to, so the problem is really in the definition of the piece-wise
function, although Axiom did understand it:

(10) -> )display values f
   Definition:
                         2
     f (x | x < 0) == - x
             2
     f x == x

I know that for this specific example I can use something like sign(x)
instead of defining it as a piece-wise function, but this is just an
example, and I think that this should work in principle, so... what am I
doing wrong?

Thanks in advance,

Sumant

-- 
Sumant S. R. Oemrawsingh
address@hidden




reply via email to

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