3
$\begingroup$

My main issue (multivariate calculus), I want to plot the body made within the surfaces

y + z = 4, y = 4 - x^2, y = 0 and z = 0.

the shape of which I am going to triple integrate as soon as I figure out how (not this topic but help is always welcome).

So far I have been trying using Plot3d, Contourplot3D and RegionFunction to show the area,

First try:

Show[
  {Plot3D[{z = 4 - y, y = 4 - x^2}, {x, -2, 2}, {y, -1, 5}, 
     Mesh -> None], 
   ContourPlot3D[{z == 0, y == 0}, {x, -2, 2}, {y, -1, 5}, {z, -1, 7}]}, 
  PlotRange -> All, AxesLabel -> {x, y}, Mesh -> None]

Second try:

Show[
  Plot3D[{4 - y, 4 - x^2, 0,}, {x, -2, 2}, {y, 0, 4.1},
    PlotStyle -> 
      {{Blue, Opacity[0.7]}, {Yellow, Opacity[0.4]}, 
       {Green, Opacity[0.4]}, {Red, Opacity[0.4]}}, 
      AxesLabel -> Automatic, 
      Mesh -> None]]

surfaces

(Was going to use y = 0 in red but I can't seem to get that one going so I limited to y > 0)

Now adding a RegionFunction here could maybe possibly show the shape I am working on, but I would need to use some kind of conditions since the "roof" is not simply made of one function but a mix of two. Any ideas on how I could solve this issue?

the issue being that If I add say

RegionFunction -> Function[{x, y, z}, 4 - x^2 > (4 - y)]

half of the shape will disappear.

computation

Does anyone have a good solution? As you can see from my code I am not proficient in Mathematica yet.

$\endgroup$
5
  • $\begingroup$ Have you looked at RegionPlot3D[]? $\endgroup$ May 7, 2016 at 15:07
  • $\begingroup$ Looking into it now =), lets see if I can figure it out, thanks $\endgroup$
    – Celebrin
    May 7, 2016 at 15:12
  • $\begingroup$ Is the desired result something like the output of this: RegionPlot3D[ 0 <= z <= 4 - y && 0 <= y <= 4 - x^2, {x, -2, 2}, {y, -1, 5}, {z, 0, 6}, Mesh -> None, PlotPoints -> 100, PlotStyle -> Directive[Yellow, Opacity[0.5]]]? $\endgroup$
    – kglr
    May 7, 2016 at 15:14
  • $\begingroup$ Yes definetely, I would wish on some differences in color to visualize better, but yes, this is more or less what I want, thanks alot!, now I just need to figure this out so I can replicate it. I still find it kinda hard to visualize in my head, not to mention which limits to put on x y z, , thanks for this =) $\endgroup$
    – Celebrin
    May 7, 2016 at 15:35
  • $\begingroup$ @Celebrin, with Plot3D you can use RegionFunction -> Function[{x, y, z}, 0 <= z <= Min[4 - x^2, (4 - y)]] to get the same region. $\endgroup$
    – kglr
    May 7, 2016 at 15:36

2 Answers 2

5
$\begingroup$
Plot3D[{4 - y, 4 - x^2, 0}, {x, -2, 2}, {y, 0, 4.1}, 
 PlotStyle -> {{Blue, Opacity[0.7]}, {Yellow, Opacity[0.4]}, {Green,  Opacity[0.4]}}, 
 AxesLabel -> Automatic, Mesh -> None, 
 RegionFunction -> Function[{x, y, z}, 0 <= z <= Min[4 - x^2, (4 - y)]]]

Mathematica graphics

ParametricPlot3D:

ParametricPlot3D[{{x, y, ConditionalExpression[4 - x^2, 4 - x^2 <= (4 - y)]}, 
 {x, y, ConditionalExpression[4 - y, 4 - x^2 > (4 - y)]}, {x, y, 0},
 {x, 0, Min[y, 1] (4 - x^2)}}, 
 {x, -2, 2}, {y, 0, 4.1}, Mesh -> None,  PlotPoints -> 100,
 PlotStyle -> {Opacity[0.5, Blue], Opacity[0.5, Green], 
               Opacity[0.5, Yellow], Opacity[0.9, Red]}]

Mathematica graphics

$\endgroup$
4
  • $\begingroup$ Great! =) that is really great =) , in my opinion a better visualisation, no? I am however getting syntax errors with that code and cannot seem to find the fault, are you running it in a Show[] or something? Expression "Plot3D[{4-y,4-x^2,0},{x,-2,2},{y,0,4.1},PlotStyle-><<1>>" has no closing "]". $\endgroup$
    – Celebrin
    May 7, 2016 at 16:02
  • $\begingroup$ @Celebrin, I agree; it is faster than RegionPlot3D too. I added the missing { that was causing the error error message. $\endgroup$
    – kglr
    May 7, 2016 at 16:23
  • $\begingroup$ Btw, any ideas if I wanted to bring in the y=0 plane too?, could I bring it into plot3d? $\endgroup$
    – Celebrin
    May 7, 2016 at 16:30
  • $\begingroup$ @Celebrin, i updated with an alternative approach using ParametricPlot3D that includes a way to depict the y==0 plane. $\endgroup$
    – kglr
    May 7, 2016 at 16:56
1
$\begingroup$
r = ImplicitRegion[{y + z <= 4, y <= 4 - x^2, y >= 0 , z >= 0}, {x, y,
     z}];
i = HoldForm[Integrate[1, {x, -2, 2}, {y, 0, 4 - x^2}, {z, 0, 4 - y}]];
cp = ContourPlot3D[{z == 0, y == 0, 4 - y - x^2 == 0, 
    y + z == 4}, {x, -2, 2}, {y, 0, 4}, {z, 0, 4}, Mesh -> None, 
   ContourStyle -> {Red, Green, Blue, Orange}, 
   PlotLegends -> "Expressions"];
rp = RegionPlot3D[r, PlotPoints -> 100, Background -> Black];
TraditionalForm[Column[
  {r,
   Row[{i, "=", ReleaseHold[i]}],
   Row[{"Volume[r]= ", Volume[r]}],
   Row[{cp, rp}]}, Alignment -> Center]]

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.