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


```python
x  = np.linspace(0, 2*np.pi)
x[:5]
```




    array([0.        , 0.12822827, 0.25645654, 0.38468481, 0.51291309])




```python
len(x)
```




$$50$$




```python
x  = np.linspace(0, 2*np.pi, 100)
len(x)
```




$$100$$




```python
y = np.sin(x)
```


```python
y[:5]
```




    array([0.        , 0.06342392, 0.12659245, 0.18925124, 0.25114799])




```python
plt.figure(figsize=(6,4))
plt.plot(x,y, 'x-', ms = 5, label = "$\sin(x)$")
plt.plot(x,np.cos(x), label = "$\cos(x)$", lw = 2)
plt.legend()
plt.xlabel("$x$", fontsize = 18)
plt.ylabel("$y$", fontsize = 18)
plt.grid(False)
plt.title("Funciones", fontsize = 18)
plt.show()
```


```python
np.exp?
```


```python
#help(np.exp)
```

### Sympy


```python
import sympy as sym
sym.init_printing(use_latex='mathjax')
```


```python
sym.var('x')
sym.sin(x)*np.sin(3)
```




$$0.141120008059867 \sin{\left (x \right )}$$




```python
sym.sin(x)* sym.cos(x) * sym.tan(x)
```




$$\sin{\left (x \right )} \cos{\left (x \right )} \tan{\left (x \right )}$$



### Funciones 


```python
sym.var('x', real = True)
```




$$x$$




```python
f = x**2; f
```




$$x^{2}$$




```python
df = sym.diff(f,x,1)
```


```python
# resolver f'(x)=0 y mostrar soluciones
xc = sym.solve(df, x)
xc
```




$$\left [ 0\right ]$$




```python
f
```




$$x^{2}$$




```python
f_num = sym.lambdify([x], f, 'numpy')
x_vec = np.linspace(-5, 5, 100)

# graficar
plt.plot(x_vec, f_num(x_vec), color = "green")
plt.xlabel('$x$', fontsize = 18)
plt.ylabel('$x^2$', fontsize = 18)
plt.show()
```

### Como se definen funciones


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


```python
def f(x):
    return x**2
```


```python
def h(x,y):
    return np.sin(x)/np.tan(y)
```


```python
x = np.linspace(-5,5)
plt.plot(x, f(x), "--")
plt.plot(x, h(x,.1), "-.")
plt.plot(x, h(x,.3), "-")
plt.scatter([0], [0], s = 400, lw = 0)
plt.scatter([1.7], [10], marker = "D", s = 400, lw = 0)
plt.scatter([-1.7], [-10], marker = "P", s = 400, lw = 0)
#plt.grid()
plt.show()
```


```python
plt.scatter?
```


```python

```

288b8a9a87f9be7ead327eca55f1520dab6a0312
ipynb
Jupyter Notebook
Modulo1/Clase4Lazaro.ipynb
douglasparism/SimulacionM2018
85953efb86c7ebf2f398474608dfda18cb4cf5b8
MIT
Modulo1/Clase4Lazaro.ipynb
douglasparism/SimulacionM2018
85953efb86c7ebf2f398474608dfda18cb4cf5b8
MIT
Modulo1/Clase4Lazaro.ipynb
douglasparism/SimulacionM2018
85953efb86c7ebf2f398474608dfda18cb4cf5b8
MIT
Qwen/Qwen-72B
1. YES
2. YES