Está en la página 1de 1

import matplotlib.

pyplot as plt
import numpy as np
# LE PEDIMOS LOS DATOS DE EPSILON Y SIGMA
# AL USUARIO
e= float(input("epsilon: "))
s= float (input("sigma: "))

# NÚMERO DE PASOS
n=20

#DEFINIMOS NUESTRA FUNCION


#POTENCIAL DE LENNARD-JONES
def potencial (r,e=e,s=s):
return 4*e*((s/r)**12-(s/r)**6)
#LA PRIMERA DERIVADA DE LA FUNCIÓN
def f_prima (r,e=e,s=s):
return 4*e*(-12*(s**12)*(r**-13)+6*(s**6)*(r**-7))
#LA SEGUNDA DERIVADA DE LA FUNCIÓN
def f_biprima (r,e=e,s=s):
return 4*e*(12*13*(s**12)*(r**-14)-6*7*(s**6)*(r**-8))

x0=0.5

for i in range (n):


x1=x0-f_prima(x0)/f_biprima(x0)
x0=x1
print (x0)

x = np.linspace(0.5,5.0,100)
y = potencial(x)

plt.plot(x,y,'b-')
plt.show()

También podría gustarte