File: SimpleNumber.schelp

package info (click to toggle)
supercollider 1%3A3.13.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,292 kB
  • sloc: cpp: 476,363; lisp: 84,680; ansic: 77,685; sh: 25,509; python: 7,909; makefile: 3,440; perl: 1,964; javascript: 974; xml: 826; java: 677; yacc: 314; lex: 175; objc: 152; ruby: 136
file content (1662 lines) | stat: -rw-r--r-- 45,806 bytes parent folder | download | duplicates (2)
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
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
CLASS:: SimpleNumber
summary:: one-dimensional value
categories:: Math
related::Classes/Polar, Classes/Complex, Classes/Float, Classes/Integer, Classes/UnaryOpUGen, Classes/BinaryOpUGen, Guides/Tour-of-Special-Functions

DESCRIPTION::
Base class for numbers which can be represented by a single one dimensional value.

Most of the Unary and Binary operations are also implemented by link::Classes/UnaryOpUGen:: and link::Classes/BinaryOpUGen::, so you can get more examples by looking at the help for those.

CLASSMETHODS::

method:: new
allocates a new SimpleNumber.



INSTANCEMETHODS::

private:: prSimpleNumberSeries

subsection:: math support

method:: +
Addition


method:: -
Subtraction

method:: *
Multiplication

method:: /
Division

method:: %
Modulo

method:: mod
Modulo

method:: div
Integer Division

method:: **
Exponentiation

method:: !=
Is not

method:: >
greater than

method:: <
greater than

method:: >=
greater or equal than

method:: <=
smaller or equal than

method:: lcm
Least common multiple

method:: gcd
Greatest common divisor

method:: round
Round to multiple of aNumber

method:: roundUp
Round up to a multiple of aNumber. For roundDown use Link::Classes/SimpleNumber#-trunc#trunc::.

method:: smallButNotZero
Check if the value is closer to zero than a threshold, but not zero.

argument::thresh
The threshold to use for comparison.

method:: trunc
Truncate to multiple of aNumber (e.g. it rounds numbers down to a multiple of aNumber).

method:: softRound
Rounds the value to a multiple of strong::resolution::. By using strong::margin:: and strong::strength:: you can control which values will be rounded, and by how much.

Conceptually this is the equivalent of MIDI quantization in a DAW/MIDI sequencer. In particular it allows a certain sloppiness close to the strong::resolution:: value.

Note: this method expects values >= 0.

argument::resolution
Round this value to a multiple of resolution. E.g. if you chose 1, then all values would be rounded to the nearest integer.
argument::margin
Values that are within ±strong::margin:: from a multiple of strong::resolution:: will be left as they are.

E.g. if you chose a resolution value of 0.5 and a margin of 0.01, then the values 0.501 and 0.499 would be left as they are, but the value 0.502 would become 0.5.

This should be a value between 0 and strong::resolution::.
argument::strength
Determines the degree to which this number will be changed.

If strength is 1, then this function will return the nearest resolution. If it is 0, then value of this number will be left unchanged.

E.g. If the resolution was 1 and strength was 0.5, then the value 0.6 would become 0.8.
discussion::
code::
((0..10) / 5).collect { |num| [num, num.softRound(1, 0, 1)] };
((0..10) / 5).collect { |num| [num, num.softRound(1, 0.3, 1)] };
((0..10) / 5).collect { |num| [num, num.softRound(1, 0, 0.5)] };
::

method:: snap
Rounds the values strong::margin:: distance from resolution to a multiple of resolution. By using strong::margin:: and strong::strength:: you can control when values will be rounded, and by how much.

Conceptually this is the equivalent of 'snap' in a graphics program. Values within a certain distance (strong::margin::) from a grid line are snapped to it. All other values are unchanged.

Note: this method expects values >= 0.

argument::resolution
Snap this value to a multiple of resolution. E.g. if you chose 1, then all values would be rounded to the nearest integer.

argument::margin
Only values that are greater ±strong::margin:: from a multiple of strong::resolution:: value will be changed. Values that are less than strong::margin:: will be unchanged.

E.g. if you chose a resolution value of 0.5 and a margin of 0.01, then the values 0.501 and 0.499 would be snapped to 0.5, but the value 0.502 would be unchanged.

This should be a value between 0 and strong::resolution::.

argument::strength
Determines the degree to which this number will be changed.

If strength is 1, then this function will return the nearest resolution. If it is 0, then value of this number will be left unchanged.

E.g. If the resolution was 1 and strength was 0.5, then the value 0.6 would become 0.8.
discussion::
code::
((0..10) / 5).collect { |num| [num, num.snap(1, 0, 1)] };
((0..10) / 5).collect { |num| [num, num.snap(1, 0.3, 1)] };
((0..10) / 5).collect { |num| [num, num.snap(1, 0, 0.5)] };
::

method:: thresh

method:: min
Minimum

method:: max
Maximum

method:: wrap2

method:: atan2
Arctangent of (this/aNumber)

method:: hypot
Square root of the sum of the squares.


method:: log
returns:: Base e logarithm.

method:: log2
returns:: Base 2 logarithm.

method:: log10
returns:: Base 10 logarithm.

method:: neg
returns:: negation

method:: abs
returns:: absolute value.

method:: sign
returns:: Answer -1 if negative, +1 if positive or 0 if zero.

method:: ceil
returns:: next larger integer.

method:: floor
returns:: next smaller integer

method:: sin
Sine

method:: cos
Cosine

method:: tan
Tangent

method:: asin
Arcsine

method:: acos
Arccosine

method:: atan
Arctangent

method:: sinh
Hyperbolic sine

method:: cosh
Hyperbolic cosine

method:: tanh
Hyperbolic tangent

method:: frac
fractional part

method:: squared
the square of the number

method:: cubed
the cube of the number

method:: sqrt
the square root of the number.

method:: exp
e to the power of the receiver.

method:: reciprocal
1 / this

method:: pow
this to the power of aNumber

method:: fold2
the folded value, a bitwise or with aNumber

method:: previousPowerOf
the number relative to this that is the previous power of aNumber

method:: nextPowerOf
the next power of aNumber

method:: nextPowerOfTwo
returns:: the number relative to this that is the next power of 2

method:: nextPowerOfThree
the next power of three

method:: hash
returns:: a hash value

method:: <!
returns:: the receiver. aNumber is ignored.

method:: &
Bitwise And

method::|
Bitwise Or

method:: bitXor
Bitwise Exclusive Or

method:: bitHammingDistance
Binary Hamming distance: the count of bits that are not the same in the two numbers

method:: bitTest
returns:: true if bit at index aNumber is set.

method:: bitNot
returns:: ones complement

method:: <<
Binary shift left.

method:: >>
Binary shift right.

method:: +>>
Unsigned binary shift right.

method:: rightShift
returns:: performs a binary right shift

method:: unsignedRightShift
returns:: performs an unsigned right shift

method:: leftShift
returns:: performs a binary left shift

method:: bitOr
returns:: performs a bitwise or with aNumber

method:: bitAnd
returns:: performs a bitwise and with aNumber

method:: ring1
(a * b) + a

method:: ring2
((a*b) + a + b)

method:: ring3
(a * a *b)

method:: ring4
((a*a *b) - (a*b*b))

method:: difsqr
(a*a) - (b*b)

method:: sumsqr
(a*a) + (b*b)

method:: sqrdif
(a - b) ** 2

method:: sqrsum
(a + b) ** 2

method:: absdif
(a - b).abs

method:: moddif
On a circle, there are two distances between two points. This operator returns the smaller value of the two.
code::
moddif(0.75, 0, 1)
::

method:: amclip
0  when  b <= 0,  a*b  when  b > 0

method:: scaleneg
a * b when a < 0, otherwise a.

method:: clip2
clips receiver to +/- aNumber

method:: excess
Returns the difference of the receiver and its clipped form.
discussion::
code::
(a - clip2(a,b))
::

method:: madd
code::
this * a + b
::

subsection:: testing
method:: isPositive
Answer if the number is >= 0.

method:: isNegative
Answer if the number is < 0.

method:: isStrictlyPositive
Answer if the number is > 0.

method:: booleanValue
returns:: true, if strictly positive ( > 0), otherwise false (see link::Classes/Boolean::)

method:: isNaN
method:: ==

subsection:: conversion

method:: asFraction
argument::denominator
argument::fasterBetter
if true, asFraction may find a much closer approximation and do it faster.
returns:: an array of denominator and divisor of the nearest and smallest fraction

method:: asAudioRateInput
Converts this into an audiorate input.

method:: asTimeString
Produces a time string in the clock format inspired by ISO 8601 time interval display (truncated representation) code::(ddd:)hh:mm:ss(.z)::, interpreting the receiver as time in seconds. See link::Classes/String#-asSecs:: for the inverse function.
argument:: precision
accuracy of the fraction of seconds; since the number of decimal places is also an argument, code::precision:: is clamped to code::10.pow(decimalPlaces.neg)::, i.e. code::0.001:: for code::decimalPlaces = 3::
argument::maxDays
maximum number of days
argument::dropDaysIfPossible
a link::Classes/Boolean::. If set to code::true::, and the number of days in the formatted string
would be 0, that section of the resulting string is omitted
argument::decimalPlaces
number of decimal places representing fraction of seconds, clamped to code::0::; if code::0::, the string is formatted as code::(ddd:)hh:mm:ss::
discussion::
code::
(
var start;
start = Main.elapsedTime;
{
	loop {
		(Main.elapsedTime - start).asTimeString.postln;
		0.05.wait
	}
}.fork;
)
::

method:: asPoint
returns:: this as link::Classes/Point::. x = y = this.

method:: asComplex
returns:: this as link::Classes/Point::. x = y = this.

method:: asWarp
argument::spec
a link::Classes/ControlSpec::
returns:: this as link::Classes/CurveWarp:: according to spec.

method:: asFloat
returns:: this as link::Classes/Float::

method:: asRect
returns:: a link::Classes/Rect:: with x = y = w = h = this.

method:: asBoolean
returns:: this as a link::Classes/Boolean::.  this > 0

method:: asQuant
returns:: the values as link::Classes/Quant::

method:: asInteger
returns:: this as link::Classes/Integer::

subsection:: timing

method::wait
within a routine, yield the number so that the clock can wait for this many beats. Outside a Routine, this trows an error (see also Routine for details).

discussion::
Create a routine by a function fork
code::
(
fork {
	1.wait;
	"I did wait".postln;
	1.0.rand.wait;
	"No you didn't".postln;
	2.wait;
	(1..).do { |i|
		"yes I did".postln;
		i.asFloat.rand.wait;
		"no you didn't".postln;
		i.wait
	}
}
)
::

method:: waitUntil
like wait, only specify a time (measured in beats of the current thread's clock). Outside a Routine, this throws an error (see also Routine for details).

method:: sleep
make the current thread sleep, until woken up by re-scheduling. Outside a Routine, this trows an error (see also Routine for details).

method:: nextTimeOnGrid
argument::clock
returns:: the next possible multiple of the clock's beats.

method:: schedBundleArrayOnClock



subsection:: series and arrays

method:: nearestInList
returns:: the value in the list closest to this

discussion::
code::
(
l = [0, 0.5, 0.9, 1];
(0, 0.05..1).collect { |i| i.nearestInList(l) }
)
::

method:: nearestInScale
argument:: scale
an array of SimpleNumbers each treated as a step in the octave.
argument:: stepsPerOctave
12 by default
returns:: the value in the collection closest to this, assuming an octave repeating table of note values.

discussion::
code::
(
l = [0, 1, 5, 9, 11]; // pentatonic scale
(60, 61..76).collect { |i| i.nearestInScale(l, 12) }
)
::

method:: series
Generate an arithmetic series from teletype::this:: over strong::second:: to strong::last::.

If strong::second:: is teletype::nil::, it is one magnitude step towards last (1 or -1).
code::
series(5, 7, 10);
series(5, nil, 10);
(5, 7 .. 10)
::
This is used in the shortcuts:
code::
(0..100);
(1, 3 .. 17)
::

returns::
An link::Classes/Array::.

discussion::
The last value may not be included in the result if the step size does not divide evenly into the range of the series.

method:: seriesIter
Create a link::Classes/Routine:: that iterates over an arithmetic series from teletype::this:: over strong::second:: to strong::last::.

Since this is a lazy operation, strong::last:: can be code::inf::, generating an endless series. If unspecified, strong::last:: is code::inf:: or code::-inf:: depending on the step direction.
code::
r = seriesIter(0, 5, 52);
r.nextN(8);
r.nextN(8); // reaches 'last', then nils

r = seriesIter(0, 5); // last = inf
r.nextN(8); // run repeatedly
::
See also link::#-series:: and link::Guides/ListComprehensions::.

returns::
A link::Classes/Routine::.


subsection:: windowing

method:: rectWindow
returns:: a value for a rectangular window function between 0 and 1.

method:: hanWindow
returns:: a value for a hanning window function between 0 and 1.

method:: welWindow
returns:: a value for a welsh window function between 0 and 1.

method:: triWindow
returns:: a value for a triangle window function between 0 and 1.

subsection:: mapping

method:: distort
A nonlinear distortion function.

Implements:
teletype::
this / (1.0 - abs(this))
::
Visualize:
code::
(
{ var saw = LFSaw.ar(2 * 0.01.reciprocal);
	[saw, saw.distort]
}.plot.superpose_(true)
)
::

method:: softclip
Distortion with a perfectly linear region from -0.5 to +0.5.

Implements:
teletype::
if (abs(this) < 0.5) { this } { (abs(this) - 0.25) / this };
::
Visualize:
code::
(
{ var saw = LFSaw.ar(2 * 0.01.reciprocal);
	[saw, saw.softclip]
}.plot.superpose_(true)
)
::

method:: scurve
Map receiver in the onto an S-curve bound to [0,1].
Implements:
teletype::
this * this * (3.0 - (2.0 * this))
::
with teletype::this:: clipped to [0,1].
code::
((-100..200) / 100 ).collect(_.scurve).plot
::

method:: ramp
Map the receiver onto a ramp starting at code::0.0::, ending at code::1.0::, effectively clipping the receiver at [0,1].
discussion::
code::
(
	var vals = (-100..200) / 100;
	vals.collect(_.ramp).plot
	.domainSpecs_(
		[vals.minItem, vals.maxItem].asSpec
	)
	.axisLabelX_("input").axisLabelY_("output")
)
::

method::magnitude
returns:: The absolute value.

Alternatively conceived of as the link::Classes/Polar#-magnitude:: or link::Classes/Complex#-magnitude::, wherein the receiver is the real part and the imaginary part is code::0.0::.

method::angle
returns:: Angle of receiver (in radians) conceived as link::Classes/Polar:: or link::Classes/Complex:: number, wherein the receiver is the real part and the imaginary part is code::0.0::. I.e. teletype::if (this.isPositive) { 0.0 } { pi }::.


method:: degreeToKey
argument:: scale
an array of SimpleNumbers each treated as a step in the octave.
argument:: stepsPerOctave
12 is the standard chromatic scale.
discussion::
the value is truncated to an integer and used as an index into an octave repeating table of note values. Indices wrap around the table and shift octaves as they do.

code::
(
l = [0, 1, 5, 9, 11]; // pentatonic scale
(1, 2..15).collect{|i|
	i.degreeToKey(l, 12)
};
)
::

method:: keyToDegree
inverse of degreeToKey.
argument:: scale
an array of SimpleNumbers each treated as a step in the octave.
argument:: stepsPerOctave
12 is the standard chromatic scale.
discussion::
code::
(
l = [0, 1, 5, 9, 11]; // pentatonic scale
(60, 61..75).collect { |i| i.keyToDegree(l, 12) }
)
::
code::
(
l = [0, 1, 5, 9, 11]; // pentatonic scale
(60, 61..75).postln.collect { |i| i.keyToDegree(l, 12).degreeToKey(l) }
)
::


method::gaussCurve
Map the receiver onto a gauss function.

Uses the formula:
teletype::
a * -exp((this - b).squared / (2 * c.squared))
::
where code::a:: is the distribution amplitude, code::b:: is the mean (typically denoted emphasis::mu::), and the variance is code::c.squared:: (emphasis::sigma::^2).

The method defaults to a "standard normal distribution": a zero mean and both the peak amplitude and variance are code::1.0:: (code::a = 1.0, b = 0.0, c = 1.0::).
code::
(0..1000).normalize(-10, 10).collect { |num| num.gaussCurve }.plot;
::


method:: equalWithPrecision

argument::that
the number to compare with within precision

argument::precision
The absolute precision, independent of the value compared

argument::relativePrecision
The precision relative to the larger absolute of the values compared.


returns:: true if receiver is closer to that than precision.

discussion::
code::
3.1.equalWithPrecision(3.0, 0.05); // false
3.1.equalWithPrecision(3.0, 0.1); // false
3.1.equalWithPrecision(3.0, 0.11); // true
3000.1.equalWithPrecision(3000.0, 0, 0.01); // true
3.1.equalWithPrecision(3.0, 0, 0.01); // false

::

method:: quantize
Deprecated. Round the receiver to the quantum. If you're looking for MIDI quantization type features use CODE::SimpleNumber#-softRound::
argument::quantum
amount.
argument::tolerance
allowed tolerance.
argument::strength
Determines how much the value is allowed to differ in the tolerance range.
discussion::
code::
((0..10) / 10).collect { |num| num.quantize(1, 0.3, 0.5) }.postcs.plot;
((0..10) / 10).collect { |num| num.quantize(1, 0.6, 0.5) }.postcs.plot;
((0..10) / 10).collect { |num| num.quantize(1, 1.0, 0.5) }.postcs.plot;
::

method:: linlin
map the receiver from an assumed linear input range to a linear output range. If the input exceeds the assumed input range, the behaviour is specified by the clip argument.
argument::inMin
assumed input minimum
argument::inMax
assumed input maximum
argument::outMin
output minimum
argument::outMax
output maximum
argument::clip
nil (don't clip)
\max (clip ceiling)
\min (clip floor)
\minmax (clip both - this is default).

discussion::
code::
(0..10).collect { |num| num.linlin(0, 10, -4.3, 100) };
(0..10).linlin(0, 10, -4.3, 100); // equivalent.
::

method::linexp
map the receiver from an assumed linear input range (inMin..inMax) to an exponential output range (outMin..outMax). The output range must not include zero. If the input exceeds the input range, the following behaviours are specified by the clip argument.
argument::inMin
assumed input minimum
argument::inMax
assumed input maximum
argument::outMin
output minimum
argument::outMax
output maximum
argument::clip
nil (don't clip)
\max (clip ceiling)
\min (clip floor)
\minmax (clip both - this is default).
discussion::
code::
(0..10).collect { |num| num.linexp(0, 10, 4.3, 100) };
(0..10).linexp(0, 10, 4.3, 100); // equivalent.
::

method::explin
map the receiver from an assumed exponential input range (inMin..inMax) to a linear output range (outMin..outMax). If the input exceeds the assumed input range. The input range must not include zero.
If the input exceeds the input range, the following behaviours are specified by the clip argument.
argument::inMin
assumed input minimum
argument::inMax
assumed input maximum
argument::outMin
output minimum
argument::outMax
output maximum
argument::clip
nil (don't clip)
\max (clip ceiling)
\min (clip floor)
\minmax (clip both - this is default).
discussion::
code::
(1..10).collect { |num| num.explin(0.1, 10, -4.3, 100) };
(1..10).explin(0.1, 10, -4.3, 100); // equivalent.
::

method::expexp
map the receiver from an assumed exponential input range (inMin..inMax) to an exponential output range (outMin..outMax). If the input exceeds the assumed input range. Both input range and output range must not include zero.
If the input exceeds the input range, the following behaviours are specified by the clip argument.
argument::inMin
assumed input minimum
argument::inMax
assumed input maximum
argument::outMin
output minimum
argument::outMax
output maximum
argument::clip
nil (don't clip)
\max (clip ceiling)
\min (clip floor)
\minmax (clip both - this is default).
discussion::
code::
(1..10).collect { |num| num.expexp(0.1, 10, 4.3, 100) };
(1..10).expexp(0.1, 10, 4.3, 100); // equivalent.
::

method::lincurve
map the receiver from an assumed linear input range (inMin..inMax) to an exponential curve output range (outMin..outMax). A curve is like the curve parameter in Env. Unlike with linexp, the output range may include zero.
If the input exceeds the input range, the following behaviours are specified by the clip argument.
argument::inMin
assumed input minimum
argument::inMax
assumed input maximum
argument::outMin
output minimum
argument::outMax
output maximum
argument::curve
0 (linear) <0 (concave, negatively curved) >0 (convex, positively curved)
argument::clip
nil (don't clip)
\max (clip ceiling)
\min (clip floor)
\minmax (clip both - this is default).
discussion::
code::
(0..10).collect { |num| num.lincurve(0, 10, -4.3, 100, -3) };
(0..10).lincurve(0, 10, -4.3, 100, -3); // equivalent.
::
code::
// different curves:
(-4..4).do { |val|
	(0..100).collect(_.lincurve(0, 100, 0, 1, val)).plot
}
::

method::curvelin
map the receiver from an assumed curve-exponential input range (inMin..inMax) to a linear output range (outMin..outMax). If the input exceeds the assumed input range. A curve is like the curve parameter in Env. Unlike with explin, the input range may include zero. If the input exceeds the input range, the following behaviours are specified by the clip argument.
argument::inMin
assumed input minimum
argument::inMax
assumed input maximum
argument::outMin
output minimum
argument::outMax
output maximum
argument::curve
0 (linear) <0 (concave, negatively curved) >0 (convex, positively curved)
argument::clip
nil (don't clip)
\max (clip ceiling)
\min (clip floor)
\minmax (clip both - this is default).

discussion::
code::
(1..10).collect { |num| num.curvelin(0, 10, -4.3, 100, -3) };
(1..10).curvelin(0, 10, -4.3, 100, -3); // equivalent.
::
code::
// different curves:
(-4..4).do { |val|
	(0..100).collect(_.curvelin(0, 100, 0, 1, val)).plot
}
::

method::bilin
map the receiver from two assumed linear input ranges (inMin..inCenter) and (inCenter..inMax) to two linear output ranges (outMin..outCenter) and (outCenter..outMax). If the input exceeds the input range, the following behaviours are specified by the clip argument.
argument::inCenter
argument::inMin
assumed input minimum
argument::inMax
assumed input maximum
argument::outCenter
argument::outMin
output minimum
argument::outMax
output maximum
argument::clip
nil (don't clip)
\max (clip ceiling)
\min (clip floor)
\minmax (clip both - this is default).
discussion::
code::
var center = 0.5, ctlCenter;
w = Window("bilin", Rect(100, 100, 200, 100)).front;
a = Slider(w, Rect(20, 20, 150, 20)).value_(0.5);
b = Slider(w, Rect(20, 45, 150, 20)).value_(0.5);
b.action = { center = b.value };
a.mouseDownAction = { ctlCenter = a.value };
a.action = {
	b.value = a.value.bilin(ctlCenter, 0, 1, center, 0, 1);
};
::


method::biexp
map the receiver from two assumed exponential input ranges (inMin..inCenter) and (inCenter..inMax) to two linear output ranges (outMin..outCenter) and (outCenter..outMax). The input range must not include zero. If the input exceeds the input range, the following behaviours are specified by the clip argument.
argument::inCenter
argument::inMin
assumed input minimum
argument::inMax
assumed input maximum
argument::outCenter
argument::outMin
output minimum
argument::outMax
output maximum
argument::clip
nil (don't clip)
\max (clip ceiling)
\min (clip floor)
\minmax (clip both - this is default).

discussion::
code::
// doesn't properly work yet.
(
var center = 0.5, ctlCenter;
w = Window("biexp", Rect(100, 100, 200, 100)).front;
a = Slider(w, Rect(20, 20, 150, 20)).value_(0.5);
b = Slider(w, Rect(20, 45, 150, 20)).value_(0.5);
b.action = { center = b.value };
a.mouseDownAction = { ctlCenter = a.value + 0.05 };
a.action = {
	b.value = (a.value + 0.1).biexp(ctlCenter, 0.1, 1.1, center, 0, 1);
};
)
::

method::lcurve
map the receiver onto an L-curve.

discussion::
Uses the formula
code::
a * (m * exp(x) * rTau + 1) / (n * exp(x) * rTau + 1)
::
This is used for smoothing values and limiting them to a range.
code::
(0..1000).normalize(-10, 10).collect { |num| num.lcurve }.plot;
::


method:: degrad
returns:: converts degree to radian

method:: raddeg
returns:: converts radian to degree

method:: midicps
Convert MIDI note to cycles per second
returns:: cycles per second

method:: cpsmidi
Convert cycles per second to MIDI note.
returns:: midi note


method:: midiratio
Convert an interval in semitones to a ratio.
returns:: a ratio

method:: ratiomidi
Convert a ratio to an interval in semitones.
returns:: an interval in semitones

method:: ampdb
Convert a linear amplitude to decibels.


method:: dbamp
Convert a decibels to a linear amplitude.

method:: octcps
Convert decimal octaves to cycles per second.

method:: cpsoct
Convert cycles per second to decimal octaves.


subsection:: streams

method:: storeOn
stores this on the given stream
method:: printOn
prints this on the given stream

subsection:: random

method:: coin
Let emphasis::x:: be the receiver clipped to the range [0, 1]. With probability emphasis::x::, return true. With probability 1 - emphasis::x::, return false.

method:: rand
returns:: Random number from zero up to the receiver, exclusive.

method:: rand2
returns:: a random number from -this to +this.

method:: rrand
argument::aNumber
the upper limit
argument::adverb
returns:: a random number in the interval ]a, b[.
discussion::
If both a and b are link::Classes/Integer:: then the result will be an link::Classes/Integer::.

method:: linrand
returns:: a linearly distributed random number from zero to this.

method:: bilinrand
returns:: Bilateral linearly distributed random number from -this to +this.

method:: sum3rand
This was suggested by Larry Polansky as a loose approximation of gaussian.
returns:: A random number from -this to +this that is the result of summing three uniform random generators to yield a bell-like distribution.

method:: exprand
an exponentially distributed random number in the interval ]a, b[. This is always a link::Classes/Float::.
(Note that the distribution of numbers is not exactly an EMPHASIS::exponential distribution::, since that would be unbounded: we might call it a EMPHASIS::logarithmic uniform distribution::.)
argument::aNumber
the upper limit
argument::adverb

method:: gauss
a gaussian distributed random number.
argument::standardDeviation
the upper limit
discussion::
Always returns a link::Classes/Float::.
code::
(0..1000).collect { |num| gauss(0.0, num) }.plot;
::

method:: partition
randomly partition a number into parts of at least min size.
argument:: parts
number of parts
argument:: min
the minimum size

discussion::
code::
75.partition(8, 3);
75.partition(75, 1);
::


subsection:: UGen Compatibility Methods

Some methods to ease the development of generic ugen code.

method:: lag, lag2, lag3, lagud, lag2ud, lag3ud, slew, varlag

returns:: code::this::


subsection:: misc

method:: isValidUGenInput
returns:: false if receiver cannot be used in UGen.


subsection::Special Functions

A variety of Special Functions are supplied by the Boost C++ library. The library's
link::http://www.boost.org/doc/libs/1_66_0/libs/math/doc/html/special.html##online documentation::
 serves as the primary reference for the following functions. The methods
here match closely with those found in the source library, as do argument names.

Below you'll find descriptions of the functions and their bounds, but for
visualizing the functions, have a look in link::Guides/Tour-of-Special-Functions::.

warning::Many of the functions are only valid in certain numerical ranges. For the most part, error handling
happens in the underlying boost functions. While these errors are often obtuse, you'll usually find
a useful message at the end of the error regarding proper ranges and the erroneous value supplied.
Refer to the online documentation for more detailed descriptions, and the
link::Guides/Tour-of-Special-Functions:: for plots showing ranges and asymptotes.::


subsection:: Number Series
Take a tour of link::Guides/Tour-of-Special-Functions#Number Series#Number Series::.

method:: bernouliB2n
Returns the (2*code::n::)th Bernoulli number.

Because all odd numbered Bernoulli numbers are zero
(apart from B(1) which is -1/2) the interface will only
return the even numbered Bernoulli numbers.

method:: tangentT2n
Returns a single tangent number at code::i::. Also called a zag function.


subsection:: Gamma Functions
Take a tour of link::Guides/Tour-of-Special-Functions#Gamma Functions#Gamma Functions::.

method:: tgamma
Returns the "true gamma" of value code::z::.

method:: tgamma1pm1
Returns code::gamma(dz + 1) - 1::.

method:: lgamma
Returns the natural logarithm of the gamma function.

method:: digamma
Returns the digamma or psi function of code::z::.

Digamma is defined as the logarithmic derivative of the gamma function.

method:: trigamma
Returns the trigamma function of code::z::.

Trigamma is defined as the derivative of the digamma function.

method:: polygamma
Returns the polygamma function of code::z::.

Polygamma is defined as the code::n::'th derivative of the digamma function.

method:: tgammaRatio
Returns the ratio of gamma functions code::tgamma(a) / tgamma(b)::.

method:: tgammaDeltaRatio
Returns the ratio of gamma functions code::tgamma(a) / tgamma(a+delta)::.

method:: gammaP
Returns the normalised lower incomplete gamma function.

Requires code::a:: > 0 and code::z:: >= 0.

method:: gammaQ
Returns the normalised upper incomplete gamma function.

Requires code::a:: > 0 and code::z:: >= 0.

method:: tgammaLower
Returns the full (non-normalised) lower incomplete gamma function.

Requires code::a:: > 0 and code::z:: >= 0.

method:: tgammaUpper
Returns the full (non-normalised) upper incomplete gamma function.

Requires code::a:: > 0 and code::z:: >= 0.

method:: gammaPInv
Returns a value such that code::p = gamma_p(a, x)::.

Requires code::a:: > 0 and 1 >= code::p,q:: >= 0.

method:: gammaQInv
Returns a value x such that code::q = gamma_q(a, x)::.

Requires code::a:: > 0 and 1 >= code::p,q:: >= 0.

method:: gammaPInvA
Returns a value such that code::p = gamma_p(a, x)::.

Requires code::x:: > 0 and 1 >= code::p,q:: >= 0.

method:: gammaQInvA
Returns a value x such that code::q = gamma_q(a, x)::.

Requires code::x:: > 0 and 1 >= code::p,q:: >= 0.

method:: gammaPDerivative
Implements the partial derivative with respect to x of the incomplete gamma function (lower).

method:: gammaQDerivative
Implements the partial derivative with respect to x of the incomplete gamma function (upper).


subsection:: Factorials and Binomial Coefficients
Take a tour of link::Guides/Tour-of-Special-Functions#Factorials and Binomial Coefficients#Factorials and Binomial Coefficients::.

method:: factorial
Returns code::i!::.

warning::code::factorial:: will overflow if code::i > 170::::

method:: doubleFactorial
Returns code::i!!::.

For strong::even:: code::i::, code::i !! = i(i-2)(i-4)(i-6) ... (4)(2)::.

For strong::odd:: code::i::, code::i !! = i(i-2)(i-4)(i-6) ... (3)(1)::.

method:: risingFactorial
Returns the rising factorial of code::x:: and code::i:::

code::x(x+1)(x+2)(x+3)...(x+i-1)::

Both code::x:: and code::i:: can be negative as well as positive.

method:: fallingFactorial
Returns the falling factorial of code::x:: and code::i:::

code::x(x-1)(x-2)(x-3)...(x-i+1)::

This function is only defined for positive code::i::. Argument code::x:: can be either positive or negative.

method:: binomialCoefficient
Requires code::k:: <= code::n::.


subsection:: Beta Functions
Take a tour of link::Guides/Tour-of-Special-Functions#Beta Functions#Beta Functions::.

method:: beta
The beta function is defined by: code::tgamma(a)*tgamma(b) / tgamma(a+b)::.

method:: ibeta
Returns the normalised incomplete beta function of code::a::, code::b:: and code::x::.

Require 0 <= code::x:: <= 1, code::a,b:: >= 0, and in addition that not both code::a:: and code::b:: are zero.

method:: ibetaC
Returns the normalised complement of the incomplete beta function of code::a::, code::b:: and code::x::.

Require 0 <= code::x:: <= 1, code::a,b:: >= 0, and in addition that not both code::a:: and code::b:: are zero.

method:: betaFull
Returns the full (non-normalised) incomplete beta function of code::a::, code::b:: and code::x::.

Require 0 <= code::x:: <= 1, and code::a,b:: > 0.

method:: betaFullC
Returns the full (non-normalised) complement of the incomplete beta function of code::a::, code::b:: and code::x::.

Require 0 <= code::x:: <= 1, and code::a,b:: > 0.

method:: ibetaInv
Returns a value code::x:: such that: code::p = ibeta(a, b, x)::.

Requires code::a,b:: > 0 and 0 <= code::p:: <= 1.

method:: ibetaCInv
Returns a value code::x:: such that: code::q = ibetaC(a, b, x)::.

Requires code::a,b:: > 0 and 0 <= code::q:: <= 1.

method:: ibetaInvA
Returns a value code::a:: such that: code::p = ibeta(a, b, x)::.

Requires code::b:: > 0, 0 < code::x:: < 1, and 0 <= code::p:: <= 1.

method:: ibetaCInvA
Returns a value code::a:: such that: code::q = ibetaC(a, b, x)::.

Requires code::b:: > 0, 0 < code::x:: < 1, and 0 <= code::q:: <= 1.

method:: ibetaInvB
Returns a value code::b:: such that: code::p = ibeta(a, b, x)::.

Requires code::a:: > 0, 0 < code::x:: < 1, and 0 <= code::p:: <= 1.

method:: ibetaCInvB
Returns a value code::b:: such that: code::q = ibetaC(a, b, x)::.

Requires code::a:: > 0, 0 < code::x:: < 1, and 0 <= code::q:: <= 1.

method:: ibetaDerivative
Returns the partial derivative with respect to code::x:: of the incomplete
beta function code::ibeta(a,b,x)::.


subsection:: Error Functions
Take a tour of link::Guides/Tour-of-Special-Functions#Error Functions#Error Functions::.

method:: erf
Returns the error function of code::z::.

method:: erfC
Returns the complement of the error function of code::z::.

method:: erfInv
Returns the inverse error function of code::z::, that is a value code::x:: such that:

code::p = erf(x)::.

method:: erfCInv
Returns the inverse of the complement of the error function of code::z::,
that is a value code::x:: such that:

code::p = erfC(x)::


subsection:: Polynomials
Take a tour of link::Guides/Tour-of-Special-Functions#Polynomials#Polynomials::.

method:: legendreP
Returns the Legendre Polynomial of the first kind.

Requires -1 <= code::x:: <= 1.

method:: legendrePPrime
Returns the derivatives of the Legendre polynomials.

method:: legendrePZeros
Since the Legendre polynomials are alternatively even and odd, only the
non-negative zeros are returned. For the odd Legendre polynomials, the
first zero is always zero. The rest of the zeros are returned in increasing order.

method:: legendrePAssoc
Returns the associated Legendre polynomial of the first kind.

Requires -1 <= code::x:: <= 1.

method:: legendreQ
Returns the value of the Legendre polynomial that is the
second solution to the Legendre differential equation.

Requires -1 <= code::x:: <= 1.

method:: laguerre
Returns the value of the Laguerre Polynomial of order code::n:: at point code::x::.

method:: laguerreAssoc
Returns the Associated Laguerre polynomial of degree of dgree code::n:: and order code::m:: at point code::x::.

method:: hermite
Returns the value of the Hermite Polynomial of order code::n:: at point code::x::.

method:: chebyshevT
Returns the Chebyshev polynomials of the first kind.

method:: chebyshevU
Returns the Chebyshev polynomials of the second kind.

method:: chebyshevTPrime
Returns the derivatives of the Chebyshev polynomials of the first kind.

method:: chebyshevTZeros
Returns the roots (zeros) of the code::n::-th Chebyshev polynomial of the first kind.

method:: sphericalHarmonic
Returns the (code::Complex::) value of the Spherical Harmonic.

code::theta:: is taken as the polar (colatitudinal) coordinate within code::[0, pi]::,
and code::phi:: as the azimuthal (longitudinal) coordinate within code::[0,2pi]::.

See boost documentation for further information, including a note about the
Condon-Shortley phase term of code::(-1)^m::.

method:: sphericalHarmonicR
Returns the real part of the Spherical Harmonic.

method:: sphericalHarmonicI
Returns the imaginary part of the Spherical Harmonic.


subsection:: Bessel Functions
Take a tour of link::Guides/Tour-of-Special-Functions#Bessel Functions#Bessel Functions::.

method:: cylBesselJ
Returns the result of the Bessel functions of the first kind.

The functions return the result of code::domain_error:: whenever the result is
undefined or complex. This occurs when code::x < 0:: and code::v:: is
not an integer, or when code::x == 0:: and code::v != 0::.

method:: cylNeumann
Returns the result of the Bessel functions of the second kind.

The functions return the result of code::domain_error:: whenever the result is
undefined or complex. This occurs when code::x <= 0::.

method:: cylBesselJZero
Returns a single zero or root of the Bessel function of the first kind.

code::index:: is a 1-based index of zero of the cylindrical Bessel function of order code::v::.

method:: cylNeumannZero
Returns a single zero or root of the Neumann function (Bessel function of the second kind).

code::index:: is a 1-based index of zero of the cylindrical Neumann function of order code::v::.

method:: cylBesselI
Returns the result of the modified Bessel functions of the first kind.

method:: cylBesselK
Returns the result of the modified Bessel functions of the second kind.

Requires code::x > 0::.

method:: sphBessel
Returns the result of the spherical Bessel functions of the first kind.

Requires code::x:: > 0.

method:: sphNeumann
Returns the result of the spherical Bessel functions of the first kind.

Requires code::x:: > 0.

method:: cylBesselJPrime
Returns the first derivative with respect to x of the corresponding Bessel function.

method:: cylNeumannPrime
Returns the first derivative with respect to x of the corresponding Neumann function.

Requires code:: x > 0::.

method:: cylBesselIPrime
Returns the first derivative with respect to x of the corresponding Bessel function.

method:: cylBesselKPrime
Returns the first derivative with respect to x of the corresponding Bessel function.

Requires code:: x > 0::.

method:: sphBesselPrime
Returns the first derivative with respect to x of the corresponding Bessel function.

Requires code:: x > 0::.

method:: sphNeumannPrime
Returns the first derivative with respect to x of the corresponding Neumann function.

Requires code:: x > 0::.


subsection:: Hankel Functions
Take a tour of link::Guides/Tour-of-Special-Functions#Hankel Functions#Hankel Functions::.

method:: cylHankel1
Returns the result of the Hankel functions of the first kind.

method:: cylHankel2
Returns the result of the Hankel functions of the second kind.

method:: sphHankel1
Returns the result of the spherical Hankel functions of the first kind.

method:: sphHankel2
Returns the result of the spherical Hankel functions of the second kind.


subsection:: Airy Functions
Take a tour of link::Guides/Tour-of-Special-Functions#Airy Functions#Airy Functions::.

method:: airyAi
Returns the result of the Airy function Ai at code::x::.

method:: airyBi
Returns the result of the Airy function Bi at code::x::.

method:: airyAiPrime
Returns the derivative of the Airy function Ai at code::x::.

method:: airyBiPrime
Returns the derivative of the Airy function Bi at code::x::.

method:: airyAiZero
Returns the code::m::th zero or root of the Airy Ai function. The Airy Ai
function has an infinite number of zeros on the negative real axis.

code::m:: is 1-based.

method:: airyBiZero
Returns the code::m::th zero or root (1-based) of the Airy Bi function. The Airy Bi
function has an infinite number of zeros on the negative real axis.

code::m:: is 1-based.


subsection:: Elliptic Integrals
Take a tour of link::Guides/Tour-of-Special-Functions#Elliptic Integrals#Elliptic Integrals::.

method:: ellintRf
Returns Carlson's Elliptic Integral RF.

Requires that code::x,y >= 0::, with at most one of them zero, and that code::z >= 0::.

method:: ellintRd
Returns Carlson's Elliptic Integral RD.

Requires that code::x,y >= 0::, with at most one of them zero, and that code::z >= 0::.

method:: ellintRj
Returns Carlson's Elliptic Integral RJ.

Requires that code::x,y,z >= 0::, with at most one of them zero, and that code::p != 0::.

method:: ellintRc
Returns Carlson's Elliptic Integral RC.

Requires that code::x >= 0::, with at most one of them zero, and that code::y != 0::.

method:: ellintRg
Returns Carlson's Elliptic Integral RG.

Requires that code::x,y >= 0::.

method:: ellint1
Returns the incomplete elliptic integral of the first kind, Legendre form.

Requires code::-1 <= k <= 1::.

method:: ellint1C
Returns the complete elliptic integral of the first kind, Legendre form.

Requires code::-1 <= k <= 1::.

method:: ellint2
Returns the incomplete elliptic integral of the second kind, Legendre form.

Requires code::-1 <= k <= 1::.

method:: ellint2C
Returns the complete elliptic integral of the second kind, Legendre form.

Requires code::-1 <= k <= 1::.

method:: ellint3
Returns the incomplete elliptic integral of the third kind, Legendre form.

Requires code::-1 <= k <= 1:: and code::n < 1/sin^2(phi)::.

method:: ellint3C
Returns the complete elliptic integral of the third kind, Legendre form.

Requires code::-1 <= k <= 1:: and code::n < 1::.

method:: ellintD
Returns the incomplete elliptic integral strong::D(phi, k)::, Legendre form.

Requires code::-1 <= k <= 1::.

method:: ellintDC
Returns the complete elliptic integral strong::D(phi, k)::, Legendre form.

Requires code::-1 <= k <= 1::.

method:: jacobiZeta
Returns the result of the Jacobi Zeta Function.

Requires code::-1 <= k <= 1::.

method:: heumanLambda
Returns the result of the Heuman Lambda Function.

Requires code::-1 <= k <= 1::.


subsection:: Jacobi Elliptic Functions

Like all elliptic functions, these can be parameterised in a number of ways:

LIST::
##In terms of a parameter code::m::.
##In terms of the elliptic modulus code::k:: where code::m = k^2::.
##In terms of the modular angle code::α::, where code::m = sin2α::.
::
This implementation takes the elliptic modulus code::k:: as the parameter.
In addition the variable code::u:: is used to express an amplitude strong::φ::.
All take the elliptic modulus as the first argument - this is for alignment with the link::#Elliptic Integrals::.

Take a tour of link::Guides/Tour-of-Special-Functions#Jacobi Elliptic Functions#Jacobi Elliptic Functions::.

method:: jacobiCd

method:: jacobiCn

method:: jacobiCs

method:: jacobiDc

method:: jacobiDn

method:: jacobiDs

method:: jacobiNc

method:: jacobiNd

method:: jacobiNs

method:: jacobiSc

method:: jacobiSd

method:: jacobiSn


subsection:: Zeta Functions
Take a tour of link::Guides/Tour-of-Special-Functions#Zeta Functions#Zeta Functions::.

method:: zeta
Returns the zeta function of code::z::.

Requires code::z != 1::.


subsection:: Exponential Integrals
Take a tour of link::Guides/Tour-of-Special-Functions#Exponential Integrals#Exponential Integrals::.

method:: expintEn
Returns the exponential integral En of code::z::.

Requires that when code::n == 1::, code::z !=0::.

method:: expintEi
Returns the exponential integral of code::z::.

Requires code::z != 0::.


subsection:: Basic Functions
Take a tour of link::Guides/Tour-of-Special-Functions#Basic Functions#Basic Functions::.

method:: sinPi
Returns code::sin(x * π)::.

method:: cosPi
Returns code::cos(x * π)::.

method:: log1p
Returns the natural logarithm of code::x+1::.

method:: expm1
Returns code::e^x - 1::.

method:: cbrt
Returns the cube root of code::x::.

method:: sqrt1pm1
Returns code::sqrt(1+x) - 1::.

method:: powm1
Returns code::x^y - 1::.


subsection:: Sinus Cardinal (Sinc) and Hyperbolic Sinus Cardinal Functions
Take a tour of link::Guides/Tour-of-Special-Functions#Sinus Cardinal (Sinc) and Hyperbolic Sinus Cardinal Functions, Inverse Hyperbolic Functions#Sinus Cardinal (Sinc) and Hyperbolic Sinus Cardinal Functions::.

method:: sincPi
Returns the Sinus Cardinal of code::x::. Also known as the "sinc" function.

code::sincPi(x) = sin(x) / x::

method:: sinhcPi
Returns the Hyperbolic Sinus Cardinal of code::x::.

code::sinhcPi(x) = sinh(x) / x::


subsection:: Inverse Hyperbolic Functions
Take a tour of link::Guides/Tour-of-Special-Functions#Sinus Cardinal (Sinc) and Hyperbolic Sinus Cardinal Functions, Inverse Hyperbolic Functions#Inverse Hyperbolic Functions::.

method:: asinh
Returns the reciprocal of the hyperbolic sine function at code::x::.

method:: acosh
Returns the reciprocal of the hyperbolic cosine function at code::x::.

Requires code::x >= 1::.

method:: atanh
Returns the reciprocal of the hyperbolic sine function at code::x::.

Requires code::-1 < x < 1::.


subsection:: Owen's T Function
Take a tour of link::Guides/Tour-of-Special-Functions#Owen#Owen's T Function::.

method:: owensT
Returns the Owens T function of code::h:: and code::a::.


private:: acosh, airyAi, airyAiPrime, airyAiZero, acosh, airyAi, airyAiPrime, airyAiZero, airyBi, airyBiPrime, airyBiZero, asinh, atanh, bernouliB2n, beta, betaFull, betaFullC, binomialCoefficient, cbrt, chebyshevT, chebyshevTPrime, chebyshevTZeros, chebyshevU, cosPi, cylBesselI, cylBesselIPrime, cylBesselJ, cylBesselJPrime, cylBesselJZero, cylBesselK, cylBesselKPrime, cylHankel1, cylHankel2, cylNeumann, cylNeumannPrime, cylNeumannZero, digamma, doubleFactorial, ellint1, ellint1C, ellint2, ellint2C, ellint3, ellint3C, ellintD, ellintDC, ellintRc, ellintRd, ellintRf, ellintRg, ellintRj, erf, erfC, erfCInv, erfInv, expintEi, expintEn, expm1, factorial, fallingFactorial, gammaP, gammaPDerivative, gammaPInv, gammaPInvA, gammaQ, gammaQDerivative, gammaQInv, gammaQInvA, hermite, heumanLambda, ibeta, ibetaC, ibetaCInv, ibetaCInvA, ibetaCInvB, ibetaDerivative, ibetaInv, ibetaInvA, ibetaInvB, jacobiCd, jacobiCn, jacobiCs, jacobiDc, jacobiDn, jacobiDs, jacobiNc, jacobiNd, jacobiNs, jacobiSc, jacobiSd, jacobiSn, jacobiZeta, laguerre, laguerreAssoc, legendreP, legendrePAssoc, legendrePPrime, legendrePZeros, legendreQ, lgamma, log1p, owensT, polygamma, pow, powm1, prHermite, prLaguerreAssoc, prLegendreQ, risingFactorial, sinPi, sincPi, sinhcPi, sphBessel, sphBesselPrime, sphHankel1, sphHankel2, sphNeumann, sphNeumannPrime, sphericalHarmonic, sphericalHarmonicI, sphericalHarmonicR, sqrt1pm1, tangentT2n, tgamma, tgamma1pm1, tgammaDeltaRatio, tgammaLower, tgammaRatio, tgammaUpper, trigamma, zeta