First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

By using f(x)= syntax, your are defining a Symbolic function of the symbolic variable x. Then floor(x) is a symbolic expression. And mod just don't eat a symbolic expression as first argument.

sage: a = floor(x)
sage: type(a)
<type 'sage.symbolic.expression.Expression'>
sage: mod(a, 5)   # raises value error

Use Python way of defining a function:

sage: def f(x): return mod(floor(x), 5)
sage: f(17.3)
2

See also Some Common Issues with Functions in the Sage Guided tour.

click to hide/show revision 2
No.2 Revision

By using f(x)= syntax, your are defining a Symbolic function of the symbolic variable x. Then floor(x) is a symbolic expression. And mod just don't eat a symbolic expression as first argument.

sage: a = floor(x)
sage: type(a)
<type 'sage.symbolic.expression.Expression'>
sage: mod(a, 5)   # raises value type error

Use Python way of defining a function:

sage: def f(x): return mod(floor(x), 5)
sage: f(17.3)
2

See also Some Common Issues with Functions in the Sage Guided tour.

click to hide/show revision 3
No.3 Revision

By using f(x)= syntax, your are defining a Symbolic function of the symbolic variable x. Then floor(x) is a symbolic expression. And mod just don't eat a symbolic expression as first argument.

sage: a = floor(x)
sage: type(a)
<type 'sage.symbolic.expression.Expression'>
sage: mod(a, 5)   # raises type error

Use Python way of defining a function:

sage: def f(x): return mod(floor(x), 5)
sage: f(17.3)
2

See also this post or the section Some Common Issues with Functions in the Sage Guided tour.