DOWLOAD-DESKTOP-NOTEBOOK.nb (122 KB)
Neat! Is it your result and is it new? Do you think expression can be simplified? This does not work
but maybe similar trigonometry.
Appendix: To simplify B_n formula.
We have:
sol2 = (I (-I \[Pi] + 2 Log[1 - E^(-I 2^(-(1/2) + n) \[Pi])] - 2 Log[1 - E^(I 2^(-(1/2) + n) \[Pi])] - Log[1 - E^(-I 2^(1/2 + n) \[Pi])] + Log[1 - E^(I 2^(1/2 + n) \[Pi])]))/(2 \[Pi])
sol5 = FullSimplify[Re[sol2] // ComplexExpand, Assumptions -> n \[Element] Integers]
Table[sol5, {n, 1, 5}]
Now we need find a pattern.The first ingredient in the formula:
We have:
FindSequenceFunction[{1, 2, 4, 8, 16}, n]
(*2^(-1 + n)*)
Finding the second ingredient in the formula is the same how I found at first:
FindSequenceFunction[{2, 4, 8, 16, 32}, n]
(*2^n*)
Substitution:
FullSimplify[(\[Pi] - (4 ArcTan[Sin[n Sqrt[2] \[Pi]]/(1 - Cos[n Sqrt[2] \[Pi]])] /. n -> 2^(n - 1)) + (2 ArcTan[Sin[n Sqrt[2] \[Pi]]/(
1 - Cos[n Sqrt[2] \[Pi]])] /. n -> 2^n))/(2 \[Pi])] // Expand
Yes, I found this formula.Is it new? Probably so. I searched in the web, but did not find a similar formula.
I tried to simplify, but I have not yet succeeded.
Just checking: is this, then, some kind of spigot algorithm for sqrt(2)?
No is not algorithm, it’s better than that. It simple, it’s a formula, or function.
An example:
To start calculating binary digits from, say, the 8th place only need substitute for n=8,9,10,11,12,13,14,15…That it’s all.
formula =1/2 - (2 ArcTan[Cot[2^(-(3/2) + n) \[Pi]]])/\[Pi] + ArcTan[Cot[2^(-(1/2) + n) \[Pi]]]/\[Pi]
sol = Table[formula, {n, 8, 15}] // N // Round
{1, 0, 0, 0, 0, 0, 1, 0}
and say from n=1…15:
sol2 = Table[formula, {n, 1, 15}] // N // Round
{1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0}
I think it is then a spigot algorithm, because you have extensions, like the famous one for Pi in base 16 which calculates the nth digit directly… Algorithm here can be read as function:
A further refinement is an algorithm which can compute a single arbitrary digit, without first computing the preceding digits: an example is the Bailey-Borwein-Plouffe formula, a digit extraction algorithm for ? which produces hexadecimal digits.
You’re right.So let it be.
Have a nice day. ![]()
Mariusz.
Finding formula for the n-th digit in the binary representation of Sqrt[2] using Floor function.
sol = RSolve[{b[n + 2] == a[n + 1] - 2*a[n], a[n] == Floor[Sqrt[2]*2^n], b[0] == 1, b[1] == 0}, {b[n], a[n]}, n]
sol2 = FullSimplify[b[n] /. sol[[1]], Assumptions -> {n > 0, n \[Element] Integers}]
This is formula for the n-th digit in the binary representation of \sqrt{2} for n > 0 and n\in \mathbb{Z} using Floor function.
Table[sol22 /. n -> m, {m, 1, 50}]
I am interested in proving that the proportion of binary digits of \sqrt{2} is exactly \frac{1}{2}, and I have worked on this for a long time. You wrote a great article using the Fourier series expansion for the fractional part function. I am looking at a simpler formula (I have yet to find one!) but have asked my question on StackExchange, here. For your convenience, my question is posted below:
Is it possible to find an expression of the form
where i^2 = -1 and \alpha_k, \beta_k, a_k, b_k real numbers? Maybe with r< 5 if possible. I am trying to compute the mean value (average) of \{ 2^n \sqrt{2}\}= 2^n \sqrt{2} - \lfloor 2^n \sqrt{2}\rfloor over n=0, 1,2, \cdots. Let us denote as p this mean value: p is the proportion of binary digits of \sqrt{2} equal to one, and p is widely believed to be equal to \frac{1}{2}.
Note that
Assuming we have a simple closed form for \lfloor 2^k \sqrt{2}\rfloor as suggested in the first formula, then we can have a closed form for p_n, involving a finite number of terms. I don’t expect this to be true if you replace \sqrt{2} by (say) \pi or \log 2, but I would expect this to work with any quadratic irrational.
Of course you can always use the Fourrier series to represent the fractional part function, but I don’t think it would be easy to handle: it involves an infinite number of terms (r=\infty.)
I found this very interesting so I tried to find a similar formula for the n-th digit of \sqrt2 in decimal. For that I used the following, already existing formula for the decimal expansion of \sqrt2 (from A002193 - OEIS):
a(n)=-10 \cdot \lfloor 2^{-\frac{3}{2}+n} \cdot 5^{-2+n}\rfloor + \lfloor 2^{-\frac{1}{2}+n} \cdot 5^{-1+n} \rfloor,
applying this on it:
\lfloor x\rfloor =x-\frac{1}{2}+\frac{\sum _{k=1}^{\infty } \frac{\sin (2 k \pi x)}{k}}{\pi }
and then following the same steps you did for base 2. This way I got the following formula:
B_{10}(n) = \frac{9}{2}-\frac{10 \tan ^{-1}\left(\cot \left(\sqrt{2} \pi10^{n-2} \right)\right)}{\pi }+\frac{\tan ^{-1}\left(\cot \left(\sqrt{2} \pi 10^{n-1} \right)\right)}{\pi },
which was working as expected. At this point I had a suspicion for a generalized formula for the n-th digit in any base b \geq 2 :
B_{b}(n) = \frac{b-1}{2}-\frac{b \tan ^{-1}\left(\cot \left(\sqrt{2} \pi \cdot b^{n-2} \right)\right)}{\pi }+\frac{\tan ^{-1}\left(\cot \left(\sqrt{2} \pi \cdot b^{n-1} \right)\right)}{\pi }
which is the formula you found for b=2 and the one I found for b=10 and I also tried b=16 for Hexadecimal and it returned correct values. But at this point I had another suspicion, namely that you could generalize it so that you get the b-th base expansion for any positive real number 0 < u \in \mathbb{R}:
B_{b}(n) = \frac{b-1}{2}-\frac{b \tan ^{-1}\left(\cot \left( u \cdot \pi \cdot b^{n-2} \right)\right)}{\pi }+\frac{\tan ^{-1}\left(\cot \left(u \cdot \pi \cdot b^{n-1} \right)\right)}{\pi },
and indeed, this formula could return for example the binary and decimal expansions of u=\pi or u=\frac{1}{9}. I am not sure how useful these formulae would be though because you need the value of u to calculate the n-th digit with it.
Hello, here is one I have found recently:
The n’th binary digit of sqrt(2) is given by
floor(Sum_{n>=1} A005875(n)/exp(Pi*n/(2^((2/3)*k+(1/3))))) mod 2
Will give the k-th binary digit of sqrt(2), where A005875 is the number of ways to write n as sum of 3 squares. See image of the formula : r_3(n) is A005875.
NOTE : there is one for sqrt(10) also which is
NOTE 2: The series converge quite slowly but there is a marker for the decimal point which enables to get the n’th. The actual precision is very high when k >> 1.
– you have earned Featured Contributor Badge ![]()
Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!
Try, where u is Pi:
F[n_, b_, u_] := Floor[b^(-1 + n) *u] - b*Floor[b^(-2 + n) *u] ;
{Table[F[n, 10, ((2^(2 + 4 n) (1 - 3^(-1 - 4 n)) (4 n)!)/
EulerE[4 n])^(1/(1 + 4 n))], {n, 1, 50}], mm = N[Pi, 50];
RealDigits[mm, 10][[1]]} // MatrixForm
(*Pi for base = 10 *)
{Table[F[n, 2, ((2^(2 + 4 n) (1 - 3^(-1 - 4 n)) (4 n)!)/
EulerE[4 n])^(1/(1 + 4 n))], {n, 0, 55}], mm = N[Pi, 17];
RealDigits[mm, 2][[1]]} // MatrixForm
(*Pi for base = 2 *)
Formula the n-th digit off Pi for base=b:
$B_b(n)=\left\lfloor b^{-1+n} \left(\frac{2^{2+4 n} \left(1-3^{-1-4 n}\right) (4 n)!}{E_{4 n}}\right){}^{\frac{1}{1+4 n}}\right\rfloor -b
\left\lfloor b^{-2+n} \left(\frac{2^{2+4 n} \left(1-3^{-1-4 n}\right) (4 n)!}{E_{4 n}}\right){}^{\frac{1}{1+4 n}}\right\rfloor$
Where: EulerE[4 n] are Euler numbers.
f[n_] := I Sum[Binomial[k, l] ((-1)^l*(k - 2 l)^(4 n + 1))/(2^k*I^k*k), {k, 1,4 n + 1}, {l, 0, k}]
Table[{EulerE[4*n], f[n]}, {n, 1, 5}] // MatrixForm
Regards M.I
Hey, while trying to simplify the equation further I was able to get this:
The n-th digit in base b of a number u can be calculated as:
Given that \tan^{-1}(\cot(x))=\frac{\pi}{2}-(x \mod \pi) this can be simplified to:
Given that \frac{x\mod a}{a}=\frac{x}{a}-\lfloor\frac{x}{a}\rfloor this can be further simplified to:
This one is nice and simple but I still don’t think it would be useful

