Re: Defining piece-wise functions and drawing, integrating, ...

Martin Rubey <[email protected]>
Newsgroups gmane.comp.mathematics.axiom.user
Message-ID <[email protected]>
Dear Sumant,

You have sent an excellent example!

"Sumant S.R. Oemrawsingh" <[email protected]> writes:

> 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 

Reading this line, you might find out what happened: axiom interprets your
function f as being from Variable x to Polynomial Integer.  Try - in a fresh
session -

  )set message bottom on

(or shorter, )se me bo on) and

  x<0

You will see, x is interpreted as a polynomial integer! Thus, the inequality
x<0 in your function definition will never hold!

There is a way out though: tell axiom to draw a function from DoubleFloat to
DoubleFloat:

  draw(f, -1..1)

Look carefully at the messages, and look up "draw" in HyperDoc or with

  )display operations draw

(shorter: )di op draw)


> If I now continue to integrate,
> 
> (4) -> integrate(f(x),x=-1..1)

Here, I think, you are out of luck.  axiom's Expression Domain does not yet
provide piecewise functions.  You can only do it numerically:

(19) -> romberg(f, -1,1,0.1,0.1,10,20)

   (19)  [value= 0.0,error= 0.0,totalpts= 2049,success= true]
   Type: Record(value: Float,error: Float,totalpts: Integer,success: Boolean)

hope that helps,

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.