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 = 7, 6
numerator, denominator = 3, 2


# Program
# Program
Line 196: Line 196:
def calculate_complementary_pair(numerator, denominator):
def calculate_complementary_pair(numerator, denominator):
     """
     """
     Calculates the perfect complementary pair based on the difference
     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, perfect_log, numerator, denominator):
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(perfect_log / (ratio_log / ed) + 0.5)  # Rounds to the nearest integer
         mapping = int(superparticular_log / (ratio_log / ed) + 0.5)  # Rounds to the nearest integer
         error = mapping * (ratio_log / ed) - perfect_log
         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 perfect complementary pairs
# 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"Perfect complementary pair of {numerator}/{denominator} are: {pair_1[0]}/{pair_1[1]} and {pair_2[0]}/{pair_2[1]}")
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
perfect_complementary_ratio = pair_1[0] / pair_1[1]
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)
perfect_complementary_log_cents = calculate_log_ratio(perfect_complementary_ratio)
superparticular_complementary_log_cents = calculate_log_ratio(superparticular_complementary_ratio)


# Output the mappings
# Output the mappings
print_mappings(ratio_log_cents, perfect_complementary_log_cents, numerator, denominator)
print_mappings(ratio_log_cents, superparticular_complementary_log_cents, numerator, denominator)
</pre>
</pre>