| 1 | initial version |
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.
| 2 | No.2 Revision |
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.
| 3 | No.3 Revision |
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.
| 4 | No.4 Revision |
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
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.