```python
%matplotlib notebook
from sympy import *
import numpy as np
import matplotlib.pyplot as plt
init_printing()
```


```python
var("x y")
```


```python
f=(x**2)+(y**2)
f
```


```python
dfx=f.diff(x)
dfy=f.diff(y)
pc=solve([dfx,dfy],[x,y])

dfx,dfy,pc
```


```python
dfxx=dfx.diff(x)
dfxy=dfx.diff(y)
dfyx=dfy.diff(x)
dfyy=dfy.diff(y)

D=dfxx*dfyy - dfxy
D.subs(pc),dfxx.subs(pc)
```


```python
#matriz con segunda derivada
H=hessian(f,[x,y])
H
```




$$\left[\begin{matrix}2 & 0\\0 & 2\end{matrix}\right]$$




```python
H.eigenvals()
```


```python
#ejemplo
```


```python
f=(x**3)+3*(x**2)+3*(y**3)+3*(y**2)+24
f
```


```python
#gradient
nablaf=[f.diff(var) for var in [x,y]]
nablaf
```


```python
#puntos criticos
pcs=solve(nablaf)
pcs
```


```python
H=hessian(f,[x,y])
H
```




$$\left[\begin{matrix}6 x + 6 & 0\\0 & 18 y + 6\end{matrix}\right]$$




```python
for pc in pcs:
    eig=H.subs(pc).eigenvals()
    print("Puntos criticos:",pc,"sus eigenvalores:",eig)
```

    Puntos criticos: {x: -2, y: -2/3} sus eigenvalores: {-6: 2}
    Puntos criticos: {x: -2, y: 0} sus eigenvalores: {-6: 1, 6: 1}
    Puntos criticos: {x: 0, y: -2/3} sus eigenvalores: {-6: 1, 6: 1}
    Puntos criticos: {x: 0, y: 0} sus eigenvalores: {6: 2}



```python
x_=np.arange(-3,3,.1)
y_=np.arange(-3,3,.1)

xx_, yy_=np.meshgrid(x_,y_)
F =xx_**3 + 3*yy_**3 + 3*xx_**2 + 3*yy_**2 + 24
```


```python
fig = plt.figure()
ax = fig.gca(projection="3d")
surf = ax.plot_surface(xx_,yy_,F)

ax.set_xlaber("X Label")
ax.set_ylaber("Y Label")
ax.set_zlaber("Z Label")
plt.show()
```


```python

```

09622d7fe7ea8eb7ed4d7114bc3e63bea3552029
ipynb
Jupyter Notebook
Modulo 1/Clase_5.ipynb
anapaugiusti99/Simulacin_Matematica
c1b20d739ebd0d453158076be5772f8d35f1d2e4
MIT
Modulo 1/Clase_5.ipynb
anapaugiusti99/Simulacin_Matematica
c1b20d739ebd0d453158076be5772f8d35f1d2e4
MIT
Modulo 1/Clase_5.ipynb
anapaugiusti99/Simulacin_Matematica
c1b20d739ebd0d453158076be5772f8d35f1d2e4
MIT
Qwen/Qwen-72B
1. YES
2. YES