import math

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

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

ea = 1  
i = 0   
xr = xi  

while ea > es:
    xra = xr
    
    xr = xs - (funcion(xs) * (xi - xs)) / (funcion(xi) - funcion(xs))
    
    i += 1
    
    if i > 1:
        ea = abs((xr - xra) / xr) * 100

    if funcion(xi) * funcion(xr) < 0:
        xs = xr
    else:
        xi = xr

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

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