1
$\begingroup$

I'd like to 3D-plot the region between the infinite cone $z=1-x^2-y^2$ and the plane $z = 1-y, z \ge 0$ in Mathematica 10. Also I'd like to know if there is any way (in Mathematica) to calculate the volume of the region above. Thanks a lot

P.S. This is the region I tried to plot from a book.

enter image description here

$\endgroup$
  • 1
    $\begingroup$ Have you tried ImplicitRegion and Volume? $\endgroup$ – Edmund Dec 8 '15 at 18:06
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Michael E2 Dec 8 '15 at 19:01
  • $\begingroup$ Thanks for the answer. I already tried ImplicitRegion but i can't get the correct plot. could you write here the exact input please? $\endgroup$ – ConCarayiannis Dec 8 '15 at 23:03
3
$\begingroup$

I started this mainly for fun, I guess, but it makes a nice, sharp plot. The region needs to have a nice CylindricalDecomposition. Reduce will compute this, too. It makes a predictable format that can be rewritten easily into code for other standard Mathematica functions.

CylindricalDecomposition[z < 1 - x^2 - y^2 && z >= 0 && z > 1 - y, {y, x, z}]
Reduce[z < 1 - x^2 - y^2 && z >= 0 && z > 1 - y, {y, x, z}]
Reduce[z < 1 - x^2 - y^2 && z >= 0 && z > 1 - y, z]
(*  all give the same answer:
  0 < y < 1 && -Sqrt[y - y^2] < x < Sqrt[y - y^2] && 1 - y < z < 1 - x^2 - y^2
*)

This example gives a simple cylindrical decomposition. Often a region can be written only as a sum of such cylindrical regions. CylindricalDecomposition returns the "sum" in the form

Or[cd1, cd2,...]

This case, too, is easy to handle (e.g. replace Or by List, perhaps), but how to do it depends on the application. So I will leave it to the interested reader to explore.

Code:

ClearAll[cdapply];
cdapply[f_, argsfn_: List, opts___] := 
  HoldPattern[
    And[_[u1_, ___, u_Symbol /; Context[u] === "Global`", ___, u2_],
     _[v1_, ___, v_Symbol /; Context[v] === "Global`", ___, v2_], _[w1_, ___, w2_]]
    ] :> f[argsfn[w1, w2], {u, u1, u2}, {v, v1, v2}, opts];

The need for ___ between the arguments is because there are two ways to express an inequality $a < b < c$:

Less[a, b, c]
Inequality[a, Less, b, Less, c]

The pattern matches both, but the code does assume the inequality is Less (or LessEqual).

OP's example, with three views of the result:

cd = Reduce[z < 1 - x^2 - y^2 && z >= 0 && z > 1 - y, z];
cd /. cdapply[Plot3D, List, PlotPoints -> 50];
GraphicsRow[{%, %, %}]

Mathematica graphics

cd /. cdapply[Integrate, #2 - #1 &]
(*  π/32  *)

Here's what code the replacement rule is constructing:

cad /. cdapply[Inactive@Plot3D, List, PlotPoints -> 50]

Mathematica graphics

cad /. cdapply[Inactive[Integrate], #2 - #1 &]

Mathematica graphics

One could adapt the replacement rule to handle functions like Integrate that allow three or more parameters as arguments.

ClearAll[cdapplyAll];
cdapplyAll[f_, argsfn_: (1 &), opts___] := 
  HoldPattern[
    And[_[u1_, ___, u_Symbol /; Context[u] === "Global`", ___, u2_],
     _[v1_, ___, v_Symbol /; Context[v] === "Global`", ___, v2_],
     _[w1_, ___, w_Symbol /; Context[w] === "Global`", ___, w2_]]
    ] :> f[argsfn[{u, u1, u2}, {v, v1, v2}, {w, w1, w2}],
           {u, u1, u2}, {v, v1, v2}, {w, w1, w2}, opts];

cd /. cdapplyAll[Integrate]
(*  π/32  *)

cad /. cdapplyAll[Inactive[Integrate]]

Mathematica graphics

$\endgroup$
2
$\begingroup$
RegionPlot3D[z < 1 - x^2 - y^2 && z >= 0 && z > 1 - y,
 {x, -1, 1}, {y, -1, 1}, {z, -1, 1},
 PlotPoints -> 50]

enter image description here

Integrate[
          If[z < 1 - x^2 - y^2 && z >= 0 && z > 1 - y, 1, 0],
          {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]

${\pi \over 32}$

Alternatively:

myRegion = 
  ImplicitRegion[0 <= z < 1 - x^2 - y^2 && z > 1 - y , {x, y, z}];

RegionPlot3D[myRegion, PlotStyle -> Opacity[0.5], PlotPoints -> 50]

enter image description here

RegionMeasure[myRegion]

${\pi \over 32}$

$\endgroup$
  • $\begingroup$ Wow!! Thanks a lot David, that helped me a lot :) $\endgroup$ – ConCarayiannis Dec 9 '15 at 9:40
  • $\begingroup$ @ConCarayiannis As I said, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign. It's the SE way to say thanks, as well. :) $\endgroup$ – Michael E2 Feb 21 '16 at 16:08
1
$\begingroup$
reg = ImplicitRegion[1 - y <= z <= 1 - x^2 - y^2 && z >= 0, {x, y, z}];

Volume[reg]

(*  Pi/32  *)

Show[
 Plot3D[1 - x^2 - y^2,
  {x, -1, 1}, {y, -1, 1},
  PlotStyle ->
   Directive[Blue, Opacity[0.4]]],
 Plot3D[1 - y,
  {x, -1, 1}, {y, -1, 1},
  PlotStyle ->
   Directive[Gray, Opacity[0.4]]],
 RegionPlot3D[reg,
  PlotStyle -> Red,
  PlotPoints -> 100],
 AxesLabel ->
  (Style[#, 14, Bold] & /@ {"x", "y", "z"})]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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