Ask Your Question
0

plotting regions in 3D

asked 2013-09-21 13:53:44 -0600

anonymous user

Anonymous

updated 2013-09-21 23:41:23 -0600

tmonteil gravatar image

I have recently learned to plot regions in the xy-plane as follows:

region_plot([y - 2*x<= 0, 0<x, x<2, 0<y, y<3], (x, -3, 3), (y, -3, 3))

My question is: How do I plot the same region, but living in 3-space? How do I add an extra condition (namely, z=0) so that the region appears in 3-space? The reason I ask is that I want to plot a two-varialbe function and its region of integration in the same plot.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-09-22 00:03:23 -0600

tmonteil gravatar image

updated 2013-09-22 00:03:44 -0600

You can use implicit_plot3d as follows:

sage: region = implicit_plot3d(z, (x, -3, 3), (y, -3, 3), (z, -3, 3), plot_points=100, region=lambda x,y,z: y - 2*x<= 0 and 0<x and x<2 and 0<y and y<3)
sage: region.show()
edit flag offensive delete link more

Comments

Thank you for your help. What does that lambda command do? Also, suppose I want to extend that region upward; that is, let z >=0 and get a solid. Is there an easy tweak to your code to do that?

strangelove1221 gravatar imagestrangelove1221 ( 2013-09-22 05:38:50 -0600 )edit

This comment box destroys some symbols, see my answer below.

tmonteil gravatar imagetmonteil ( 2013-09-22 08:22:59 -0600 )edit
1

answered 2013-09-22 08:27:56 -0600

tmonteil gravatar image

updated 2013-09-22 08:29:06 -0600

The line

lambda x,y,z: y - 2*x<= 0 and 0<x and x<2 and 0<y and y<3

just defines a function that takes x,y,z as arguments, and that returns the boolean (y - 2*x<= 0 and 0<x and x<2 and 0<y and y<3).

To solve your second question, one could think about defining

sage: implicit_plot3d(0, (x, -3, 3), (y, -3, 3), (z, -3, 3), plot_points=100, region=lambda x,y,z: y - 2*x<= 0 and 0<x and x<2 and 0<y and y<3).show()

but the function 0 does not define a surface but a volume, and plot3d does not show anything.

A possible workaround could be to plot many parallel surfaces:

sage: implicit_plot3d(z, (x, -3, 3), (y, -3, 3), (z, -3, 3), plot_points=100, contour=[i/100 for i in range(100)], region=lambda x,y,z: y - 2*x<= 0 and 0<x and x<2 and 0<y and y<3).show()
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2013-09-21 13:53:44 -0600

Seen: 333 times

Last updated: Sep 22 '13