# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import numpy as np
import matplotlib.pyplot as plt
# %matplotlib inline

x = np.linspace(2, 2*np.pi)
len(x)
print(x[:5])

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

y = np.sin(x)
len(y)

y[:5]

plt.figure(figsize=(12,4))
plt.plot(x,y, "x-" , ms=7, label = "$\sin(x)$")
plt.plot(x,np.cos(x), label = "$\cos(x)$", lw = 5)
plt.xlabel("$x$", fontsize = 18)
plt.ylabel("$y$", fontsize = 18)
plt.title("Funciones")
plt.legend()
plt.grid()
plt.plot(x,0*x, lw = 1)
plt.show()


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

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

sym.var("x", real = True)

f= x**2; f

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

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

# +
# convertir f e una función que se pueda evaluar numéricamente 

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

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

import numpy as np
import matplotlib.pyplot as plt
# %matplotlib inline

def f(x):
    return x**2


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


x = np.linspace(-5,5)
plt.plot(x,f(x),"--")
plt.plot(x,h(x,.1), "-.")
plt.plot(x,h(x,.4), "-")
plt.scatter(0,0,marker = "D",s=50,lw=50)
plt.show



StarcoderdataJupyterScriptsDedupFiltered