import math

# --------------------------------------------------------------------------------------
# ENTRADA
xi = float(input('Ingrese el valor del punto inicial xi: '))
es = float(input('Ingrese el error estimado: '))
# --------------------------------------------------------------------------------------

# --------------------------------------------------------------------------------------
# PROCESO
# --------------------------------------------------------------------------------------
def funcion(x):
    return math.exp(x) - 3 * x

def derivadaf(x):
    return math.exp(x) - 3
    
ea = 1
i = 0  
xr = xi 

while funcion(xr) != 0 and ea > es:
    xra = xr  
    
    xr = xr - funcion(xr) / derivadaf(xr)
    
    i += 1
    
    if i > 1:
        ea = abs((xr - xra) / xr) * 100

# --------------------------------------------------------------------------------------

# --------------------------------------------------------------------------------------
# SALIDA
print('xr: ', xr)
print('Error aproximado: ', ea)
print('Número de iteraciones: ', i)
# --------------------------------------------------------------------------------------
