# Parametric equations and eq. of tangent plane

I have written the following code to determine the equation of a plane tangent to a surface at a given point:

z[x_, y_] := Log[x y^2 - 2]
zx[x_, y_] := Evaluate@D[z[x, y], x]
zy[x_, y_] := Evaluate@D[z[x, y], y]
tanPlane[x_, y_, x0_, y0_] :=
Expand[z[x0, y0] + zx[x0, y0] (x - x0) + zy[x0, y0] (y - y0)]
tanPlane[x, y, 3, 1]


It works well. But I'm now interested in writing code to find the equation of a tangent plane to a given parametric surface at a specific point.

So, for example, say $$x = u + v, y = 3u^2, z = u-v$$; at point (2,3,0).

How would I write code to calculate the eq. of the tangent plane to this surface? I've got this so far, which gives me the normal vector.

x[t] := u^2
y[t] := v^2
z[t] := u + 2 v
R[t] := {x[t], y[t], z[t]}
Cross[D[R[t], u], D[R[t], v]]


What I want to do is to auto-evaluate the given point, which will solve for the right $$u$$ and $$v$$ and then write and simplify the eq. of the plane.

• Commented Jan 8, 2021 at 15:03
• Checking that out; good code for other problems certainly, but trying to see how I can use it here.
– JDVC
Commented Jan 8, 2021 at 15:09

The following code seems to work for me

ClearAll[x, y, z, xyzuv, tanPlane];
xyzuv[u_,v_] := {u + v, 3 u^2, u - v};
tanPlane[x0_,y0_,z0_] := Module[{u, v, u0, v0, xyz, t},
{u0, v0} = {u, v} /. First @
Solve[(xyz = xyzuv[u, v]) == {x0, y0, z0}, {u, v}];
t = Cross[D[xyz, u], D[xyz, v]] /. {u -> u0, v -> v0};
Dot[t, {x, y, z} - {x0, y0, z0}]];


For example, the expression

tanPlane @@ xyzuv[1, 3] == 0


returns

-6(-4 + x) + 2(-3 + y) - 6(2 + z) == 0


which is the equation of the tangent plane at (4, 3, 2) which comes from u=1 and v=3. The simplified form of the equation is 3x - y + 3z = 3.

Note that in the code I explicitly use global variables x,y,z for the equation of the tangent plane.

• Hmmm..... I can't get that work. I'm using MMA 12.2. But @Somos, your code gives me an error. Commented Jan 10, 2021 at 23:36
• I got it to work. I just need to clear the variables. Thanks so much for your help. Commented Jan 11, 2021 at 1:30
• The tangent plane should be 3 x - y + 3 z - 3 == 0 Commented Jan 11, 2021 at 4:30
• @cvgmt Thanks for your helpful comment! I changed the variable bindings of my code which works as it should now. Commented Jan 11, 2021 at 17:23

In the old days, I would do it the way Somos did in his answer. These days, I very much like using the built-in region functionality of Mathematica:

surf[u_, v_] := {u^2, v^2, u + 2 v}

pla = InfinitePlane[surf[u, v], Transpose[D[surf[u, v], {{u, v}}]]];

Simplify[RegionMember[pla /. Thread[{u, v} -> {1, 1}], {x, y, z}], {x, y, z} ∈ Reals]
3 + x + 2 y == 2 z


Of course, for visualization purposes, pla is already usable as is:

sstyle = Directive[Specularity[White, 3], ColorData[97, 1],
Lighting -> {{"Ambient", RGBColor[0.197, 0.252, 0.333]},
{"Directional", RGBColor[0.155, 0.213, 0.298],
ImageScaled[{0, 2, 2}]},
{"Directional", RGBColor[0.155, 0.213, 0.298],
ImageScaled[{2, 2, 2}]},
{"Directional", RGBColor[0.155, 0.213, 0.298],
ImageScaled[{2, 0, 2}]}}];

Show[ParametricPlot3D[surf[u, v], {u, -3/2, 3/2}, {v, -3/2, 3/2}],
Graphics3D[{{sstyle, pla /. Thread[{u, v} -> {1, 1}]},
{Directive[AbsolutePointSize[5], ColorData[97, 4]],
Point[surf[1, 1]]}}], PlotRange -> All]


(This was supposed to be a comment that got too long.)

r[u_, v_] := {u^2, v^2, u + 2 v};
tangentPlane2[u0_,
v0_] := ({x, y, z} - r[u, v]) .
Cross[D[r[u, v], u], D[r[u, v], v]] == 0 /. {u -> u0, v -> v0} //
Simplify
tangentPlane2[1, 1]


3 + x + 2 y == 2 z

r[u_, v_] := {u^2, v^2, u + 2 v};
tangentPlane1[u0_, v0_] :=
Module[{u, v},
Last@RegionMember[
InfinitePlane[r[u, v], {D[r[u, v], u], D[r[u, v], v]}], {x, y,
z}] /. {u -> u0, v -> v0}]
tangentPlane1[1, 1] // Simplify


3 + x + 2 y == 2 z