flat assembler
Message board for the users of flat assembler.
flat assembler
> Heap > What is the best pie you can get with 9 digits? Goto page Previous 1, 2, 3 ... 24, 25, 26, 27, 28, 29 Next 
Author 

3(5167)/(24+89) another in the set of 6 correct places, lol.
There are a lot of possible patterns. 

02 Jan 2017, 03:37 

So, the best answers as of now are still correct to 6 decimal places:
T.G.: (2+6*9/743)*8^(1/5) = 3.14159288348 ... bitRAKE: 3(5167)/(24+89) = 3.14159292035 ... Come on! Something even better is out there! 

02 Jan 2017, 04:06 

The power searches take a long time...
Three) 3+4^6^1/(7^2*589) I can search any pattern you think might be fruitful. 

02 Jan 2017, 05:05 

bitRAKE wrote: 3+4^6^1/(7^2*589) bitRAKE wrote: I can search any pattern you think might be fruitful. 42722830  using seven digits, from 1 to 7 I need the exact value. The pi approximation will be correct to 7 decimal places! Thanks! 

02 Jan 2017, 05:22 

Just found one, which has the same value as 355/113:
3^1 + (4^2)/((9+5)*8 + 7  6) = 3.14159292035 ... Still correct to 6 decimal places. 

02 Jan 2017, 07:41 

So, the best answers as of now are still correct to 6 decimal places:
T.G.: (2+6*9/743)*8^(1/5) = 3.14159288348 ... bitRAKE: 3(5167)/(24+89) = 3.14159292035 ... YONG: 3^1 + (4^2)/((9+5)*8 + 7  6) = 3.14159292035 ... Come on! Something even better is out there! 

02 Jan 2017, 07:43 

My simple "eval" script was able to search only through specific types of expressions, so to give it a try I wrote a proofofconcept script in fasmg that does a brute force search through all possible expressions in RPN notation:
Code: aim = 3.141592653589793238462643383279502884197169399375105820974
delta = 1 ; start showing results when they are within this distance from the aim
digits db '1234'
digits_count = $digits
operators db '+*/^'
operators_count = $operators
ln2 = 0.693147180559945309417232121458176568075500134360255254120
while 1
repeat 1 shl (digits_count1), separators:0
; Create numbers from digits:
position = 0
repeat digits_count, index:0
load digit:byte from digits+position
position = position + 1
number#index = digit'0'
while separators shr (position1) and 1
load digit:byte from digits+position
position = position + 1
number#index = number#index*10 + digit'0'
end while
if position >= digits_count
numbers_count = %
break
end if
end repeat
variations_count = 1
repeat numbers_count1
variations_count = variations_count*operators_count
end repeat
repeat variations_count, variation:0
; Prepare distribution of operators:
operators_count0 = 0
counter = numbers_count1
while 1
repeat counter
operators_count#% = 1
end repeat
; Evaluate:
variation_cursor = variation
repeat numbers_count, index:0
stack =: number#index
repeat operators_count#index
tmp = stack
restore stack
operator_index = variation_cursor mod operators_count
variation_cursor = variation_cursor / operators_count
load operator:1 from operators+operator_index
if operator = '+'
stack = stack + tmp
else if operator = ''
stack = stack  tmp
else if operator = '*'
stack = stack * tmp
else if operator = '/'
stack = float stack / tmp
else if operator = '^'
if tmp < 20 & tmp > 20 & tmp = trunc tmp
tmp = trunc tmp
inv = 0
if tmp < 0
inv = 1
tmp = tmp
end if
sq = stack
stack = 1
while tmp
if tmp and 1
stack = stack * sq
end if
sq = sq * sq
tmp = tmp shr 1
end while
if inv
stack = float 1/stack
end if
else
x = float stack
if x > 0
ln = 2*(x1)/(x+1)
repeat 4
k = trunc (ln/ln2)
r = ln  k*ln2
term = 1
exp = term
repeat 12
term = term*r/(float %)
exp = exp + term
end repeat
exp = exp shl k
ln = ln + 2*(xexp)/(x+exp)
end repeat
x = ln*tmp
k = trunc (x/ln2)
r = x  k*ln2
term = 1
stack = term
repeat 12
term = term*r/(float %)
stack = stack + term
end repeat
stack = stack shl k
else
stack = 0
end if
end if
else
err 'unknown operator'
end if
end repeat
end repeat
result = stack
restore stack
d = resultaim
if (d > 0 & d < delta)  (d < 0 & d > delta)
if d > 0
delta = d
else
delta = d
end if
; Display generated expression:
variation_cursor = variation
repeat numbers_count, index:0
if % > 1
display ' '
end if
repeat 1, x: number#index
display `x
end repeat
repeat operators_count#index
operator_index = variation_cursor mod operators_count
variation_cursor = variation_cursor / operators_count
load operator:1 from operators+operator_index
display ' ',operator
end repeat
end repeat
out showfloat result
display ' = ',out,13,10
end if
; Next distribution of operators:
counter = 1
repeat numbers_count1, index:0
if operators_count#index > 0
operators_count#% = operators_count#% + 1
counter = operators_count#index  1
operators_count#index = 0
break
end if
end repeat
if counter < 0
break
end if
end while
end repeat
end repeat
; Next permutation of digits:
i = digits_count1
while i >= 0
load b:byte from digits+i
i = i  1
if i >= 0
load a:byte from digits+i
if a < b
break
end if
end if
end while
if i < 0
break
end if
j = i + 1
while j < digits_count1
load c:byte from digits+j+1
if c > a
b = c
j = j + 1
else
break
end if
end while
store b:byte at digits+i
store a:byte at digits+j
i = i + 1
j = digits_count1
while i < j
load x:byte from digits+i
load y:byte from digits+j
store x:byte at digits+j
store y:byte at digits+i
i = i + 1
j = j  1
end while
end while (The script uses the "showfloat" macro I once shared in the other thread.) Some interesting results from my test searches with small sets of digits: with digits 14 the best possible approximation of pi is 3+2/14 = 3.1428571429..., interestingly digits 15 yield no better result. For a set of digits 16 some better results start coming in, for example 1*(354)^(2/6)=3.141380652... but I have not yet finished this search. YONG wrote: See if you can find an expression for each of these numbers with your program: (...) ___ * This is now in the official fasmg releases as a hidden "v2" option. Last edited by Tomasz Grysztar on 08 Sep 2017, 17:04; edited 9 times in total 

02 Jan 2017, 09:38 

Am I dreaming?
How come the above script  written by T.G.  actually has some comments? 

02 Jan 2017, 11:49 

And another bug in fasmg found thanks to these scripts...


02 Jan 2017, 15:26 

Code: 5)
296^5/(814)^7+3
(278^4+1)/59^6+3
(6/8)^5 * (3/9)^1 * (7/4)^2
[6^(43)+7^(92)]/8^(1+5) 

02 Jan 2017, 18:53 

Tomasz Grysztar wrote: And another bug in fasmg found thanks to these scripts... I like how you choose to iterate between the operators  very concise. 

02 Jan 2017, 19:58 

bitRAKE wrote:
Whether the formulation of problem allows to unary minus is another issue. This probably should be clarified. 

02 Jan 2017, 20:06 

Tomasz Grysztar wrote: but for example if we had allowed square root (which is also an unary operator) ... ^(1/2) becomes √ Allowing the radical sign of the higher roots means freeing up at least one digit: ^(1/n) becomes ^n √ Allowing unary minus in the power means freeing up at least one digit: (1/x)^n becomes x^(n) A wise forum member once said, "Something something keeping up the standards something something." So, I would say we better stick to those restrictive rules and maintain the difficulty of the problem. 

03 Jan 2017, 03:48 

bitRAKE wrote:
The expression ( 6 / 8 )^5 * (3/9)^1 * (7/4)^2 gives 0.24224853515. Something is wrong with your program. 

03 Jan 2017, 03:57 

YONG wrote: 888582403  using six digits, either {2, 4, 5, 7, 8, 9} or {3, 4, 5, 6, 7, 8} Code: [RPN] 5 2 * 9 4 78 /  ^ = (5*2)^(9(4/78)) = 888623816.274... If we raise this to the power 1/(3*6), which is what I suspect you wanted to do, we get an approximation of pi, but it is much worse than the ones we already have: Code: ((5*2)^(9(4/78)))^(1/(3*6)) = 3.1416007876788536... The search for 42722830 that you also asked for is practically out of reach with fasmg script, because the number of expressions for seven digits is much larger. But I we write a native implementation of the searcher, then such search may become possible. But brute force scans with 8 and 9 digits are going to be out of reach anyway. 

05 Jan 2017, 09:12 

@T.G.: Thank you very much.
So, six digits is basically the limit for your script. Then give the following a try: 924269  using six digits: {2, 5, 6, 7, 8, 9}, {3, 4, 5, 7, 8, 9}, {2, 4, 5, 6, 7, 8}, {2, 3, 5, 6, 7, 9}, or {2, 3, 4, 6, 8, 9}. (924269)^(1/(3*4)) = (924269)^(1/(2*6)) = (924269)^(1/(3+9)) = (924269)^(1/( 4 + 8 )) = (924269)^(1/(5+7)) = 3.14159260217 ... (correct to 7 decimal places) If I can use one more digit (4), here is the solution: (6^3 * 4279 + 5)^(1/(8+4)) = 924269^(1/12) = 3.14159260217 ... Please give me some good news this time! 

05 Jan 2017, 10:20 

I have continued to look for 888582403 with other sets of digits, because there are also other ways to make 1/18 power. And I found this one:
Code: [RPN]41 5 ^ 9 7 ^  8 * = (41^59^7)*8 = 888585856 Code: ((41^59^7)*8)^(2/36)=3.14159333180... 

05 Jan 2017, 13:56 

Tomasz Grysztar wrote: there are also other ways to make 1/18 power 1/12 = 2/24 = 2/( 3 * 8 ) = 2/(4*6) = 4/48 = 4/( 6 * 8 ) = 8/96 So, please also try: {1, 4, 5, 6, 7, 9}, {1, 3, 5, 7, 8, 9}, {1, 2, 3, 5, 7, 9}, and {1, 2, 3, 4, 5, 7} for 924269. Thanks! 

06 Jan 2017, 01:33 

Any number n within the range
888582131 =< n =< 888582639 can give a pi approximation correct to 7 (or more) decimal places. Come on! 

06 Jan 2017, 04:57 

Goto page Previous 1, 2, 3 ... 24, 25, 26, 27, 28, 29 Next < Last Thread  Next Thread > 
Forum Rules:

Copyright © 20042018, Tomasz Grysztar.
Powered by rwasa.