Ask Your Question

Revision history [back]

When you write:

sage: laregion(x,y,z)= (y<=-1.1 or y>=-0.96)

you do not define a PYthon function, but a symbolic expression:

sage: type(laregion)
<class 'sage.symbolic.expression.Expression'>

which explains why the third code does not work.

Now, when you compare two expressions with a Python logical or, Sage (actually Python), tries the first memner, and if the first member is False, it returns the second member:

sage: bool(y<=-1.1)
False

Hence,

sage: laregion
(x, y, z) |--> y >= -0.960000000000000

This explains why the second code does not work.

When you write:

sage: laregion(x,y,z)= (y<=-1.1 or y>=-0.96)

you do not define a PYthon function, but a symbolic expression:

sage: type(laregion)
<class 'sage.symbolic.expression.Expression'>

which explains why the third code does not work.

Now, when you compare two expressions with a Python logical or, Sage (actually Python), tries the first memner, member, and if the first member is False, it returns the second member:

sage: bool(y<=-1.1)
False

Hence,

sage: laregion
(x, y, z) |--> y >= -0.960000000000000

This explains why the second code does not work.

We can not experiment your code since you did not provide the code for h and lacouleur.

When you write:

sage: laregion(x,y,z)= laregion(x,y,z) = (y<=-1.1 or y>=-0.96)

you do not define a PYthon function, but a symbolic expression:

sage: type(laregion)
<class 'sage.symbolic.expression.Expression'>

which explains why the third code does not work.

Now, when you compare two expressions with a Python logical or, Sage (actually Python), tries the first member, and if the first member is False, it returns the second member:

sage: bool(y<=-1.1)
False

Hence,

sage: laregion
(x, y, z) |--> y >= -0.960000000000000

This explains why the second code does not work.

We can not experiment your code since you did not provide the code for h and lacouleur.

When you write:

sage: laregion(x,y,z) = (y<=-1.1 or y>=-0.96)

you do not define a PYthon function, but a symbolic expression:

sage: type(laregion)
<class 'sage.symbolic.expression.Expression'>

which explains why the third code does not work.

Now, when you compare two expressions with a Python logical or, Sage (actually Python), tries the first member, and if the first member is False, it returns the second member:

sage: bool(y<=-1.1)
False

Hence,

sage: laregion
(x, y, z) |--> y >= -0.960000000000000

This explains why the second code does not work.

EDIT : If you want to define and use a Python function named laregion, you can do:

sage: laregion = lambda x,y,z: y<=-1.1 or y>=-0.96

or (recommended):

sage: def laregion(x,y,z):
....:     return y<=-1.1 or y>=-0.96