The function h:(ℝ^3)⟶ℝ, h(x,y,z)=(x^2)+(y^2)+(z^2)is composed with the curve c:ℝ⟶(ℝ^3)given by c(t)=(t,2t+2,0).  The composition (h∘c)(t)=(((t))^2)+(((2t+2))^2)+(((0))^2)=5(t^2)+8t+4 is a real-valued function on ℝ.  But what does it mean?

h[x_,y_,z_]:=x^2+y^2+z^2;levelsets=ContourPlot3D[{x^2+y^2+z^2},{x,-10,10},{y,-10,10},{z,-10,0},Mesh->None,ContourStyle->Opacity[.5],Contours->{0,1,5,10,20,40,60,85},PlotRange->{{-10,10},{-10,10},{-10,10}},Boxed->False,AxesOrigin->{0,0,0},ImageSize->400];
curve = ParametricPlot3D[{t,2t+2,0},{t,-20,20},PlotStyle->{Red,Thick}];
tdot[t_]:=Graphics3D[{PointSize[.02],Blue,Point[{t,2t+2,0}]}];
Manipulate[{Show[levelsets,tdot[t],curve],":  the f-value along c"f[t,2t+2,0]},{t,-6,4}]

The function f:(ℝ^2)⟶ℝ, f(x,y)=(x^2)+(y^2)is composed with the curve p:ℝ⟶(ℝ^2)given by p(t)=(t,2t+2).  The composition (f∘p)(t)=(((t))^2)+(((2t+2))^2)=5(t^2)+8t+4 is real-valued.  Does f have extrema along p(t)? Of course it does.   By the method of Lagrange Multipliers, the curve p(t), which corresponds to the function y=2x+2, is just the 0-level set of the function g(x,y)=y-(2x+2).  Here, 
f will have critical points along p(t) whenever the gradient of f and that of g are multiples of each other.  Follow the arrows here.

f[x_,y_]:=x^2+y^2;
g[x_,y_]:=y-(2x+2);
g[t_]:=2t+2;
flevelsets=ContourPlot[{x^2+y^2},{x,-10,10},{y,-10,10},Contours->{0,1,5,10,20,40,60,85,98},PlotRange->{{-10,10},{-10,10},{0,100}},AspectRatio->1,Frame->False,Axes->True,ImageSize->400];
path= ParametricPlot[{t,g[t]},{t,-20,20},PlotStyle->{Red,Thick}];
pdot[t_]:=Graphics[{PointSize[.02],Blue,Point[{t,g[t]}]}];
gGradient[t_]:= Graphics[{Green,Thick,Arrow[{{t,g[t]},{-2+t,1+g[t]}}]}];
fGradient[t_]:=Graphics[{Yellow,Thick,Arrow[{{t,g[t]},{2t+t,2g[t]+g[t]}}]}];
Manipulate[{Show[flevelsets,gGradient[t],fGradient[t],path,pdot[t]],":  the f-value along c"f[t,g[t]]},{t,-6,4}]

The function f:(ℝ^3)⟶ℝ, f(x,y,z)=2x+(y^2)-(z^2)is constrained by the two equations 
x-2y=0 and x+z=0.  These are the two 0-level sets of the functions (Subscript[g, 1])(x,y,z)=x-2y=0, 
and (Subscript[g, 2])(x,y,z)=x+z=0.  Does f have extrema along S,the intersection of the 0-level sets of (Subscript[g, 1]) and (Subscript[g, 2])?  By the method of Lagrange Multipliers, if we can find a place along the intersection line where ∇f  = (Subscript[λ, 1])∇(Subscript[g, 1])+(Subscript[λ, 2])∇(Subscript[g, 2]), or where ∇f lives in the plane spanned by ∇(Subscript[g, 1])and ∇(Subscript[g, 2]).  Again, follow the arrows here.

ff[x_,y_,z_]:=2x+y^2-z^2;
g1[x_,y_,z_]:=x-2y;
g2[x_,y_,z_]:=x+z;

g1levelset = ParametricPlot3D[{t,t/2,u},{u,-10,10},{t,-20,20}, Mesh->None,PlotStyle->Blue,PlotRange->{{-10,10},{-10,10},{-10,10}}];
g2levelset = ParametricPlot3D[{t,u,-t},{t,-10,10},{u,-10,10}, Mesh->None,PlotStyle->Green];
slevelset = ParametricPlot3D[{-2t,-t,2t},{t,-10,10},PlotStyle->{Red,Thick}];
fflevelset = ContourPlot3D[2x+y^2-z^2,{x,-10,10},{y,-10,10},{z,-10,10}, Mesh->None,ContourStyle->Opacity[.5],Contours->10];

sdot[t_]:=Graphics3D[{PointSize[.02],Blue,Point[{-2t,-t,2t}]}];
g1Gradient[t_]:= Graphics3D[{Blue,Thick,Arrow[{{-2t,-t,2t},{1-2t,-2-t,2t}}]}];
g2Gradient[t_]:= Graphics3D[{Green,Thick,Arrow[{{-2t,-t,2t},{1-2t,-t,1+2t}}]}];
ffGradient[t_]:= Graphics3D[{Red,Thick,Arrow[{{-2t,-t,2t},{2-2t,-2t-t,-4t+2t}}]}];
Clear[g1g2plane]
g1g2[x_,y_]:=x+.5y;
g1g2plane [t_]:= Plot3D[g1g2[x,y]+9/2*t,{x,-10,10},{y,-10,10}, Mesh->None,PlotStyle->Yellow];



Show[g1levelset,g2levelset,slevelset,Boxed->False, AxesOrigin->{0,0,0}]
Show[fflevelset,slevelset,Boxed->False, AxesOrigin->{0,0,0}]
Manipulate[{Show[fflevelset,g1Gradient[t],g2Gradient[t],ffGradient[t],slevelset,sdot[t]],":  the f-value along c"ff[-2t,-t,2t]},{t,-6,4}]
 Manipulate[{Show[g1Gradient[t],g2Gradient[t],g1g2plane[t],ffGradient[t],slevelset,sdot[t],ImageSize->500,PlotRange->{{-5,5},{-5,5},{-5,5}}],":  the f-value along c"ff[-2t,-t,2t]},{t,-6,4}]