# Defining the Beta-Function
Let $A=\{a_1,a_2,\ldots,a_m\}$ and $B=\{b_1,b_2,\ldots,b_n\}$ be two sets of positive integers. We define the function $F_{\beta}$ as follows:
\begin{equation}
F_{\beta}(A)=\sum_{S_A\in2^A}\prod_{a\in S_A}\frac{1}{a}=\frac{1}{a_1}+\frac{1}{a_2}+\ldots+\frac{1}{a_m}+\frac{1}{a_1a_2}+\ldots+\frac{1}{a_1a_m}+\ldots+\frac{1}{a_1a_2\ldots a_m}
\end{equation}
The power set of $A$, denoted with $2^A$ is the set of all possible subsets of $A$, see for example Mazur (2010, p. 5).
We define a relation $\sim_{\beta}$ between two sets such that two sets $A\sim_{\beta}B$ relate to each other when $F_{\beta}(A)=F_{\beta}(B)$. 
# References
David R. Mazur (2010). Combinatorics: A Guided Tour. Washington, DC: The Mathematical Association of America.


```python
from itertools import chain, combinations
def powerset(iterable):
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(1, len(s)+1))

def F_Beta(integer_set):
    powset = list(powerset(integer_set))
    F=0
    for subset in powset:
        prod=1
        for element in subset:
            prod=prod/element
        F+=prod
    return F

# Beta(A,1) - F_Beta(A) = 1
def Beta(integer_set, k, exclude_last=False):
    l = len(integer_set)
    if l == 0:
        return 0
    if exclude_last == True and l == 1:
        return 0

    beta=1
    stop = l-1 if exclude_last == True else l
    for index in range(stop):
        element = integer_set[index]
        beta *= (1+1/(k*element))
    return beta

def distance(set_a, set_b):
    return abs(F_Beta(set_a) - F_Beta(set_b))

def generate_collatz_set(v1, n, k):
    a = []
    if n<1 or v1%2==0:
        return a
    vi = v1
    a.append(vi)
    for i in range(n-1):
        vi = k*vi+1
        while vi%2 == 0:
            vi /= 2
        if vi in a:
            return [] if len(a)<n else a
        elif vi == 1:
            a.append(int(vi))
            return [] if len(a)<n else a
        else:
            a.append(int(vi))
    return a

A=[135,85,215]
B=[65,165,415]
C=[6335,17919]
D=[4887,110591]
print(F_Beta(C))
print(Beta(D,1))
print(distance(A,B))
print(generate_collatz_set(17,30,5))
```

    0.00021366869143188546
    1.0002136686914318
    0.0
    []



```python
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import csv

max=200
x = np.linspace(0, max-1, max)
y = np.linspace(0, max-1, max)
X, Y = np.meshgrid(x, y)
X = X.astype(int)
Y = Y.astype(int)
Z = np.zeros(shape=(max,max))
arr_csv = [[]]
k=3

def func(x, y):
    v1 = 2*x+1
    n = y+1
    collatz_set = generate_collatz_set(v1,n,k)
    beta = float(Beta(collatz_set, k, True))
    #print("{} {} {}".format(n, beta, collatz_set))
    return beta

fn_vectorized = np.vectorize(func)
Z = fn_vectorized(X, Y)

for x in range(Z.shape[0]):
    for y in range(Z.shape[1]):
        #arr_csv.append([2*x+1,y+1,Z[x,y]])
        arr_csv.append([x,y,Z[x,y]])

with open("c:/temp/collatz_beta.csv", "w", newline='') as my_csv:
    csvWriter = csv.writer(my_csv, delimiter=',')
    csvWriter.writerow(["v1", "n", "beta(v1,n,k={})".format(k)])
    csvWriter.writerows(arr_csv)

fig = plt.figure()
ax = plt.axes(projection="3d")
ax.plot_wireframe(X, Y, Z)
ax.set_xlabel('v1')
ax.set_ylabel('n')
ax.set_zlabel('beta(v1,n)')
plt.show()
```

526bdb6cc8051e75f291121ff2e2bc6a2a5214db
ipynb
Jupyter Notebook
03 Engel Expansion/Python/notebook/beta.ipynb
Sultanow/collatz
d8a5137af508be19da371fff787c114f1b5185c3
CC-BY-4.0
2021-04-01T15:12:10.000Z
2021-04-01T15:54:55.000Z
03 Engel Expansion/Python/notebook/beta.ipynb
Sultanow/collatz
d8a5137af508be19da371fff787c114f1b5185c3
CC-BY-4.0
03 Engel Expansion/Python/notebook/beta.ipynb
Sultanow/collatz
d8a5137af508be19da371fff787c114f1b5185c3
CC-BY-4.0
2021-05-06T20:44:07.000Z
2021-05-06T20:44:07.000Z
Qwen/Qwen-72B
1. YES
2. YES