1
$\begingroup$

Suppose to have the set of inequalities

$$ \begin{equation} \begin{aligned} 2x+3y+z\leq5,\\ 4x+y+2z\leq11,\\ 3x+4y+2z\leq8,\\ x\geq0,\\ y\geq0,\\ z\geq0,\\ \end{aligned} \end{equation} $$ and suppose that you want to show the RegionPlot3D associated to it together with the point $(0,0,0)$ (maybe by highlighting the point somehow).

How can you do it?

One last thing: suppose to have multiple points, say (0,0,0), (2.5,0,0), and (2,0,1) and that you want to make a sort of path (0,0,0)-> (2.5,0,0) -> (2,0,1) on the region, how can you do it?

$\endgroup$
1
  • $\begingroup$ Maybe I will use Sphere to plot the point? $\endgroup$ Feb 22, 2022 at 17:08

3 Answers 3

0
$\begingroup$

We can use HalfSpace[{2, 3, 1}, 5] to describe 2 x + 3 y + z <= 5 etc.

reg = RegionIntersection[HalfSpace[{2, 3, 1}, 5], 
   HalfSpace[{4, 1, 2}, 11], HalfSpace[{3, 4, 2}, 8], 
   HalfSpace[-{1, 0, 0}, 0], HalfSpace[-{0, 1, 0}, 0], 
   HalfSpace[-{0, 0, 1}, 0]];
Show[Region[Style[reg, Directive[Opacity[.8], Orange]]], 
 Region[Style[Line[{{0, 0, 0}, {2.5, 0, 0}, {2, 0, 1}}], 
   Directive[Red, AbsoluteThickness[5]]]], 
 Region[Style[Ball[{{0, 0, 0}, {2.5, 0, 0}, {2, 0, 1}}, .08], 
   Darker@Cyan]], Boxed -> True]

enter image description here

$\endgroup$
3
$\begingroup$
Clear["Global`*"]

Add points with Graphics3D and combine graphics with Show.

Show[
 RegionPlot3D[
  2 x + 3 y + z <= 5 && 4 x + y + 2 z <= 11 && 
   3 x + 4 y + 2 z <= 8 && x >= 0 && y >= 0 && z >= 0,
  {x, 0, 3}, {y, 0, 2}, {z, 0, 5}],
 Graphics3D[
  {Red, AbsolutePointSize[6], Point[{0, 0, 0}]}]]

enter image description here

EDIT: For multiple points

rgn = ImplicitRegion[
   2 x + 3 y + z <= 5 && 4 x + y + 2 z <= 11 &&
    3 x + 4 y + 2 z <= 8 && 
    x >= 0 && y >= 0 && z >= 0,
   {x, y, z}];

SeedRandom[1234];

Show[
 RegionPlot3D[rgn[[1]],
  {x, 0, 3}, {y, 0, 2}, {z, 0, 5},
  PlotStyle -> Opacity[0.3]],
 Graphics3D[
  {Red, AbsolutePointSize[6],
   Point[RandomPoint[rgn, 5]]}]]

enter image description here

$\endgroup$
0
2
$\begingroup$

EDIT so I missed the last three conditions

Show[
 RegionPlot3D[{2 x + 3 y + z <= 5 && 4 x + y + 2 z <= 11 && 
    3 x + 4 y + 2 z <= 8 && x > 0 && y > 0 && z > 0}, {x, -1, 
   2}, {y, -1, 2}, {z, -1, 2}
  , PlotStyle -> Directive[Yellow, Opacity[0.1]]
  , Mesh -> 5
  ],
 Graphics3D[{Red, Opacity[0.5], Sphere[{0, 0, 0}, 0.3]}]
 ]

enter image description here


EDIT 2

For additional points making a path:

pts = {{0, 0, 0}, {2.5, 0, 0}, {2, 0, 1}};

and add to Graphics:

, Sphere[#, 0.05] & /@ pts
, Thickness[0.02], Line@pts

original answer

Show[
 RegionPlot3D[{2 x + 3 y + z <= 5 && 4 x + y + 2 z <= 11 && 
    3 x + 4 y + 2 z <= 8}, {x, -1, 3}, {y, -1, 3}, {z, -1, 3}
  , PlotStyle -> Directive[Yellow, Opacity[0.1]]
  , Mesh -> 5
  ],
 Graphics3D[{Red, Opacity[0.5], Sphere[{0, 0, 0}, 0.3]}]
 ]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.