Ask Your Question
0

implicit3D region

asked 2022-03-01 14:33:15 +0200

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

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2022-03-01 15:02:33 +0200

tmonteil gravatar image

updated 2022-03-02 10:35:33 +0200

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
edit flag offensive delete link more

Comments

thanks very much tmonteil, it works very fine

ErWinz gravatar imageErWinz ( 2022-03-03 09:54:25 +0200 )edit
0

answered 2022-03-01 17:33:15 +0200

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…

edit flag offensive delete link more

Comments

I added some bits on my answer.

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

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: 2022-03-01 14:33:15 +0200

Seen: 148 times

Last updated: Mar 02 '22