1
$\begingroup$

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?

$\endgroup$
4
  • $\begingroup$ 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" $\endgroup$
    – yoyo
    Dec 21, 2011 at 16:10
  • $\begingroup$ 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! $\endgroup$
    – Verbeia
    Jan 12, 2012 at 1:53
  • $\begingroup$ @Verbeia:I have committed, hope we go to beta phase soon :-) $\endgroup$
    – Quixotic
    Jan 12, 2012 at 14:57
  • $\begingroup$ @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. $\endgroup$
    – Verbeia
    Jan 13, 2012 at 1:33

3 Answers 3

5
$\begingroup$

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

$\endgroup$
4
$\begingroup$
Plot3D[5-Sqrt[x^2+y^2],{x,-5,5},{y,-5,5},PlotRange->{0,5}]
$\endgroup$
4
$\begingroup$

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

$\endgroup$
2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .