*A draft notebook from my Calculus II files.*

In [1]:

```
from sympy import *
```

In [2]:

```
init_printing()
```

Consider:

$$ f(x, y) = x^2 \sin{y}$$In [3]:

```
x, y = symbols('x y')
```

In [4]:

```
f = x**2 * sin(y)
```

In [5]:

```
dx = diff(f, x)
dx
```

Out[5]:

In [6]:

```
dy = diff(f, y)
dy
```

Out[6]:

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.

In [8]:

```
g = x**2 + y**2
g
```

Out[8]:

In [10]:

```
g = plotting.plot3d(g, (x, -5, 5), (y, -5, 5))
```

In [9]:

```
gradient = [
diff(g, x),
diff(g, y)
]
gradient
```

Out[9]:

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?

In [17]:

```
p1 = {'x': 1, 'y': 1}
```

In [18]:

```
delAtP1 = [d.subs(p1) for d in gradient]
delAtP1
```

Out[18]:

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.