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.

I'm new to Mathematica and I need to ask how to graph a sphere, cylinder, etc.. using cartesian equations.

For example in sphere's case $x^2+y^2+z^2=1$

I tried to use Plot3D but it doesn't work..

share|improve this question
3  
Mathematica's help docs are generally going to be your #1 resource. Click on Plot3D, hit F1, and within a click or two you will find RegionPlot3D and other related functions (by following the "see also" links at the bottom). –  amr Apr 27 '13 at 19:00
add comment

1 Answer

RegionPlot3D[x^2 + y^2 + z^2 <= 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]

or

RegionPlot3D[Norm[{x, y, z}] <= 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]

enter image description here

RegionPlot3D[x^2 + y^2 <= 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]

enter image description here

Edit
All together now!

opt = {Mesh -> False, Boxed -> False, Axes -> False};
Show[
 RegionPlot3D[x^2 + y^2 + z^2 <= 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
              Evaluate@opt, PlotStyle -> Directive[Yellow]], 
 RegionPlot3D[x^2 + y^2 <= 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
              Evaluate@opt, PlotStyle -> Directive[Red, Opacity[0.5]]]]

enter image description here

share|improve this answer
7  
Or ContourPlot3D[ x^2 + y^2 + z^2 == 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}] –  Silvia Apr 27 '13 at 16:33
    
Thank you very much Silvia =))) –  German Apr 27 '13 at 16:55
    
@belisarius: Using RegionPlot3D gives the "solid sphere", a 3-manifold, whereas the OP asked for the spherical surface, a 2-manifold, and that's what ContourPlot3D gives. (Not that one would see much difference graphically--unless one began slicing into the object.) –  murray Apr 28 '13 at 15:32
    
@murray Thanks. I'm aware of that, but as the OP asked for a "graph" and not for a mathematical description of the surface, I think the result is "almost but not quite .." –  belisarius Apr 28 '13 at 15:57
add comment

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.