First time here? Check out the FAQ!

Ask Your Question
0

implicit3D region

asked 3 years ago

ErWinz gravatar image

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

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 3 years ago

tmonteil gravatar image

updated 3 years ago

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
Preview: (hide)
link

Comments

thanks very much tmonteil, it works very fine

ErWinz gravatar imageErWinz ( 3 years ago )
0

answered 3 years ago

ErWinz gravatar image

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

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

i understand your explanations

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…

Preview: (hide)
link

Comments

I added some bits on my answer.

tmonteil gravatar imagetmonteil ( 3 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 3 years ago

Seen: 232 times

Last updated: Mar 02 '22