Partial Derivarives and Tangent Plane
Author: Joseph Lo

y_0 = %v

x_0 = %v

θ

Trace along a chosen direction

Normal Vector at (x0, y0)

Trace along x = x0

Trace along y = y0

Tangent plane at (x0, y0)

fx

y0 = 0.2 (slider from -1 to 1, step 0.05)
x0 = 0.1 (slider from 0.1 to 0.1, step 0.05)
tanDirSize = 0.5
angle = 1.98 (slider from 0 to 1.98, step 0.02)
theta: (angle * π)
Psin: sin(theta)
Pcos: cos(theta)
f(x, y) = exp((-(x^(2) + y^(2))))
fy = Derivative(f(x, y), y)
fx = Derivative(f(x, y), x)
Point: (x0, y0)
xP: x(Point)
yP: y(Point)
fP: f(xP, yP)
fyP: fy(xP, yP)
fxP: fx(xP, yP)
fsP: (Pcos * fxP) + (Psin * fyP)
tanPlaneSize = 0.5
tracecheck = false
PointSurface: (xP, yP, fP)
dy: tanPlaneSize / sqrt(1 + fyP^(2))
dx: tanPlaneSize / sqrt(1 + fxP^(2))
P4: (xP + dx, yP + dy, fP + (fxP * dx) + (fyP * dy))
P5: (xP - dx, yP + dy, fP - (fxP * dx) + (fyP * dy))
P6: (xP - dx, yP - dy, fP - (fxP * dx) - (fyP * dy))
P7: (xP + dx, yP - dy, fP + (fxP * dx) - (fyP * dy))
TanPlane = Surface(xP + s, yP + t, fP + (s * fxP) + (t * fyP), s, (-dx), dx, t, (-dy), dy)
Surface = Surface(s, t, f(s, t), s, -1.5, 1.5, t, -1.5, 1.5)
trace = CurveCartesian((t * Pcos) + xP, (t * Psin) + yP, f((t * Pcos) + xP, (t * Psin) + yP), t, -3, 3)
Plane = Surface((s * Pcos) + xP, (s * Psin) + yP, t, s, -3, 3, t, -2, 2)
tanDirLenNorm: tanDirSize / sqrt(1 + fxP^(2) + fyP^(2))
tanDirLenx: tanDirSize / sqrt(1 + fxP^(2))
tanDirLeny: tanDirSize / sqrt(1 + fyP^(2))
tanArrowx = Vector((xP, yP, fP), (xP + tanDirLenx, yP, fP + (tanDirLenx * fxP)))
tanDirLen: tanDirSize / sqrt(1 + fsP^(2))
tanArrow = Vector((xP, yP, fP), (xP + (tanDirLen * Pcos), yP + (tanDirLen * Psin), fP + (tanDirLen * fsP)))
tanArrowy = Vector((xP, yP, fP), (xP, yP + tanDirLeny, fP + (tanDirLeny * fyP)))
tanNorm = Vector((xP, yP, fP), (xP - (tanDirLenNorm * fxP), yP - (tanDirLenNorm * fyP), fP + tanDirLenNorm))
tangentx = Line((xP, yP, fP), tanArrowx)
tangenty = Line((xP, yP, fP), tanArrowy)
tangent = Line((xP, yP, fP), tanArrow)
normalcheck = false
poly1, a, b, c, d = Polygon((-2.7, 1.2), (7.3, 1.2), (7.3, 9.2), (-2.7, 9.2))
traceycheck = true
tracexcheck = true
tanplanecheck = false
Arrowx = Vector((xP, yP), (xP + tanDirSize, yP))
Arrowy = Vector((xP, yP), (xP, yP + tanDirSize))
Arrow = Vector((xP, yP), (xP + (tanDirSize * Pcos), yP + (tanDirSize * Psin)))
A = Point(Arrowx)
B = Point(Arrow)
α = Angle(A, Point, B)
m = Segment((xP, yP), (xP + tanDirSize, yP))
tracex = CurveCartesian(t, yP, f(t, yP), t, -1.5, 1.5)
tracey = CurveCartesian(xP, t, f(xP, t), t, -1.5, 1.5)
text1: "At point (" + x0 + ", " + y0 + ")"
text2: "Direction of the trace:
θ = " + angle + "π"
text6: "Tangent plane at (" + x0 + ", " + y0 + ")"
C: ((0.4 * cos(theta / 2)) + xP, (0.4 * sin(theta / 2)) + yP)
text5: "Normal vector at (" + x0 + ", " + y0 + ")"
linex = Line((xP, yP), Arrowx)
liney = Line((xP, yP), Arrowy)
line = Line((xP, yP), Arrow)
texttracexneg: "Trace along y = " + y0 + ", ∂f/∂x < 0"
texttracexzero: "Trace along y = " + y0 + ", ∂f/∂x = 0"
texttracexpos: "Trace along y = " + y0 + ", ∂f/∂x > 0"
texttracex: "Trace along y = " + y0 + ""
texttrceypos: "Trace along x = " + x0 + ", ∂f/∂y > 0"
texttraceyzero: "Trace along x = " + x0 + ", ∂f/∂y = 0"
texttraceyneg: "Trace along x = " + x0 + ", ∂f/∂y < 0"
texttracey: "Trace along x = " + x0 + ""
Ponplane: (xP, yP, 0)
e = Segment(PointSurface, Ponplane)