# Formula for computing sqrt(2) of binary numbers

**URL:** <https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344>\
**Category:** Staff Picks\
**Tags:** discrete-mathematics, equation-solving, symbolic-computations, staff-pick, mathematics-and-foundations\
**Created:** [April 16, 2017, 10:38pm UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344 "2017-04-16T22:38:51Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![mariuszi28cg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mariuszi28cg/32/308_2.png) [@mariuszi28cg](https://community.wolfram.com/u/mariuszi28cg)\
**Post date:** [April 16, 2017, 10:38pm UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344/1 "2017-04-16T22:38:51Z")

</div>

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/373ccb1d-e97f-40ec-aa0a-0d3001c4728d)

[DOWLOAD-DESKTOP-NOTEBOOK.nb](https://community.wolfram.com/uploads/short-url/sVIyxBJ17nkNhd5jJHJjgB72ljf.nb) (122 KB)

---

<div class="post-metadata">

**Author:** ![samcarrettie](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/samcarrettie/32/29668_2.png) [@samcarrettie](https://community.wolfram.com/u/samcarrettie)\
**Post date:** [April 18, 2017, 11:00pm UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344/2 "2017-04-18T23:00:36Z")

</div>

Neat! Is it your result and is it new? Do you think expression can be simplified? This does not work

\arctan{u}+\arctan{v}=\arctan\left(\frac{u+v}{1-uv}\right)

but maybe similar trigonometry.

---

<div class="post-metadata">

**Author:** ![mariuszi28cg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mariuszi28cg/32/308_2.png) [@mariuszi28cg](https://community.wolfram.com/u/mariuszi28cg)\
**Post date:** [April 19, 2017, 6:48am UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344/3 "2017-04-19T06:48:58Z")

</div>

**Appendix: To simplify B\_n formula.**

We have:

B\_n=\frac{i \left(-i \pi +2 \log \left(1-e^{-i 2^{-\frac{1}{2}+n} \pi }\right)-2 \log \left(1-e^{i 2^{-\frac{1}{2}+n} \pi }\right)-\log \left(1-e^{-i 2^{\frac{1}{2}+n} \pi }\right)+\log \left(1-e^{i 2^{\frac{1}{2}+n} \pi }\right)\right)}{2 \pi }

```
 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}]

```

\left\{\frac{\pi -4 \tan ^{-1}\left(\frac{\sin \left(\sqrt{2} \pi \right)}{1-\cos \left(\sqrt{2} \pi \right)}\right)+2 \tan ^{-1}\left(\frac{\sin \left(2 \sqrt{2} \pi \right)}{1-\cos \left(2 \sqrt{2} \pi \right)}\right)}{2 \pi },\frac{\pi -4 \tan ^{-1}\left(\frac{\sin \left(2 \sqrt{2} \pi \right)}{1-\cos \left(2 \sqrt{2} \pi \right)}\right)+2 \tan ^{-1}\left(\frac{\sin \left(4 \sqrt{2} \pi \right)}{1-\cos \left(4 \sqrt{2} \pi \right)}\right)}{2 \pi },\frac{\pi -4 \tan ^{-1}\left(\frac{\sin \left(4 \sqrt{2} \pi \right)}{1-\cos \left(4 \sqrt{2} \pi \right)}\right)+2 \tan ^{-1}\left(\frac{\sin \left(8 \sqrt{2} \pi \right)}{1-\cos \left(8 \sqrt{2} \pi \right)}\right)}{2 \pi },\frac{\pi -4 \tan ^{-1}\left(\frac{\sin \left(8 \sqrt{2} \pi \right)}{1-\cos \left(8 \sqrt{2} \pi \right)}\right)+2 \tan ^{-1}\left(\frac{\sin \left(16 \sqrt{2} \pi \right)}{1-\cos \left(16 \sqrt{2} \pi \right)}\right)}{2 \pi },\frac{\pi -4 \tan ^{-1}\left(\frac{\sin \left(16 \sqrt{2} \pi \right)}{1-\cos \left(16 \sqrt{2} \pi \right)}\right)+2 \tan ^{-1}\left(\frac{\sin \left(32 \sqrt{2} \pi \right)}{1-\cos \left(32 \sqrt{2} \pi \right)}\right)}{2 \pi }\right\}

Now we need find a pattern.The first ingredient in the formula:  
We have:

\left\{4 \tan ^{-1}\left(\frac{\sin \left(\sqrt{2} \pi \right)}{1-\cos \left(\sqrt{2} \pi \right)}\right),4 \tan ^{-1}\left(\frac{\sin \left(2 \sqrt{2} \pi \right)}{1-\cos \left(2 \sqrt{2} \pi \right)}\right),4 \tan ^{-1}\left(\frac{\sin \left(4 \sqrt{2} \pi \right)}{1-\cos \left(4 \sqrt{2} \pi \right)}\right),4 \tan ^{-1}\left(\frac{\sin \left(8 \sqrt{2} \pi \right)}{1-\cos \left(8 \sqrt{2} \pi \right)}\right),\tan ^{-1}\left(\frac{\sin \left(16 \sqrt{2} \pi \right)}{1-\cos \left(16 \sqrt{2} \pi \right)}\right)\right\}

```
 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:

\frac{\pi -\left(4 \tan ^{-1}\left(\frac{\sin \left(n \sqrt{2} \pi \right)}{1-\cos \left(n \sqrt{2} \pi \right)}\right)\text{/.}\, n\to 2^{n-1}\right)+\left(2 \tan ^{-1}\left(\frac{\sin \left(n \sqrt{2} \pi \right)}{1-\cos \left(n \sqrt{2} \pi \right)}\right)\text{/.}\, n\to 2^n\right)}{2 \pi }

```
  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

```

B\_n = \frac{1}{2}-\frac{2 \tan ^{-1}\left(\cot \left(2^{-\frac{3}{2}+n} \pi \right)\right)}{\pi }+\frac{\tan ^{-1}\left(\cot \left(2^{-\frac{1}{2}+n} \pi \right)\right)}{\pi }

---

<div class="post-metadata">

**Author:** ![mariuszi28cg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mariuszi28cg/32/308_2.png) [@mariuszi28cg](https://community.wolfram.com/u/mariuszi28cg)\
**Post date:** [April 19, 2017, 6:57am UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344/4 "2017-04-19T06:57:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sghuisman](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sghuisman/32/27850_2.png) [@sghuisman](https://community.wolfram.com/u/sghuisman)\
**Post date:** [April 19, 2017, 12:03pm UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344/5 "2017-04-19T12:03:28Z")

</div>

Just checking: is this, then, some kind of spigot algorithm for sqrt(2)?

> **[Spigot algorithm](https://en.wikipedia.org/wiki/Spigot_algorithm)**
>
> A spigot algorithm is an algorithm for computing the value of a transcendental number (such as π or e) that generates the digits of the number sequentially from left to right providing increasing precision as the algorithm proceeds. Spigot algorithms also aim to minimize the amount of intermediate storage required. The name comes from the sense of the word "spigot" for a tap or valve controlling the flow of a liquid. Spigot algorithms can be contrasted with algorithms that store and process com...

---

<div class="post-metadata">

**Author:** ![mariuszi28cg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mariuszi28cg/32/308_2.png) [@mariuszi28cg](https://community.wolfram.com/u/mariuszi28cg)\
**Post date:** [April 19, 2017, 9:20pm UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344/6 "2017-04-19T21:20:01Z")

</div>

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}

---

<div class="post-metadata">

**Author:** ![sghuisman](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sghuisman/32/27850_2.png) [@sghuisman](https://community.wolfram.com/u/sghuisman)\
**Post date:** [April 19, 2017, 9:26pm UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344/7 "2017-04-19T21:26:24Z")

</div>

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.

> **[Spigot algorithm](https://en.wikipedia.org/wiki/Spigot_algorithm)**
>
> A spigot algorithm is an algorithm for computing the value of a transcendental number (such as π or e) that generates the digits of the number sequentially from left to right providing increasing precision as the algorithm proceeds. Spigot algorithms also aim to minimize the amount of intermediate storage required. The name comes from the sense of the word "spigot" for a tap or valve controlling the flow of a liquid. Spigot algorithms can be contrasted with algorithms that store and process com...

---

<div class="post-metadata">

**Author:** ![mariuszi28cg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mariuszi28cg/32/308_2.png) [@mariuszi28cg](https://community.wolfram.com/u/mariuszi28cg)\
**Post date:** [April 20, 2017, 6:50am UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344/8 "2017-04-20T06:50:44Z")

</div>

You’re right.So let it be.

Have a nice day. 🙂

Mariusz.

---

<div class="post-metadata">

**Author:** ![mariuszi28cg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mariuszi28cg/32/308_2.png) [@mariuszi28cg](https://community.wolfram.com/u/mariuszi28cg)\
**Post date:** [April 26, 2017, 2:33pm UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344/9 "2017-04-26T14:33:53Z")

</div>

**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}]

```

B\_n=-2 \left\lfloor 2^{-\frac{3}{2}+n}\right\rfloor +\left\lfloor 2^{-\frac{1}{2}+n}\right\rfloor

**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}] 

```

\{1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, \\ 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, \\ 1, 0, 0, 1\}

---

<div class="post-metadata">

**Author:** ![vincentg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/vincentg/32/31647_2.png) [@vincentg](https://community.wolfram.com/u/vincentg)\
**Post date:** [September 18, 2019, 5:25pm UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344/10 "2019-09-18T17:25:34Z")

</div>

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](https://math.stackexchange.com/questions/3361096/simple-recursion-or-closed-form-for-lfloor-2n-sqrt2-rfloor). For your convenience, my question is posted below:

Is it possible to find an expression of the form

\lfloor 2^n \sqrt{2}\rfloor = \sum\_{k=1}^r (\alpha\_k + \beta\_ki)\cdot\Big(a\_k+b\_k i\Big)^n,

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

p=\lim\_{n\rightarrow\infty} p\_n, \mbox{ with } p\_n = \frac{1}{n}\sum\_{k=1}^n \Big( 2^k \sqrt{2} - \lfloor 2^k \sqrt{2}\rfloor\Big).

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.)

---

<div class="post-metadata">

**Author:** ![maximilian050403g](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@maximilian050403g](https://community.wolfram.com/u/maximilian050403g)\
**Post date:** [December 8, 2021, 3:45pm UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344/11 "2021-12-08T15:45:58Z")

</div>

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](http://oeis.org/A002193)):

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.

---

<div class="post-metadata">

**Author:** ![simonplouffe](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@simonplouffe](https://community.wolfram.com/u/simonplouffe)\
**Post date:** [January 2, 2024, 5:27pm UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344/12 "2024-01-02T17:27:01Z")

</div>

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](https://oeis.org/A005875) is the number of ways to write n as sum of 3 squares. See image of the formula : r\_3(n) is A005875.

 ![Image2.PNG](https://global.discourse-cdn.com/wolfram/original/3X/9/9/99b46f7ea35e162f01632975040d971ca10ae3dc.png)

NOTE : there is one for sqrt(10) also which is

 ![Image1.PNG](https://global.discourse-cdn.com/wolfram/original/2X/4/44ceb25cf1d20e05fdaebb4f9f1b05f531bbd8cb.png)

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.

---

<div class="post-metadata">

**Author:** ![wolframcommunity](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/wolframcommunity/32/8335_2.png) [@wolframcommunity](https://community.wolfram.com/u/wolframcommunity)\
**Post date:** [January 2, 2024, 7:37pm UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344/13 "2024-01-02T19:37:58Z")

</div>

![news-congrads-kkluyshnik-02-04-19.jpg](https://global.discourse-cdn.com/wolfram/original/3X/6/a/6a310c2d0904616faf4e6e148260c9f29ab9f4eb.jpeg) – you have earned _ **Featured Contributor Badge** _ ![2015-11-02_10-07-11.png](https://global.discourse-cdn.com/wolfram/original/3X/5/0/50e59c9ead62f729e7130d3ea1482555a75602b6.png)  
Your exceptional post has been selected for our editorial column _ **Staff Picks** _ [http://wolfr.am/StaffPicks](http://wolfr.am/StaffPicks) and [Your Profile](http://community.wolfram.com/web/mariuszi28cg) is now distinguished by a _ **Featured Contributor Badge** _ and is displayed on the [Featured Contributor Board](https://community.wolfram.com/people). Thank you!

---

<div class="post-metadata">

**Author:** ![mariuszi28cg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mariuszi28cg/32/308_2.png) [@mariuszi28cg](https://community.wolfram.com/u/mariuszi28cg)\
**Post date:** [January 2, 2024, 10:57pm UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344/14 "2024-01-02T22:57:14Z")

</div>

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](https://en.wikipedia.org/wiki/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

---

<div class="post-metadata">

**Author:** ![maximilian050403g](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@maximilian050403g](https://community.wolfram.com/u/maximilian050403g)\
**Post date:** [August 27, 2025, 10:49am UTC](https://community.wolfram.com/t/formula-for-computing-sqrt-2-of-binary-numbers/10344/15 "2025-08-27T10:49:08Z")

</div>

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:

B\_b(n):=\frac{b-1}{2}-\frac{b\cdot\tan^{-1}(\cot(u\cdot\pi\cdot b^{n-1}))}{\pi}+\frac{\tan^{-1}(\cot(u\cdot\pi\cdot b^{n}))}{\pi}

Given that \tan^{-1}(\cot(x))=\frac{\pi}{2}-(x \mod \pi) this can be simplified to:

B\_b(n):=\frac{b-1}{2}-\frac{b\cdot(\frac{\pi}{2}-(u\cdot\pi\cdot b^{n-1}\mod \pi))}{\pi}+\frac{\frac{\pi}{2}-(u\cdot\pi\cdot b^{n}\mod \pi)}{\pi}

Given that \frac{x\mod a}{a}=\frac{x}{a}-\lfloor\frac{x}{a}\rfloor this can be further simplified to:

\begin{align} B\_b(n):&=\frac{b-1}{2}-b\cdot(\frac{1}{2}-(u\cdot b^{n-1}-\lfloor u\cdot b^{n-1}\rfloor)) + \frac{1}{2}-u\cdot b^{n}+\lfloor u\cdot b^{n}\rfloor \\ &= \frac{b-1}{2}-\frac{b}{2}+b\cdot u\cdot b^{n-1}-b\cdot\lfloor u\cdot b^{n-1}\rfloor + \frac{1}{2}-u\cdot b^{n}+\lfloor u\cdot b^{n}\rfloor \\ &= -b\cdot\lfloor u\cdot b^{n-1}\rfloor +\lfloor u\cdot b^{n}\rfloor \\ &= \lfloor u\cdot b^{n}\rfloor -b\cdot\lfloor u\cdot b^{n-1}\rfloor \\ \end{align}

This one is nice and simple but I still don’t think it would be useful
