1
$\begingroup$

How would I plot in 3D: $\begin{cases} (4 - z^2) = x^2 + y^2, 2 \le z \le 4 \\ x^2 + y^2 = 4, -2 \le z \le 2 \end{cases}$.

I tried http://reference.wolfram.com/mathematica/ref/Piecewise.html

ContourPlot3D[ Piecewise[{(4 - z)^2 == x ^2 + y^2, 2 \le z \le 4}, {x^2 + y^2 = 4, -2 \le z \le 2}], {x, -3, 3}, {y, -3 , 3}, {z, -2, 4}]

I realise there's tex in my code but I don't know how otherwise to symbolise my attempt.

$\endgroup$
  • 1
    $\begingroup$ Your code omits the function Piecewise -- how did you try to use it? Also, your code mixes Mathematica with TeX -- I don't think that's going to work. $\endgroup$ – Michael E2 Apr 5 '14 at 15:23
  • $\begingroup$ Your first equation has only one point of trueness, so just delete it and do ContourPlot3D[4 == x^2 + y^2, {x, -3, 3}, {y, -3, 3}, {z, -2, 2}] $\endgroup$ – Coolwater Apr 5 '14 at 15:24
  • $\begingroup$ @MichaelE2: Thanks. I emended my question. Piecewise still doesn't function though. $\endgroup$ – Greek - Area 51 Proposal Apr 5 '14 at 16:11
  • $\begingroup$ @Coolwater: Would you please explain "one true point of trueness"? $\endgroup$ – Greek - Area 51 Proposal Apr 5 '14 at 16:11
  • $\begingroup$ I thought your first equation would give an empty contour plot, because only one point in R^3 satisfy it. The thing is I was looking at your latex equations which says (4-z^2) rather than (4-z)^2 $\endgroup$ – Coolwater Apr 5 '14 at 19:40
5
$\begingroup$

I would plot each separately and combine them:

Show[
 ContourPlot3D[(4 - z)^2 == (x^2 + y^2), {x, -3, 3}, {y, -3, 3}, {z, 2, 4}],
 ContourPlot3D[x^2 + y^2 == 4, {x, -3, 3}, {y, -3, 3}, {z, -2, 2}],
 PlotRange -> All
 ]

Mathematica graphics

$\endgroup$
2
$\begingroup$

Piecewise version :

ContourPlot3D[ x^2 + y^2 == 
                Piecewise[{{(4 - z)^2, 2 <= z <= 4}, {4, -2 <= z <= 2}}],
                 {x, -3, 3}, {y, -3, 3}, {z, -2, 4}, PlotRange -> All ]
$\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.