Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
516 B
1
Indexable
Never
from math import sqrt

# True values
true_value_7_13 = 7 / 13
true_value_sqrt_42 = sqrt(42)

# Approximated values
approx_7_13 = 0.538
approx_sqrt_42 = 6.48

# Absolute and relative errors for 7/13
abs_error_7_13 = abs(true_value_7_13 - approx_7_13)
rel_error_7_13 = (abs_error_7_13 / true_value_7_13) * 100

# Absolute and relative errors for sqrt(42)
abs_error_sqrt_42 = abs(true_value_sqrt_42 - approx_sqrt_42)
rel_error_sqrt_42 = (abs_error_sqrt_42 / true_value_sqrt_42) * 100

rel_error_7_13, rel_error_sqrt_42
Leave a Comment