arithmeticbilliard

Draw arithmetic billiards
git clone https://git.tronto.net/arithmeticbilliard
Download | Log | Files | Refs | README | LICENSE

commit 1c2df2e866091377fa6454a21341727abc098517
parent 50f8e9bf1997a1bd3f076046a1bae16ad610dd41
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Tue,  8 Aug 2023 20:13:41 +0200

Added multiplicity stats

Diffstat:
A__pycache__/billiard3d.cpython-311.pyc | 0
Mbilliard3d.py | 52+++++++++++++++++++++++++++++-----------------------
Amultiplicity_stats.py | 46++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+), 23 deletions(-)

diff --git a/__pycache__/billiard3d.cpython-311.pyc b/__pycache__/billiard3d.cpython-311.pyc Binary files differ. diff --git a/billiard3d.py b/billiard3d.py @@ -54,11 +54,7 @@ def is_double(path): return False -def print_multiplicities(n, sizes, r): - print("") - print("Points with multiplicity > 1:") - print("") - +def get_multiplicities(n, sizes, r): d = dict() path = [tuple(x) for x in get_path(n, sizes, r)] @@ -72,6 +68,15 @@ def print_multiplicities(n, sizes, r): for p in d: d[p] //= 2 + return d + +def print_multiplicities(n, sizes, r): + d = get_multiplicities(n, sizes, r) + + print("") + print("Points with multiplicity > 1:") + print("") + for i in range(2, max(d.values())+1): L = [] for point in d: @@ -259,21 +264,22 @@ def user_input(): # Main routine below ############################################################################### -# You can choose to write your input here or to get it interactively -#sizes, r, pic = [15, 9, 7], [2, 0, 0], "p" -#sizes, r, pic = [2, 3, 4], [0, 0, 0], "3" -sizes, r, pic = user_input() - -print("---------------------------------") -print_multiplicities(len(sizes), sizes, r) -print("---------------------------------") -print_points_on_edges(sizes, r) -print("---------------------------------") - -if pic == "p": - draw_3d_projections(sizes, r) -elif pic == "3": - draw_3d_picture(sizes, r) -else: - draw_3d_projections(sizes, r) - draw_3d_picture(sizes, r) +if __name__ == '__main__': + # You can choose to write your input here or to get it interactively + #sizes, r, pic = [15, 9, 7], [2, 0, 0], "p" + #sizes, r, pic = [2, 3, 4], [0, 0, 0], "3" + sizes, r, pic = user_input() + + print("---------------------------------") + print_multiplicities(len(sizes), sizes, r) + print("---------------------------------") + print_points_on_edges(sizes, r) + print("---------------------------------") + + if pic == "p": + draw_3d_projections(sizes, r) + elif pic == "3": + draw_3d_picture(sizes, r) + else: + draw_3d_projections(sizes, r) + draw_3d_picture(sizes, r) diff --git a/multiplicity_stats.py b/multiplicity_stats.py @@ -0,0 +1,46 @@ +import billiard3d +import sys + +def get_stats(i, j, k, mult): + for r1 in range(i+1): + for r2 in range(j+1): + for r3 in range(k+1): + d = billiard3d.get_multiplicities(3, [i, j, k], [r1, r2, r3]) + for key in d: + mult[d[key]] += 1 + +def print_stats(N): + mult = [0] * 10 + for i in range(1, N+1): + for j in range(i, N+1): + for k in range(j, N+1): + get_stats(i, j, k, mult) + + print("Statistics for paths with 0 < a <= b <= c <= {0}".format(N)) + print("Considering all paths starting from any possible point") + for i in range(1, 10): + if mult[i] != 0: + print("Multiplicity {0}: {1} points".format(i, mult[i])) + print("There are no points of positive multiplicity different from those listed above") + +def print_stats_single(a, b, c): + mult = [0] * 10 + get_stats(a, b, c, mult) + + print("Statistics for paths with a={0}, b={1} and c={2}".format(a, b, c)) + print("Considering all paths starting from any possible point") + for i in range(1, 10): + if mult[i] != 0: + print("Multiplicity {0}: {1} points".format(i, mult[i])) + print("There are no points of positive multiplicity different from those listed above") + +if len(sys.argv) == 2: + N = int(sys.argv[1]) + print_stats(N) +elif len(sys.argv) == 4: + a, b, c = int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]) + print_stats_single(a, b, c) +else: + print("Use one of the following options:") + print("\tpython multiplicity_stats.py N\t\t # For all possible sizes up to N") + print("\tpython multiplicity_stats.py a b c\t # For all starting points for the single 3d box (a,b,c)")