Skip to content

Commit 9fe695d

Browse files
committed
doc: clean up definition wordings
1 parent 054aacb commit 9fe695d

9 files changed

Lines changed: 113 additions & 3 deletions

File tree

src/compute-engine/library/arithmetic.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
185185
// Functions
186186
//
187187
Abs: {
188+
description: 'Absolute value (magnitude) of a number.',
188189
wikidata: 'Q3317982', // magnitude 'Q120812 (for reals)
189190
broadcastable: true,
190191
idempotent: true,
@@ -201,6 +202,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
201202
},
202203

203204
Add: {
205+
description: 'Sum of two or more values.',
204206
wikidata: 'Q32043',
205207
associative: true,
206208
commutative: true,
@@ -266,6 +268,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
266268
},
267269

268270
Chop: {
271+
description: 'Replace tiny numeric values with zero.',
269272
associative: true,
270273
broadcastable: true,
271274
idempotent: true,
@@ -292,6 +295,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
292295
// },
293296

294297
Divide: {
298+
description: 'Quotient of a numerator and one or more denominators.',
295299
wikidata: 'Q1226939',
296300
complexity: 2500,
297301
broadcastable: true,
@@ -350,6 +354,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
350354
},
351355

352356
Exp: {
357+
description: 'Natural exponential function: e^x.',
353358
wikidata: 'Q168698',
354359
broadcastable: true,
355360
complexity: 3500,
@@ -504,6 +509,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
504509
},
505510

506511
Floor: {
512+
description: 'Rounds a number down to the nearest integer.',
507513
wikidata: 'Q56860783',
508514
complexity: 1250,
509515
broadcastable: true,
@@ -548,6 +554,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
548554
},
549555

550556
Gamma: {
557+
description: 'Gamma function, extending factorial to complex numbers.',
551558
wikidata: 'Q190573',
552559
complexity: 8000,
553560
broadcastable: true,
@@ -568,6 +575,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
568575
},
569576

570577
GammaLn: {
578+
description: 'Natural logarithm of the gamma function.',
571579
complexity: 8000,
572580
broadcastable: true,
573581
signature: '(number) -> number',
@@ -918,6 +926,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
918926
},
919927

920928
Multiply: {
929+
description: 'Product of two or more values.',
921930
wikidata: 'Q40276',
922931
associative: true,
923932
commutative: true,
@@ -1033,6 +1042,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
10331042
},
10341043

10351044
Power: {
1045+
description: 'Exponentiation: raise a base to a power.',
10361046
wikidata: 'Q33456',
10371047
broadcastable: true,
10381048
complexity: 3500,
@@ -1116,6 +1126,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
11161126
},
11171127

11181128
Rational: {
1129+
description: 'Construct a rational number from a numerator and denominator.',
11191130
complexity: 2400,
11201131

11211132
signature: '(number, integer?) -> rational',
@@ -1164,6 +1175,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
11641175
},
11651176

11661177
Root: {
1178+
description: 'n-th root of a value.',
11671179
complexity: 3200,
11681180
broadcastable: true,
11691181

@@ -1231,6 +1243,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
12311243
},
12321244

12331245
Round: {
1246+
description: 'Rounds a number to the nearest integer.',
12341247
complexity: 1250,
12351248
broadcastable: true,
12361249
signature: '(number) -> integer',
@@ -1264,6 +1277,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
12641277

12651278
/** Heaviside step function: H(x) = 0 for x < 0, 1/2 for x = 0, 1 for x > 0 */
12661279
Heaviside: {
1280+
description: 'Heaviside step function.',
12671281
complexity: 1200,
12681282
broadcastable: true,
12691283
signature: '(number) -> real',
@@ -1278,6 +1292,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
12781292
},
12791293

12801294
Sign: {
1295+
description: 'Sign of a number: -1, 0, or 1.',
12811296
complexity: 1200,
12821297
broadcastable: true,
12831298
signature: '(number) -> integer',
@@ -1362,6 +1377,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
13621377
},
13631378

13641379
Square: {
1380+
description: 'Square of a number: x^2.',
13651381
wikidata: 'Q3075175',
13661382
complexity: 3100,
13671383
broadcastable: true,
@@ -1387,6 +1403,7 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
13871403
},
13881404

13891405
Subtract: {
1406+
description: 'Difference between two or more values.',
13901407
wikidata: 'Q40754',
13911408
complexity: 1350,
13921409
broadcastable: true,
@@ -1575,9 +1592,11 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
15751592

15761593
{
15771594
PreIncrement: {
1595+
description: 'Increment a number by one.',
15781596
signature: '(number) -> number',
15791597
},
15801598
PreDecrement: {
1599+
description: 'Decrement a number by one.',
15811600
signature: '(number) -> number',
15821601
},
15831602
},

src/compute-engine/library/calculus.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ volumes
103103
// with values of the order that can be either fractional or negative
104104
//
105105
Derivative: {
106+
description: 'Derivative operator that returns a derivative function.',
106107
broadcastable: false,
107108

108109
lazy: true,
@@ -133,6 +134,8 @@ volumes
133134
// This is equivalent to `["Apply", ["Derivative", "Sin"], "x"]`
134135

135136
D: {
137+
description:
138+
'Symbolic partial derivative with respect to one or more variables.',
136139
broadcastable: false,
137140

138141
scoped: true,
@@ -204,6 +207,7 @@ volumes
204207

205208
// Evaluate a numerical approximation of a derivative at point x
206209
ND: {
210+
description: 'Numerical derivative evaluated at a point.',
207211
broadcastable: false,
208212
lazy: true,
209213
signature: '(function, at:number) -> number',
@@ -225,6 +229,7 @@ volumes
225229
},
226230

227231
Integrate: {
232+
description: 'Symbolic integral with optional bounds.',
228233
wikidata: 'Q80091',
229234
broadcastable: false,
230235

@@ -336,6 +341,7 @@ volumes
336341
},
337342

338343
NIntegrate: {
344+
description: 'Numerical approximation of a definite integral.',
339345
broadcastable: false,
340346
lazy: true,
341347
signature: '(function, limits:(tuple|symbol)?) -> number',

src/compute-engine/library/combinatorics.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { isFunction } from '../boxed-expression/type-guards';
66
export const COMBINATORICS_LIBRARY: SymbolDefinitions[] = [
77
{
88
Choose: {
9+
description:
10+
'Binomial coefficient: number of ways to choose k items from n.',
911
complexity: 1200,
1012
signature: '(n:number, m:number) -> number',
1113
type: () => 'finite_integer',

src/compute-engine/library/complex.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { isNumber } from '../boxed-expression/type-guards';
77
export const COMPLEX_LIBRARY: SymbolDefinitions[] = [
88
{
99
Real: {
10+
description: 'Real part of a complex number.',
1011
// @todo: could be extended to return an expression, i.e. ["Real", ["Add", "x", ["Complex", 0, 5]]] -> "x". Not for any operator, but at least for Add, Multiply, Negate, etc.
1112
broadcastable: true,
1213
complexity: 1200,
@@ -26,6 +27,7 @@ export const COMPLEX_LIBRARY: SymbolDefinitions[] = [
2627
},
2728
},
2829
Imaginary: {
30+
description: 'Imaginary part of a complex number.',
2931
broadcastable: true,
3032
complexity: 1200,
3133
signature: '(number) -> real',
@@ -44,6 +46,7 @@ export const COMPLEX_LIBRARY: SymbolDefinitions[] = [
4446
},
4547
},
4648
Argument: {
49+
description: 'Complex argument (phase angle) of a number.',
4750
broadcastable: true,
4851
complexity: 1200,
4952
signature: '(number) -> real',
@@ -60,6 +63,7 @@ export const COMPLEX_LIBRARY: SymbolDefinitions[] = [
6063
// For Abs (magnitude) see src/compute-engine/library/processAbs
6164

6265
AbsArg: {
66+
description: 'Tuple of magnitude and argument of a complex number.',
6367
broadcastable: true,
6468
complexity: 1200,
6569
signature: '(number) -> tuple<real, real>',
@@ -73,6 +77,7 @@ export const COMPLEX_LIBRARY: SymbolDefinitions[] = [
7377
},
7478

7579
Conjugate: {
80+
description: 'Complex conjugate of a number.',
7681
broadcastable: true,
7782
complexity: 1200,
7883
signature: '(number) -> number',
@@ -87,6 +92,7 @@ export const COMPLEX_LIBRARY: SymbolDefinitions[] = [
8792
},
8893

8994
ComplexRoots: {
95+
description: 'All n-th complex roots of a number.',
9096
broadcastable: true,
9197
complexity: 1200,
9298
signature: '(number, number) -> list<number>',

src/compute-engine/library/control-structures.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { isFunction, isSymbol, sym } from '../boxed-expression/type-guards';
1515
export const CONTROL_STRUCTURES_LIBRARY: SymbolDefinitions[] = [
1616
{
1717
Block: {
18+
description: 'Evaluate a sequence of expressions in a local scope.',
1819
lazy: true,
1920
scoped: true,
2021
signature: '(unknown*) -> unknown',
@@ -29,6 +30,7 @@ export const CONTROL_STRUCTURES_LIBRARY: SymbolDefinitions[] = [
2930
// A condition expression tests for one or more conditions of an expression
3031
// ['Condition', value, "positive"]
3132
Condition: {
33+
description: 'Test whether a value satisfies one or more conditions.',
3234
lazy: true,
3335
signature: '(value, symbol) -> boolean',
3436
evaluate: ([value, conds], { engine }) => {
@@ -44,6 +46,7 @@ export const CONTROL_STRUCTURES_LIBRARY: SymbolDefinitions[] = [
4446
},
4547

4648
If: {
49+
description: 'Conditional branch: evaluate one of two expressions.',
4750
lazy: true,
4851
signature: '(expression, expression, expression) -> any',
4952
type: ([_cond, ifTrue, ifFalse]) =>
@@ -63,6 +66,7 @@ export const CONTROL_STRUCTURES_LIBRARY: SymbolDefinitions[] = [
6366
},
6467

6568
Loop: {
69+
description: 'Evaluate a body expression over elements of a collection.',
6670
lazy: true,
6771
signature: '(body:expression, collection:expression) -> any',
6872
type: ([body]) => body.type,
@@ -73,6 +77,7 @@ export const CONTROL_STRUCTURES_LIBRARY: SymbolDefinitions[] = [
7377
},
7478

7579
Which: {
80+
description: 'Return the value for the first condition that is true.',
7681
lazy: true,
7782
signature: '(expression+) -> unknown',
7883
type: (args) => {
@@ -91,7 +96,11 @@ export const CONTROL_STRUCTURES_LIBRARY: SymbolDefinitions[] = [
9196
evaluate: (ops, options) => evaluateWhich(ops, options),
9297
},
9398

94-
FixedPoint: { lazy: true, signature: '(any) -> unknown' },
99+
FixedPoint: {
100+
description: 'Iterate a function until a fixed point is reached.',
101+
lazy: true,
102+
signature: '(any) -> unknown',
103+
},
95104
},
96105
];
97106

0 commit comments

Comments
 (0)