Newer
Older
import math
def errorrelativo(valorreal, valoraproximado):
return abs((valorreal - valoraproximado) / valorreal) * 100
def sen_aproximado(theta):
return theta
maxerror = 3.0
thetamaximo = math.radians(90)
for theta in range(1, int(math.degrees(thetamaximo)) + 1):
thetaenrads = math.radians(theta)
senoreal = math.sin(thetaenrads)
senoaprox = sen_aproximado(thetaenrads)
error = errorrelativo(senoreal, senoaprox)
if error > maxerror:
theta_maximo = math.radians(theta - 1)
break
print(f"El ángulo máximo para la aproximación con un error inferior al {maxerror}% es: {math.degrees(theta_maximo)} grados.")