Post Reply 
Micro-challenge: Special Event
01-02-2023, 09:16 PM
Post: #21
RE: Micro-challenge: Special Event
(12-26-2022 02:00 PM)Thomas Klemm Wrote:  \(
\begin{align}
\pi = 2 + \frac{1}{3}\left(2 + \frac{2}{5}\left(2 + \frac{3}{7}\left(2 + \cdots \right)\right)\right)
\end{align}
\)

Thus we can write in this specific basis: \(\pi = 2.2222\cdots\).

How does this identity derived?

BTW, there was a typo, the number have no radix point.
Here is APL, with 50 2's, decoded with variable radix on the left

      {(⌽⍵÷1+2×⍵)⊥(2+0×⍵)}⍳50
3.141592654
Find all posts by this user
Quote this message in a reply
01-03-2023, 04:26 AM
Post: #22
RE: Micro-challenge: Special Event
(01-02-2023 09:16 PM)Albert Chan Wrote:  BTW, there was a typo, the number have no radix point.

Believe it or not, that was on purpose.

(01-02-2023 09:16 PM)Albert Chan Wrote:  How does this identity derived?

Quote:It was derived from the Leibniz series (16.59) without great effort if one just uses the Euler transformation [76, p. 255].

\(
\begin{align}
\pi = 4 \left(1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + - \cdots \right) \\
\end{align}
\)

76. Konrad Knopp, Infinite sequences and series Dover Publications, New York, 1956
From: \(\pi\) Unleashed, p. 78
Find all posts by this user
Quote this message in a reply
01-03-2023, 03:24 PM (This post was last modified: 01-04-2023 02:33 PM by Albert Chan.)
Post: #23
RE: Micro-challenge: Special Event
(01-03-2023 04:26 AM)Thomas Klemm Wrote:  
(01-02-2023 09:16 PM)Albert Chan Wrote:  BTW, there was a typo, the number have no radix point.

Believe it or not, that was on purpose.

I get it now ... it is not a typo.

Test with horner's rule code that allowed variable base (in a table)
Code:
function peval(a, b, s)
    s = s or 0
    if type(b) == 'table' then
        for i=1,#a do s = s*b[i] + a[i] end
    else
        for i=1,#a do s = s*b + a[i] end
    end
    return s
end

For example, 2 weeks 3 days 4 hours 5 minutes, convert to weeks only.
We could convert it all to minutes, then divide by minutes in 1 week.

lua> peval({2,3,4,5}, {1,7,24,60}), peval({1,0,0,0}, {1,7,24,60})
24725      10080
lua> 24725 / 10080
2.452876984126984

We could also do this in 1 shot: 2 + 1/7*(3 + 1/24*(4 + 1/60*5))

lua> peval({5,4,3,2}, {1,1/60,1/24,1/7})
2.452876984126984

Note: base first element is only a placeholder, that's why it stay put.
From Lua peval(a, b) code. With default s = 0, s*b[1] + a[1] = a[1]
As long as b[1] is finite, it will not affect result.

If we set s = a[1], and skip innermost factor, we get the same reult.

lua> peval({4,3,2}, {1/60,1/24,1/7}, 5)
2.452876984126984

(12-26-2022 02:00 PM)Thomas Klemm Wrote:  \(
\begin{align}
\pi = 2 + \frac{1}{3}\left(2 + \frac{2}{5}\left(2 + \frac{3}{7}\left(2 + \cdots \right)\right)\right)
\end{align}
\)

Thus we can write in this specific basis: \(\pi = 2.2222\cdots\).

To make pi = (2.2222 ...)b, we do the same way.

(2.2222)b = (22222 / 10000)b

lua> b = {1, 3/1, 5/2, 7/3, 9/4}
lua> peval({2,2,2,2,2}, b), peval({1,0,0,0,0}, b)
122      39.375
lua> 122 / 39.375 -- = 3 + 31/315
3.0984126984126985
Find all posts by this user
Quote this message in a reply
01-04-2023, 01:56 AM
Post: #24
RE: Micro-challenge: Special Event
(12-26-2022 02:00 PM)Thomas Klemm Wrote:  \(
\begin{align}
\pi = 2 + \frac{1}{3}\left(2 + \frac{2}{5}\left(2 + \frac{3}{7}\left(2 + \cdots \right)\right)\right)
\end{align}
\)

Here’s a program for the HP-42S to calculate \(\pi\):
Code:
00 { 22-Byte Prgm }
01 2
02▸LBL 00
03 RCL× ST Y
04 2
05 RCL× ST Z
06 1
07 +
08 ÷
09 2
10 +
11 DSE ST Y
12 GTO 00
13 END

Example

40 R/S

3.14159265359
Find all posts by this user
Quote this message in a reply
01-04-2023, 06:48 PM (This post was last modified: 01-05-2023 12:53 AM by Albert Chan.)
Post: #25
RE: Micro-challenge: Special Event
(01-04-2023 01:56 AM)Thomas Klemm Wrote:  Here’s a program for the HP-42S to calculate \(\pi\) ...
Example

40 R/S

3.14159265359

FYI, 40 meant 40 digits after radix point (total 41 digits)

lua> require'fun'()
lua> horner = fn's,a,b: s*b+a'
lua> terms = fn'n: range(n,1,-1)'
lua> pi_atan_euler = fn'x: 2, x/(2*x+1)'

x → ∞ produced (2, 1/2): 2*(1/2) + 2 = 3

(2.2222 ...)b last digit = 3 converge to pi faster.

lua> terms(40) :map(pi_atan_euler) :reduce(horner, 2)
3.141592653589546
lua> terms(40) :map(pi_atan_euler) :reduce(horner, 3)
3.1415926535896728



Another example, pi = 6*asin(1/2) taylor series.

\(\displaystyle \pi = 3 +
\left(\frac{1^2}{4×2×3}\right) \left(3 +\;
\left(\frac{3^2}{4×4×5}\right) \left(3 +\;
\left(\frac{5^2}{4×6×7}\right) \left(3 +\;
\cdots \right) \right) \right) \)

lua> pi_asin_half = fn'x: x=2*x-1; 3, (x*x)/(4*(x+1)*(x+2))'

x → ∞ produced (3, 1/4): 3*(1/4) + 3 = 3.75

(3.3333 ...)b last digit = 3.75 converge to pi faster.

(1/4) = (1/2)^2 --> about half terms needed for equivalent accuracy.

lua> terms(20) :map(pi_asin_half) :reduce(horner, 3)
3.141592653589791
lua> terms(20) :map(pi_asin_half) :reduce(horner, 3+.75)
3.1415926535897927

Or, we turn this into ratio of "integers", with top digit base = 4*2*3/1^2 = 24.
Note: range(20) mean 1 .. 20

lua> base = range(20): map(fn'x: x=2*x-1; (4*(x+1)*(x+2))/(x*x)')
lua> n = zip(xrepeat(3), base) :reduce(horner, 3)
lua> d = base :product()
lua> n/d, (n+.75)/d
3.141592653589791      3.141592653589793
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)