Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Could anybody tell me how to plot $z= 5-\sqrt{x^2+y^2}, 0 \le z \le 5$ in mathematica?

I haven't done much on multivariable yet, but I am inquisitive to know how to plot this cone on mathematica?

share|improve this question
    
i would use cylindrical coords $z=5-r, 0\leq r\leq5, 0\leq\theta\leq2\pi$ after looking up how to plot something like this in the mathematica "help" –  yoyo Dec 21 '11 at 16:10
    
You might be interested in the proposal for a Mathematica-specific StackExchange site. We are quite close to getting into beta, so please consider committing soon! –  Verbeia Jan 12 '12 at 1:53
    
@Verbeia:I have committed, hope we go to beta phase soon :-) –  Quixotic Jan 12 '12 at 14:57
    
@MaX you don't seem to be in the list. You might not have confirmed your email address. Please do this. The confirmation email might be caught in your spam-catcher. –  Verbeia Jan 13 '12 at 1:33

3 Answers 3

up vote 4 down vote accepted
Plot3D[5-Sqrt[x^2+y^2],{x,-5,5},{y,-5,5},PlotRange->{0,5}]
share|improve this answer

RegionPlot3D can be useful for this.

RegionPlot3D[
 z - (5 - Sqrt[x^2 + y^2]),
 {x, -5, 5}, {y, -5, 5}, {z, 0, 5}, 
 PlotPoints -> 50
]

Mathematica graphics

share|improve this answer

To restrict the plot to $0 \le z \le 5$, you can use the option RegionFunction, like so:

Plot3D[5 - Sqrt[x^2 + y^2], {x, -5, 5}, {y, -5, 5}, 
 RegionFunction -> Function[{x, y, z}, 0 < z < 5]]

Mathematica graphics

An essential difference between RegionFunction and PlotRange:

  • when using RegionFunction, all points generated outside the region are discarded before building the 3D object to show, and the boundary of the region is computed and plotted nicely.

  • when using PlotRange, all points are included in the 3D object, but it is clipped to a box determined by the plot range while rendering.

You can only restrict what's being show to a box using PlotRange while RegionFunction lets you specify a region of any shape. Please also see my two answers here.


You may also want to use a custom mesh, to make it prettier. Here's how to do it without leaving Cartesian coordinates:

Plot3D[5 - Sqrt[x^2 + y^2], {x, -5, 5}, {y, -5, 5}, 
 RegionFunction -> Function[{x, y, z}, 0 < z < 5], 
 MeshFunctions -> Function[{x, y, z}, z]]

Mathematica graphics

MeshFunctions -> {Function[{x, y, z}, z], 
                  Function[{x, y, z}, ArcTan[x, y]]}

Mathematica graphics

share|improve this answer
    
Looks pretty. +1 –  Mr.Wizard Jan 17 '12 at 14:41
    
@Mr.W I tried to make them pretty and anti-aliased but I ran into the problem of ticks not scaling properly. –  Szabolcs Jan 17 '12 at 15:47

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.