Plotting a region in $3D$ space

164 Views Asked by At

I would like to know if someone knows of a software where I can plot the following region

$$ D = \{ (x,y,z) \in \mathbb{R}^3: 0 \leq x \leq 1 , \; x^2 \leq y \leq x, \; \; 0 \leq z \leq x \} $$

thanks

3

There are 3 best solutions below

1
On BEST ANSWER

In Mathematica you get a plot of the region using

RegionPlot3D[0 <= x <= 1 && x^2 <= y <= x && 0 <= z <= x,
             {x, 0, 1}, {y, 0, 1}, {z, 0, 1}]

The first argument you'll easily identify as your region specification. The following arguments give the variables and the range which should be shown (you generally want the complete region to be inside, but not too much space around it).

Now, this command gives only a quite approximate image of the shape, because it uses too few points. The following gives a much better image:

RegionPlot3D[0 <= x <= 1 && x^2 <= y <= x && 0 <= z <= x,
             {x, 0, 1}, {y, 0, 1}, {z, 0, 1},
             PlotPoints->100]

The extra argument tells Mathematica to calculate 100 points in each direction, which gives a better image.

Also note that if you only get a black blob (which happens for me with those commands, although it theoretically shouldn't), you'll have to add PlotStyle->White to the command, like this:

RegionPlot3D[0 <= x <= 1 && x^2 <= y <= x && 0 <= z <= x,
             {x, 0, 1}, {y, 0, 1}, {z, 0, 1},
             PlotPoints->100, PlotStyle->White]

Instead of White you can use another colour (which is mainly useful if you want to show several regions in the same picture).

Also if you want your axes to be labelled, you can use the AxesLabel option, like this:

RegionPlot3D[0 <= x <= 1 && x^2 <= y <= x && 0 <= z <= x,
             {x, 0, 1}, {y, 0, 1}, {z, 0, 1},
             PlotPoints->100, PlotStyle->White,
             AxesLabel->{HoldForm[x], HoldForm[y], HoldForm[z]}]

The HoldForm protects against any assignments you may have done to those variables prior to the statement (otherwise, if you had assigned x=3 previously, your x axis would be labelled 3 instead of x).

The result of the last command looks like this:

Resulting image of previous command

Note that inside Mathematica, you can interactively rotate that image.

0
On

Here's the Mathematica code:

RegionPlot3D[
  0 <= x && x <= 1 && x^2 <= y && y <= x && 0 <= z && z <= x,
 {x, 0, 1}, {y, 0, 1}, {z, 0, 1},
 AxesLabel -> {x, y, z}, PlotPoints -> 35
]

and the output:

enter image description here

0
On

In Maple this can be done with plots:-implicitplot3d, but a sharper result is obtained more easily by simply using the plot3d command with its filled option.

The upper z-surface is simply z=x, and the lower surface is z=0, and filling between them corresponds to your constraints z>=0 and z<=x.

plot3d(x, y = x .. x^2, x = 0 .. 1,
       filled=[color=blue,style=patchnogrid,transparency=0.5]);

enter image description here

If I had used plots:-implicitplot3d instead then I would have had to specify some ranges explicitly for each of x, y, and z. In the above call to plot3d I did not have to deduce in advance (by hand, or by using other commands) or specify in the call to the command that the y-range was 0..1 and that the z-range was 0..1. I was able to avoid that step (and use plot3d directly) because the constraints are simple enough. I feel that the distinction is important enough to warrant a mention.