<a href="https://colab.research.google.com/github/HenriqueCCdA/ElementosFinitosCurso/blob/main/notebooks/plot3d.ipynb" target="_parent"></a>


```python
import matplotlib.pyplot as plt
import numpy as np
```

\begin{equation}
f(x,y) = x*y^2
\end{equation}

\begin{equation}
\nabla f(x,y) =
\begin{bmatrix}
y^2\\
2*x*y
\end{bmatrix}
\end{equation}

\begin{equation}
\nabla \bullet \nabla f(x,y) = 2*x
\end{equation}


```python
def func(x,y):
  return x*y**2

def grad(x,y):

  dfdx = y**2
  dfdy = 2*x*y 

  return (dfdx, dfdy)

def div(x, y):
  return 2*x
```


```python
x, y   = np.mgrid[-20:20:0.1,-20:20:0.1]
xi, yi = np.mgrid[-20:20:1.0,-20:20:1.0]

f = func(x,y)

gf = grad(xi,yi)

d = div(x, y)

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(20,10))

c = ax1.pcolor(x, y, f, cmap=plt.get_cmap("jet"))
ax1.set_title('f(x,y)', fontsize=18)
ax1.quiver(xi, yi, gf[0], gf[1])

c = ax2.pcolor(x, y, d, cmap=plt.get_cmap("jet"))
ax2.set_title('div(f)(x,y)', fontsize=18)
ax2.quiver(xi, yi, gf[0], gf[1])

ax1.set_xlabel("x", fontsize=14)
ax1.set_ylabel("y", fontsize=14)

fig.tight_layout()
plt.show()
```


```python

```

1d934926304342c63ddb43577821d0c566abc4fc
ipynb
Jupyter Notebook
notebooks/plot3d.ipynb
HenriqueCCdA/ElementosFinitosCurso
5cd37d3d3d77a5b6234fad5fca871d907558dff4
MIT
2021-09-28T00:31:07.000Z
2021-09-28T00:31:25.000Z
notebooks/plot3d.ipynb
HenriqueCCdA/ElementosFinitosCurso
5cd37d3d3d77a5b6234fad5fca871d907558dff4
MIT
notebooks/plot3d.ipynb
HenriqueCCdA/ElementosFinitosCurso
5cd37d3d3d77a5b6234fad5fca871d907558dff4
MIT
Qwen/Qwen-72B
1. YES
2. YES