Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
1  
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. –  Michael E2 Apr 5 at 15:23
    
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}] –  Coolwater Apr 5 at 15:24
    
@MichaelE2: Thanks. I emended my question. Piecewise still doesn't function though. –  Law Area 51 Proposal - Commit Apr 5 at 16:11
    
@Coolwater: Would you please explain "one true point of trueness"? –  Law Area 51 Proposal - Commit Apr 5 at 16:11
    
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 –  Coolwater Apr 5 at 19:40

2 Answers 2

up vote 5 down vote accepted

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

share|improve this answer

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 ]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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