"""Reproduzierbare Winkelpruefung; benoetigt Python 3 und mpmath.""" import mpmath as mp def examine(dps): with mp.workdps(dps): phi = (1 + mp.sqrt(5)) / 2 tolerance = mp.power(10, -(dps - 20)) sine = {a: mp.sin(mp.pi * a / 180) for a in range(1, 100)} cosine = {b: mp.cos(mp.pi * b / 180) for b in range(1, 100) if b != 90} matches, golden_pairs = [], [] checked = 0 for a in range(1, 100): for b, denominator in cosine.items(): checked += 1 q = abs(sine[a] / denominator) # Im definierten Winkelbereich sind dies genau die |q|=1-Faelle. if a + b == 90 or abs(a - b) == 90: q = mp.mpf(1) # Vier Anfangsziffern OHNE Rundung; die fuehrende 0 zaehlt mit. integer_digits = len(str(int(mp.floor(q)))) first_four = f"{int(mp.floor(q * mp.power(10, 4 - integer_digits))):04d}" input_digits = f"{a:02d}{b:02d}" if sorted(first_four) == sorted(input_digits): matches.append(input_digits) # Numerischer Vergleich; die drei Identitaeten separat beweisbar. if abs(q - 1 / phi) < tolerance: golden_pairs.append(input_digits) common = sorted(set(matches) & set(golden_pairs)) return checked, matches, golden_pairs, common EXPECTED_MATCHES = "0107 0610 0841 1077 1210 1220 1598 1860 4081 4807 5261 6592 8187 8492 8851 9478".split() EXPECTED = (9702, EXPECTED_MATCHES, ["1860", "3036", "3618"], ["1860"]) if __name__ == "__main__": result_120 = examine(120) result_200 = examine(200) assert result_120 == result_200 == EXPECTED, "Ergebnisabweichung" for precision, result in [(120, result_120), (200, result_200)]: checked, matches, golden_pairs, common = result print(f"Praezision: {precision} Dezimalstellen; gepruefte Paare: {checked}") print(f"Zifferntreffer ({len(matches)}): {' '.join(matches)}") print(f"1/Phi-Paare: {' '.join(golden_pairs)}") print(f"Gemeinsamer Treffer: {' '.join(common)}")