# Cross section of $z=2x^2-y^2$

I am trying to get the cross section of the graph $z = 2x^2 - y^2$ and I have no clue where to even start. I am supposed to take the cross section at $x=0, x=-1, x=1, y=0, y=1, y=1, z=0, z=1$, and $z=-1$.

I tried taking my original code and just subbing in the values that I am supposed to take the cross section at, but that does not seem correct. My TA mentioned something about a Show function, but did not explain how it worked.

My original code:

Plot3D[2x^2-y^2, {x,-1,1}, {y,-1,1}]


You can visualize the slices with ParametricPlot3D

GraphicsRow[
With[{slice = #},
Show[
ParametricPlot3D[{x, y, f[x, y]}, {x, -2, 2}, {y, -2, 2},
AxesLabel -> {"x", "y", "f"}, ViewVector -> {4, -7, 11}],
ParametricPlot3D[
Evaluate[slice /@ {-1, 0, 1}], {a, -5, 5}, {b, -5, 5}],
BoxRatios -> {1, 1, 1}]
] & /@ {{#, a, b} &, {a, #, b} &, {a, b, #} &}, ImageSize -> 750
] Notice how useful the Show function is here. Basically it allows you to "show" multiple plots within the same graphics object. You could get flashier and highlight the curves where the slices intersect the surface (try, for example, ParametricPlot3D[{-1, y, f[-1, y]}, {y, -2, 2}]), but I'll leave that up to you.

(I've also made use of Map (/ @) which is a very useful tool when you're working over lists, and With, which is a scoping construct that, among other things, can make using Map much clearer.)

And to get plots of the specific slices

plotfuns = {f[#, a] == b &, f[a, #] == b &, f[a, b] == # &};
framelabels = {{"y", "z"}, {"x", "z"}, {"x", "y"}};
plotlabels = {"f[" <> ToString[#] <> ", y]" &,
"f[x, " <> ToString[#] <> "]" &, "f[x, y] == " <> ToString[#] &};

GraphicsGrid[
With[{plotinfo = #},
ContourPlot[Evaluate@plotinfo[][#], {a, -2, 2}, {b, -2, 2},
AspectRatio -> 1, FrameLabel -> plotinfo[],
PlotLabel -> plotinfo[][#]] & /@ {-1, 0, 1}] & /@
Transpose[{plotfuns, framelabels, plotlabels}],
ImageSize -> 750
] f = Function[{x, y}, 2 x^2 - y^2]
slicePts = {-1, 0, 1}
(* slice on x: *)
Plot[f[#, y], {y, -2, 2}] & /@ slicePts
(* slice on y: *)
Plot[f[x, #], {x, -2, 2}] & /@ slicePts
(* slice on z: *)
ContourPlot[# == f[x, y], {x, -2, 2}, {y, -2, 2}] & /@ slicePts


You can also use MeshFunctions

Manipulate[
Plot3D[2 x^2 - y^2, {x, -2, 2}, {y, -2, 2}, MeshFunctions -> (fun),
Mesh -> {msh},MeshStyle -> Red],
{fun, {#1 &, #2 &, #3 &}}, {msh, {{-1}, {0}, {1}}}] 