# Traces of the level surface $z=4x^2+y^2$

I came up with this method to plot the traces of the surface $z=4x^2+y^2$, in this case for $z=1$, 2, 3, and 4.

ContourPlot3D[{z == 4 x^2 + y^2, z == 1, z == 2, z == 3,
z == 4}, {x, -2, 2}, {y, -2, 2}, {z, 0, 4.01},
ContourStyle -> {Opacity[0.3]},
PlotPoints -> 30, MaxRecursion -> 3,
Mesh -> {{1, 2, 3, 4}}, MeshFunctions -> {#3 &},
MeshStyle -> {Thick, Red},
AxesLabel -> {"x", "y", "z"}]


Which produces this image: I am now looking for a way to hide the surface $z=4x^2+y^2$, but keep the planes and the mesh curves.

Any suggestions?

Update:

Consider obtaining traces for the surface $z=y^2-x^2$ using technique shown by MichaelE2.

ContourPlot3D[z, {x, -2, 2}, {y, -2, 2}, {z, -1.5, 1.5},
Contours -> {-1, 0, 1}, ContourStyle -> {Opacity[0.3]},
PlotPoints -> 30, MaxRecursion -> 3, Mesh -> {{0}},
MeshFunctions -> {Function[{x, y, z}, z - (y^2 - x^2)]},
MeshStyle -> Directive[Thick, Red], AxesLabel -> Automatic]


Image: ContourPlot3D[x, {x, -2, 2}, {y, -2, 2}, {z, -1.5, 1.5},
Contours -> {-1, 0, 1}, ContourStyle -> {Opacity[0.3]},
PlotPoints -> 30, MaxRecursion -> 3, Mesh -> {{0}},
MeshFunctions -> {Function[{x, y, z}, z - (y^2 - x^2)]},
MeshStyle -> Directive[Thick, Red], AxesLabel -> Automatic]


Image: ContourPlot3D[y, {x, -2, 2}, {y, -2, 2}, {z, -1.5, 1.5},
Contours -> {-1, 0, 1}, ContourStyle -> {Opacity[0.3]},
PlotPoints -> 30, MaxRecursion -> 3, Mesh -> {{0}},
MeshFunctions -> {Function[{x, y, z}, z - (y^2 - x^2)]},
MeshStyle -> Directive[Thick, Red], AxesLabel -> Automatic]


Image: I think this gives students a very simple way to get the traces for a quadratic surface.

• How about changing ContourStyle -> {Opacity[0.3]} to ContourStyle -> {Opacity[0.0], Opacity[0.3], Opacity[0.3], Opacity[0.3], Opacity[0.3]} ? – Gregory Rut Jun 5 '15 at 20:18
• @GregoryRut: This worked very well, but I also had to include a BoundaryStyle->None. Thanks for the help and the good idea. – David Jun 5 '15 at 21:52
• @GregoryRut Somewhat better is ContourStyle -> {None, Opacity[0.3], Opacity[0.3], Opacity[0.3], Opacity[0.3]}. The plot will be almost 20% smaller. (Omitting the paraboloid altogether makes the plot almost 50% smaller.) – Michael E2 Jun 5 '15 at 22:05
• Question: I don't see any mention of derivatives or integrals anywhere in the question, so why put in the calculus-and-analysis tag? Here, you are merely slicing surfaces… – J. M.'s ennui Jun 5 '15 at 23:08
• @Guesswhoitis. First, this problem is from Stewart's Early Transcendentals Calculus Book 5th Ed (we have a bunch of free books on reserve so students don't have to pay \$250 to buy a book), section 12.6, Examples #4 and 5. So it is a very seriously hard calculus problem (students are expected to draw it by hand). Second, if some folks search this site for calculus examples by using a tag, then the calculus tag could be helpful. How's that? – David Jun 6 '15 at 5:00

You could omit the (paraboloid) surface and use its formula as a mesh function:

ContourPlot3D[z, {x, -2, 2}, {y, -2, 2}, {z, 0, 4.01},
Contours -> Range, ContourStyle -> {Opacity[0.3]},
PlotPoints -> 30, MaxRecursion -> 3, Mesh -> {{0}},
MeshFunctions -> {Function[{x, y, z}, z - (4 x^2 + y^2)]},
MeshStyle -> Directive[Thick, Red], AxesLabel -> Automatic] You may like the simpler approach above, but if you want to get fancy, you could highlight the ellipses.

ContourPlot3D[z, {x, -2, 2}, {y, -2, 2}, {z, 0, 4.01},
Contours -> Range, ContourStyle -> {Opacity[0.3]},
PlotPoints -> 30, MaxRecursion -> 3, Mesh -> {Range[0.5, 3.5], {0}},
{Opacity[ 0.2], ##} & @@@
("DefaultPlotStyle" /. (Method /. ChartingResolvePlotTheme["Default", ContourPlot3D])),
{Opacity[0.7], ##} & @@@
("DefaultPlotStyle" /. (Method /. ChartingResolvePlotTheme["Default", ContourPlot3D]))
},
MeshFunctions -> {#3 &, Function[{x, y, z}, z - (4 x^2 + y^2)]},
MeshStyle -> Directive[Thick, Red], AxesLabel -> {"x", "y", "z"}] • Yep, the first method will be easier for my students to understand, so that is my preference. I think I understand what it does so I will be able to explain it to the students. It plots the level surface for z, and because of Mesh->Range, it plots the level surfaces z=1, z=2, z=3, z=4, which are the four planes. Then the MeshFunctions->{Function[x,y,z], z-(4x^2+y^2)]} Sketch all the points on each plane that satisfies z-(4x^2+y^2)=0. Have I got that correct? Also, I used your technique to get the traces for the surface z=y^2-x^2. See the update in my original post. – David Jun 5 '15 at 22:37
• @David, Yep, you got it. And you can change the range to get a denser slices; e.g. Range[0, 4, 0.2]. Note that ContourPlot won't plot an isolated point. You'd have to offset the range slightly to mark the bottom of the paraboloid; e.g. Range[0.002, 4.002, 0.5]. (You know, every now and then computing these plots are crashing my kernel, including my plots and yours. Nothing reproducible.) – Michael E2 Jun 5 '15 at 23:24
• Me too. Ever since updating to Mathematica 10.1, I've been experiencing all kinds of problems. The Beep, telling me the Kernel quit. I've had lockups where I have had to Force Quit Mathematica (I'm on a MacBook Pro 10.10.3), and I have had crash reports. I've sent several of them to Wolfram Support along with some notebooks. – David Jun 6 '15 at 2:57