login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Submitted by : (unknown) at: 2007-11-17T22:32:30-08:00 (10 years ago)
Name :
Axiom Version :
Category : Severity : Status :
Optional subject :  
Optional comment :

Define the following function:

axiom
f(x|x<0)==-x**2
Type: Void
axiom
f(x)==x**2
Type: Void

Then, draw the function

axiom
draw(f(x),x=-1..1)
There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation. Cannot find a definition or applicable library operation named < with argument type(s) Variable(x) NonNegativeInteger
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. FriCAS will attempt to step through and interpret the code. There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named < with argument type(s) Variable(x) NonNegativeInteger
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

Note that the function is compiled with Variable x -> Polynomial Integer, and the viewport shows the function x*x, even for x<0, where it should show -x*x.

The same holds when you eval the function:

axiom
eval(f(x),x=-5)
There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation. Cannot find a definition or applicable library operation named < with argument type(s) Variable(x) NonNegativeInteger
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. FriCAS will attempt to step through and interpret the code. There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named < with argument type(s) Variable(x) NonNegativeInteger
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

Here, we should expect -25. And shouldn't

axiom
f(x)
There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation. Cannot find a definition or applicable library operation named < with argument type(s) Variable(x) NonNegativeInteger
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. FriCAS will attempt to step through and interpret the code. There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named < with argument type(s) Variable(x) NonNegativeInteger
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

result in something similar to

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

Integration, therefore, also goes wrong,

axiom
integrate(f(x),x=-5..5)
There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation. Cannot find a definition or applicable library operation named < with argument type(s) Variable(x) NonNegativeInteger
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. FriCAS will attempt to step through and interpret the code. There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named < with argument type(s) Variable(x) NonNegativeInteger
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

which should of course yield 0. It would appear that in certain operations, when performing a function on f (like draw, eval, integrate), or when x is not specified, it is assumed to be positive. After that, the actual value is filled in and this can therefore yield an erroneous result.

I use Version: Axiom 3.9 (September 2005) on gentoo (amd64).


On June 3, 2007 Bill Page wrote:

An anonymous author wrote:

  Axiom is being inconsistent, and this is an interpreter bug!

In the Axiom programming language it is possible to avoid the immediate evaluation of f(x) in some contexts. For example

axiom
[f(x) for x in -5..5]
axiom
Compiling function f with type Integer -> Integer

\label{eq1}\left[ -{25}, \: -{16}, \: - 9, \: - 4, \: - 1, \: 0, \: 1, \: 4, \: 9, \:{16}, \:{25}\right](1)
Type: List(Integer)

but the Axiom interpreter does not treat [\dots] as an operator or even a generator. Perhaps this could be considered inconsistent. In this regard the Aldor programming language is certainly more general and more consistent.

But to be consistent with other parts of Axiom as it exists now it is possible to write this in an equivalent "functional" style:

axiom
map(f,expand(-5..5))

\label{eq2}\left[ -{25}, \: -{16}, \: - 9, \: - 4, \: - 1, \: 0, \: 1, \: 4, \: 9, \:{16}, \:{25}\right](2)
Type: List(Integer)

numerical evaluation --anonymous, Sun, 03 Jun 2007 03:39:47 -0500 reply
This rewriting does not change the result or explain the difference in handling. map(f, ...) is not exactly the same syntax as integrate(f(x), ...). I think the real reason for the failure of eval, integrate is these functions are not programmed to handle conditionals in function definitions.

axiom
h(x | x<=0) == -x^2
Type: Void
axiom
eval(h(x), x=-2)
There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation. Cannot find a definition or applicable library operation named < with argument type(s) NonNegativeInteger Variable(x)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. FriCAS will attempt to step through and interpret the code. There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named < with argument type(s) NonNegativeInteger Variable(x)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. integrate(h(x), x=-2..0)
There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation. Cannot find a definition or applicable library operation named < with argument type(s) NonNegativeInteger Variable(x)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. FriCAS will attempt to step through and interpret the code. There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named < with argument type(s) NonNegativeInteger Variable(x)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. integrate(h(x), x=-2.0..0.0)
There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation. Cannot find a definition or applicable library operation named < with argument type(s) NonNegativeInteger Variable(x)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. FriCAS will attempt to step through and interpret the code. There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named < with argument type(s) NonNegativeInteger Variable(x)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

If the interpreter is able to find another definition for h that is valid, it would have used it. Instead of compiling the function h, as in the handling of map(h, ...), and which is what it might have done, the interpreter is trying to evaluate exactly, not numerically. Are there any numerical integration functions in Axiom? Indeed, how can I compute something like

axiom
[h(x) for x in -1.0..0.0 by 0.5]
The lower bound in a loop must be an integer.

Must I manually translate an integer segment to a float segment (a la old Fortran)?

axiom
[h(-1.0+0.5*i) for i in 0..2]
axiom
Compiling function h with type Float -> Float

\label{eq3}\left[ -{1.0}, \: -{0.25}, \:{0.0}\right](3)
Type: List(Float)

Re: numerical evaluation --billpage, Sun, 03 Jun 2007 12:13:47 -0500 reply
Anonymous wrote:
  I think the real reason for the failure of eval, integrate is these
  functions are not programmed to handle conditionals in function
  definitions.

No that is not correct. The function definition you have is incomplete. Your h is only defined for x<=0. So Axiom cannot evaluate this for the value x since

axiom
x<=0
There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named < with argument type(s) NonNegativeInteger Variable(x)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

That is why it says: "The function h is not defined for the given argument(s)." (Note: click on + axiom on the right to see the output of the compiler.)

Anonymous wrote:

  the interpreter is trying to evaluate exactly, not numerically

Yes that is always true in Axiom. Axiom never makes an approximation unless you specifically ask it to.

Anonymous wrote:

  Are there any numerical integration functions in Axiom?

Yes. For example search for romberg in hyperdoc.

Anonymous wrote:

  Must I manually translate an integer segment to a
  float segment?

I do not know exactly what you mean by a "float segment" but yes I think writing:

  [h(-1.0+0.5*i) for i in 0..2]

is sensible if that is the output that you want.

What you are calling a "float segment" might be something for like an "interval" but that is a different story.

SEG Float is a valid constructor --anonymous, Wed, 06 Jun 2007 15:45:26 -0500 reply
No that is not correct. The function definition you have is incomplete. Your h is only defined for x<=0. So Axiom cannot evaluate >this for the value x since

I think Axiom is "stupid" to even think that in the definition of h, the x is symbolic as in POLY INT or EXPR INT. The function definition is complete as shown by the correct execution of [h(-1.0+0.5*i) for i in 0..2]. A function h is NOT the same as a value h(x) where x is a variable in EXPR INT. We should integrate h, not h(x).

Since it is not related to this issue report, the discussion of "float segments" has been moved to SandBoxFloatSegment.

Re: Axiom is "stupid" --billpage, Wed, 06 Jun 2007 16:33:52 -0500 reply
Anonymous wrote:
  Axiom is "stupid" to even think that in the definition
  of h, the x is symbolic

In Axiom x, 1, and 1.0 are all equally symbolic. The distinction between "symbolic" and "numeric" is not relevant. All of these things are members of some domain or other and the Axiom interpreter will make some assumptions unless you specify explicitly which domains (e.g. in this case the assumed domains are Variable(x), PositiveInteger, and Float, respectively).

Anonymous wrote:

  definition [ h(x | x<=0) == -x^2 ]is complete as shown 

No it is not. This is just a function prototype, not a function. The Axiom intetpreter automatically fills in the missing information based on the context where you use this prototype so what you get is the evaluation of a function that was partly created by assumptions made by the Axiom interpreter. These assumptions do not work when you call h with something of type Variable(x).

Functions and Segments --wyscc, Thu, 07 Jun 2007 05:03:55 -0400 reply
billpage wrote:
  Anonymous wrote::

    Axiom is "stupid" to even think that in the definition
    of h, the x is symbolic

  In Axiom x, 1, and 1.0 are all equally symbolic. The distinction
  between "symbolic" and "numeric" is not relevant.

I think anonymous' view is correct: a function is just a rule that assigns a value when given a value. The h defined earlier (a function prototype as you call it) can only be interpreted with a source domain that has an order, a multiplication, and a negation. However, if x is interpreted as a FIXED element in POLY INT, h is no longer a function from POLY INT to POLY INT (unless you view h as defining the substitution homomorphism on Q[x] sending x to -x^2; but that is not what we meant when we want to integrate h). As far as calculus goes, we integrate a function, NOT a polynomial h(x) with a FIXED indeterminate x although by abuse of notation, we use the polynomial h(x) to mean the function itself. Thus for Axiom to test x < 0 with x as a FIXED interminate in Q[x] in a function (or function prototype) definition is unwise no matter what context; x must be interpreted as a dummy variable (place holder) only.

Re: FIXED element in POLY INT --Bill Page, Sun, 10 Jun 2007 22:57:39 -0500 reply
wyscc wrote:
if x is interpreted as a FIXED element in POLY INT, h is no longer a function from POLY INT to POLY INT (unless you view h as defining the substitution homomorphism on Q[x] sending x to x^2; but that is not what we meant when we want to integrate h).

The definition

axiom
h(x | x<=0) == -x^2
Compiled code for h has been cleared. 1 old definition(s) deleted for function or rule h
Type: Void
axiom
h(x | x>0) == x^2
Type: Void

does not necessarily have anything to do with integration or polynomials since we know nothing at all about what the domain and co-domain of the function will be. If we had already specified a signature such as:

  h:Float->Float

then we could be sure that integration is at least in principle possible. But as it stands we only have part of the body of a potential function, i.e. a function prototype.

In any case x here is just a placeholder or dummy variable.

But given only the prototype, if in Axiom I write:

  h(w)

where w was not previously defined then the interpreter starts by assuming that w is just a variable:

axiom
w

\label{eq4}w(4)
Type: Variable(w)

But to interpret what is meant by w<=0, w>0, - and w^2, after a search of possibilities, Axiom finds that it can coerce the variable w to the a Polynomial Integer where <= and > are interpreted as lexical ordering and w^2 is given by w*w, as multiplication of polynomials. It is not necessary to think in terms of "substitution homomorphism".

Even when we specify a signature such as:

  h:Polynomial Integer -> Polynomial Integer

The x on the lhs and the expression -x^2 on the rhs of == in the prototype for h above is not a polynomial. It remains a dummy variable as defined according to the semantics of the Axiom programming language. But in this case the prototype does define a mapping (not necessarily a homomorphism) from polynomials into polynomials.

wyscc wrote:
As far as calculus goes, we integrate a function, NOT a polynomial ...

I agree. What we really would like to write is something like:

  integrate(h)

and we would expect the result to be another function. But this can be very difficult for arbitrary piecewise functions.

Name: #358 Variable is apparently always assumed to be positive? => #358 EXPR does not handle conditional definitions Category: Axiom Mathematics => Axiom Library

The problem, even with draw is in the EXPR domain. If you issue

axiom
draw(f, -5..5)
axiom
Compiling function f with type DoubleFloat -> DoubleFloat 
   Graph data being transmitted to the viewport manager...
   FriCAS2D data being transmitted to the viewport manager...

\label{eq5}\mbox{\rm \hbox{\axiomType{TwoDimensionalViewport}\ } :}\mbox{\tt "FriCAS2D"}(5)
Type: TwoDimensionalViewport?

the result will be fine. However, if you give f(x) as an argument, the library will internally convert it to INPUTFORM and then compile it as an expression, which fails of course...




  Subject:   Be Bold !!
  ( 13 subscribers )  
Please rate this page: