Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (590)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  The Wrath of Ackermann  (Read 1402 times)
0 Members and 1 Guest are viewing this topic.
Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Posted 2014-07-07 06:47:48 »

First, the intro video that got me thinking about this in the first place...

Ackermann's Function
<a href="http://www.youtube.com/v/i7sm9dzFtEI?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/i7sm9dzFtEI?version=3&amp;hl=en_US&amp;start=</a>


For those too lazy to go through that video, this topic is about Ackermann's function. Literally a function to prove that even computing has its limits. The recursive case in Ackermann's function is pretty simple and can be written in a few lines of code.



1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
public class ackermann {

   public static void main(String[] args){
      for(int i = 0; i < 6; i++){
         for(int j = 0; j < 6; j++){
            System.out.printf("ackerman (%d, %d) is: %d\n", i, j, ack(i, j));
         }
      }
   }

        private static int ack(int m, int n){
      int ans;
      if (m == 0)
         ans = n+1;
      else if (n == 0)
         ans = ack(m-1, 1);
      else
         ans = ack(m-1, ack(m, n-1));
     
      return ans;
   }
}


However, this does a number on processing machines, with A(4,2) taking ages to compute on even the most powerful machines. (With Java, I had to do a bit more to avoid stack overflow errors...) I think before we even think about tackling the universe, I'm actually curious about how deep into Ackmermann's function we can calculate today before our computer's die from the processing strain. No matter how much I optimized, we just couldn't think of a good way to calculate past A(4,2)...

Any thoughts or takers?

Offline Roquen
« Reply #1 - Posted 2014-07-07 08:14:29 »

Well uncomputable functions and undecidable/unsolvable problems are called that for a good reason.  Busy beaver is a fun example.   
Offline Roquen
« Reply #2 - Posted 2014-07-07 08:31:20 »

Wait.  Past A(4,2)?  A(4,2) requires 2^16 bits (assuming unsigned).
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ags1

JGO Wizard


Medals: 72
Projects: 3
Exp: 5 years


Make code not war!


« Reply #3 - Posted 2014-07-07 08:35:25 »

I guess a 99.9% approximation of this function would be blindingly fast. After, even common functions like sin() or cos() are only calculated to a certain degree of precision.

Offline pjt33
« Reply #4 - Posted 2014-07-07 09:14:28 »

No matter how much I optimized, we just couldn't think of a good way to calculate past A(4,2)...

Any thoughts or takers?
Depends what you mean by calculate. For m > 2, A(m, n) + 3 = 2 → (n+3) → (m − 2) = 2 → (2 → (n+2) → (m − 2)) → (m − 3) = 2 → (A(m, n − 1) + 3) → (m − 3), so in particular A(4, n) + 3 = 2A(4, n − 1) + 3. If you want to calculate that naïvely as a list of bits, you'll run into trouble. But selecting the correct representation of your data is the first thing to learn in computing.
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 835
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #5 - Posted 2014-07-07 12:51:06 »

Super-duper fast: (until 64 bit overflow)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
public class Ackermann {

   private static final int MAX = 5;

   public static void main(String[] args) {
      for(int i = 0; i < MAX; i++) {
         for(int j = 0; j < MAX; j++) {
            long t0 = System.nanoTime();
            long got = ack(i, j);
            long t1 = System.nanoTime();
            System.out.printf("ackerman (%d, %d) is: %d (took: %d micros)\n", i, j, got, (t1 - t0) / 1000);
         }
      }
   }

   private static long ack(long m, long n) {
      if(m == 0)
         return m0(n);
      if(m == 1)
         return m1(n);
      if(m == 2)
         return m2(n);
      if(m == 3)
         return m3(n);

      long ans;
      if(m == 0)
         ans = n + 1;
      else if(n == 0)
         ans = ack(m - 1, 1);
      else
         ans = ack(m - 1, ack(m, n - 1));

      return ans;
   }

   private static long m0(long n) {
      return n + 1;
   }

   private static long m1(long n) {
      return n + 2;
   }

   private static long m2(long n) {
      return n * 2 + 3;
   }

   private static long m3(long n) {
      long sum = 1;
      for(int i = 0; i <= n; i++)
         if((sum = (sum << 1) + 3) < 0L)
            throw new IllegalStateException("64 bit overflow");
      return sum;
   }
}


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
ackerman (0, 0) is: 1 (took: 2 micros)
ackerman (0, 1) is: 2 (took: 0 micros)
ackerman (0, 2) is: 3 (took: 0 micros)
ackerman (0, 3) is: 4 (took: 0 micros)
ackerman (0, 4) is: 5 (took: 0 micros)
ackerman (1, 0) is: 2 (took: 2 micros)
ackerman (1, 1) is: 3 (took: 0 micros)
ackerman (1, 2) is: 4 (took: 0 micros)
ackerman (1, 3) is: 5 (took: 0 micros)
ackerman (1, 4) is: 6 (took: 0 micros)
ackerman (2, 0) is: 3 (took: 2 micros)
ackerman (2, 1) is: 5 (took: 0 micros)
ackerman (2, 2) is: 7 (took: 0 micros)
ackerman (2, 3) is: 9 (took: 0 micros)
ackerman (2, 4) is: 11 (took: 0 micros)
ackerman (3, 0) is: 5 (took: 2 micros)
ackerman (3, 1) is: 13 (took: 0 micros)
ackerman (3, 2) is: 29 (took: 0 micros)
ackerman (3, 3) is: 61 (took: 0 micros)
ackerman (3, 4) is: 125 (took: 0 micros)
ackerman (4, 0) is: 13 (took: 0 micros)
ackerman (4, 1) is: 65533 (took: 1 micros)

Exception in thread "main" java.lang.IllegalStateException: 64 bit overflow
   at softlylit.main.Ackermann.m3(Ackermann.java:57)
   at softlylit.main.Ackermann.ack(Ackermann.java:26)
   at softlylit.main.Ackermann.ack(Ackermann.java:34)
   at softlylit.main.Ackermann.main(Ackermann.java:11)

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 835
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #6 - Posted 2014-07-07 13:10:57 »

A(4,2) in 362 milliseconds
A(4,2) in 107 microseconds (~1.1ms)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
import java.math.BigInteger;

public class BigAckermann {

   private static final int MAX = 5;

   public static void main(String[] args) {
      for(int i = 0; i < MAX; i++) {
         for(int j = 0; j < MAX; j++) {
            long t0 = System.nanoTime();
            BigInteger got = ack(BigInteger.valueOf(i), BigInteger.valueOf(j));
            long t1 = System.nanoTime();
            if(i < 4) {
               System.out.printf("big.ackerman (%d, %d) is: %d (took: %d micros)\n", i, j, got, (t1 - t0) / 1000);
            }
            else {
               System.out.printf("big.ackerman (%d, %d) is: ... (took: %d micros)\n", i, j, (t1 - t0) / 1000);
               String str = got.toString();
               for(int k = 0; k < str.length(); k += 80) {
                  System.out.println(str.substring(k, Math.min(k + 80, str.length())));
               }
            }
         }
      }
   }

   private static BigInteger ack(BigInteger m, BigInteger n) {
      if(m.equals(valueOf(0)))
         return m0(n);
      if(m.equals(valueOf(1)))
         return m1(n);
      if(m.equals(valueOf(2)))
         return m2(n);
      if(m.equals(valueOf(3)))
         return m3(n);
      if(m.equals(valueOf(4)))
         return m4(n);

      BigInteger ans;
      if(n.equals(valueOf(0)))
         ans = ack(m.subtract(valueOf(1)), valueOf(1));
      else
         ans = ack(m.subtract(valueOf(1)), ack(m, n.subtract(valueOf(1))));

      return ans;
   }

   private static BigInteger m0(BigInteger n) {
      return n.add(valueOf(1));
   }

   private static BigInteger m1(BigInteger n) {
      return n.add(valueOf(2));
   }

   private static BigInteger m2(BigInteger n) {
      return n.shiftLeft(1).add(valueOf(3));
   }

   private static BigInteger m3(BigInteger n) {
      BigInteger sum = valueOf(1);
      for(int i = 0; n.subtract(valueOf(i)).signum() >= 0; i++) {
         sum = sum.shiftLeft(1);
         sum = sum.add(valueOf(3));
      }
      return sum;
   }

   private static BigInteger m4(BigInteger n) {
      BigInteger pow = valueOf(1);
      for(int k = 0, len = n.intValue() + 3; k < len; k++)
         if(pow.intValue() <= 0)
            throw new IllegalStateException("2^MAX");
         else
            pow = valueOf(1).shiftLeft(pow.intValue());
      return pow.subtract(valueOf(3));
   }

   private static final BigInteger[] table = new BigInteger[1024];
   static {
      for(int i = 0; i < table.length; i++)
         table[i] = BigInteger.valueOf(i);
   }

   private static BigInteger valueOf(int i) {
      if(i < table.length)
         return table[i];
      return BigInteger.valueOf(i);
   }



A(4,0) = (222)-3
A(4,1) = (2222)-3
A(4,2) = (22222)-3

No wonder this scales poorly Smiley Shocked

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
233  
234  
235  
236  
237  
238  
239  
240  
241  
242  
243  
244  
245  
246  
247  
248  
249  
250  
251  
252  
253  
254  
255  
256  
257  
258  
259  
260  
261  
262  
263  
264  
265  
266  
267  
268  
269  
270  
271  
272  
273  
274  
275  
276  
277  
big.ackerman (0, 0) is: 1 (took: 9 micros)
big.ackerman (0, 1) is: 2 (took: 5 micros)
big.ackerman (0, 2) is: 3 (took: 2 micros)
big.ackerman (0, 3) is: 4 (took: 1 micros)
big.ackerman (0, 4) is: 5 (took: 1 micros)
big.ackerman (1, 0) is: 2 (took: 3 micros)
big.ackerman (1, 1) is: 3 (took: 2 micros)
big.ackerman (1, 2) is: 4 (took: 2 micros)
big.ackerman (1, 3) is: 5 (took: 2 micros)
big.ackerman (1, 4) is: 6 (took: 2 micros)
big.ackerman (2, 0) is: 3 (took: 7 micros)
big.ackerman (2, 1) is: 5 (took: 3 micros)
big.ackerman (2, 2) is: 7 (took: 3 micros)
big.ackerman (2, 3) is: 9 (took: 3 micros)
big.ackerman (2, 4) is: 11 (took: 3 micros)
big.ackerman (3, 0) is: 5 (took: 11 micros)
big.ackerman (3, 1) is: 13 (took: 11 micros)
big.ackerman (3, 2) is: 29 (took: 9 micros)
big.ackerman (3, 3) is: 61 (took: 11 micros)
big.ackerman (3, 4) is: 125 (took: 13 micros)
big.ackerman (4, 0) is: ... (took: 9 micros)
13
big.ackerman (4, 1) is: ... (took: 8 micros)
65533
big.ackerman (4, 2) is: ... (took: 107 micros)
20035299304068464649790723515602557504478254755697514192650169737108940595563114
53089506130880933348101038234342907263181822949382118812668869506364761547029165
04187191635158796634721944293092798208430910485599057015931895963952486337236720
30029169695921561087649488892540908059114570376752085002066715637023661263597471
44807111774815880914135742720967190151836282560618091458852699826141425030123391
10827360384376787644904320596037912449090570756031403507616256247603186379312648
47037437829549756137709816046144133086921181024859591523801953310302921628001605
68670105651646750568038741529463842244845292537361442533614373729088303794601274
72495841486491593064725201515569392262818069165079638106413227530726714399815850
88112926289011342377827055674210800700652839633221550778312142885516755540733451
07213112427399562982719769150054883905223804357045848197956393157853510018992000
02414196370681355984046403947219401606951769015611972698233789001764151719005113
34663068981402193834814354263873065395529696913880241581618595611006403621197961
01859534802787167200122604642492385111393400464351623867567078745259464670903886
54774348321789701276445552940909202195958575162297333357615955239488529757995402
84719435299135437637059869289137571537400019863943324648900525431066296691652434
19174691389632476560289415199775477703138064781342309596190960654591300890188887
58808473362595606544488850144733570605881709016210849971452956834406197969056546
98136311620535793697914032363284962330464210661362002201757878518574091620504897
11781820400187282939943446186224328009837323764931814789848119452713007440220765
68091037620399920349202390662626449190916798546151577883906039772075927937885224
12943010174580868622633692847258514030396155585643303854506886522131148136384083
84778263790459607186876728509763471271988890680478243230394718650525660978150729
86114143030581692792497140916105941718535227588750447759221830115878070197553572
22414000195481020056617735897814995323252085897534635470077866904064290167638081
61740550405117670093673202804549339027992491867306539931640720492238474815280619
16690093380573212081635070763435166986962502096902316285935007187419057916124153
68975148082619048479465717366010058924766554458408383347905441448176842553272073
15586349347605137419779525190365032198020108764738368682531025183377533908861426
18480037400808223810407646887847164755294532694766170042446106331123802113458869
45322001165640763270230742924260515828110703870183453245676356259514300320374327
40780879056283663406965030844225855967039271869461158513793386475699748568670079
82396060439347885086164926030494506174341236582835214480672667684180708375486221
14082365798029612000274413244384324023312574035450193524287764308802328508558860
89962774458164680857875115807014743763867976955049991643998284357290415378143438
84730348426190338884149403136613985425763557710533558020662218557706008255128889
33322264362819848386132395706761914096385338323743437588308592337222846442879962
45605476932428998432652677378373173288063210753211238680604674708428051166488709
08477029120816110491255559832236624486855665140268464120969498259056551921618810
43412268389962830716548685255369148502995396755039549383718534059000961874894739
92880432496373165753803673586710175783994818471798498246948060532081996066183434
01247609663951977802144119975254670408060849934417825628509272652370989865153946
21930046073645079262129759176982938923670151709920915315678144397912484757062378
04600009918293321306880570046591458387208088016887445835557926258465124763087148
56631352893416611749061752667149267217612833084527393646924458289257138887783905
63004824837998396920292222154861459023734782226825216399574408017271441461795592
26175083889020074169926238300282286249284182671243405751424188569994272331606998
71298688277182061721445314257494401506613946316919762918150657974552623619122484
80638900336690743659892263495641146655030629659601997206362026035219177767406687
77463549375318899587866282125469797102065747232721372918144666659421872003474508
94283091153518927111428710837615922238027660532782335166155514936937577846667014
57179719012271178127804502400263847587883393968179629506907988171216906869295382
48529830023476068454114178139110648560236549754227497231007615131870024053910510
91381784372179142252858743209852495787803468370333781842144401713868812424998441
86181292711985333153825673218704215306311977485352146709553346263366108646673322
92409879849256691109516143618601548909740241913509623043612196128165950518666022
03071561368473236466086890501426391390651506390819937885231836505989729912540447
94434251667742996598118492331515552728832740283526884424087528112832899806259126
73699546247341543333500147231430612750390307397135252069338173843322950701049061
86753943313078479801565513038475815568523621801041965025559618193498631591323303
60964619059902361126811960234418433633345949276319461017166529138237171823942992
16272538461776065694542297877071383198817036964588689811863210976900355735884624
46483570629145305275710127887202796536447972402540544813274839179412882642383517
19491972097971459368875371987291308317380339110161285474153773777159517280841116
27597186384924222802373441925469991983672192131287035585307966942713416391033882
75431861364349010094319740904733101447629986172542442335561223743571582593338280
49862438924982227807159517627578471094751190334822414120251826887137281931042534
78196128440176479531505057110722974314569915223451643121848657575786528197564843
50895838472292353455946452121583165775147129870822590929265563883665112068194383
69041162526687100445602437042006637090019411855571604720446436969328500600469281
40507119069261393993902735534545567470314903886022024639948260501762431969305640
66636662609020704888743889890749815286544438186291738290105182086993638266186830
39152732645812867828066013375000965933646251460917231803129303478774212346791184
54791311109897794648216922505629399956793483801699157439700537542134485874586856
04728675106542334189383909911058646559511364606105515683854121745980180713316361
25730796111683438637676673073545834947897883163301292408008363568259391571131309
78030516441716682518346573675934198084958947940983292500086389778563494693212473
42610306271374507728615692259662857385790553324064184901845132828463270926975383
08673084091422476594744399733481308109863994173797896570106870267341619671965915
99588537834822988270125605842365589539690306474965584147981310997157542043256395
77607048510088157829140825077773855979012912940730946278594450585941227319481275
32251523248015034665190482289614066468903051025109162377704484862302294889667113
80555607956620732449373374027836767300203011615227008921843515652121379215748206
85935692079021450227713309998772945959695281704458218195608096581170279806266989
12050615607423256868422713062950098644218534708104071289176469065508361299166947
78023822502789667843489199409657361704586786242554006942516693979292624714524945
40885842272615375526007190433632919637577750217600519580069384763578958687848953
68721228985578068265181927036320994801558744555751753127364714212955364940843855
86615208012115079075068553344489258693283859653013272046970694571546959353658571
78889486233329246520273585318853337094845540333656535698817258252891805663548836
37437933484118455801683318276768346462919956055134700391478768086403226296166415
60667508153710646723108461964247537490553744805318226002710216400980584497526023
03564003808347205314994117296573678506642140084269649710324191918212121320693976
91439233683747092282677387081322366800869247034915868409911530983154120635661231
87504305467536983230827966457417620806593177265685841681837966106144963432544111
70694170022265781735835125982108076910196105222926387974504901925431190062056190
65774524161919131875339840493439768233102984658933183730158095925228292068208622
30332585280119266496314441316442773003237792274712330696417149945532261035475145
63129066885434542686978844774298177749371011761465162418361668025481529633530849
08499430067636548061029400946937506098455885580439704859144495844450799784970455
83550685408745163316464118083123079704389849190506587586425810738422420591191941
67418249045270028826398305795005734171148703118714283418449915345670291528010448
51451760553069714417613685823841027876593246626899784183196203122624211773914772
08004883578333569204533935953254564897028558589735505751235129536540502842081022
78524877660357424636667314868027948605244578267362623085297826505711462484659591
42102781227889414481639949738818846227682448516220518170767221698632657016543169
19742651230041757329904473537672536845792754365412826553581858046840069367718605
02007054724754840080553042495185449526724726134731817474218007857469346544713603
69758841180294080396167469462885406791721386012254195038197045384172680063988206
56328792839582708510919958839448297775647152026132871089526163417707151642899487
95356485455355314875497813400996485449863582484769059003311696130376612792346432
31297066284113074270462020320133683503854253603136367635752126047074253112092334
02837482949453104727418969287275572027615272268283376741393425652653283068469997
59709775000556088993268502504921288406827413988163154045649035077587168007405568
57240217586854390532281337707074158307562696283169556874240605277264858530506113
56384851965918968649596335568216975437621430778665934730450164822432964891270709
89807667662567151726906205881554966638257382927418208227896068448822298339481667
09840390242835143068137672534601260072692629694686727507943461904399966189796119
28750519442356402644303271737341591281496056168353988188569484045342311424613559
92527233006488162746672352375123431189344211888508507935816384899448754475633168
92138696755743027379537852625423290248810471819390372206668947022042588368958409
39998453560948869946833852579675161882159410981624918741813364726965123980677561
94791255795744647142786862405375057610420426714936608498023827468057598259133100
69199419046519065311719089260779491192179464073551296338645230356733455880333131
97080365457184791550432654899559705862888286866606618021882248602144999973122164
13817065348017551043840662441282280361664890425737764095632648282525840766904560
84394903252905263375323165090876813366142423983095308065496618793819491200339194
89494065132398816642080088395554942237096734840072642705701165089075196155370186
26479745638118785617545711340047381076276301495330973517418065547911266093803431
13785325328835333520249343659791293412848549709468263290758301930726653377825593
14331110963848053940859283988907796210479847919686876539987477095912788727475874
43980677982496827827220092644994455938041460877064194181044075826980568803894965
46165879839046605876453418102899071942930217745199761044950431968415034555140448
20928933378657363052830619990077748726922998608279053171691876578860908941817057
99340489021844155979109267686279659758395248392673488363474565168701616624064242
42412289611180106156823425393921800524834547237792199112285959141918774917938233
40010078128326506710281781396029120914720100947878752551263372884222353869490067
92766451163475810119387531965724212147603828477477457170457861041738574791130190
85838778901523343430130052827970385803598151829296003056826120919509437373254541
71056383887047528950563961029843641360935641632589408137981511693338619797339821
67076100460798009601602482309694304380695662012321365014054958625061528258803302
29083858124784693157203232336018994694376477267218793768264318283826035645206994
68630216048874528424363593558622333506235945002890558581611275341783750455936126
13085264082805121387317749020024955273873458595640516083058305377073253397155262
04447054295735383611136775231699727402929416742044232481138750756313190782721888
64053374694213842169928862940479635305150560788126366206497231257579019598873041
19562622734372890051656111109411174527796548279047125058199907749806382155937688
55464988229389854082913251290764783863224947810167534916934892881042030156102833
86143827378160946341335383578340765314321417150655877547820252454780657301342277
47061674424196895261316427410469547462148375628829977180418678508454696561915090
86958742511844358373065909514609804512474094113738999278224929833677960110153870
96129749705566301637307202750734759922943792393824427421186158236161317886392553
09511718842129850830723825972914414225157940388301135908333165185823496722125962
18125070581137594955250227472746743698871319266707692991990844671612287388584575
84622726573330753735572823951616964175198675012681745429323738294143824814377139
86190671665757294580780482055951188168718807521297183263644215533678775127476694
07901170575098195750845635652173895441798750745238544552001335720333323798950743
93905312918212255259833790909463630202185353848854825062897715616963860712382771
72562131346054940177041358173193176337013633225281912754719144345092071184883836
68181742633429496118700915030491653394647637177664391207983474946273978221715020
90670190302469762151278521956142070806461631373236517853976292092025500288962012
97014137964003805573494926907353514596120867479654773369295877362863566014376796
40384307968641385634478013282612845891848985280480488441808216394239740143629034
81665458114454366460032490618763039502356402044530748210241366895196644221339200
75747912868380517515063466256939193774028351207566626082989049187728783385217852
27920457718469658552787904475621926639920084093020756739253637356283908298175779
02153202106409617373283598494066652141198183810884515459772895164572131897797907
49194101314836854463961690460703010759681893374121757598816512700076126278916951
04063158576375347874200702220510708912576123616580268068158584998526314658780866
16800733264676830206391697203064894405628195406190685242003053463156621891327309
06968735318164109451428803660599522024824888671155442910472192913424834643870536
85086487490991788126705656653871910497218200423714927401644609434598453925367061
32210616533085662021188968234005752675486101476993688738209584552211571923479686
88816085363161586288015039594941852948922707441082820716930338781808493620401825
52222710109856534448172074707560192459155994310729495781978785905789400525401228
67517142511184356437184053563024181225473266093302710397968091064939272722683035
41046763259135527968383770501985523462122285841055711992173171796980433931770775
07556270560478317798444476375602546370333692471142208155199736913719751632413027
48712199863404548248524570118553342675264715978310731245663429805221455494156252
72402891533335434934121786203700726031527987077187249123449447714790952073476138
54254853115527733010303424768358654960937223240071545181297326920810584240905577
25645803681462234493189708138897143299831347617799679712453782310703739151473878
69211918756670031932128189680332269659445928621060743882741691946516226763254066
50708810710303941788605648937698167341590259251946118236429456526693722031555047
00213598846292758012527715422016629954863130324912311029627923723899766416803497
14122652793190763632613681414551637665655983978848938173308266877990196288693229
65973799519316211872154552873941702436698855938887933167445333631195415184040882
83815193421234122820030950313341050704760159987985472529190665222479319715440331
79483683737322082188577334162385644138070054191353024594391350255453188645479625
22602517629283743304651023610575835145507394433396102162296754614157811271970017
38611494279501411253280621254775810512972088465263158094806633687670147310733540
71771087661593585681409821296773075919738297344144525668877085532457088895832099
38234321027182241147637327913575686154212528496579033350931527769255058456440105
52192644505312073756287744998163646332835816140330175813967359427327690448920361
88038675495575180689005853292720149392350052584514670698262854825788326739873522
04572282392902071448222198855871028969919358730742778151597576207640239512438602
02032596596250212578349957710085626386118233813318509014686577064010676278617583
77277289589274603940393033727187385053691295712671506689668849388088514294360996
20129667590792250822753138128498515269029317002631363289420957975779593276355311
62066753488651317323872438748063513314512644889967589828812925480076425186586490
24111112730135719718138160258317850693224400799865663537154408845486639318170839
57357807990597308390948818040609359591909074739609044101505163217496814121007657
19177483767355751000733616922386537429079457803200042337452807566153042929014495
78062963413838355178359976470885134900485697369796523869584599459559209070905895
68914511414126845054621179450266117501669282602509507707782119504326173832235624
37601776799362796099368975191394965033358507155418436456852616674243688920371037
49532842592713161053783498074073915863381796765842525803673720646935124865223848
13416638080615057048290598906964519364400185971204257230073164100099169875242603
77362177763430621616744884930810929901009517974541564251204822086714586849255132
44426677712786372821133153622430109182439124338021404624222334915355951689081628
84879899882736304453724321742802157557779670216663170479697281724833928410156422
74507271779269399929740308072770395013581545142494049026536105825409373114653104
94338248437971860693721444460082679800247122948940576185389220342560830269705287
66213773735943942241147070740729027254613073585417456914194464876243576823970657
03184168467540733466346293673983620004041400714054277632480132742202685393698869
78760700959004868465062677136307097982100655728510130660101078063374334477307347
86538817426812307437660666433127753564665786037151929227684404582732832438082128
41218776132042460464900801054731426749260826922155637405486241717031027919996942
64562095561981645454766204502241144940474934983220680719135276798674781345820385
95704134661779372285349400316315995440936840895725334387029867178297703733328068
01764639502090023941931499115009105276821119510999063166150311585582835582607179
41005252858361136996130344279017381178741206128818206202326384986151565645123004
77929675636183457681050433417695430675380411139285537925292413473394810505320257
08728186307291158911335942014761872664291564036371927602306283840650425441742335
46454998705531872688792642410214736369862546374715974435494344389973005174252511
08773578863909468120966734281525859199248576404880550713298142993599114632399191
13959926752576359007446572810191805841807342227734721397723218231771716916400108
82611254909336118678057572239101818616854910850088527227437421208652485237245624
86976622453848192986711294529455154970305859193071984971054141816369689761311267
44027009648667545934567059936995464500558921628047976365686133316563907395703272
03438917541526750091501119885687270884819553167693168127289214303137681801644547
73675183534978579242764633541624336011259602521095016122641103460834656482355979
34274056868849224458745493776752120324703803035491157544831295275891939893680876
32768543876955769488142284431199859570072752139317683783177033913042306095899913
73146845690104220951619670705064202567338734461156552761759927271518776600102389
44760539789516945708802728736225121076224091810066700883474737605156285533943565
84375627124124445765166306408593950794755092046393224520253546363444479175566172
59621871992791865754908578529500128402290350615149373101070094461510116137124237
61426722541732055959202782129325725947146417224977321316381845326555279604270541
87149623658525245864893325414506264233788565146467060429856478196846159366328895
42997807225422647904006160197519750074605451500602918066382714970161109879513366
33771378434416194053121445291855180136575558667615019373029691932076120009255065
08158327550849934076879725236998702356793102680413674571895664143185267905471716
99629903630155456450900448027890557019683283136307189976991531666792089587685722
90600915472919636381673596673959975710326015571920237348580521128117458610065152
59888384311451189488055212914577569914657753004138471712457796504817585639507289
5337539755822087777506072339445587895905719156733

Exception in thread "main" java.lang.IllegalStateException: 2^MAX
   at softlylit.main.BigAckermann.m4(BigAckermann.java:75)
   at softlylit.main.BigAckermann.ack(BigAckermann.java:39)
   at softlylit.main.BigAckermann.main(BigAckermann.java:13)

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 835
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #7 - Posted 2014-07-07 14:24:44 »

A(4,2) is pretty much a hard limit - it's even trivial to compute (about 1ms).


I guess a 99.9% approximation of this function would be blindingly fast. After, even common functions like sin() or cos() are only calculated to a certain degree of precision.
A(4,3) is impossible, due to memory requirements, as we raise 2 to the power of the big number printed in the previous post, which dwarfs the number of atoms in the universe - so there would be no way to represent it, in this universe.


Errrr, I just saw all the 'optimisations' were also to be found in the Wikipedia article... all that hard work for nothing Smiley

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline ags1

JGO Wizard


Medals: 72
Projects: 3
Exp: 5 years


Make code not war!


« Reply #8 - Posted 2014-07-07 19:02:57 »

You can always write down a number no matter how big it is. All you need is the right syntax.

Offline Roquen
« Reply #9 - Posted 2014-07-07 19:04:14 »

No you can't.  That's the point.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ags1

JGO Wizard


Medals: 72
Projects: 3
Exp: 5 years


Make code not war!


« Reply #10 - Posted 2014-07-07 19:12:49 »

Write down the number of atoms in the universe. Put a squared next to it.

Offline Longarmx
« Reply #11 - Posted 2014-07-07 19:23:35 »

Write down the number of atoms in the universe. Put a squared next to it.

Or, just 2^ack(4,3)  Wink

Offline ags1

JGO Wizard


Medals: 72
Projects: 3
Exp: 5 years


Make code not war!


« Reply #12 - Posted 2014-07-07 19:24:46 »

(ack(4,3))^ack(4,3)

Offline Longarmx
« Reply #13 - Posted 2014-07-07 19:36:03 »

The mother of all computations:

ack(g64, g64);

Offline Roquen
« Reply #14 - Posted 2014-07-07 19:45:34 »

ack(g64, g64);
That would be an insanely big number.  But all of this is beside the point.  There are things which can't be computed or even manipulated symbolically in finite time and/or space.
Offline Roquen
« Reply #15 - Posted 2014-07-07 19:49:03 »

Oh yeah, since it came up: https://plus.google.com/117663015413546257905/posts/KJTgfjkTZCQ
Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #16 - Posted 2014-07-08 03:20:40 »

Whew, well at least I can lay this to rest. Thanks for tackling this problem. It was really cool trying to out optimize this for a weekend. I feel a bit of reserve that our technology is the limiter in the ability to calculate A(4,3), and it isn't just me.

Though I can't shake the feeling that future beings will call us idiots once they dig this up...  Pointing

Offline Roquen
« Reply #17 - Posted 2014-07-08 07:10:55 »

The thing about proofs is: there are no counter examples unless they're flawed.
Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (29 views)
2014-11-22 12:13:56

xFryIx (71 views)
2014-11-13 12:34:49

digdugdiggy (50 views)
2014-11-12 21:11:50

digdugdiggy (44 views)
2014-11-12 21:10:15

digdugdiggy (38 views)
2014-11-12 21:09:33

kovacsa (62 views)
2014-11-07 19:57:14

TehJavaDev (67 views)
2014-11-03 22:04:50

BurntPizza (64 views)
2014-11-03 18:54:52

moogie (80 views)
2014-11-03 06:22:04

CopyableCougar4 (80 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!