Define the following function:
fricas
(1) -> f(x|x<0)==-x**2
Type: Void
fricas
f(x)==x**2
Type: Void
Then, draw the function
fricas
draw(f(x),x=-1..1)
There are 3 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 3 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:
fricas
eval(f(x),x=-5)
There are 3 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 3 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
fricas
f(x)
There are 3 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 3 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
fricas
)display values f
CONCAT
Definition:
,
f (x | x < 0) == - x**2
f x == x**2
Integration, therefore, also goes wrong,
fricas
integrate(f(x),x=-5..5)
There are 3 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 3 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
fricas
[f(x) for x in -5..5]
There are no library operations named **
Use HyperDoc Browse or issue
)what op **
to learn if there is any operation containing " ** " in its name.
Cannot find a definition or applicable library operation named **
with argument type(s)
Integer
PositiveInteger
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.
Cannot compile map: f
We will attempt to interpret the code.
There are no library operations named **
Use HyperDoc Browse or issue
)what op **
to learn if there is any operation containing " ** " in its name.
Cannot find a definition or applicable library operation named **
with argument type(s)
Integer
PositiveInteger
Perhaps you should use "@" to indicate the required return type,
or "$" to specify which version of the function you need.
but the Axiom interpreter does not treat 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:
fricas
map(f,expand(-5..5))
There are no library operations named **
Use HyperDoc Browse or issue
)what op **
to learn if there is any operation containing " ** " in its name.
There are no library operations named **
Use HyperDoc Browse or issue
)what op **
to learn if there is any operation containing " ** " in its name.
There are 66 exposed and 13 unexposed library operations named map
having 2 argument(s) but none was determined to be applicable.
Use HyperDoc Browse, or issue
)display op map
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 map
with argument type(s)
FunctionCalled(f)
List(Integer)
Perhaps you should use "@" to indicate the required return type,
or "$" to specify which version of the function you need.
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.
fricas
h(x | x<=0) == -x^2
Type: Void
fricas
eval(h(x), x=-2)
There are 2 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 2 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.
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
fricas
[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)?
fricas
[h(-1.0+0.5*i) for i in 0..2]
fricas
Compiling function h with type Float -> Float
Type: List(Float)
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
fricas
x<=0
There are 2 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.
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.
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.
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).
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 sending
to ; 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 with a
FIXED indeterminate although by abuse of notation, we use the polynomial
to mean the function itself. Thus for Axiom to test with as a
FIXED interminate in in a function (or function prototype) definition
is unwise no matter what context; x must be interpreted as a dummy variable
(place holder) only.
- 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 sending to ; but that is
not what we meant when we want to integrate h).
The definition
fricas
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
fricas
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:
fricas
w
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
fricas
draw(f, -5..5)
There are no library operations named **
Use HyperDoc Browse or issue
)what op **
to learn if there is any operation containing " ** " in its name.
There are no library operations named **
Use HyperDoc Browse or issue
)what op **
to learn if there is any operation containing " ** " in its name.
There are 10 exposed and 0 unexposed library operations named draw
having 2 argument(s) but none was determined to be applicable.
Use HyperDoc Browse, or issue
)display op draw
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 draw
with argument type(s)
FunctionCalled(f)
Segment(Integer)
Perhaps you should use "@" to indicate the required return type,
or "$" to specify which version of the function you need.
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...