# implicit3D region

hi my question is about the 3 following codes :

implicit_plot3d(h, (x, xmin,xmax), (y, ymin, ymax), (z, zmin, zmax),color=lacouleur,adaptive=True,mesh=True,region=lambda x,y,z: y<=-1.1 or y>=-0.96)
implicit_plot3d(h, (x, xmin,xmax), (y, ymin, ymax), (z, zmin, zmax),color=lacouleur,adaptive=True,mesh=True,region=lambda x,y,z: laregion(x,y,z))
implicit_plot3d(h, (x, xmin,xmax), (y, ymin, ymax), (z, zmin, zmax),color=lacouleur,adaptive=True,mesh=True,region=laregion)

• the first works very fine
• the second gives an empty draw
• the third gives plenty of errors

i precize that the program includes this :

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


I dont understand why the 3 codes dont give the same result : for me it is the same code…

Vinz

edit retag close merge delete

Sort by » oldest newest most voted

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

more

thanks very much tmonteil, it works very fine

( 2022-03-03 09:54:25 +0200 )edit

sorry here : f(x,y)=x^3+x*y

h(x,y,z)=f(x,y)-z


my aim is to put the region of definition at the beginning of the programm that's why i tried to define it by a function but i understand that :

 (y<=-1.1 or y>=-0.96)


dont act the same way if it is in a pure sage function like implicit3d or in a function that will be interpreted as a python function.

My problematic is not very important, it is comfort, but i really wonder how to solve it…

more

( 2022-03-02 10:35:46 +0200 )edit