/
math.html
652 lines (590 loc) · 34.4 KB
/
math.html
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=800">
<title>math</title>
<link rel="stylesheet" type="text/css" href="testindex.css">
<script src="testglobals.js"></script>
<script src="testgeneric.js"></script>
<!-- custom -->
<style>
table {width: 780px;}
</style>
</head>
<body>
<table>
<tr><td><h2>TorZillaPrint</h2></td></tr>
<tr><td class="blurb"><a class="return" href="../index.html">return to TZP index</a></td></tr>
</table>
<table id="tb3">
<col width="1%"><col width="9%"><col width="90%">
<thead><tr><th colspan="3">math: version 2.5</th></tr></thead>
<tr><td colspan="3" class="intro">
<span class="no_color">Hashes all results, and compares those results to a control set, to build a list
of tests that provides entropy. The (ongoing) results are <a class="blue" href="mathdata.html">here</a>.</span>
</td></tr>
<tr><td colspan="2"></td>
<td>
<button onClick="outputMath(`firefox`)">firefox</button>
<button onClick="outputMath(`chrome`)">chrome</button>
<button onClick="outputMath(`safari`)">safari</button>
</td></tr>
<tr><td colspan="3"><hr></td></tr>
<tr><td colspan="3"><span id="perfE" class="mono"></span>
<span class="btn0 btn" onClick="copyclip(`engine`)">[ copy ]</span> ENGINE</td></tr>
<tr><td colspan="2">engine</td><td class="mono spaces" id="engine"></td></tr>
<tr><td colspan="3"></td></tr>
<tr><td colspan="3"><hr></td></tr>
<tr><td colspan="3"><span id="perf" class="c mono"></span>
<span class="btn0 btn" onClick="copyclip(`report`)">[ copy ]</span> SHORT REPORT</td></tr>
<tr><td colspan="2"></td><td class="c mono spaces" id="report"></td></tr>
<tr><td colspan="3"></td></tr>
<tr><td colspan="3"><hr></td></tr>
<tr><td colspan="3">DIFFS ANALYSIS</td></tr>
<tr><td colspan="2"></td><td class="s3">vs control</td></tr>
<tr><td colspan="2"></td><td class="mono">denoted in <span class="s1">pale red</span></td></tr>
<tr><td colspan="2">function</td><td class="c mono spaces" id="diff1"></td></tr>
<tr><td colspan="2">polyfill</td><td class="c mono spaces" id="diff2"></td></tr>
<tr><td colspan="2">test no's</td><td class="c mono spaces" id="numbers"></td></tr>
<tr><td colspan="3"></td></tr>
<tr><td colspan="2"></td><td class="s3">polyfill vs function</td></tr>
<tr><td colspan="2"></td><td class="mono">denoted with <span class = "s1">[match]</span></td></tr>
<tr><td colspan="2">diffs</td><td class="c mono spaces" id="diff0"></td></tr>
<tr><td colspan="3"></td></tr>
<tr><td colspan="3"><hr></td></tr>
<tr><td colspan="3"><span class="btn0 btn" onClick="copyclip(`mathdata`)">[ copy ]</span> DATA</td></tr>
<tr><td></td><td colspan="2" class="c mono spaces" id="mathdata"></td></tr>
</table>
<br>
<script>
'use strict';
var t0, // perf
fns = [], // what tests to run
n = 0.123,
bigN = 5.860847362277284e+38
// control sets
var controlname = ""
var setFF = [
'1.4474840516030247','0.7853981633974483','709.889355822726','Infinity','1.811526272460853','1.8115262724608532','0.881373587019543','0.8813735870195432','0.12331227519187199','691.4686750787736','691.4686750787736','1.8622957433108482','1.885022066017804','1.1071487177940904','1.2626272556789115','0.5493061443340548','0.5493061443340548','5e-311','1.0038848218538872','4.641588833612779','4.641588833612778','1.4645918875615231','1.4645918875615231','-0.37419577499634155','-0.7854805190645291','0.7914463018528902','-0.767224894221913','-0.7415825695514536','0.5403023058681397','0.7086865671674246','-0.7482651726250321','0.9924450321351935','-1','-0.10868049424995659','-0.8913089376870335','-0.7108118501064332','-0.5369116957490239','-0.40677759702517235','-0.7017203400855445','0.43628480636189976','-0.6982689820462376','-0.6982689820462376','-0.6534063185820198','0.45375574259827833','0.6459044007438142','1.5430806348152437','1.5430806348152437','11.591953275521519','11.591953275521519','9.199870313877774e+307','Infinity','1.046919966902314e+308','Infinity','1.718281828459045','1.718281828459045','22.140692632779267','22.140692632779267','1.1308844209474893','23.140692632779267','9.539392014169456','9.539392014169458','8.288489826731114e+38','8.288489826731116e+38','100.14767208675258','100.14767208675259','101.7610227859332','101.76102278593319','100.00960859865252','100.0096085986525','100.01040630344927','100.01040630344929','100.00999950005','100.00999950004999','100.00249996875078','100.0024999687508','100.00377216279418','100.00377216279416','-2.0955709236097197','1.1447298858494002','0.11600367575630613','0.11600367575630613','1.4210804127942926','1.4210804127942926','-0.9100948885606021','-0.9100948885606022','0.49714987269413385','0.49714987269413385','0.4342944819032518','0.4342944819032518','1.965773398945507','1.965773398945507','-0.1591745389548616','-0.1591745389548616','0.8822181462033635','0.8822181462033635','0.15917453895486158','0.15917453895486158','1.7926429945344482','1.792642994534448','-0.36221568869946325','-0.3622156886994632','0.48288235131479357','0.4828823513147936','-0.15051499783199057','-0.15051499783199057','0.15051499783199063','0.1505149978319906','0.15051499783199063','0.1505149978319906','-0.9273497301314576','-0.6188863822787813','-0.6112387023768895','0.6413781736901984','0.6708616046081811','0.8414709848078965','-0.7055234578073583','0.66339975236386','0.994076732536068','1.2246467991473532e-16','-0.7181630308570678','-0.765996413898051','0.9989410140273757','0.10135692924965614','-0.37463575478582023','-0.9892668187780497','1.1752011936438014','1.1752011936438014','11.548739357257748','11.548739357257748','7.544137102816975','7.544137102816975','0.75','0.75','1.9978980091062795','1.9978980091062797','9.199870313877774e+307','Infinity','0.44807597941469024','0.4480759794146903','0.7675231451261164','0.7675231451261164','1.935066822174357','1.9350668221743568','1.046919966902314e+308','Infinity','0.3507135583350036','1.7724538509055159','2.478247463217681','0.7879079967710036','-0.7723059681318761','-0.8359715365344825','-0.904635076595654','1.5574077246549023','-0.9955366596368418','-0.8865837628611647','0.5086861259107568','-1.2246467991473532e-16','0.686676154645243','1.618281713571588','-3.353712870537601','-1.922295546179998','-1.922295546179998','2.5824856130712437','0.12238344189440875','0.12238344189440872','0.99627207622075','0.9962720762207501','1.0220893335845176e+91','1.9275814160560185e-50','3.720075976020851e-44','8269017203802410','6.003867926738811e-37','1.2093335584550061e-16','1.665592934758592e+36','1125899906842611.5','8.881784197001154e-16'
]
var setChrome = [
'1.4474840516030247','0.7853981633974483','709.889355822726','Infinity','1.811526272460853','1.8115262724608532','0.881373587019543','0.8813735870195432','0.12331227519187199','691.4686750787736','691.4686750787736','1.8622957433108482','1.885022066017804','1.1071487177940904','1.2626272556789115','0.5493061443340548','0.5493061443340548','5e-311','1.0038848218538872','4.641588833612779','4.641588833612778','1.4645918875615231','1.4645918875615234','-0.37419577499634155','-0.7854805190645291','0.7914463018528903','-0.767224894221913','-0.7415825695514535','0.5403023058681398','0.7086865671674247','-0.7482651726250322','0.9924450321351935','-1','-0.10868049424995659','-0.8913089376870335','-0.7108118501064331','-0.536911695749024','-0.4067775970251724','-0.7017203400855446','0.4362848063618998','-0.6982689820462377','-0.6982689820462377','-0.6534063185820198','0.4537557425982784','0.6459044007438142','1.5430806348152437','1.5430806348152437','11.591953275521519','11.591953275521519','9.199870313877772e+307','Infinity','1.0469199669023138e+308','Infinity','1.718281828459045','1.718281828459045','22.140692632779267','22.140692632779267','1.1308844209474893','23.140692632779267','9.539392014169456','9.539392014169458','8.288489826731116e+38','8.288489826731116e+38','100.14767208675259','100.14767208675259','101.76102278593319','101.76102278593319','100.0096085986525','100.0096085986525','100.01040630344929','100.01040630344929','100.00999950004999','100.00999950004999','100.0024999687508','100.0024999687508','100.00377216279416','100.00377216279416','-2.0955709236097197','1.1447298858494002','0.11600367575630613','0.11600367575630613','1.4210804127942926','1.4210804127942926','-0.9100948885606021','-0.9100948885606022','0.4971498726941338','0.49714987269413385','0.4342944819032518','0.4342944819032518','1.9657733989455068','1.965773398945507','-0.1591745389548616','-0.1591745389548616','0.8822181462033634','0.8822181462033635','0.15917453895486158','0.15917453895486158','1.792642994534448','1.792642994534448','-0.36221568869946325','-0.3622156886994632','0.4828823513147936','0.4828823513147936','-0.15051499783199057','-0.15051499783199057','0.1505149978319906','0.1505149978319906','0.1505149978319906','0.1505149978319906','-0.9273497301314576','-0.6188863822787813','-0.6112387023768895','0.6413781736901984','0.6708616046081811','0.8414709848078965','-0.7055234578073583','0.66339975236386','0.994076732536068','1.2246467991473532e-16','-0.7181630308570677','-0.7659964138980511','0.9989410140273756','0.10135692924965616','-0.3746357547858202','-0.9892668187780498','1.1752011936438014','1.1752011936438014','11.548739357257748','11.548739357257748','7.544137102816975','7.544137102816975','0.75','0.75','1.9978980091062795','1.9978980091062797','9.199870313877772e+307','Infinity','0.44807597941469024','0.4480759794146903','0.7675231451261164','0.7675231451261164','1.935066822174357','1.9350668221743568','1.0469199669023138e+308','Infinity','0.3507135583350036','1.7724538509055159','2.478247463217681','0.7879079967710036','-0.7723059681318761','-0.8359715365344825','-0.904635076595654','1.5574077246549023','-0.9955366596368418','-0.8865837628611647','0.5086861259107568','-1.2246467991473532e-16','0.6866761546452431','1.6182817135715877','-3.3537128705376014','-1.9222955461799982','-1.9222955461799982','2.5824856130712432','0.12238344189440875','0.12238344189440872','0.99627207622075','0.9962720762207501','1.022089333584519e+91','1.9275814160560204e-50','3.7200759760208555e-44','8269017203802394','6.003867926738829e-37','1.20933355845501e-16','1.6655929347585958e+36','1125899906842616.2','8.881784197001191e-16'
]
var setSafari = [
'1.4474840516030245','0.7853981633974483','709.889355822726','Infinity','1.811526272460853','1.8115262724608532','0.8813735870195432','0.8813735870195432','0.12331227519187199','691.4686750787736','691.4686750787736','1.8622957433108482','1.885022066017804','1.1071487177940906','1.2626272556789115','0.5493061443340549','0.5493061443340549','5e-311','1.0038848218538872','4.641588833612779','4.641588833612778','1.4645918875615234','1.4645918875615231','-0.3741957749963415','-0.7854805190645292','0.7914463018528903','-0.7672248942219131','-0.7415825695514535','0.5403023058681398','0.7086865671674247','-0.7482651726250322','0.9924450321351935','-1','-0.10868049424995659','-0.8913089376870335','-0.7108118501064331','-0.536911695749024','-0.40677759702517235','-0.7017203400855446','0.4362848063618998','-0.6982689820462377','-0.6982689820462377','-0.6534063185820198','0.4537557425982784','0.6459044007438142','1.5430806348152437','1.5430806348152437','11.591953275521519','11.591953275521519','9.199870313877772e+307','Infinity','1.0469199669023138e+308','Infinity','1.7182818284590453','1.718281828459045','22.140692632779267','22.140692632779267','1.1308844209474893','23.140692632779267','9.539392014169456','9.539392014169458','8.288489826731116e+38','8.288489826731116e+38','100.14767208675259','100.14767208675259','101.76102278593319','101.76102278593319','100.0096085986525','100.0096085986525','100.01040630344929','100.01040630344929','100.00999950004999','100.00999950004999','100.0024999687508','100.0024999687508','100.00377216279416','100.00377216279416','-2.0955709236097197','1.1447298858494002','0.11600367575630613','0.11600367575630613','1.4210804127942926','1.4210804127942926','-0.9100948885606021','-0.9100948885606022','0.49714987269413385','0.49714987269413385','0.4342944819032518','0.4342944819032518','1.965773398945507','1.965773398945507','-0.1591745389548616','-0.1591745389548616','0.8822181462033635','0.8822181462033635','0.15917453895486158','0.15917453895486158','1.7926429945344482','1.792642994534448','-0.36221568869946325','-0.3622156886994632','0.48288235131479357','0.4828823513147936','-0.15051499783199057','-0.15051499783199057','0.15051499783199063','0.1505149978319906','0.15051499783199063','0.1505149978319906','-0.9273497301314577','-0.6188863822787812','-0.6112387023768895','0.6413781736901984','0.6708616046081811','0.8414709848078965','-0.7055234578073583','0.66339975236386','0.994076732536068','1.2246467991473532e-16','-0.7181630308570677','-0.765996413898051','0.9989410140273756','0.10135692924965616','-0.37463575478582023','-0.9892668187780498','1.1752011936438014','1.1752011936438014','11.548739357257746','11.548739357257748','7.544137102816975','7.544137102816975','0.75','0.75','1.9978980091062795','1.9978980091062797','9.199870313877772e+307','Infinity','0.44807597941469024','0.4480759794146903','0.7675231451261164','0.7675231451261164','1.9350668221743568','1.9350668221743568','1.0469199669023138e+308','Infinity','0.3507135583350036','1.7724538509055159','2.4782474632176816','0.7879079967710035','-0.772305968131876','-0.8359715365344824','-0.9046350765956541','1.557407724654902','-0.9955366596368417','-0.8865837628611646','0.5086861259107567','-1.2246467991473532e-16','0.686676154645243','1.6182817135715875','-3.353712870537602','-1.922295546179998','-1.922295546179998','2.5824856130712437','0.12238344189440876','0.12238344189440872','0.99627207622075','0.9962720762207501','1.022089333584519e+91','1.9275814160560206e-50','3.7200759760208555e-44','8269017203802394','6.003867926738829e-37','1.20933355845501e-16','1.6655929347585955e+36','1125899906842616.2','8.881784197001191e-16'
]
function get_engine() {
let et0 = performance.now()
function cbrt(x) {
try {
let y = Math.pow(Math.abs(x), 1 / 3)
return x < 0 ? -y : y
} catch(e) {
return "error"
}
}
let res = [], engine = zNEW.trim()
for(let i=0; i < 6; i++) {
try {
let fnResult = "unknown"
if (i == 0) {
fnResult = cbrt(Math.PI) // polyfill
} else if (i == 1) {
fnResult = Math.log10(7*Math.LOG10E)
} else if (i == 2) {
fnResult = Math.log10(2*Math.SQRT1_2)
} else if (i == 3) {
fnResult = Math.acos(0.123)
} else if (i == 4) {
fnResult = Math.acosh(Math.SQRT2)
} else if (i == 5) {
fnResult = Math.atan(2)
}
res.push(fnResult)
} catch(e) {
res.push("error")
}
}
let hash = sha1(res.join())
if (hash == "ede9ca53efbb1902cc213a0beb692fe1e58f9d7a") {engine = s3 +"blink"+ sc
} else if (hash == "05513f36d87dd78af60ab448736fd0898d36b7a9") {engine = s3 +"webkit"+ sc
} else if (hash == "38172d9426d77af71baa402940bad1336d3091d0") {engine = s3 +"edgeHTML"+ sc
} else if (hash == "36f067c652c8cfd9072580fca1f177f07da7ecf0") {engine = s3 +"trident"+ sc // also presto if we don't use `let`
} else if (hash == "225f4a612fdca4065043a4becff76a87ab324a74") {engine = "gecko [a]" // abraham
} else if (hash == "cb89002a8d6fabf859f679fd318dffda1b4ae0ea") {engine = "gecko [b]" // me
}
if (engine.substring(0,5) == "gecko") {
engine = s3 + engine + sc
// 52: 837961
// only check for PM28+
try {
let test52 = new Intl.DateTimeFormat(undefined, {timeZone: "Europe/Warsaw"})
// 53: 1317307
// eliminate FF53+
try {
Object.defineProperty([], "length", {get(){}})
} catch(e) {
if (e.name == "RangeError") {
// 61
// catch something PM did that ESR52 didn't
// note: this would only apply to later v28 releases
try {
let test61 = (" a").trimStart()
engine += "<br><br>but wait.. I did some extra tests<br>"
+ s12.trim() +"real engine:" + sc + s3 +"goanna [52esr]"+ sc
} catch(e) {}
}
}
} catch(e) {}
}
dom.perfE.innerHTML = Math.round(performance.now()-et0) +" ms"
dom.engine.innerHTML = s12.trim() + hash + sc +"<br> · "+ res.join("<br> · ")
+"<br>"+ s12.trim() +"engine:"+ sc + engine
}
function build_controlset(engine) {
let c = []
if (engine == "firefox") {c = setFF
} else if (engine == "chrome") {c = setChrome
} else if (engine == "safari") {c = setSafari}
fns = [
// [item, function, value, description, control, poly1 control, poly2 control]
[0,'acos', [n], n, c[0]],
[1,'acos', [Math.SQRT1_2], "Math.SQRT1_2", c[1]],
[0,'acosh', [1e308], "1e300", c[2], c[3]],
[1,'acosh', [Math.PI], "Math.PI", c[4], c[5]],
[2,'acosh', [Math.SQRT2], "Math.SQRT2", c[6], c[7]],
[0,'asin', [n], n, c[8]],
[0,'asinh', [1e300], "1e300", c[9], c[10]],
[1,'asinh', [Math.PI], "Math.PI", c[11], c[12]],
[0,'atan', [2], "2", c[13]],
[1,'atan', [Math.PI], "Math.PI", c[14]],
[0,'atanh', [0.5], "0.5", c[15], c[16]],
[0,'atan2', [1e-310, 2], "1e-310, 2", c[17]],
[1,'atan2', [Math.PI, 2], "Math.PI, 2", c[18]],
[0,'cbrt', [100], "100", c[19], c[20]],
[1,'cbrt', [Math.PI], "Math.PI", c[21], c[22]],
// original TZP cos
[0,'cos', [1e251], "1e251", c[23]],
[1,'cos', [1e140], "1e140", c[24]],
[2,'cos', [1e12], "1e12", c[25]],
[3,'cos', [1e130], "1e130", c[26]],
[4,'cos', [1e272], "1e272", c[27]],
[5,'cos', [1e0], "1e0", c[28]],
[6,'cos', [1e284], "1e284", c[29]],
[7,'cos', [1e75], "1e75", c[30]],
[8,'cos', [n], n, c[31]],
[9,'cos', [Math.PI], "Math.PI", c[32]],
[10,'cos', [bigN], "bigN", c[33]], // creep says unique in Tor
[11,'cos', [-1e308], '-1e308', c[34]],
[12,'cos', [13*Math.E], '13*Math.E', c[35]],
[13,'cos', [57*Math.E], '57*Math.E', c[36]],
[14,'cos', [21*Math.LN2], '21*Math.LN2', c[37]],
[15,'cos', [51*Math.LN2], '51*Math.LN2', c[38]],
[16,'cos', [21*Math.LOG2E], '21*Math.LOG2E', c[39]],
[17,'cos', [25*Math.SQRT2], '25*Math.SQRT2', c[40]],
[18,'cos', [50*Math.SQRT1_2], '50*Math.SQRT1_2', c[41]],
[19,'cos', [21*Math.SQRT1_2], '21*Math.SQRT1_2', c[42]],
[20,'cos', [17*Math.LOG10E], '17*Math.LOG10E', c[43]],
[21,'cos', [2*Math.LOG10E], '2*Math.LOG10E', c[44]],
[0,'cosh', [1], "1", c[45], c[46]],
[1,'cosh', [Math.PI], "Math.PI", c[47], c[48]],
[2,'cosh', [492*Math.LOG2E], '492*Math.LOG2E', c[49], c[50]],
[3,'cosh', [502*Math.SQRT2], '502*Math.SQRT2', c[51], c[52]],
[0,'expm1', [1], "1", c[53], c[54]],
[1,'expm1', [Math.PI], "Math.PI", c[55], c[56]],
[0,'exp', [n], n, c[57]],
[1,'exp', [Math.PI], "Math.PI", c[58]],
[0,'hypot', [1,2,3,4,5,6], "1,2,3,4,5,6", c[59], c[60]],
[1,'hypot', [bigN, bigN], "bigN, bigN", c[61], c[62]],
[2,'hypot', [2*Math.E,-100], '2*Math.E,-100', c[63], c[64]],
[3,'hypot', [6*Math.PI,-100], '6*Math.PI,-100', c[65], c[66]],
[4,'hypot', [2*Math.LN2,-100], '2*Math.LN2,-100', c[67], c[68]],
[5,'hypot', [Math.LOG2E,-100], 'Math.LOG2E,-100', c[69], c[70]],
[6,'hypot', [Math.SQRT2,-100], 'Math.SQRT2,-100', c[71], c[72]],
[7,'hypot', [Math.SQRT1_2,-100], 'Math.SQRT1_2,-100',c[73], c[74]],
[8,'hypot', [2*Math.LOG10E,-100], '2*Math.LOG10E,-100', c[75], c[76]],
[0,'log', [n], n, c[77]],
[1,'log', [Math.PI], "Math.PI", c[78]],
[0,'log1p', [n], n, c[79], c[80]],
[1,'log1p', [Math.PI], "Math.PI", c[81], c[82]],
[0,'log10', [n], n, c[83], c[84]],
[1,'log10', [Math.PI], "Math.PI", c[85], c[86]],
[2,'log10', [Math.E], "Math.E", c[87], c[88]],
[3,'log10', [34*Math.E], '34*Math.E', c[89], c[90]],
[4,'log10', [Math.LN2], "Math.LN2", c[91], c[92]],
[5,'log10', [11*Math.LN2], '11*Math.LN2', c[93], c[94]],
[6,'log10', [Math.LOG2E], "Math.LOG2E", c[95], c[96]],
[7,'log10', [43*Math.LOG2E], '43*Math.LOG2E', c[97], c[98]],
[8,'log10', [Math.LOG10E], "Math.LOG10E", c[99], c[100]],
[9,'log10', [7*Math.LOG10E], '7*Math.LOG10E', c[101], c[102]],
[10,'log10', [Math.SQRT1_2], "Math.SQRT1_2", c[103], c[104]],
[11,'log10', [2*Math.SQRT1_2], '2*Math.SQRT1_2', c[105], c[106]],
[12,'log10', [Math.SQRT2], "Math.SQRT2", c[107], c[108]],
// original TZP value but with sin
[0,'sin', [1e251], "1e251", c[109]],
[1,'sin', [1e140], "1e140", c[110]],
[2,'sin', [1e12], "1e12", c[111]],
[3,'sin', [1e130], "1e130", c[112]],
[4,'sin', [1e272], "1e272", c[113]],
[5,'sin', [1e0], "1e0", c[114]],
[6,'sin', [1e284], "1e284", c[115]],
[7,'sin', [1e75], "1e75", c[116]],
[8,'sin', [bigN], "bigN", c[117]], // creep says unique in Tor
[9,'sin', [Math.PI], "Math.PI", c[118]], // creep says unique in Tor
[10,'sin', [39*Math.E], "39*Math.E", c[119]],
[11,'sin', [35*Math.LN2], "35*Math.LN2", c[120]],
[12,'sin', [110*Math.LOG2E], "110*Math.LOG2E", c[121]],
[13,'sin', [7*Math.LOG10E], "7*Math.LOG10E", c[122]],
[14,'sin', [35*Math.SQRT1_2], "35*Math.SQRT1_2", c[123]],
[15,'sin', [21*Math.SQRT2], "21*Math.SQRT2", c[124]],
[0,'sinh', [1], "1", c[125], c[126]],
[1,'sinh', [Math.PI], "Math.PI", c[127], c[128]],
[2,'sinh', [Math.E], "Math.E", c[129], c[130]],
[3,'sinh', [Math.LN2], "Math.LN2", c[131], c[132]],
[4,'sinh', [Math.LOG2E], "Math.LOG2E", c[133], c[134]],
[5,'sinh', [492*Math.LOG2E], '492*Math.LOG2E', c[135], c[136]],
[6,'sinh', [Math.LOG10E], "Math.LOG10E", c[137], c[138]],
[7,'sinh', [Math.SQRT1_2], "Math.SQRT1_2", c[139], c[140]],
[8,'sinh', [Math.SQRT2], "Math.SQRT2", c[141], c[142]],
[9,'sinh', [502*Math.SQRT2], '502*Math.SQRT2', c[143], c[144]],
[0,'sqrt', [n], n, c[145]],
[1,'sqrt', [Math.PI], "Math.PI", c[146]],
// original TZP with tan
[0,'tan', [1e251], "1e251", c[147]],
[1,'tan', [1e140], "1e140", c[148]],
[2,'tan', [1e12], "1e12", c[149]],
[3,'tan', [1e130], "1e130", c[150]],
[4,'tan', [1e272], "1e272", c[151]],
[5,'tan', [1e0], "1e0", c[152]],
[6,'tan', [1e284], "1e284", c[153]],
[7,'tan', [1e75], "1e75", c[154]],
[8,'tan', [-1e308], "-1e308", c[155]],
[9,'tan', [Math.PI], "Math.PI", c[156]],
[10,'tan', [6*Math.E], '6*Math.E', c[157]],
[11,'tan', [6*Math.LN2], '6*Math.LN2', c[158]],
[12,'tan', [10*Math.LOG2E], '10*Math.LOG2E', c[159]],
[13,'tan', [17*Math.SQRT2], '17*Math.SQRT2', c[160]],
[14,'tan', [34*Math.SQRT1_2], '34*Math.SQRT1_2', c[161]],
[15,'tan', [10*Math.LOG10E], '10*Math.LOG10E', c[162]],
[0,'tanh', [n], n, c[163], c[164]],
[1,'tanh', [Math.PI], "Math.PI", c[165], c[166]],
[0,'pow', [n,-100], n+",-100", c[167]],
[1,'pow', [Math.PI,-100], "Math.PI,-100", c[168]],
[2,'pow', [Math.E,-100], "Math.E,-100", c[169]],
[3,'pow', [Math.LN2,-100], "Math.LN2,-100", c[170]],
[4,'pow', [Math.LN10,-100], "Math.LN10,-100", c[171]],
[5,'pow', [Math.LOG2E,-100], "Math.LOG2E,-100", c[172]],
[6,'pow', [Math.LOG10E,-100], "Math.LOG10E,-100", c[173]],
[7,'pow', [Math.SQRT1_2,-100], "Math.SQRT1_2,-100", c[174]],
[8,'pow', [Math.SQRT2,-100], "Math.SQRT2,-100", c[175]],
]
}
// POLYFILLS
const acosh = x => Math.log(x + Math.sqrt(x * x - 1))
const asinh = x => {
const absX = Math.abs(x)
if (absX < Math.pow(2, -28)) {
return x
}
const w = (
absX > Math.pow(2, 28) ? Math.log(absX) + Math.LN2 :
absX > 2 ? Math.log(2 * absX + 1 / Math.sqrt(x * x + 1)) :
Math.log1p(absX + (x * x) / (1 + Math.sqrt(1 + (x * x))))
)
return x > 0 ? w : -w
}
const atanh = x => Math.log((1 + x) / (1 - x)) / 2
function cbrt(x) {
let y = Math.pow(Math.abs(x), 1 / 3)
return x < 0 ? -y : y
}
const cosh = x => (Math.exp(x) + Math.exp(-x)) / 2
const expm1 = x => Math.exp(x) - 1
function hypot(array) {
let i, s = 0,
max = 0,
isInfinity = false,
len = array.length
for (i = 0; i < len; ++i) {
const arg = Math.abs(+array[i])
if (arg === Infinity) {
isInfinity = true
}
if (arg > max) {
s *= (max / arg) * (max / arg)
max = arg
}
s += arg === 0 && max === 0 ? 0 : (arg / max) * (arg / max)
}
return isInfinity ? Infinity : (max === Infinity ? Infinity : max * Math.sqrt(s))
}
const log1p = x => {
const nearX = (x + 1) - 1
return (
x < -1 || x !== x ? NaN :
x === 0 || x === Infinity ? x :
nearX === 0 ? x :
x * (Math.log(x + 1) / nearX)
)
}
const log2 = x => Math.log(x) * Math.LOG2E
const log10 = x => Math.log(x) * Math.LOG10E
const sinh = x => (Math.exp(x) - Math.exp(-x)) / 2
const tanh = x => {
const a = Math.exp(+x)
const b = Math.exp(-x)
return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (a + b)
}
function get_results() {
// vars
let display = [],
prevFn = "start",
demarc = false,
strDemarc = "----------------------------------------------------",
sColor = s3,
vPad = 19, // value tested
fPad = vPad + 7, // function + value
rPad = 23, // result
nPad = 5, // user number: 5 means k indents by 2, and k+"p1"/"p2" is covered in diffs
bigNstr = "* bigN = " + bigN
// BUILD TEST RESULTS
let math1 = [], // functions
math2 = [], // polyfills
numbers = [], // numbers which make a difference
numberchk = [], // make sure no duplicates
polymatch = [],
fnmatch = [], // do not match control
diffs = [] // fn + poly don't match
let generate = []
for(let i=0; i < fns.length; i++) {
let fn = fns[i]
let k = fn[0] // user defined number
let kpad = (k.toString()).padStart(nPad)
let fnResult = (Math[fn[1]](...fn[2])).toString()
let fnValue = fn[3].toString()
let fnControl = fn[4].toString()
let fnName = fn[1].toString()
numberchk.push(fnName+"-"+k.toString())
// fn result
let isFnDiff = false
if (fnResult !== fnControl) {
isFnDiff = true
fnmatch.push(k+":"+fnName+"("+fn[3]+"):"+fnControl +":"+fnResult)
numbers.push(fnName +":"+ k.toString())
}
math1.push(fnName+"("+fnValue+"):"+fnResult)
generate.push("'"+fnResult+"'")
// poly tests
let poly1Result = ""
let poly1Control = ""
if (fn[5] !== undefined && fn[5] !== "") {
poly1Control = fn[5].toString()
if (fnName == "acosh") {poly1Result = acosh(...fn[2])
} else if (fnName == "asinh") {poly1Result = asinh(...fn[2])
} else if (fnName == "atanh") {poly1Result = atanh(...fn[2])
} else if (fnName == "cbrt") {poly1Result = cbrt(...fn[2])
} else if (fnName == "cosh" ) {poly1Result = cosh(...fn[2])
} else if (fnName == "expm1") {poly1Result = expm1(...fn[2])
} else if (fnName == "hypot") {poly1Result = hypot([...fn[2]]) // pass array
} else if (fnName == "log1p") {poly1Result = log1p(...fn[2])
} else if (fnName == "log2" ) {poly1Result = log2(...fn[2])
} else if (fnName == "log10") {poly1Result = log10(...fn[2])
} else if (fnName == "sinh" ) {poly1Result = sinh(...fn[2])
} else if (fnName == "tanh" ) {poly1Result = tanh(...fn[2])}
poly1Result = poly1Result.toString()
//console.debug(k, fn[3], fnName, poly1Control, poly1Result)
}
// poly1 results
let isPolyDiff = false, isDiff = false
if (poly1Result !== "") {
if (poly1Result !== poly1Control) {
isPolyDiff = true
polymatch.push(k+"p1:"+fnName+"("+fn[3]+"):"+poly1Control +":"+poly1Result)
numbers.push(fnName +":"+ k.toString() +"p1")
}
math2.push(fnName+"("+fnValue+")polyfill1:"+poly1Result)
generate.push("'"+poly1Result+"'")
// does not match fn
if (poly1Result !== fnResult) {
isDiff = true
diffs.push(k+"p1:"+fnName+"("+fn[3]+"):"+fnResult +":"+poly1Result)
}
}
// color & pad
if (isFnDiff) {
fnResult = s1.trim() + fnResult.padStart(rPad) + sc
} else {
fnResult = fnResult.padStart(rPad)
}
if (isPolyDiff) {
poly1Result = s1.trim() + poly1Result.padStart(rPad) + sc
} else {
poly1Result = poly1Result.padStart(rPad)
}
if (isDiff) {
poly1Result += s1 +"[match]"+ sc
}
if (poly1Result !== "") {
fnResult += ", " + poly1Result
}
// demarcate each function
if (prevFn !== fnName) {demarc = true} else {demarc = false}
if (demarc == true) {
display.push(sColor.trim() + strDemarc +"<br>"+ fnName.toUpperCase() + sc)
}
display.push(kpad+": "+ sColor + fnValue.padEnd(vPad) + sc +": "+ fnResult)
// remember last function
prevFn = fn[1]
}
// generate control lists
//console.log("CONTROL LIST:\n " + generate.join(","))
// NUMBER+NAME DUPE CHECK
numberchk = numberchk.filter(function(item, position) {return numberchk.indexOf(item) === position})
if (fns.length !== numberchk.length) {
console.debug("fns array has duplicate user defined test ids")
}
// NUMBERS
let numstr = "none", mathPrev = "", mathNext = "", tmp_nums = []
if (numbers.length > 0) {
let numdisplay = []
for(let i=0; i < numbers.length; i++) {
let part0 = numbers[i].split(":")[0]
let part1 = numbers[i].split(":")[1]
part1 = part1.replace(/\p1/g, s12.trim() +"p1"+ sc)
// build number string
tmp_nums.push(part1)
if (i < numbers.length - 1) {
mathNext = numbers[(i+1)].split(":")[0]
} else {
mathNext = "end"
}
// next math function is diff: write data
if (mathNext !== part0) {
numdisplay.push(s12.trim() + part0.padStart(5) + sc +": "+ tmp_nums.join(", "))
tmp_nums = [] // reset
}
mathPrev = part0
}
numstr = numdisplay.join("<br>")
}
dom.numbers.innerHTML = numstr
// DIFFS FUNCTION
function output_diffs(array, type) {
let output = []
if (array.length > 0) {
for(let i=0; i < array.length; i++) {
let part0 = array[i].split(":")[0]
part0 = (part0.toString()).padStart(nPad)
let part1 = array[i].split(":")[1]
part1 = (part1.toString()).padEnd(fPad)
let part2 = array[i].split(":")[2]
part2 = (part2.toString()).padStart(rPad)
let part3 = array[i].split(":")[3]
output.push(s12.trim() + part1 + sc +" s/be "+ s3.trim() + part2 + sc +" got"+ s1 + part3 + sc)
}
document.getElementById("diff" + type).innerHTML = output.join("<br>")
} else {
document.getElementById("diff" + type).innerHTML = "none"
}
}
// HASHES
let hash1 = sha1(math1.join())
let hash2 = sha1(math2.join())
let math3 = math1.concat(math2)
let hash0 = sha1(math3.join())
//console.debug(math3.join("\n"))
let maincode = get_code(hash0)
if (numstr == "none") {
numstr = s12.trim() +" nos: "+ sc + numstr
}
// SHORT REPORT
let report = s12.trim() +"control: "+ controlname
+"<br>"+ strDemarc + sc
+"<br>"+ s12.trim() +" hash: "+ sc + hash0 + maincode
+"<br>"+ s12.trim() +" func: "+ sc + hash1
+"<br>"+ s12.trim() +" poly: "+ sc + hash2
+"<br>"+ numstr
dom.report.innerHTML = report
// LONG REPORT
output_diffs(diffs, 0)
output_diffs(fnmatch, 1)
output_diffs(polymatch, 2)
// DATA
dom.mathdata.innerHTML = report
+"<br><br>"+ bigNstr.padStart(52)
+"<br>"+ display.join("<br>")
// PERF
dom.perf.innerHTML = Math.round(performance.now()-t0) +" ms"
}
function get_code(hash) {
let r = ""
// FF
// windows
if (hash == "97c37c8c3b1de92333bf1993a7350cf785b2715d") {r="F1"} // Win7 64bit: FF68-82 64bit [CONTROL]
else if (hash == "d9e8b78b68a5d1086af27ceec9315f0797ccec7c") {r="F2"} // Win7 64bit: FF68-82 32bit
else if (hash == "06f9ca0df07d4836116143158b670c9d3a417cd4") {r="F3"} // Win7 64bit: TB68-78 64bit
else if (hash == "dd277bcf4a12289404b0aab1ae43be060be5a12a") {r="F4"} // Win7 64bit: TB68-78 32bit
// pending windows machine no 2 tests (which I know provide more entropy)
// rampaa
//else if (hash == "b0130c424be28aac4ed155c679c9baf951349b75") {r="something"} // Win10 64bit: FF80 64bit
// hash: b0130c424be28aac4ed155c679c9baf951349b75 [NEW]
// func: e8dd64a68e81d54fbaab58bd3b48cbe2179f6587
// poly: 0cde3749d8f342c858af1eef6b48f2e2be985440
// cos: 5, 7, 14, 16, 17, 18
// sin: 14
// tan: 12
// android
else if (hash == "571b9a318869bd09dab3fd83fd88883a66188011") {r="F20"} // android 9 aarch64 | browserstacks: android 10, 11
else if (hash == "56c05c3f03fb55c3c046ad1b68d05d2392fe0c54") {r="F21"} // browserstacks: android 6,7,7.1,8,9
else if (hash == "da130b6da16b5ddffc42ebf56259c4746d01a3b6") {r="F22"} // browserstacks: android 9
else if (hash == "d246b2f0103139eb4407a7dfe4dda2af0bcca4e6") {r="F23"} // browserstacks: android 10
else if (hash == "a624571a642dbcb468f6d2d8203d0659d351bdc1") {r="F24"} // browserstacks: android 5
else if (hash == "02e1298182c58da58956df1342b525bd5aecfd7e") {r="F25"} // browserstacks: android 4.4
else if (hash == "66b3de14094fec47652f8ad203e6d8e6c9ee418f") {r="F26"} // android 8, browserstacks 8.1, chromeOS-32bit android 9
// linux
else if (hash == "e6c7b364678e8ecec909088314318acb8430ee47") {r="F30"}
else if (hash == "05ea8b9bed51553711e3bbaa552449d8ea40c4be") {r="F31"}
// mac
else if (hash == "84ad7bbb52342b6c224c0fe45977184bc943bb92") {r="F50"}
// obsolete linux
else if (hash == "2047b6e1afc4c6bbe55d061e33fa8026c7afd648") {r="F80"} // mint32: FF60-67
else if (hash == "ac4f01ae0d298a6ef48bb20aa594a77fb14b0968") {r="F81"} // mint32: TB60
// obsolete windows
else if (hash == "3ada7d492e4fa7a7a6acea446fa24ec3ff370556") {r="F96"} // Win7 64bit: FF60-67 64bit [obsolete versions]
else if (hash == "a8b5e74f336489c1df701a95650ab091ff6de436") {r="F97"} // Win7 64bit: FF60-67 32bit [obsolete versions]
else if (hash == "8d09688f127d62709bbb5d47f7fc8c959ae151a8") {r="F98"} // Win7 64bit: TB60 64bit [obsolete versions]
else if (hash == "4796b1d067dd047768dcd2e9ecd740c0ef353d31") {r="F99"} // Win7 64bit: TB60 32bit [obsolete versions]
// CHROME
else if (hash == "42550bb913168ddbb8be40f970adc51344017cad") { r="C1"}
// SAFARI
else if (hash == "4423be6d9bec5550ad38ea9dde7ef2daf0609e0f") { r="S1"}
// iOS
else if (hash == "2e9162520d6f90c28e24d0f2e538f79f503f8a66") { r="iOS1"}
// EDGEHTML
else if (hash == "a53608a3ac4caf531014dcd4cfaac425db405398") { r="E99"}
// NEW
if (r == "") {r = zNEW} else {r = s12+"["+ r +"]"+sc}
return r
}
function outputMath(control) {
// clear
let items = document.getElementsByClassName("c mono")
for (let i=0; i < items.length; i++) {items[i].textContent = ""}
// control
if (control == "firefox") {controlname = "Firefox 78 64bit on Windows 64bit"
} else if (control == "chrome") {controlname = "Chrome 85 64bit on Windows 64bit"
} else if (control == "safari") {controlname = "Safari 13.0.5 on macOS Catalina [VM 64bit on Windows 10 64bit]"}
// build control & run
build_controlset(control)
// delay so user can see things being reset
setTimeout(function(){
t0 = performance.now()
get_results()
}, 170)
}
get_engine()
outputMath("firefox")
</script>
</body>
</html>