smath 1.13.1 → 1.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -148,6 +148,7 @@ switch (func) {
148
148
  break;
149
149
  }
150
150
  case ('tohex'): {
151
+ console.warn('toHex() is deprecated!');
151
152
  console.log(SMath.toHex(nums[0], (_e = nums[1]) !== null && _e !== void 0 ? _e : 0));
152
153
  break;
153
154
  }
package/dist/index.js CHANGED
@@ -55,10 +55,8 @@ exports.toHex = toHex;
55
55
  * @param epsilon Maximum absolute error
56
56
  * @returns True if `a` is approximately `b`
57
57
  * @example
58
- * ```js
59
58
  * const b1 = SMath.approx(1 / 3, 0.33, 1e-6), // false
60
59
  * b2 = SMath.approx(1 / 3, 0.33, 1e-2); // true
61
- * ```
62
60
  */
63
61
  function approx(a, b, epsilon) {
64
62
  if (epsilon === void 0) { epsilon = 1e-6; }
@@ -71,10 +69,8 @@ function approx(a, b, epsilon) {
71
69
  * @param max The maximum value of the range
72
70
  * @returns A clamped number
73
71
  * @example
74
- * ```js
75
72
  * const n1 = SMath.clamp(5, 0, 10), // 5
76
73
  * n2 = SMath.clamp(-2, 0, 10); // 0
77
- * ```
78
74
  */
79
75
  function clamp(n, min, max) {
80
76
  if (n < min) {
@@ -92,9 +88,7 @@ function clamp(n, min, max) {
92
88
  * @param max The maximum value in the range
93
89
  * @returns A normalized value
94
90
  * @example
95
- * ```js
96
91
  * const y = SMath.normalize(18, 9, 99); // 0.1
97
- * ```
98
92
  */
99
93
  function normalize(n, min, max) {
100
94
  if (min === max) {
@@ -109,9 +103,7 @@ function normalize(n, min, max) {
109
103
  * @param max The maximum value in the range
110
104
  * @returns A value within the number range
111
105
  * @example
112
- * ```js
113
106
  * const y = SMath.expand(0.25, 4, 6); // 4.5
114
- * ```
115
107
  */
116
108
  function expand(n, min, max) {
117
109
  return (max - min) * n + min;
@@ -125,10 +117,8 @@ function expand(n, min, max) {
125
117
  * @param max2 The maximum value for the final range
126
118
  * @returns A translated number in the final range
127
119
  * @example
128
- * ```js
129
120
  * const C = 20,
130
121
  * F = SMath.translate(C, 0, 100, 32, 212); // 68
131
- * ```
132
122
  */
133
123
  function translate(n, min1, max1, min2, max2) {
134
124
  return expand(normalize(n, min1, max1), min2, max2);
@@ -140,10 +130,8 @@ function translate(n, min1, max1, min2, max2) {
140
130
  * @param count The number of values in the space
141
131
  * @returns The linear space as an array of numbers
142
132
  * @example
143
- * ```js
144
133
  * const space = SMath.linspace(1, 5, 6);
145
134
  * // [ 1, 1.8, 2.6, 3.4, 4.2, 5 ]
146
- * ```
147
135
  */
148
136
  function linspace(min, max, count) {
149
137
  var space = [];
@@ -159,10 +147,8 @@ function linspace(min, max, count) {
159
147
  * @param count The number of values in the space
160
148
  * @returns The logarithmic space as an array of numbers
161
149
  * @example
162
- * ```js
163
150
  * const space = SMath.logspace(0, 2, 5);
164
151
  * // [ 1, 3.2, 10, 31.6, 100 ]
165
- * ```
166
152
  */
167
153
  function logspace(min, max, count) {
168
154
  return linspace(min, max, count).map(function (n) { return Math.pow(10, n); });
@@ -172,9 +158,7 @@ function logspace(min, max, count) {
172
158
  * @param n Any positive integer
173
159
  * @returns `n!`
174
160
  * @example
175
- * ```js
176
161
  * const y = SMath.factorial(5); // 120
177
- * ```
178
162
  */
179
163
  function factorial(n) {
180
164
  if (n < 0 || (n | 0) !== n) {
@@ -195,9 +179,7 @@ function factorial(n) {
195
179
  * @param n Any positive integer
196
180
  * @returns The array of prime factors
197
181
  * @example
198
- * ```js
199
182
  * const y = SMath.factors(12); // [ 2, 2, 3 ]
200
- * ```
201
183
  */
202
184
  function factors(n) {
203
185
  if (n < 0 || (n | 0) !== n) {
@@ -226,12 +208,12 @@ function factors(n) {
226
208
  * @param base Any base to round to
227
209
  * @returns `n` rounded to the nearest multiple of `base`
228
210
  * @example
229
- * ```js
230
211
  * const y = SMath.round2(Math.PI, 0.2); // 3.2
231
- * ```
232
212
  */
233
213
  function round2(n, base) {
234
- return base ? base * Math.round(n / base) : n;
214
+ var rounded = base ? base * Math.round(n / base) : n;
215
+ var precision = 10; // Removes precision errors
216
+ return parseFloat(rounded.toFixed(precision));
235
217
  }
236
218
  /**
237
219
  * Calculate the relative normalized error or deviation from any
@@ -244,9 +226,7 @@ function round2(n, base) {
244
226
  * @param actual The accepted or theoretical value
245
227
  * @returns The relative (normalized) error
246
228
  * @example
247
- * ```js
248
229
  * const e = SMath.error(22.5, 25); // -0.1
249
- * ```
250
230
  */
251
231
  function error(experimental, actual) {
252
232
  return (experimental - actual) / actual;
@@ -257,9 +237,7 @@ function error(experimental, actual) {
257
237
  * @param data An array of numeric inputs
258
238
  * @returns The sum total
259
239
  * @example
260
- * ```js
261
240
  * const y = SMath.sum([1, 2, 3]); // 6
262
- * ```
263
241
  */
264
242
  function sum(data) {
265
243
  return data.reduce(function (a, b) { return a + b; }, 0);
@@ -270,9 +248,7 @@ function sum(data) {
270
248
  * @param data An array of numeric inputs
271
249
  * @returns The product
272
250
  * @example
273
- * ```js
274
251
  * const y = SMath.prod([2, 2, 3, 5]); // 60
275
- * ```
276
252
  */
277
253
  function prod(data) {
278
254
  return data.reduce(function (a, b) { return a * b; }, 1);
@@ -282,9 +258,7 @@ function prod(data) {
282
258
  * @param data An array of numeric inputs
283
259
  * @returns The average, or mean
284
260
  * @example
285
- * ```js
286
261
  * const y = SMath.avg([1, 2, 4, 4]); // 2.75
287
- * ```
288
262
  */
289
263
  function avg(data) {
290
264
  return sum(data) / data.length;
@@ -294,9 +268,7 @@ function avg(data) {
294
268
  * @param data An array of numeric inputs
295
269
  * @returns The median of the dataset
296
270
  * @example
297
- * ```js
298
271
  * const y = SMath.median([2, 5, 3, 1]); // 2.5
299
- * ```
300
272
  */
301
273
  function median(data) {
302
274
  data.sort(function (a, b) { return a - b; });
@@ -310,9 +282,7 @@ function median(data) {
310
282
  * @param data An array of numeric inputs
311
283
  * @returns The population variance
312
284
  * @example
313
- * ```js
314
285
  * const y = SMath.varp([1, 2, 4, 4]); // 1.6875
315
- * ```
316
286
  */
317
287
  function varp(data) {
318
288
  var mean = avg(data), squares = data.map(function (x) { return Math.pow((x - mean), 2); });
@@ -323,9 +293,7 @@ function varp(data) {
323
293
  * @param data An array of numeric inputs
324
294
  * @returns The sample variance
325
295
  * @example
326
- * ```js
327
296
  * const y = SMath.vars([1, 2, 4, 4]); // 2.25
328
- * ```
329
297
  */
330
298
  function vars(data) {
331
299
  var mean = avg(data), squares = data.map(function (x) { return Math.pow((x - mean), 2); });
@@ -336,9 +304,7 @@ function vars(data) {
336
304
  * @param data An array of numeric inputs
337
305
  * @returns The population standard deviation
338
306
  * @example
339
- * ```js
340
307
  * const y = SMath.stdevp([1, 2, 3, 4]); // 1.118...
341
- * ```
342
308
  */
343
309
  function stdevp(data) {
344
310
  return Math.sqrt(varp(data));
@@ -348,9 +314,7 @@ function stdevp(data) {
348
314
  * @param data An array of numeric inputs
349
315
  * @returns The sample standard deviation
350
316
  * @example
351
- * ```js
352
317
  * const y = SMath.stdevs([1, 2, 3, 4]); // 1.29...
353
- * ```
354
318
  */
355
319
  function stdevs(data) {
356
320
  return Math.sqrt(vars(data));
@@ -361,9 +325,7 @@ function stdevs(data) {
361
325
  * @param max The maximum bound
362
326
  * @returns A random float within the range
363
327
  * @example
364
- * ```js
365
328
  * const y = SMath.runif(-2, 2); // 0.376...
366
- * ```
367
329
  */
368
330
  function runif(min, max) {
369
331
  return expand(Math.random(), min, max);
@@ -374,9 +336,7 @@ function runif(min, max) {
374
336
  * @param max The maximum bound (inclusive)
375
337
  * @returns A random integer within the range
376
338
  * @example
377
- * ```js
378
339
  * const y = SMath.rint(-4, 3); // -4
379
- * ```
380
340
  */
381
341
  function rint(min, max) {
382
342
  min |= 0;
@@ -395,9 +355,7 @@ function rint(min, max) {
395
355
  * @param stdev The standard deviation of the population
396
356
  * @returns A random float
397
357
  * @example
398
- * ```js
399
358
  * const y = SMath.rnorm(2, 3); // 1.627...
400
- * ```
401
359
  */
402
360
  function rnorm(mean, stdev) {
403
361
  if (mean === void 0) { mean = 0; }
@@ -411,9 +369,7 @@ function rnorm(mean, stdev) {
411
369
  * @param stdev The standard deviation of the population
412
370
  * @returns A population of random floats
413
371
  * @example
414
- * ```js
415
372
  * const dataset = SMath.rdist(3); // [ 1.051..., -0.779..., -2.254... ]
416
- * ```
417
373
  */
418
374
  function rdist(count, mean, stdev) {
419
375
  if (mean === void 0) { mean = 0; }
@@ -429,9 +385,7 @@ function rdist(count, mean, stdev) {
429
385
  * @param stack An array of arbitrary elements
430
386
  * @returns The `stack` array in a random order
431
387
  * @example
432
- * ```js
433
388
  * const shuffled = SMath.shuffle(['a', 'b', 'c']); // [ 'c', 'a', 'b' ]
434
- * ```
435
389
  */
436
390
  function shuffle(stack) {
437
391
  var rawData = [];
@@ -450,9 +404,7 @@ function shuffle(stack) {
450
404
  * @param discontinuity_cutoff The discontinuity cutoff
451
405
  * @returns `lim(f(x->x))`
452
406
  * @example
453
- * ```js
454
407
  * const y = SMath.lim(Math.log, 0); // -Infinity
455
- * ```
456
408
  */
457
409
  function lim(f, x, h, discontinuity_cutoff) {
458
410
  if (h === void 0) { h = 1e-3; }
@@ -522,9 +474,7 @@ function lim(f, x, h, discontinuity_cutoff) {
522
474
  * @param h Small step value
523
475
  * @returns `f'(x)`
524
476
  * @example
525
- * ```js
526
477
  * const y = SMath.differentiate(x => 3 * x ** 2, 2); // 12
527
- * ```
528
478
  */
529
479
  function differentiate(f, x, h) {
530
480
  if (h === void 0) { h = 1e-3; }
@@ -538,9 +488,7 @@ function differentiate(f, x, h) {
538
488
  * @param Ndx The number of rectangles to compute
539
489
  * @returns `F(b)-F(a)`
540
490
  * @example
541
- * ```js
542
491
  * const y = SMath.integrate(x => 3 * x ** 2, 1, 2); // 7
543
- * ```
544
492
  */
545
493
  function integrate(f, a, b, Ndx) {
546
494
  if (Ndx === void 0) { Ndx = 1e3; }
@@ -553,9 +501,7 @@ function integrate(f, a, b, Ndx) {
553
501
  * @param epsilon Maximum absolute error
554
502
  * @returns An object containing the fraction's numerator and denominator
555
503
  * @example
556
- * ```js
557
504
  * const frac = SMath.rat(0.625); // { num: 5, den: 8 }
558
- * ```
559
505
  */
560
506
  function rat(n, epsilon) {
561
507
  if (epsilon === void 0) { epsilon = 1e-6; }
@@ -579,9 +525,7 @@ function rat(n, epsilon) {
579
525
  * @param epsilon Maximum absolute error
580
526
  * @returns An object containing the whole part and fraction numerator and denominator
581
527
  * @example
582
- * ```js
583
528
  * const frac = SMath.mixed(-8 / 6); // { whole: -1, num: 1, den: 3 }
584
- * ```
585
529
  */
586
530
  function mixed(n, epsilon) {
587
531
  if (epsilon === void 0) { epsilon = 1e-6; }
@@ -593,9 +537,8 @@ function mixed(n, epsilon) {
593
537
  * @param length The minimum number of digits to show
594
538
  * @returns The number `n` converted to hexadecimal
595
539
  * @example
596
- * ```js
597
540
  * const hex = SMath.toHex(10, 2); // '0A'
598
- * ```
541
+ * @deprecated Use native `number.toString(16)`
599
542
  */
600
543
  function toHex(n, length) {
601
544
  if (length === void 0) { length = 0; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smath",
3
- "version": "1.13.1",
3
+ "version": "1.13.3",
4
4
  "description": "Small math function library",
5
5
  "homepage": "https://npm.nicfv.com/",
6
6
  "bin": "dist/bin.js",
package/types/index.d.ts CHANGED
@@ -12,10 +12,8 @@
12
12
  * @param epsilon Maximum absolute error
13
13
  * @returns True if `a` is approximately `b`
14
14
  * @example
15
- * ```js
16
15
  * const b1 = SMath.approx(1 / 3, 0.33, 1e-6), // false
17
16
  * b2 = SMath.approx(1 / 3, 0.33, 1e-2); // true
18
- * ```
19
17
  */
20
18
  export declare function approx(a: number, b: number, epsilon?: number): boolean;
21
19
  /**
@@ -25,10 +23,8 @@ export declare function approx(a: number, b: number, epsilon?: number): boolean;
25
23
  * @param max The maximum value of the range
26
24
  * @returns A clamped number
27
25
  * @example
28
- * ```js
29
26
  * const n1 = SMath.clamp(5, 0, 10), // 5
30
27
  * n2 = SMath.clamp(-2, 0, 10); // 0
31
- * ```
32
28
  */
33
29
  export declare function clamp(n: number, min: number, max: number): number;
34
30
  /**
@@ -38,9 +34,7 @@ export declare function clamp(n: number, min: number, max: number): number;
38
34
  * @param max The maximum value in the range
39
35
  * @returns A normalized value
40
36
  * @example
41
- * ```js
42
37
  * const y = SMath.normalize(18, 9, 99); // 0.1
43
- * ```
44
38
  */
45
39
  export declare function normalize(n: number, min: number, max: number): number;
46
40
  /**
@@ -50,9 +44,7 @@ export declare function normalize(n: number, min: number, max: number): number;
50
44
  * @param max The maximum value in the range
51
45
  * @returns A value within the number range
52
46
  * @example
53
- * ```js
54
47
  * const y = SMath.expand(0.25, 4, 6); // 4.5
55
- * ```
56
48
  */
57
49
  export declare function expand(n: number, min: number, max: number): number;
58
50
  /**
@@ -64,10 +56,8 @@ export declare function expand(n: number, min: number, max: number): number;
64
56
  * @param max2 The maximum value for the final range
65
57
  * @returns A translated number in the final range
66
58
  * @example
67
- * ```js
68
59
  * const C = 20,
69
60
  * F = SMath.translate(C, 0, 100, 32, 212); // 68
70
- * ```
71
61
  */
72
62
  export declare function translate(n: number, min1: number, max1: number, min2: number, max2: number): number;
73
63
  /**
@@ -77,10 +67,8 @@ export declare function translate(n: number, min1: number, max1: number, min2: n
77
67
  * @param count The number of values in the space
78
68
  * @returns The linear space as an array of numbers
79
69
  * @example
80
- * ```js
81
70
  * const space = SMath.linspace(1, 5, 6);
82
71
  * // [ 1, 1.8, 2.6, 3.4, 4.2, 5 ]
83
- * ```
84
72
  */
85
73
  export declare function linspace(min: number, max: number, count: number): number[];
86
74
  /**
@@ -90,10 +78,8 @@ export declare function linspace(min: number, max: number, count: number): numbe
90
78
  * @param count The number of values in the space
91
79
  * @returns The logarithmic space as an array of numbers
92
80
  * @example
93
- * ```js
94
81
  * const space = SMath.logspace(0, 2, 5);
95
82
  * // [ 1, 3.2, 10, 31.6, 100 ]
96
- * ```
97
83
  */
98
84
  export declare function logspace(min: number, max: number, count: number): number[];
99
85
  /**
@@ -101,9 +87,7 @@ export declare function logspace(min: number, max: number, count: number): numbe
101
87
  * @param n Any positive integer
102
88
  * @returns `n!`
103
89
  * @example
104
- * ```js
105
90
  * const y = SMath.factorial(5); // 120
106
- * ```
107
91
  */
108
92
  export declare function factorial(n: number): number;
109
93
  /**
@@ -111,9 +95,7 @@ export declare function factorial(n: number): number;
111
95
  * @param n Any positive integer
112
96
  * @returns The array of prime factors
113
97
  * @example
114
- * ```js
115
98
  * const y = SMath.factors(12); // [ 2, 2, 3 ]
116
- * ```
117
99
  */
118
100
  export declare function factors(n: number): number[];
119
101
  /**
@@ -123,9 +105,7 @@ export declare function factors(n: number): number[];
123
105
  * @param base Any base to round to
124
106
  * @returns `n` rounded to the nearest multiple of `base`
125
107
  * @example
126
- * ```js
127
108
  * const y = SMath.round2(Math.PI, 0.2); // 3.2
128
- * ```
129
109
  */
130
110
  export declare function round2(n: number, base: number): number;
131
111
  /**
@@ -139,9 +119,7 @@ export declare function round2(n: number, base: number): number;
139
119
  * @param actual The accepted or theoretical value
140
120
  * @returns The relative (normalized) error
141
121
  * @example
142
- * ```js
143
122
  * const e = SMath.error(22.5, 25); // -0.1
144
- * ```
145
123
  */
146
124
  export declare function error(experimental: number, actual: number): number;
147
125
  /**
@@ -150,9 +128,7 @@ export declare function error(experimental: number, actual: number): number;
150
128
  * @param data An array of numeric inputs
151
129
  * @returns The sum total
152
130
  * @example
153
- * ```js
154
131
  * const y = SMath.sum([1, 2, 3]); // 6
155
- * ```
156
132
  */
157
133
  export declare function sum(data: number[]): number;
158
134
  /**
@@ -161,9 +137,7 @@ export declare function sum(data: number[]): number;
161
137
  * @param data An array of numeric inputs
162
138
  * @returns The product
163
139
  * @example
164
- * ```js
165
140
  * const y = SMath.prod([2, 2, 3, 5]); // 60
166
- * ```
167
141
  */
168
142
  export declare function prod(data: number[]): number;
169
143
  /**
@@ -171,9 +145,7 @@ export declare function prod(data: number[]): number;
171
145
  * @param data An array of numeric inputs
172
146
  * @returns The average, or mean
173
147
  * @example
174
- * ```js
175
148
  * const y = SMath.avg([1, 2, 4, 4]); // 2.75
176
- * ```
177
149
  */
178
150
  export declare function avg(data: number[]): number;
179
151
  /**
@@ -181,9 +153,7 @@ export declare function avg(data: number[]): number;
181
153
  * @param data An array of numeric inputs
182
154
  * @returns The median of the dataset
183
155
  * @example
184
- * ```js
185
156
  * const y = SMath.median([2, 5, 3, 1]); // 2.5
186
- * ```
187
157
  */
188
158
  export declare function median(data: number[]): number;
189
159
  /**
@@ -191,9 +161,7 @@ export declare function median(data: number[]): number;
191
161
  * @param data An array of numeric inputs
192
162
  * @returns The population variance
193
163
  * @example
194
- * ```js
195
164
  * const y = SMath.varp([1, 2, 4, 4]); // 1.6875
196
- * ```
197
165
  */
198
166
  export declare function varp(data: number[]): number;
199
167
  /**
@@ -201,9 +169,7 @@ export declare function varp(data: number[]): number;
201
169
  * @param data An array of numeric inputs
202
170
  * @returns The sample variance
203
171
  * @example
204
- * ```js
205
172
  * const y = SMath.vars([1, 2, 4, 4]); // 2.25
206
- * ```
207
173
  */
208
174
  export declare function vars(data: number[]): number;
209
175
  /**
@@ -211,9 +177,7 @@ export declare function vars(data: number[]): number;
211
177
  * @param data An array of numeric inputs
212
178
  * @returns The population standard deviation
213
179
  * @example
214
- * ```js
215
180
  * const y = SMath.stdevp([1, 2, 3, 4]); // 1.118...
216
- * ```
217
181
  */
218
182
  export declare function stdevp(data: number[]): number;
219
183
  /**
@@ -221,9 +185,7 @@ export declare function stdevp(data: number[]): number;
221
185
  * @param data An array of numeric inputs
222
186
  * @returns The sample standard deviation
223
187
  * @example
224
- * ```js
225
188
  * const y = SMath.stdevs([1, 2, 3, 4]); // 1.29...
226
- * ```
227
189
  */
228
190
  export declare function stdevs(data: number[]): number;
229
191
  /**
@@ -232,9 +194,7 @@ export declare function stdevs(data: number[]): number;
232
194
  * @param max The maximum bound
233
195
  * @returns A random float within the range
234
196
  * @example
235
- * ```js
236
197
  * const y = SMath.runif(-2, 2); // 0.376...
237
- * ```
238
198
  */
239
199
  export declare function runif(min: number, max: number): number;
240
200
  /**
@@ -243,9 +203,7 @@ export declare function runif(min: number, max: number): number;
243
203
  * @param max The maximum bound (inclusive)
244
204
  * @returns A random integer within the range
245
205
  * @example
246
- * ```js
247
206
  * const y = SMath.rint(-4, 3); // -4
248
- * ```
249
207
  */
250
208
  export declare function rint(min: number, max: number): number;
251
209
  /**
@@ -254,9 +212,7 @@ export declare function rint(min: number, max: number): number;
254
212
  * @param stdev The standard deviation of the population
255
213
  * @returns A random float
256
214
  * @example
257
- * ```js
258
215
  * const y = SMath.rnorm(2, 3); // 1.627...
259
- * ```
260
216
  */
261
217
  export declare function rnorm(mean?: number, stdev?: number): number;
262
218
  /**
@@ -266,9 +222,7 @@ export declare function rnorm(mean?: number, stdev?: number): number;
266
222
  * @param stdev The standard deviation of the population
267
223
  * @returns A population of random floats
268
224
  * @example
269
- * ```js
270
225
  * const dataset = SMath.rdist(3); // [ 1.051..., -0.779..., -2.254... ]
271
- * ```
272
226
  */
273
227
  export declare function rdist(count: number, mean?: number, stdev?: number): number[];
274
228
  /**
@@ -276,9 +230,7 @@ export declare function rdist(count: number, mean?: number, stdev?: number): num
276
230
  * @param stack An array of arbitrary elements
277
231
  * @returns The `stack` array in a random order
278
232
  * @example
279
- * ```js
280
233
  * const shuffled = SMath.shuffle(['a', 'b', 'c']); // [ 'c', 'a', 'b' ]
281
- * ```
282
234
  */
283
235
  export declare function shuffle<T>(stack: T[]): T[];
284
236
  /**
@@ -290,9 +242,7 @@ export declare function shuffle<T>(stack: T[]): T[];
290
242
  * @param discontinuity_cutoff The discontinuity cutoff
291
243
  * @returns `lim(f(x->x))`
292
244
  * @example
293
- * ```js
294
245
  * const y = SMath.lim(Math.log, 0); // -Infinity
295
- * ```
296
246
  */
297
247
  export declare function lim(f: (x: number) => number, x: number, h?: number, discontinuity_cutoff?: number): number;
298
248
  /**
@@ -302,9 +252,7 @@ export declare function lim(f: (x: number) => number, x: number, h?: number, dis
302
252
  * @param h Small step value
303
253
  * @returns `f'(x)`
304
254
  * @example
305
- * ```js
306
255
  * const y = SMath.differentiate(x => 3 * x ** 2, 2); // 12
307
- * ```
308
256
  */
309
257
  export declare function differentiate(f: (x: number) => number, x: number, h?: number): number;
310
258
  /**
@@ -315,9 +263,7 @@ export declare function differentiate(f: (x: number) => number, x: number, h?: n
315
263
  * @param Ndx The number of rectangles to compute
316
264
  * @returns `F(b)-F(a)`
317
265
  * @example
318
- * ```js
319
266
  * const y = SMath.integrate(x => 3 * x ** 2, 1, 2); // 7
320
- * ```
321
267
  */
322
268
  export declare function integrate(f: (x: number) => number, a: number, b: number, Ndx?: number): number;
323
269
  /**
@@ -327,9 +273,7 @@ export declare function integrate(f: (x: number) => number, a: number, b: number
327
273
  * @param epsilon Maximum absolute error
328
274
  * @returns An object containing the fraction's numerator and denominator
329
275
  * @example
330
- * ```js
331
276
  * const frac = SMath.rat(0.625); // { num: 5, den: 8 }
332
- * ```
333
277
  */
334
278
  export declare function rat(n: number, epsilon?: number): {
335
279
  num: number;
@@ -343,9 +287,7 @@ export declare function rat(n: number, epsilon?: number): {
343
287
  * @param epsilon Maximum absolute error
344
288
  * @returns An object containing the whole part and fraction numerator and denominator
345
289
  * @example
346
- * ```js
347
290
  * const frac = SMath.mixed(-8 / 6); // { whole: -1, num: 1, den: 3 }
348
- * ```
349
291
  */
350
292
  export declare function mixed(n: number, epsilon?: number): {
351
293
  whole: number;
@@ -358,8 +300,7 @@ export declare function mixed(n: number, epsilon?: number): {
358
300
  * @param length The minimum number of digits to show
359
301
  * @returns The number `n` converted to hexadecimal
360
302
  * @example
361
- * ```js
362
303
  * const hex = SMath.toHex(10, 2); // '0A'
363
- * ```
304
+ * @deprecated Use native `number.toString(16)`
364
305
  */
365
306
  export declare function toHex(n: number, length?: number): string;