# Can the Function $p(t, r) = e^{r \sin \left( \frac{(2t+1) \pi}{2} \right)}$ Be Used to derive a Prime Generating Function?

I am exploring a mathematical function related to prime numbers and have written a Python script to test it. Here is the function and the code I've used:

### Math Functions:

1. Sum of Divisors Function:

$$\sigma(n) = \sum_{i=1}^{n} i, \quad \text{where } i \text{ is a divisor of } n.$$

1. Function $$r(x)$$:

$$r(x) = \sigma(x) - x,$$

where $$\sigma(x)$$ is the sum of divisors of $$x$$.

1. Function $$p(t, r)$$:

$$p(t, r) = e^{r \sin \left( \frac{(2t+1) \pi}{2} \right)}$$

### Python Code:

import math
import cmath

def sum_of_divisors(n):
# Calculate the sum of divisors σ(n)
return sum(i for i in range(1, n + 1) if n % i == 0)

def r_function(x):
# Calculate r(x) = σ(x) - x
return sum_of_divisors(x) - x

def calculate_p(t, r):
# Calculate p(t, r) using the given exponent formula
exponent = r * cmath.sin((2 * t + 1) * math.pi / 2)
return cmath.exp(exponent)

# Generate r values and calculate p(t, r)
x_values = range(1, 100)  # Adjust range as needed
results = []

for x in x_values:
r = r_function(x)
t = 1  # You can adjust this or loop through different t values
p = abs(calculate_p(t, r))
results.append((x, r, p))

# Print results
for x, r, p in results:
print(f"x = {x}, r = σ({x}) - {x} = {r}, p = {p:.6f}")


### Observations:

• Whenever $$x$$ is a prime number, $$r(x) = 1$$, and consequently, $$p(t, r) \approx 0.367879$$ (which is close to $$e^{-1}$$.
• For non-prime $$x$$, $$r(x) > 1$$, and the value of $$p(t, r)$$ tends to $$0$$ rapidly.

### Question:

Can the function $$p(t, r)$$ be formally used to identify prime numbers? Specifically:

1. Is there a better way to use $$r$$, or a closed form equation instead of $$r(x) = \sigma(x) - x$$? The better way should atleast achieve one of: a. Be closed form. b. Gives a prime generating function directly.

2. Can we generate other significant sequences other than the prime numbers sequence by choosing $$r$$, which ones?

Edit 1: $$p(x) = e^{-\frac{\sin\left(\frac{(x \pi)}{\log(x)}\right)}{\pi}}.$$ Is amazingly intereting!

• Welcome to MSE. For some basic information about writing mathematics at this site see, e.g., basic help on mathjax notation, mathjax tutorial and quick reference, main meta site math tutorial and equation editing how-to. Commented Sep 5 at 2:11
• Thanks, I fixed the errors, I was editing it as you commented Commented Sep 5 at 2:14
• Since computing $\sigma$ needs the knowledge of prime factors, $r$ and consequently $p$ themselves are dependent on this knowledge, right? It is not clear to me how $p$ then can be a prime number generator. Commented Sep 5 at 5:31
• What about employing a relation like x/log(x) Commented Sep 5 at 5:57
• What was the dowmvote for???? Commented Sep 5 at 10:07