-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprobability.py
672 lines (560 loc) · 32.2 KB
/
probability.py
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
import mpmath
mpmath.mp.dps = 80 # Set precision to 30 digits
mpmath.mp.prec = 160
def double_integral_first(a1, a2, b1, b2):
def integrand(y, x):
return x**(mpmath.mpf('2')/y)/mpmath.mpf('2')
result = mpmath.quad(lambda x:
mpmath.quad(lambda y: integrand(y, x), [b1, b2]),
[a1, a2])
return result
# Test with initial conditions
a1, a2 = mpmath.mpf('0'), mpmath.mpf('1')
b1, b2 = mpmath.mpf('0'), mpmath.mpf('1')
a1, a2 = 0, 1
b1, b2 = 0, 2
results = []
for b2 in range(1, 300):
results.append(double_integral_first(a1, a2, b1, b2))
for i in range(len(results)):
print(i+1,", ",mpmath.nstr(results[i],160))
conclusion:
For the double integral ∫∫ (x^(2/y))/2 dy dx
with bounds x: [0 to 1], y: [0 to n]
for any number:
n/2 - math.log(n/2 + 1)
more specifically:
When n = 2^k - 2 (for any positive integer k)
The result equals (n/2 - 1) - (k-1)*log(2)
when n is twice a prime
the result is n/2 - log(n/2 + 1)
n = 3^k - 2, the result is:
n/2 + log(2) - k*log(3)
When n = 2(3^(k+1) - 1) for k ≥ 0, the result
is n/2 - (k+1)log(3)
1 , 0.0945348918918356180219868845356508634280095765375199162835193
1/2 + log(2) - log(3)
2 , 0.306852819440054690582767878541823431924499865639708921557214
log(e/2)
3 , 0.583709268125844934816472788231988928549898780091406845106799
4 , 0.901387711331890308604754763077474295352509442177057780899287
2 - log(3)
5 , 1.24723703150463200431187937801499683843841540477829788307316
6 , 1.61370563888010938116553575708364686384899973128010207088021
3- log(4)
7 , 1.99592260322372592662674164761312515878051901871543298189004
7/2 + log(2) - log(9)
8 , 2.39056208756589962539924066677381236047439864573214210831269
9 , 2.79525190776157476535528854349304726825379328042348077072293
10 , 3.20824053077194499918752264161929772727700930781710881633939
5 - log(6)
11 , 3.62819782309840857336374467989285796327023218959971663869672
12 , 4.05408985094468669489464725655682027036291527041561200745013
13 , 4.48509697945773524342122755130946322390240822226641194270874
14 , 4.92055845832016407174830363562547029577349959692152156185188
7 - log(8)
15 , 5.35993383650372922916769750358505003248729712177369125694065
16 , 5.80277542266378061720950952615494859070501888435685247286171
8 - log(9)
17 , 6.24870820139350484940820468957032303083812087306203983239738
18 , 6.69741490700595431598200854531563579239889851137082468822123
9 - log(10)
19 , 7.14862474283652231291663414109247113379092484695535566397245
20 , 7.60210472720162945593805642203487070017829314606490026169461
21 , 8.05765296463079561861047928964798044963311981952118096707317
22 , 8.5150933502119996897702905201611211592015091734612652183742
11 - log(12)
23 , 8.97427135569174456021571345500580128902429742582012781459057
24 , 9.43505064253846326394651255843468139519473205524387304073153
25 , 9.89731031455561623523149641069059945413302846089659612938403
25/2 + log(2) - log(3)
26 , 10.3609426703847413854774151350986437022874151360542945873587
27 , 10.8258513505734712822339600890962649625809872204421962379789
28 , 11.2919497988977899340039954298512866558269080879050945226173
29 , 11.759159976074799063488067796915819357625561203878048972514
30 , 12.2274112777602187623310715141672937276979994625547303196342
15- 4*log(2)
31 , 12.6966396190934650739600433065705215636063027226046439182169
32 , 13.1667866559437839197504653821268734644117969874123738368492
33 , 13.6377991190705316297111200447888091989128140505090715358543
34 , 14.109628242103835307792277404696772022629518749990061230644
17 - log(18)
35 , 14.5822292679157208650491364504267294041754225471880234055045
36 , 15.0555610208335595399909725681121464627626207387007224123059
37 , 15.5295855344302988819684994429703322586227416317726690530013
38 , 16.0042677264460090065647764238574592243233983770204549123823
39 , 16.4795751138556375055504687484207689796990896649715499564802
40 , 16.955477562276577003499402019634294565715424712594038243881
41 , 17.4319470648663828859443896081123295325163639494868713593937
42 , 17.9089575466416841465208243005766941321027930116981090194769
43 , 18.3864846907896255520259823143869375192549176644557858233921
44 , 18.864505784070850309193247168189803881557619685165337369108
45 , 19.3429995788498867225962814516860028591794496323494807020791
46 , 19.821946169652054380353058398702944591126009039105421620409
23 - log(24)
47 , 20.301326882449318699206526634571817108801330675198015257118
48 , 20.7811241751317992507984813335476247209487972914642842166254
49 , 21.2613215478356195377724522666625243278398065639521174933715
50 , 21.7419034619785179545292804369765048271192319208770817985138
51 , 22.2228552670078234752727629824291187977155223814531411651876
52 , 22.7041631339956709258142642892324228860575283265407525314188
26- 3*log(3)
53 , 23.185813995327474390754529210266859628728191926163833612225
54 , 23.6677954898247960760601830136404671342119150016875033451409
55 , 24.1500959127253951580129594526477973261906303152404660688282
56 , 24.6327041700135259728167279676380883945054870860863526400137
57 , 25.1156097366542258588011817477384789440121533450303423357722
58 , 25.5988026183378446245867633083931100877514079535492509246521
59 , 26.0822733163866340606658430180325618217598183912697401897046
60 , 26.5660127955148537540708356754576427895500610695222053745488
61 , 27.0500124541684126215213889041699454291434342891228342561508
62 , 27.534264097200273452913839392709117159622499328198886721669
31 - 5* log(2)
63 , 28.0187599106643081987629853466666703237446308353209111027569
64 , 28.5034924385335197645428111851123449955308025882488003202517
65 , 28.9884545611689792497471601250944538175085672311293943898998
66 , 29.4736394753838386103332332606686968963362968530455825946315
67 , 29.9590406759626859272152340527254547449856292616941333813778
68 , 30.4446519385105863202938879233306326308373139161532279378891
69 , 30.9304673035186298880877775889451424713159236076599968757881
70 , 31.4164810615438899983750452832385954545540186156342176326788
71 , 31.9026877394115541803251232640196339971707472894977249606825
72 , 32.3890820873557755556319043289685528360999224128431274517918
73 , 32.8756590670236348688204682180832755843768068679930802288952
74 , 33.3624138402736142305737404466539698946871206043558264585933
75 , 33.8493417587062614602499358000498675386167085508308820449837
76 , 34.3364383538703535725512673215121556905472414974277730992887
77 , 34.8236993280929238152442865799767656459019589099199039020518
78 , 35.311120545886063697147544302399282656247898242642716025912
79 , 35.7986980258875065438362511737680737494855379030695485436886
79/2 + log(2) - 4*log(3)
80 , 36.286427933295692196133236626962592411623589530615706358515
81 , 36.7743065727633473859417598981668061150461870776958386748341
82 , 37.2623303817166316940821698981761179976399245782162993574107
83 , 37.7504959240696288545669381703588623929616957674894118988745
84 , 38.2387998843064375765271574866541529644408638151091324729234
85 , 38.7272390619053615908387148521737392579334966626151486522835
86 , 39.2158103660817388371035921791185175640272928773422654215117
87 , 39.7045108108278054710994165807883273486708397472438529650571
88 , 40.1933375102296802426087501929287609511794175300780469369219
89 , 40.6822876740430952682583919364496782336331474600098548240206
90 , 41.1713586035109049997760150467316273134821195508094937711428
91 , 41.6605476874066893720928225599932936529780706460510013868186
92 , 42.1498523982899414131790493302278262911039494979717418156089
93 , 42.6392702889594044748074453563441353913125195187996557628363
94 , 43.1287989890921090709358262772447680230505089047276827339387
47-log(48)
95 , 43.618436202056562487300510499754214854266585231684163819221
96 , 44.1081797018893733897892945131136405407258305408421716591528
97 , 44.5980273304253553825647980696479958589588121647775963325215
98 , 45.0879769945718539413812492120894481528732971570865453301551
99 , 45.5780266637186858585330338545451874111846175471517559923462
100 , 46.0681743672756742283552201452043477597643064295743786069012
101 , 46.5584181923303095386486298064047357474472390259717770658558
102 , 47.0487562814185726451120483155183282590437317865212382005486
103 , 47.5391868304024219383158748078662834942653234927039192386639
104 , 48.0297080864478781658555308609709422296400222470972975672224
105 , 48.5203183460980391361128333044348995665123538582407309274985
106 , 49.0110159534357256163970321677742463179820281921630136449486
107 , 49.5017992983308016090399156692489749170151512508684722877055
108 , 49.9926668147675290813372970888086830606526917917860947257548
109 , 50.4836169792476111736538912135042036995279319893719234640616
110 , 50.9746483092648507666429508921822905661364148673535550356808
111 , 51.4657593618476047408351006278421548960461697456788788636864
112 , 51.956948732165449848595727331189620758115130180884622470863
113 , 52.4482150521966952440097199564217928101075184652533230753859
114 , 52.9395569894535806633994958461799118264299869517086137535434
115 , 53.4309732457621891905732542060478065539752510739565691115584
116 , 53.9224625560942805493839496262803023759366532106526034493019
117 , 54.4140236874484159240623447601418703028502123922002509086433
118 , 54.9056554377778993151695311869349335196759078191715120381818
119 , 55.3973566349632042212933449655279179684320864264856441213544
120 , 55.8891261358266887512486108965743852536843182569357918802444
121 , 56.3809628251875278141552235114982432750515991071445023707848
122 , 56.8728656149549084446536035539994662214745609351444664880785
123 , 57.3648334432576441856149541217796136494986960715741652114083
124 , 57.8568652736084673121041567827117688610679341547888859466906
125 , 58.3489600941013540363697913137418841732015910104157932120475
126 , 58.8411169166403281434966072712509405915469991938211478351987
127 , 59.3333347761982731945491443711898038278688733916379284851932
128 , 59.8256127301043628893457532252084937556691307009650675047917
129 , 60.317949857358793765267808110288650674967590129716399755475
130 , 60.8103452579735744551255790636541684274553024538710614337815
131 , 61.302798052338191544302851946127143301201036143466704195595
132 , 61.7953073806090339403299280036362772494330670967954460804397
133 , 62.2878724021215158606307370774644118146074271066068429491916
134 , 62.7804922948238933009160011392105203282607967187116342851713
135 , 63.2731662547318203941020419934783111775123649603246488656173
136 , 63.7658934954027406177980019312672781769101291273382897834126
137 , 64.2586732474292535522284472025826327856329034740067783868413
138 , 64.7515047579506410108766558018724560627618137817535937629137
139 , 65.2443872901817770312010362147634771545319590745443284048888
140 , 65.7373201229586845786705454674869659032404234733041532778229
141 , 66.2303025503000380293018011019277286634485253356208263233812
142 , 66.7233338809839446889578131617804188864785184813002693232187
143 , 67.2164134381393709076332007558700773230553858661524430577865
144 , 67.7095405588516088709078911425614574290952471551199860742122
145 , 68.2027145937812090078112813976492914041538401173709676714226
146 , 68.6959349067958302462146722075103762680244222784653885653215
147 , 69.1892008746144861684248038463540560802194153631768730213204
148 , 69.6825118864636895594032360966250990163013067336153413424249
149 , 70.1758673437450209806209958219737002778177637417689891611127
150 , 70.6692666597136689211565083251957933266116204700218781491331
151 , 71.162709259167509846377207029739998623192316006103174619171
152 , 71.6561945781463161508327036785916909705412084164969337355235
153 , 72.1497220636406986888873084636896317180999598496320863693317
154 , 72.6432911733104082631340352000539791224717413630938247898285
155 , 73.136901375211637251992786885054701319333256503494609188983
156 , 73.6305521475329785058270544585185890778264587755859555925916
157 , 74.1242429783397137838775177455065930930680318236698841565023
158 , 74.6179733653261183877303121809411060881723981082649771394418
159 , 75.1117428155754823135051265462048007199960350899641620851546
160 , 75.6055508453275612344190190523098971814100377686918096572183
161 , 76.0993969797531829753522997553374266914436131116152083918229
162 , 76.5932807527357468867160045055044158435480893962817580490549
163 , 77.0872017066593646993592839733443339240807013683586813150347
164 , 77.5811593922034020765245277767086295469706869433618903653739
165 , 78.075153368143190202157481344713397202278177531721832140589
166 , 78.5691832011566863846649377767179414295644244438823510479506
167 , 79.0632484656368718373102572383275393584649642447997991024181
168 , 79.5573487435096835451497060489006858248861956331554635894144
169 , 80.0514836240572854666177142157252716215431397574134184831328
170 , 80.5456527037464922671099253651959763963653636807751841634633
171 , 81.0398555860621663624837317330171850988896472266222796331091
172 , 81.5340918813454162814214827307155626898579965282812003428233
173 , 82.0283612066364312551103607115626215593872126962850042211771
174 , 82.5226631855217935276863600576603409959517927430083171120516
175 , 83.0169974479861161674059365108159532393646627871813994615717
176 , 83.5113636302678601616821844593301507805953396128661140785868
177 , 84.0057613747191903132394276914367743924725667161790624331601
178 , 84.5001903296697349331915180714705843831039173957440986274617
179 , 84.9946501492941195625781450828251676408351676928906605239176
180 , 85.4891404934831499588411598149915016655576473256759065145605
181 , 85.9836610277185243692705977811100361171123278334207973155041
182 , 86.4782114229509596903587829252734507454066194164755454616827
183 , 86.9727913554816204904483771172005417646498211929092178695646
184 , 87.4674005068467440626755904385351170849025705116732625003483
185 , 87.9620385637053586851057539256199207326655902678112224080039
186 , 88.4567052177299961037618172087696497230284493636377935061488
187 , 88.9514001655003029301261436672474197244959437312738913819503
188 , 89.4461231083994591653902132348859588232370193844657074533762
189 , 89.9408737525133154365672821692558094214670586578713813700435
190 , 90.4356518085321637615185941557865914549750087703937344244786
191 , 90.9304569916550597575623010680751178038854326418233238150254
192 , 91.4252890214966171778832783782960382861910850973502155097608
193 , 91.9201476219961985073677401097441446190971402775376540940716
194 , 92.4150325213294280803720623916554639726503304064644327726825
195 , 92.9099434518219568026374347922953455930668560720068765641716
196 , 93.4048801498654100731475659481898192908833120303998574460512
197 , 93.8998423558354529140071108295896393661843948537743190076171
198 , 94.3948298140119086319640170906312715847977970227088064436848
199 , 94.8898422725008695583519148881719281128610766732804515156993
200 , 95.3848794831587405491158017330870108431091174127740171058759
201 , 95.8799412015181579771286073456530852329439024908632820675553
202 , 96.375027186715728918937988023746171191688806295196639720431
203 , 96.870137201421537130949709415194581340173488310725587353298
204 , 97.3652710117703642292313976849465591793717388916378287563957
205 , 97.8604283872945762358199888158029290403381387038670857956823
206 , 98.3556091008586273356948161940601516909682316521872898910885
207 , 98.8508129285951343053462611116051937310164140191214662719657
208 , 99.3460396498424766288986426864081069261898233583261803521937
209 , 99.8412890470838788136752758560038964500343419607876468645863
210 , 100.336560905887932856438298739512765661564522112763349257762
211 , 100.831855014850520196692532352022616766668433049789158713083
212 , 101.327171165538093826695601182976722998436853723862992041028
213 , 101.822509152432282511343630274886141892990762595219013467706
214 , 102.317868772875780306979800046316069749906528057785274758478
215 , 102.81324982701948575838271505347263962798847647425534422508
216 , 103.308652117770856299622683547790798348939651116490733401235
217 , 103.804075450743444488929878027097108292523256731692572663492
218 , 104.299519634207583771920064967350506492577191657452146416295
219 , 104.794984479042192493114210062019731427682029176990195187041
220 , 105.290469798687665864236659092046027131452431855037975154601
221 , 105.785975409099826550781126911735036541376871859906799450507
222 , 106.281501128704905457225718770724113998060914732975816149211
223 , 106.777046778355525177425222981160749879729316310187927931705
224 , 107.272612181287659431417868506383978327970669611301139977216
225 , 107.768197163078542634403850544624679522920600215458861216712
226 , 108.263801551605504539178495209731444190039630046506883584393
227 , 108.759425177005705660975996517525568250837030191362325264899
228 , 109.255067871636749934592487834963616242032018330919374765926
229 , 109.750729470038151768854690563127341833969217992981939170783
230 , 110.246409808893635353982263724721735258354486817374665444083
231 , 110.742108726994244744115007246789289089486524283862085157103
232 , 111.237826065202243881156022084589629985899750939578830225088
233 , 111.733561666415786347995522118459815219653848278081622810392
234 , 112.229315375534335239966717504822125807861153076274864562832
235 , 112.725087039424814123849041343054239941254468352158542181872
236 , 113.220876506888470614645112638683693734774712257866302599183
237 , 113.716683628628434642454068527196267471637695778591483680658
238 , 114.212508257217954005752299065476756951600407684837563728722
239 , 114.708350247069290313950820802747360833058240370325652148937
240 , 115.204209454403258911876112844069741400356586292107905234884
241 , 115.700085737219396852441005936845548044838047345264396246498
242 , 116.195978955266743441831378775116208685608818122601843570784
243 , 116.691888970015218324605767301345629469275729320908262076926
244 , 117.187815644627582504737991390040066706976098972766763484315
245 , 117.683758843931968113354717248005004426032852928300439051003
246 , 118.179718434394963135236371432541289653399060800766727601608
247 , 118.675694284095237694546514661244280410398696519846895800634
248 , 119.171686262697698876197722000321437081423195937152635747928
249 , 119.667694241428161423198646882449923326796154518795985350857
250 , 120.163718093048522002686924661253592292992434020454937637231
251 , 120.659757691832425074548535711682851149811412965575133584515
252 , 121.155812913541408726952559192283707605126090876038054325577
253 , 121.651883635401519163171692933436336688314205209640469024674
254 , 122.147969736080382834079375149792764023471499059487199525739
255 , 122.644071095664725511065437806696921116460775305358641274022
256 , 123.140187595638327885131912249731627259793373257260189598723
257 , 123.636319118860407559943783706983549674538337817620056879333
258 , 124.132465549544417579928521103750317187593630566631119195332
259 , 124.628626773237251899443469615251213553286006104766205778083
260 , 125.124802676798848455850575988830474106892089995382451446015
261 , 125.620993148382180758331305857253104477690016294302679357826
262 , 126.117198077413629145708346942195991859379802319493322547311
263 , 126.613417354573723100672003649202931158189921027207178562005
264 , 127.109650871778246234885619824668966733125536009088965309125
265 , 127.605898522159695779704171343865801644023349189438700667867
266 , 128.102160200049088630912695882178100681357566962373916616959
267 , 128.598435800958106203197278940962939450204452023195203918386
268 , 129.094725221561570551213504956006235246531926972316685216742
269 , 129.591028359680244409320362048252314529169968204939174800803
270 , 130.087345114263947991498769017752343760185296584377685975711
271 , 130.58367538537498557686314669952715252898565690216091194982
272 , 131.080019074171875084684809872020134609436864825903119402137
273 , 131.576376082893374016153769877040671989202590571808394566517
274 , 132.072746314842795308380769809809101608834628993048132050963
275 , 132.569129674372606809547834571933565728912480186528025979192
276 , 133.065526066869308242811215081124456217557403339585248923361
277 , 133.561935398738579680697577323070767948330580088158267935608
278 , 134.058357577390695701459423680414279494686313647507226607474
279 , 134.554792511226199544310593796765004627255614368401445908983
280 , 135.051240109621831721783804093305300586456458940210380095429
281 , 135.547700282916707684771244974663036363275066631539058070727
282 , 136.044172942398739269253313346028789335164923338970204968363
283 , 136.540658000291294783412200119421609686665028961038294042656
284 , 137.037155369740092719884568980469552095373025201286878013921
285 , 137.533664964800324200445116004977589250062004935436426363067
286 , 138.030186700423999379540581040322242318403018346966321013759
287 , 138.526720492447513148918162885711923496899094109268172425684
288 , 139.023266257579425598215968634411900754979885731730913594306
289 , 139.51982391338845279590526526283168914961909467383522094502
290 , 140.016393378291663561490659021103280861019747020698456610732
291 , 140.512974571542878003477391858645678377845725476519125778219
292 , 141.009567413221263698394049276191114836078339982949438207942
293 , 141.506171824220125484200422414512291304486551990806275021095
294 , 142.002787726235884936797440086052199699948922144131440255861
295 , 142.499415041757245691169552832725470154311321606884862881311
296 , 142.99605369405454085900757172489587951214391522875534355784
297 , 143.492703607169258882556991848082661844827851874754106363552
298 , 143.989364705903744249986003975166922448225806599193811878944
299 , 144.486036915811069580839036864669149802879279219842271323455
for the double form:
sqrt(n) -> n^2/4
yields Integrate[((x^(2/z))(y^(2/q)))/4 ,{q,0,n},{z,0,n},{y,0,1},{x,0,1}]
import mpmath
mpmath.mp.dps = 32
mpmath.mp.prec = 32
def triple_integral_second(a1, a2, b1, b2, c1, c2,d1,d2):
def integrand(z, y, x,q):
return (((x)**(mpmath.mpf('2')/z))*((y)**(mpmath.mpf('2')/q))) /mpmath.mpf('4')
result = mpmath.quad(lambda x:
mpmath.quad(lambda y:
mpmath.quad(lambda z:
mpmath.quad(lambda q: integrand(q,z, y, x), [d1, d2]), [c1, c2]),
[b1, b2]),
[a1, a2])
return result
# Test with fixed bounds for x and y (0 to 1)
a1, a2 = 0, 1 # x bounds
b1, b2 = 0, 1 # y bounds
results = []
# Vary z upper bound
for c2 in range(1, 300):
results.append(triple_integral_second(a1, a2, b1, b2, 0, c2,0,c2))
print(f"{c2}, {mpmath.nstr(results[c2-1],160)}")
#note that this will not run in realistically usable time
instead, just use the closed form:
for n:
∫∫∫∫((x^(2/z))(y^(2/q)))/4 dq dz dy dx = 1/4(log(((n+2)**2)/4) - n)**2
for the triple form:
Integrate[x*y*z,{x,0,sqrt(n)},{y,0,sqrt(n)},{z,0,sqrt(n)}]
sqrt(n) -> n^3/8
yields
Integrate[((x^(3/q))(y^(3/r))(z^(3/s)))/8 ,{s,0,n},{r,0,n},{q,0,n},{z,0,1},{y,0,1},{x,0,1}]
yields 1/8(log(((2n-2)³)/27) - n)³
For the integral:
∫∫∫∫∫∫ 1/8 x^(3/q) y^(3/r) z^(3/s) dx dy dz dq dr ds
Where the bounds are:
x,y,z: 0 to 1
q,r,s: 0 to n
The closed form solution is:
1/8 (n + log(3^3) - 3 log(n+3))^3
for some, however, the closed form is approximal to tanh
For n=2: 1/8(2 + log(3**3) - 3log(2+3))³ = (1 - tanh⁻¹(49/(49+3**3)))³
for n = 4: 1/8(4 + log(3**3) - 3log(4+3))³ = (2 - tanh⁻¹(158/(158+3**3)))³
For n=8: 1/8(8 + log(3**3) - 3log(8+3))³ = (4 - tanh⁻¹(652/(652+3**3)))³
For n=16: 1/8(16 + log(3**3) - 3log(16+3))³ = (8 - tanh⁻¹(3416/(3416+3**3)))³
For n=32: 1/8(32+ log(3**3) - 3log(32+3))³ = (16 - tanh⁻¹(21424/(21424+3**3)))³
for n=64: 1/8(64+ log(3**3) - 3log(64+3))³ = (32- tanh⁻¹(150368/(150368+3**3)))³
so , we can push the general form further:
1/8(n + log(3**3) - 3log(n+3))³ = (n/2 - tanh⁻¹(x/(x+3**3)))³
2,4,8,16,32
49,158,652,3416,21424
this roughly corresponds to 0.5n3+4.5n2+13.5n
1/8*(n + log(3**3) - 3*log(n+3))**3 = (n/2 - tanh⁻¹( (0.5*n**3 +4.5*n**2 + 13.5*n)/( (0.5*n**3 +4.5*n**2 + 13.5*n)+3**3)))**3
of course, tanh⁻¹(a/b) = 1/2(log(a+b)) just in general as long as b is 1 greater than a
for four dimensions:
Integrate[x*y*z*a,{x,0,sqrt(n)},{y,0,sqrt(n)},{z,0,sqrt(n)},{a,0,sqrt(n)}]
yields n^4/16
Integrate[((x^(4/q))(y^(4/r))(z^(4/s))(a^(4/t)))/16 ,{s,0,1},{r,0,1},{q,0,1},{t,0,1},{z,0,1},{y,0,1},{x,0,1},{a,0,1}]
integral_0^1 integral_0^1 integral_0^1 integral_0^1 integral_0^1 integral_0^1 integral_0^1 integral_0^1 1/16 x^(4/q) y^(4/r) z^(4/s) a^(4/t) da dx dy dz dt dq dr ds =
1/16 (1 - 4 log(5) + log(256))^4
8.323659740844868966914319116370252106637402519765632713375955855588490495913893179896444875022797465×10^-6
in accordance with previous rules:
1/16*(n + log(4**4) - 4*log(n+4))**4
furthermore under this consideration we can now refactor:
def single(n):
return n/2 - log(n/2 + 1)
def double(n):
return 1/4*(n + log(2**2) - 2*log(n+2))**2
def triple(n):
return 1/8* (n + log(3**3) - 3 *log(n+3))**3
def quad(n):
return 1/16*(n + log(4**4) - 4*log(n+4))**4
as such we can predict the general form:
for any number of dimensions of integration, where each dimension consists of
the integration of a[dim] over 0 to 1 and b[dim] 1 to n in the form
(a[dim^(ndim/b[dim])) * [same expression for all other dim] )/2^ndim
the closed form will be 1/(2^ndim)*(n + log(ndim**ndim) - ndim*log(n+ndim))**ndim
'''
For dimension d ≥ 1, consider the integral:
∫...∫ (∏ᵢ₌₁ᵈ xᵢ^(d/yᵢ))/(2^d) dx₁...dxₓ dy₁...dyₓ
where:
There are d variables xᵢ each integrated from 0 to 1
There are d variables yᵢ each integrated from 0 to n
The product term multiplies all d expressions together
The whole expression is divided by 2^d
The closed form solution appears to be:
1/(2^d) * [n + log(d^d) - d*log(n+d)]^d
This can be verified for the first few dimensions:
d=1: n/2 - log(n/2 + 1)
d=2: 1/4 * [n + log(2²) - 2log(n+2)]²
d=3: 1/8 * [n + log(3³) - 3log(n+3)]³
d=4: 1/16 * [n + log(4⁴) - 4log(n+4)]⁴
The pattern follows a clear structure where:
The denominator is always 2^d
The base expression [n + log(d^d) - d*log(n+d)] is raised to the power d
The terms inside maintain the pattern of n, log of d to d power, and d times log of (n+d)
'''
below this point is unfinished.
my thought was to try to generalize this to higher powers: stay with me here.
We observed initially the inequality that ∫ x from 0 to sqrt(n) yielded n/2
this in turn resulted in the integral x**(mpmath.mpf('2')/y)/mpmath.mpf('2')
where y serves as the "tracking" dimension
This then in turn got generalized to higher "true" dimensions,
each with their own "tracking" dimension working over the same range
and with the logic adjusted for each
so we arrived at the closed form for these
but what about generalizing in a different direction?
∫ x from 0 to cuberoot(n) yielded n^(2/3)/2
Integrate[x,{x,0,(n)^(1/3)}] = n^(2/3)/2
Integrate[x, {x, 0, n^(1/4)}] = sqrt(n)/2
integral_0^(n^(1/d)) x dx = n^(2/d)/2
Integrate[x*y*z,{x,0,(n)^(1/2)},{y,0,(n)^(1/2)},{z,0,(n)^(1/2)}] = n^(3)/8
Integrate[x*y*z,{x,0,(n)^(1/3)},{y,0,(n)^(1/3)},{z,0,(n)^(1/3)}] = n^(6/6)/8
Integrate[x*y*z,{x,0,(n)^(1/4)},{y,0,(n)^(1/4)},{z,0,(n)^(1/4)}] = n^(6/4)/8
Integrate[x*y*z,{x,0,(n)^(1/5)},{y,0,(n)^(1/5)},{z,0,(n)^(1/5)}] = n^(6/5)/8
Integrate[x*y*z*a,{x,0,(n)^(1/3)},{y,0,(n)^(1/3)},{z,0,(n)^(1/3)},{a,0,(n)^(1/3)}] = n^(8/3)/16
Integrate[x*y*z*a,{x,0,(n)^(1/4)},{y,0,(n)^(1/4)},{z,0,(n)^(1/4)},{a,0,(n)^(1/4)}] = n^(8/4)/16
Integrate[x*y*z*a,{x,0,(n)^(1/5)},{y,0,(n)^(1/5)},{z,0,(n)^(1/5)},{a,0,(n)^(1/5)}] = n^(8/5)/16
in general, therefore, to integrate the power, we have the term n^(ndim*2/pow)/ndim^2 maybe?
∫∫ (x^(2/y^(1)))/2 dy dx
Integrate[x,{x,0,(n)^(1/2)}] n/2
Integrate[((x^(2/y^(4/r)))/2,{y,0,1},{x,0,1},{y,0,1},{r,0,1}]
for the 1d form:
Integrate[(x^(2/(y^(4/3))))/2,{y,0,1},{x,0,1}] =
integral_0^1 integral_0^1 1/2 x^(2/y^(4/3)) dx dy = 1/2 (1 - 2F1(3/4, 1, 7/4, -1/2))≈0.0820501
Integrate[(x^(2/(y^(4/4))))/2,{y,0,1},{x,0,1}]
= integral_0^1 integral_0^1 1/2 x^(2/y^(4/4)) dx dy = 1/2 + log(4) - log(6)≈0.0945349
Integrate[(x^(2/(y^(4/5))))/2,{y,0,1},{x,0,1}] =
integral_0^1 integral_0^1 1/2 x^(2/y^(4/5)) dx dy = 0.103942
integral_0^2 integral_0^1 1/2 x^(2/y^(4/3)) dx dy = 1 - 2F1(3/4, 1, 7/4, -2^(1/3))≈0.310265
integral_0^2 integral_0^1 1/2 x^(2/y^(4/4)) dx dy = 1 - log(2)≈0.306853
integral_0^2 integral_0^1 1/2 x^(2/y^(4/5)) dx dy = 0.306802
all of these yield closed form values so i am not sure if i am moving in the right direction but maybe it is correct
and if these yield closed forms, then a generalization is not only possible but inevitable
but the amount of work and time involved to explore them and come up with a generalizing formula may be large and not
necessarily yield useful fruit
for the well known integral 2 * integral_0^1 1/sqrt(1 - x^z)) dx
where z=2 = pi
2 integral_0^1 1/sqrt(1 - x^(1/n)) dx =
starting with n=2,
The sequence follows the pattern 2^p/y where:
p comes from sequence A101925: 4, 5, 8, 9, 11, 12, 16, 17, 19, 20, 23, 24, 26, 27, ...
y comes from the expansion coefficients of 1/√(1-x) in sequence A001790
3, 5, 35, 63, 231, 429, 6435, 12155, 46189, 88179, 676039, 1300075, 5014575
ie, when N=8, the result is 524288/46189
every integer n ≥ 2 gives us one of our rational fractions in sequence.
an irrational number (π) at n = 1/2=0.5
an integer (4) at n = 1
and then rational fractions for all integer n ≥ 2
For 2 ∫[0 to 1] 1/sqrt(1 - x^(1+1/n)) dx where n is a power of 2:
First Γ fraction:
Numerator: 2^n + 1
Denominator: Previous numerator
A000051
a(n) = 2^n + 1.
(Formerly M0717 N0266)
+30
846
2, 3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289, 1048577, 2097153, 4194305, 8388609, 16777217, 33554433, 67108865, 134217729, 268435457, 536870913, 1073741825, 2147483649, 4294967297, 8589934593
Second Γ fraction:
Numerator: 3*2^n + 1
Denominator: 2^n + 2
A052548
a(n) = 2^n + 2.
3, 4, 6, 10, 18, 34, 66, 130, 258, 514, 1026, 2050, 4098, 8194, 16386, 32770, 65538, 131074, 262146, 524290, 1048578, 2097154, 4194306, 8388610, 16777218, 33554434, 67108866, 134217730, 268435458, 536870914, 1073741826, 2147483650
and the numerators are:
A181565
a(n) = 3*2^n + 1.
4, 7, 13, 25, 49, 97, 193, 385, 769, 1537, 3073, 6145, 12289, 24577, 49153, 98305, 196609, 393217, 786433, 1572865, 3145729, 6291457, 12582913, 25165825, 50331649, 100663297, 201326593, 402653185, 805306369, 1610612737, 3221225473
2 integral_0^1 1/sqrt(1 - x^(1 + 1/2)) dx = (2 sqrt(π) Γ(5/3))/Γ(7/6)≈3.44948
2 integral_0^1 1/sqrt(1 - x^(1 + 1/4)) dx = (2 sqrt(π) Γ(9/5))/Γ(13/10)≈3.67886
2 integral_0^1 1/sqrt(1 - x^(1 + 1/8)) dx = (2 sqrt(π) Γ(17/9))/Γ(25/18)≈3.8247
2 integral_0^1 1/sqrt(1 - x^(1 + 1/16)) dx = (2 sqrt(π) Γ(33/17))/Γ(49/34)≈3.90811
32 = (2 sqrt(π) Γ(65/33))/Γ(97/66)
64 = (2 sqrt(π) Γ(129/65))/Γ(193/130)
So our full formula for any n ≥ 1 would be:
2 ∫[0 to 1] 1/sqrt(1 - x^(1+1/n)) dx = (2 sqrt(π) Γ((2^n + 1)/(2^(n-1) + 1)))/Γ((3*2^(n-1) + 1)/(2^(n-1) + 2))
all of these results can be re-expressed in some form of π combined with Γ(1/n+1)
Beyond 2,
2 integral_0^1 1/sqrt(1 - x^(2 + 1/8)) dx = (2 sqrt(π) Γ(25/17))/Γ(33/34)≈3.08443
2 integral_0^1 1/sqrt(1 - x^(2 + 1/4)) dx = (2 sqrt(π) Γ(13/9))/Γ(17/18)≈3.03282
2 integral_0^1 1/sqrt(1 - x^(2 + 2/4)) dx = (2 sqrt(π) Γ(14/10))/Γ(18/20)≈3.03282
2 integral_0^1 1/sqrt(1 - x^(2 + 3/4)) dx = (2 sqrt(π) Γ(15/11))/Γ(19/22)≈2.86822
2 integral_0^1 1/sqrt(1 - x^(2 + 7/8)) dx = (2 sqrt(π) Γ(31/23))/Γ(39/46)≈2.83506
3 = (2 sqrt(π) Γ(16/12))/ Γ(20/24)
2 integral_0^1 1/sqrt(1 - x^(3 + 1/16)) dx = (2 sqrt(π) Γ(65/49))/Γ(81/98)≈2.78986
2 integral_0^1 1/sqrt(1 - x^(3 + 1/4)) dx = (2 sqrt(π) Γ(17/13))/Γ(21/26)≈2.74935
2 and 1/2: (2 sqrt(π) Γ(13/9))/Γ(17/18)
2 and 1/2 : (2 sqrt(π) Γ(14/10))/Γ(18/20)
2 and 3/4: (2 sqrt(π) Γ(15/11))/Γ(19/22)
3 : (2 sqrt(π) Γ(16/12))/ Γ(20/24)
Γ(1/4)^2/(2 sqrt(2 π)) aka Lemniscate
we then ask ourselves, what is the gaussian ?
why, its ((4 * sqrt(2) * Γ(5/4)^2)/π^(3/2))
and the reciprocal follows the same behavior:
π^(3/2)/(4 sqrt(2) Γ(5/4)^2) = 1/Gga
what about
evaluating ((4 * sqrt(2) * Γ(5/4)^2)/π^(3/2)) * x = ?
for 1/pi, the result is sqrt(π/2)/(4 Γ(5/4)^2)
which is in turn 1/L
1/the lemingscale constant IS the number when multiplied by the constant results in 1/pi
what about:
((4 * sqrt(2) * Γ(5/4)^2)/π^(3/2)) * x = pi/agm?
π^4/(32 Γ(5/4)^4)
(-1 + 2^(-1))! = sqrt pi
(-1 + 4^(-1))! = Γ(1/4)
(-1 + n^(-1))! = Γ(1/n)
|n- Γ(1/n)| => euler macheroni constant