Contribution
Joined 18 April 2020
Contribution (talk | contribs) No edit summary |
Contribution (talk | contribs) No edit summary |
||
(5 intermediate revisions by the same user not shown) | |||
Line 189: | Line 189: | ||
<pre> | <pre> | ||
# Enter the values for the X ratio of EDX. Ensure the numerator and denominator differ by 1 or 2. | # Enter the values for the X ratio of EDX. Ensure the numerator and denominator differ by 1 or 2. | ||
numerator, denominator = | numerator, denominator = 3, 2 | ||
# Program | # Program | ||
Line 196: | Line 196: | ||
def calculate_complementary_pair(numerator, denominator): | def calculate_complementary_pair(numerator, denominator): | ||
""" | """ | ||
Calculates the | Calculates the superparticular complementary pair based on the difference | ||
between the numerator and denominator. | between the numerator and denominator. | ||
""" | """ | ||
Line 224: | Line 224: | ||
return 1200 * log(ratio) / log(2) | return 1200 * log(ratio) / log(2) | ||
def print_mappings(ratio_log, | def print_mappings(ratio_log, superparticular_log, numerator, denominator): | ||
""" | """ | ||
Prints the mapping of ratios and their differences in logarithmic cents. | Prints the mapping of ratios and their differences in logarithmic cents. | ||
""" | """ | ||
for ed in range(1, 101): | for ed in range(1, 101): | ||
mapping = int( | mapping = int(superparticular_log / (ratio_log / ed) + 0.5) # Rounds to the nearest integer | ||
error = mapping * (ratio_log / ed) - | error = mapping * (ratio_log / ed) - superparticular_log | ||
print(f"scale: {ed}ed{numerator}/{denominator}, error: {error:.5f}") | print(f"scale: {ed}ed{numerator}/{denominator}, error: {error:.5f}") | ||
# Calculate the | # Calculate the superparticular complementary pairs | ||
(pair_1, pair_2) = calculate_complementary_pair(numerator, denominator) | (pair_1, pair_2) = calculate_complementary_pair(numerator, denominator) | ||
print(f" | print(f"Successive superparticular complementary pair of {numerator}/{denominator}: {pair_1[0]}/{pair_1[1]} and {pair_2[0]}/{pair_2[1]}") | ||
# Calculate ratios | # Calculate ratios | ||
ratio = numerator / denominator | ratio = numerator / denominator | ||
superparticular_complementary_ratio = pair_1[0] / pair_1[1] | |||
# Calculate the logarithmic values for the ratios in cents | # Calculate the logarithmic values for the ratios in cents | ||
ratio_log_cents = calculate_log_ratio(ratio) | ratio_log_cents = calculate_log_ratio(ratio) | ||
superparticular_complementary_log_cents = calculate_log_ratio(superparticular_complementary_ratio) | |||
# Output the mappings | # Output the mappings | ||
print_mappings(ratio_log_cents, | print_mappings(ratio_log_cents, superparticular_complementary_log_cents, numerator, denominator) | ||
</pre> | </pre> |