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?
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?
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]]
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]]
MeshFunctions -> {Function[{x, y, z}, z], Function[{x, y, z}, ArcTan[x, y]]}
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 ]
Plot3D[5-Sqrt[x^2+y^2],{x,-5,5},{y,-5,5},PlotRange->{0,5}]