A draft notebook from my Calculus II files.
from sympy import *
init_printing()
Consider:
$$ f(x, y) = x^2 \sin{y}$$x, y = symbols('x y')
f = x**2 * sin(y)
dx = diff(f, x)
dx
dy = diff(f, y)
dy
Also pronounced "del".
The gradient of $f$ is a vector that has all the partial derivatives in it.
In this case, $f$ is a two-variable function so there are two derivatives in it.
\begin{align} \nabla f &= \left[ \frac{f_x}{f_y} \right] \\ \\ &= \left[ \frac{ 2x \sin{y} }{ x^2 \cos{y} } \right] \end{align}The gradient points in the direction of steepest ascent. Not 100% sure what this means...
To match the example in the video linked above.
g = x**2 + y**2
g
g = plotting.plot3d(g, (x, -5, 5), (y, -5, 5))
gradient = [
diff(g, x),
diff(g, y)
]
gradient
The gradient is a function that takes in an $(x, y)$ input and returns a vector. Perhaps this vector points in the direction of steepest ascent?
p1 = {'x': 1, 'y': 1}
delAtP1 = [d.subs(p1) for d in gradient]
delAtP1
I think this means that if you are standing at $(1, 1, 2)$, you should "walk" in the $(2, 2)$ direction in order to reach a higher output value (since this is the fastest way). I don't really understand what this means.
Link to GeoGebra.