Disclaimer: - As this is a lengthy post I am going to follow Q & A pattern
Finite and infinite nested square roots of 2 can be solved to some cosine values as discussed earlier here and here
It is interesting to note that any angle $2\cos(\frac{p}{q})$ between 45° to 90° satisfying $1\over4$ < $p \over q$ <$1\over2$ where $ p \over q$ is of form $p = 2^n $ and $q$ is an odd number satisfying $2^{n+1} <q <2^{n+2}$ can be represented as cyclic infinite nested square roots of 2 ( Hereafter referred as $cin\sqrt2$) ($n \in N$, $q \in Z^+$ all odd numbers)
For example $2\cos(\frac{2\pi}{5})$ can be represented as $cin\sqrt2$[1-,1+], we have lot of others like this
Similarly any angle between 45° to 90° satisfying $1\over4$ < $p \over q$ <$1\over2$ where $ p \over q$ is of form $q = 2^n $ and $p$ is an odd number satisfying $2^{n-1} <p <2^{n-2}$ can be represented as finite nested square roots of 2. ($n \in Z^+$ and $p \in Z^+$ all odd numbers)
For example $2\cos(\frac{3\pi}{2^3})$ can be represented as $n\sqrt2(1-)$ (meaning '1' minus sign between 2 nested square roots of 2) a simplified form for $\sqrt{2-\sqrt{2}}$,
$2\cos(\frac{5\pi}{2^4})$ can be represented as $n\sqrt2(2-)$(meaning '2' minus sign between 2 nested square roots of 2) - a simplified form for $\sqrt{2-\sqrt{2-\sqrt{2}}}$
$2\cos(\frac{7\pi}{2^4})$ can be represented as $n\sqrt2(1-1+)$(meaning '1' minus sign and '1' plus sign among 3 nested square roots of 2) - a simplified form for $\sqrt{2-\sqrt{2+\sqrt{2}}}$
Following python program can find out the sequence of +ve and -ve signs in the single cycle of cyclic infinite nested square roots of 2 (except for odd number 3 - i am not able to code)
import time
n = int(input("Enter an odd number to get single cycle cinsqrt2 "))
i = 0
for i in range(n):
if 2 ** i > n and n < 2 ** (i + 1):
break
numerator = 2 ** (i - 2)
print("Numerator is", numerator)
# print("The Angle generated is", (numerator*180)/n, (numerator*180)//n,'+', ((numberator*180)%n)/n)
halfway_of_n = (n - 1) // 2
# print("Half way to n is", halfway_of_n)
lst = []
r = numerator * 2
begin = time.time()
while r != numerator:
if r > halfway_of_n:
r = n - r
r = r * 2
lst = lst + ['-']
else:
r = r * 2
lst = lst + ['+']
lst = lst + ['+']
print(len(lst))
count = lst.count('-')
print('No of minus signs is/are ', count)
count = lst.count('+')
print('No of plus signs is/are ', count)
print(lst)
end = time.time()
print('Program execution time is', end - begin)
For example by entering $5$ while running above program we get 1- and 1+ and total number of positive and negative signs as 2 which represents single cycle of infinite nested square roots of 2 for $2\cos(\frac{2\pi}{5})$
if we enter another odd number by rerunning program like if we enter $41$ we get
Enter an odd number to get single cycle cinsqrt2
Following will be displayed after execution of code
{41
Numerator is 16
Total number of signs 10
No of minus signs is/are 3
No of plus signs is/are 7
['-', '+', '-', '+', '+', '-', '+', '+', '+', '+']
Program execution time is 4.315376281738281e-05
Process finished with exit code 0}
which represents $2\cos(\frac{16\pi}{41})$ and single cycle for $cin\sqrt2[1-1+1-2+1-4+]$ has to be represented as $\sqrt{2-\sqrt{2+\sqrt{2-\sqrt{2+\sqrt{2+\sqrt{2-\sqrt{2+\sqrt{2+\sqrt{2+\sqrt{2+...}}}}}}}}}}$
Therefore by executing above Python code we can get the $cin\sqrt2$ for given cosine angle (represented in radians)
It is clear from this illustration that we can get finite and infinite nested radicals of cosine angles(in radians) which are either partial or infinite sum of geometric series respectively
There is strong relation of modulo operation of $2^n$ wrt odd number which can also predict the partial and infinite sum of the fraction
for example in $2\cos(\frac{1}{3}\pi)$ we can expand the fraction $\frac{1}{3}$ as follows
$$\frac{1}{3} = \frac{1}{2^2} + \frac{1}{2^3} - \frac{1}{2^4} + \frac{1}{2^5} - \frac{1}{2^6} + \frac{1}{2^7} - \frac{1}{2^8} + ...$$ where every partial sum (from first term to nth term) in order represents cosine angle in radians which can be expressed in finite and infinite nested square roots of 2.
We can observe alternating $+$ and $-$ signs
and for $2\cos(\frac{2}{5}\pi)$ we can expand the fraction $\frac{2}{5}$ as follows
$$\frac{2}{5} = \frac{1}{2^2} + \frac{1}{2^3} + \frac{1}{2^4} - \frac{1}{2^5} - \frac{1}{2^6} + \frac{1}{2^7} + \frac{1}{2^8} - ...$$
We can observe alternating $+,+$ and $-,-$ signs
Step 1: Immediate $2^n$ next to odd number. For $\frac{1}{3}$, immediate $2^n$ to 3 is $2^2$
Step 2: Get the modulus value. $4 \equiv 1 (\mod 3)$
Step 3: Double the result and get the modulus value again. $1\cdot2 = 2$ ; $2 \equiv 2 (\mod 3)$
Step 4: Repeat the steps till we get a single cycle where mod value is $2^{n-1}$ < odd number
Step 5: Assign $+$ sign to odd numbers and $-$ sign to even numbers in "modulus function results"
Applying these steps for $\frac{2}{5}$ we will get
$8 \equiv 3 (\mod 5)$ ($+$ sign assigned)
$6 \equiv 1 (\mod 5)$ ($+$ sign assigned)
$2 \equiv 2 (\mod 5)$ ($-$ sign assigned)
$4 \equiv 4 (\mod 5)$ ($-$ sign assigned)
Simple example is
for $\frac{2}{7}$ we will get
$8 \equiv 1 (\mod 7)$ ($+$ sign assigned)
$2 \equiv 2 (\mod 7)$ ($-$ sign assigned)
$4 \equiv 4 (\mod 7)$ ($-$ sign assigned)
$$\frac{2}{7} = \frac{1}{2^2} + \frac{1}{2^3} - \frac{1}{2^4} - \frac{1}{2^5} + \frac{1}{2^6} - \frac{1}{2^7} - \frac{1}{2^8} + ...$$
Here is seemingly tough problem but can be solved easily with above discussed method
for $\frac{16}{45}$ we will get (Radian of the angle $64^\circ$ where $2\cos\frac{16\pi}{45}$ represented as $cin\sqrt2$) here
$64 \equiv 19 (\mod 45)$ ($+$ sign assigned)
$38 \equiv 38 (\mod 45)$ ($-$ sign assigned)
$76 \equiv 31 (\mod 45)$ ($+$ sign assigned)
$62 \equiv 17 (\mod 45)$ ($+$ sign assigned)
$34 \equiv 34 (\mod 45)$ ($-$ sign assigned)
$68 \equiv 23 (\mod 45)$ ($+$ sign assigned)
$46 \equiv 1 (\mod 45)$ ($+$ sign assigned)
$2 \equiv 2 (\mod 45)$ ($-$ sign assigned)
$4 \equiv 4 (\mod 45)$ ($-$ sign assigned)
$8 \equiv 8 (\mod 45)$ ($-$ sign assigned)
$16 \equiv 16 (\mod 45)$ ($-$ sign assigned)
$32 \equiv 32 (\mod 45)$ ($-$ sign assigned)
Conglomerating signs in order we will get $(+,-,+,+,-,+,+,-,-,-,-,-)$ and when we apply these signs we will get the following infinite series
$$\frac{16}{45} = \frac{1}{2^2} + \frac{1}{2^3} - \frac{1}{2^4} + \frac{1}{2^5} + \frac{1}{2^6} - \frac{1}{2^7} + \frac{1}{2^8} + \frac{1}{2^9} - \frac{1}{2^{10}} - \frac{1}{2^{11}} - \frac{1}{2^{12}} - \frac{1}{2^{13}} - \frac{1}{2^{14}} + ...$$
To find the sum of above infinite series - (just to confirm that we are right)
we will get $$\frac{1}{2^2} + \frac{1729}{2^{14}} + \frac{1729}{2^{26}} + \frac{1729}{2^{38}} + \frac{1729}{2^{50}} + ...$$ (Voila, we got Ramanujan-Hardy number!)
$$\frac{1}{2^2} + (\frac{1729}{2^{14}} \cdot \frac{2^{12}}{2^{12}-1}) $$
$$\frac{1}{4} + \frac{1729}{4\cdot4095} = \frac{5824}{16380} = \frac{16}{45}$$
Following python program may be executed to get the moduli for single block of geometric series wrt $2^n$ for the odd number