@cortex-js/compute-engine 0.7.0 → 0.8.0
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/compute-engine.esm.js +746 -671
- package/dist/compute-engine.min.esm.js +2 -2
- package/dist/compute-engine.min.js +2 -2
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.js +2 -2
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +65 -62
- package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +38 -31
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +4 -2
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +6 -6
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +6 -6
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +3 -3
- package/dist/types/compute-engine/compute-engine.d.ts +2 -3
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/public.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-add.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +1 -1
- package/dist/types/compute-engine/library/domains.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-decimal.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/public.d.ts +514 -351
- package/dist/types/compute-engine/rules.d.ts +1 -1
- package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/math-json-format.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +1 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.8.0 */
|
|
2
2
|
* The most important classes are {@link ComputeEngine} and
|
|
3
3
|
* {@link BoxedExpression}.
|
|
4
4
|
*
|
|
@@ -231,171 +231,383 @@ export interface BoxedExpression {
|
|
|
231
231
|
readonly engine: IComputeEngine;
|
|
232
232
|
/** From `Object.valueOf()`, return a primitive value for the expression.
|
|
233
233
|
*
|
|
234
|
-
* If the expression is a machine number, or a Decimal that can be
|
|
234
|
+
* If the expression is a machine number, or a Decimal or rational that can be
|
|
235
235
|
* converted to a machine number, return a `number`.
|
|
236
236
|
*
|
|
237
|
-
* If the expression is a rational number, return `[number, number]`.
|
|
238
|
-
*
|
|
239
237
|
* If the expression is a symbol, return the name of the symbol as a `string`.
|
|
240
238
|
*
|
|
241
239
|
* Otherwise return a LaTeX representation of the expression.
|
|
242
240
|
*
|
|
243
|
-
* @category
|
|
241
|
+
* @category Primitive Methods
|
|
244
242
|
*/
|
|
245
|
-
valueOf(): number | string |
|
|
243
|
+
valueOf(): number | string | boolean;
|
|
246
244
|
/** From `Object.toString()`, return a LaTeX representation of the expression.
|
|
247
245
|
*
|
|
248
|
-
*
|
|
246
|
+
* Used when coercing a `BoxedExpression` to a `String`.
|
|
247
|
+
*
|
|
248
|
+
* @category Primitive Methods
|
|
249
249
|
*/
|
|
250
250
|
toString(): string;
|
|
251
|
-
/**
|
|
251
|
+
/** Similar to`expr.valueOf()` but includes a hint.
|
|
252
|
+
* @category Primitive Methods
|
|
253
|
+
*/
|
|
254
|
+
[Symbol.toPrimitive](hint: 'number' | 'string' | 'default'): number | string | null;
|
|
255
|
+
/** Used by `JSON.stringify()` to serialize this object to JSON.
|
|
256
|
+
*
|
|
257
|
+
* Method version of `expr.json`.
|
|
258
|
+
*
|
|
259
|
+
* @category Primitive Methods
|
|
260
|
+
*/
|
|
261
|
+
toJSON(): Expression;
|
|
262
|
+
/** If `true`, this expression is in a canonical form.
|
|
263
|
+
*
|
|
264
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
265
|
+
*
|
|
266
|
+
*/
|
|
267
|
+
get isCanonical(): boolean;
|
|
268
|
+
/** For internal use only, set when a canonical expression is created.
|
|
269
|
+
* @internal
|
|
270
|
+
*/
|
|
271
|
+
set isCanonical(val: boolean);
|
|
272
|
+
/** MathJSON representation of this expression.
|
|
273
|
+
*
|
|
274
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
252
275
|
*
|
|
253
|
-
* @category Object Methods
|
|
254
276
|
*/
|
|
255
|
-
|
|
277
|
+
readonly json: Expression;
|
|
256
278
|
/** From `Object.is()`. Equivalent to `BoxedExpression.isSame()`
|
|
257
279
|
*
|
|
258
|
-
* @category
|
|
280
|
+
* @category Primitive Methods
|
|
259
281
|
*
|
|
260
282
|
*/
|
|
261
283
|
is(rhs: unknown): boolean;
|
|
262
284
|
/** @internal */
|
|
263
|
-
|
|
264
|
-
/**
|
|
285
|
+
readonly hash: number;
|
|
286
|
+
/** LaTeX representation of this expression.
|
|
265
287
|
*
|
|
266
|
-
*
|
|
267
|
-
readonly description: string[];
|
|
268
|
-
/** An optional URL pointing to more information about the symbol or function head */
|
|
269
|
-
readonly url: string;
|
|
270
|
-
/** All boxed expressions have a head.
|
|
288
|
+
* The serialization can be customized with `ComputeEngine.latexOptions`
|
|
271
289
|
*
|
|
272
|
-
*
|
|
290
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
273
291
|
*
|
|
274
|
-
* If the head expression can be represented as a string, it is returned
|
|
275
|
-
* as a string.
|
|
276
292
|
*/
|
|
277
|
-
get
|
|
293
|
+
get latex(): LatexString;
|
|
278
294
|
/**
|
|
279
|
-
* If `this.isPure` is `true`, this is a synonym for `this.evaluate()`.
|
|
280
|
-
* Otherwise, it returns `undefined`.
|
|
281
|
-
*/
|
|
282
|
-
get value(): BoxedExpression | undefined;
|
|
283
|
-
/** Only the value of variables can be changed (symbols that are not constants) */
|
|
284
|
-
set value(value: BoxedExpression | number | undefined);
|
|
285
|
-
/** An approximation of the value of this expression. Floating-point
|
|
286
|
-
* operations may be performed.
|
|
287
295
|
*
|
|
288
|
-
*
|
|
296
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
297
|
+
* @internal
|
|
289
298
|
*/
|
|
290
|
-
|
|
291
|
-
/** If
|
|
292
|
-
*
|
|
293
|
-
* If false, the value of the expression may change, if the
|
|
294
|
-
* value of other expression changes or for other reasons.
|
|
299
|
+
set latex(val: string);
|
|
300
|
+
/** If this expression is a symbol, return the name of the symbol as a string.
|
|
301
|
+
* Otherwise, return `null`.
|
|
295
302
|
*
|
|
296
|
-
*
|
|
297
|
-
|
|
303
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
304
|
+
|
|
305
|
+
* @category Symbol Expression
|
|
298
306
|
*
|
|
299
|
-
* As an example, the `Random` function is not pure.
|
|
300
307
|
*/
|
|
301
|
-
|
|
302
|
-
/** True if the expression is a free variable, that is a symbol with no value */
|
|
303
|
-
get isFree(): boolean;
|
|
304
|
-
/** True if the expression is a constant, that is a symbol with an immutable value */
|
|
305
|
-
get isConstant(): boolean;
|
|
308
|
+
readonly symbol: string | null;
|
|
306
309
|
/**
|
|
307
|
-
* If
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
* Functions and symbols are not literals.
|
|
310
|
+
* If this is the `Nothing` symbol, return `true`.
|
|
311
|
+
*
|
|
312
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
311
313
|
*/
|
|
312
|
-
|
|
313
|
-
/** If
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
*
|
|
314
|
+
readonly isNothing: boolean;
|
|
315
|
+
/** If this expression is a string, return the value of the string.
|
|
316
|
+
* Otherwise, return `null`.
|
|
317
|
+
*
|
|
318
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
319
|
+
|
|
320
|
+
* @category String Expression
|
|
321
|
+
*
|
|
322
|
+
*/
|
|
323
|
+
readonly string: string | null;
|
|
324
|
+
/** All the subexpressions matching the head
|
|
325
|
+
*
|
|
326
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
327
|
+
*
|
|
317
328
|
*/
|
|
318
|
-
set isCanonical(val: boolean);
|
|
319
|
-
/** All the subexpressions matching the head */
|
|
320
329
|
getSubexpressions(head: string): BoxedExpression[];
|
|
321
|
-
/** All the subexpressions in this expression, recursively
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
/**
|
|
330
|
+
/** All the subexpressions in this expression, recursively
|
|
331
|
+
*
|
|
332
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
333
|
+
*
|
|
334
|
+
*/
|
|
335
|
+
readonly subexpressions: BoxedExpression[];
|
|
336
|
+
/** All the symbols in the expression, recursively
|
|
337
|
+
*
|
|
338
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
339
|
+
*
|
|
340
|
+
*/
|
|
341
|
+
readonly symbols: BoxedExpression[];
|
|
342
|
+
/** All the `["Error"]` subexpressions
|
|
343
|
+
*
|
|
344
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
345
|
+
*
|
|
346
|
+
*/
|
|
347
|
+
readonly errors: BoxedExpression[];
|
|
348
|
+
/** All boxed expressions have a head.
|
|
349
|
+
*
|
|
350
|
+
* If not a function this can be `Symbol`, `String`, `Number` or `Dictionary`.
|
|
351
|
+
*
|
|
352
|
+
* If the head expression can be represented as a string, it is returned
|
|
353
|
+
* as a string.
|
|
354
|
+
*
|
|
355
|
+
* **Note** applicable to canonical and non-canonical expressions. The head
|
|
356
|
+
* of a non-canonical expression may be different than the head of its
|
|
357
|
+
* canonical counterpart. For example the canonical counterpart of `["Divide", 5, 7]` is `["Rational", 5, 5]`.
|
|
358
|
+
*/
|
|
359
|
+
readonly head: BoxedExpression | string;
|
|
360
|
+
/** The list of arguments of the function, its "tail".
|
|
361
|
+
*
|
|
362
|
+
* If the expression is not a function, return `null`.
|
|
363
|
+
*
|
|
364
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
328
365
|
*
|
|
329
366
|
* @category Function Expression
|
|
330
367
|
*
|
|
331
368
|
*/
|
|
332
|
-
|
|
369
|
+
readonly ops: null | BoxedExpression[];
|
|
333
370
|
/** If this expression is a function, the number of operands, otherwise 0.
|
|
334
371
|
*
|
|
335
372
|
* Note that a function can have 0 operands, so to check if this expression
|
|
336
373
|
* is a function, check if `this.ops !== null` instead.
|
|
337
374
|
*
|
|
375
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
376
|
+
*
|
|
338
377
|
* @category Function Expression
|
|
339
378
|
*
|
|
340
379
|
*/
|
|
341
|
-
|
|
380
|
+
readonly nops: number;
|
|
342
381
|
/** First operand, i.e.`this.ops[0]`
|
|
343
382
|
*
|
|
383
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
344
384
|
*
|
|
345
385
|
* @category Function Expression
|
|
346
386
|
*
|
|
347
387
|
*
|
|
348
388
|
*/
|
|
349
|
-
|
|
350
|
-
/** Second operand, i.e.`this.ops[
|
|
389
|
+
readonly op1: BoxedExpression;
|
|
390
|
+
/** Second operand, i.e.`this.ops[1]`
|
|
351
391
|
*
|
|
392
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
352
393
|
*
|
|
353
394
|
* @category Function Expression
|
|
354
395
|
*
|
|
355
396
|
*
|
|
356
397
|
*/
|
|
357
|
-
|
|
398
|
+
readonly op2: BoxedExpression;
|
|
358
399
|
/** Third operand, i.e. `this.ops[2]`
|
|
359
400
|
*
|
|
401
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
360
402
|
*
|
|
361
403
|
* @category Function Expression
|
|
362
404
|
*
|
|
363
405
|
*
|
|
364
406
|
*/
|
|
365
|
-
|
|
366
|
-
/**
|
|
407
|
+
readonly op3: BoxedExpression;
|
|
408
|
+
/** `true` if this expression or any of its subexpressions is an `["Error"]`
|
|
409
|
+
* expression.
|
|
367
410
|
*
|
|
368
|
-
*
|
|
411
|
+
* **Note** applicable to canonical and non-canonical expressions. For
|
|
412
|
+
* non-canonical expression, this may indicate a syntax error while parsing
|
|
413
|
+
* LaTeX. For canonical expression, this may indicate argument domain
|
|
414
|
+
* mismatch, or missing or unexpected arguments.
|
|
369
415
|
*
|
|
370
|
-
* @category
|
|
416
|
+
* @category Symbol Expression
|
|
371
417
|
*
|
|
372
418
|
*/
|
|
373
|
-
|
|
419
|
+
readonly isValid: boolean;
|
|
374
420
|
/**
|
|
421
|
+
* If `true`, this expression represents a value that was not calculated
|
|
422
|
+
* and that does not reference another expression.
|
|
375
423
|
*
|
|
376
|
-
*
|
|
424
|
+
* This means the expression is either a number, a string or a dictionary.
|
|
425
|
+
* Functions and symbols are not literals.
|
|
426
|
+
*
|
|
427
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
428
|
+
*/
|
|
429
|
+
readonly isLiteral: boolean;
|
|
430
|
+
/** If true, the value of the expression never changes and evaluating it has
|
|
431
|
+
* no side-effects.
|
|
432
|
+
* If false, the value of the expression may change, if the
|
|
433
|
+
* value of other expression changes or for other reasons.
|
|
434
|
+
*
|
|
435
|
+
* If `this.isPure` is `false`, `this.value` is undefined. Call
|
|
436
|
+
* `this.evaluate()` to determine the value of the expression instead.
|
|
437
|
+
*
|
|
438
|
+
* As an example, the `Random` function is not pure.
|
|
439
|
+
*
|
|
440
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
377
441
|
*/
|
|
378
|
-
|
|
442
|
+
readonly isPure: boolean;
|
|
443
|
+
/** True if the expression is a free variable, that is a symbol with no value */
|
|
444
|
+
readonly isFree: boolean;
|
|
445
|
+
/** True if the expression is a constant, that is a symbol with an immutable value */
|
|
446
|
+
readonly isConstant: boolean;
|
|
379
447
|
/**
|
|
380
|
-
*
|
|
448
|
+
* Return the canonical form of this expression.
|
|
381
449
|
*
|
|
382
|
-
*
|
|
450
|
+
* If a function, after putting all the arguments in canonical form, find
|
|
451
|
+
* a corresponding function definition in the current context.
|
|
452
|
+
*
|
|
453
|
+
* Apply the function definition flags:
|
|
454
|
+
* - `associative`: \\( f(a, f(b), c) \longrightarrow f(a, b, c) \\)
|
|
455
|
+
* - `idempotent`: \\( f(f(a)) \longrightarrow f(a) \\)
|
|
456
|
+
* - `involution`: \\( f(f(a)) \longrightarrow a \\)
|
|
457
|
+
* - `commutative`: sort the arguments.
|
|
458
|
+
*
|
|
459
|
+
* Additionally, some simplifications involving exact computations on
|
|
460
|
+
* small integers may be performed.
|
|
461
|
+
*
|
|
462
|
+
* For example:
|
|
463
|
+
* - \\( 2 + x + 1 \longrightarrow x + 3 \\)
|
|
464
|
+
* - \\( \sqrt{4} \longrightarrow 2 \\)
|
|
465
|
+
* - \\(\frac{4}{10} \longrightarrow \frac{2}{5} \\).
|
|
466
|
+
*
|
|
467
|
+
* However, no calculation is performed involving floating point numbers, so
|
|
468
|
+
* \\( \sqrt(2) \longrightarrow \sqrt(2) \\).
|
|
469
|
+
*
|
|
470
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
471
|
+
* Expressions that are already canonical return themselves.
|
|
383
472
|
*
|
|
384
473
|
*/
|
|
385
|
-
|
|
474
|
+
get canonical(): BoxedExpression;
|
|
386
475
|
/**
|
|
387
|
-
* If this expression is a
|
|
388
|
-
* `key` entry.
|
|
476
|
+
* If this expression is a function, apply the function `fn` to all its operands.
|
|
389
477
|
*
|
|
390
|
-
*
|
|
478
|
+
* Replace the head of this expression with `head`, if defined.
|
|
479
|
+
*
|
|
480
|
+
* If this expression is a dictionary, return a new dictionary with the values
|
|
481
|
+
* modified by `fn`.
|
|
482
|
+
*
|
|
483
|
+
* If `head` is provided, return a function expression with the modified
|
|
484
|
+
* dictionary as operand, otherwise return the modified dictionary.
|
|
485
|
+
*
|
|
486
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
487
|
+
*
|
|
488
|
+
* */
|
|
489
|
+
apply(fn: (x: BoxedExpression) => SemiBoxedExpression, head?: string): BoxedExpression;
|
|
490
|
+
/**
|
|
491
|
+
* Replace all the symbols in the expression as indicated.
|
|
492
|
+
*
|
|
493
|
+
* Note the same effect can be achieved with `this.replace()`, but
|
|
494
|
+
* using `this.subs()` is more efficient, and simpler.
|
|
495
|
+
*
|
|
496
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
391
497
|
*
|
|
392
498
|
*/
|
|
393
|
-
|
|
499
|
+
subs(sub: Substitution): BoxedExpression;
|
|
500
|
+
/**
|
|
501
|
+
* Transform the expression by applying the rules:
|
|
502
|
+
* if the `lhs` of a rule matches, it is replaced by its `rhs`.
|
|
503
|
+
*
|
|
504
|
+
* If no rules apply, return `null`.
|
|
505
|
+
*
|
|
506
|
+
* See also `subs` for a simple substitution.
|
|
507
|
+
*
|
|
508
|
+
*
|
|
509
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
510
|
+
*
|
|
511
|
+
*/
|
|
512
|
+
replace(rules: BoxedRuleSet, options?: ReplaceOptions): null | BoxedExpression;
|
|
513
|
+
/**
|
|
514
|
+
* True if the expression includes a symbol `v` or a function head `v`.
|
|
515
|
+
*
|
|
516
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
517
|
+
*/
|
|
518
|
+
has(v: string | string[]): boolean;
|
|
519
|
+
/** Structural/symbolic equality (weak equality).
|
|
520
|
+
*
|
|
521
|
+
* `ce.parse('1+x').isSame(ce.parse('x+1'))` is `false`
|
|
522
|
+
*
|
|
523
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
524
|
+
*
|
|
525
|
+
* @category Relational Operator
|
|
526
|
+
*/
|
|
527
|
+
isSame(rhs: BoxedExpression): boolean;
|
|
528
|
+
/** Attempt to match this expression to the `rhs` expression.
|
|
529
|
+
*
|
|
530
|
+
* If `rhs` does not match, return `null`.
|
|
531
|
+
*
|
|
532
|
+
* Otherwise return an object literal.
|
|
533
|
+
*
|
|
534
|
+
* If this expression includes wildcards (symbols with a name that starts
|
|
535
|
+
* with `_`), the object literal will include a prop for each matching named
|
|
536
|
+
* wildcard.
|
|
537
|
+
*
|
|
538
|
+
* If `rhs` matches this pattern but there are no named wildcards, return
|
|
539
|
+
* the empty object literal, `{}`.
|
|
540
|
+
*
|
|
541
|
+
* **Note** applicable to canonical and non-canonical expressions.
|
|
542
|
+
*
|
|
543
|
+
*/
|
|
544
|
+
match(rhs: BoxedExpression, options?: PatternMatchOption): Substitution | null;
|
|
545
|
+
/**
|
|
546
|
+
* "Not a Number".
|
|
547
|
+
*
|
|
548
|
+
* A value representing undefined result of computations, such as `0/0`,
|
|
549
|
+
* as per the floating point format standard IEEE-754.
|
|
550
|
+
*
|
|
551
|
+
* Note that if `isNaN` is true, `isNumber` is also true (yes, `NaN` is a
|
|
552
|
+
* number).
|
|
553
|
+
*
|
|
554
|
+
* @category Expression Properties
|
|
555
|
+
*
|
|
556
|
+
*/
|
|
557
|
+
readonly isNaN: boolean | undefined;
|
|
558
|
+
/**
|
|
559
|
+
* The numeric value of this expression is 0.
|
|
560
|
+
*
|
|
561
|
+
* @category Expression Properties
|
|
562
|
+
*/
|
|
563
|
+
readonly isZero: boolean | undefined;
|
|
394
564
|
/**
|
|
395
|
-
*
|
|
565
|
+
* The numeric value of this expression is not 0.
|
|
566
|
+
* @category Expression Properties
|
|
567
|
+
*/
|
|
568
|
+
readonly isNotZero: boolean | undefined;
|
|
569
|
+
/**
|
|
570
|
+
* The numeric value of this expression is not 1.
|
|
571
|
+
* @category Expression Properties
|
|
572
|
+
*/
|
|
573
|
+
readonly isOne: boolean | undefined;
|
|
574
|
+
/**
|
|
575
|
+
* The numeric value of this expression is not -1.
|
|
576
|
+
* @category Expression Properties
|
|
577
|
+
*/
|
|
578
|
+
readonly isNegativeOne: boolean | undefined;
|
|
579
|
+
/** The numeric value of this expression is ±Infinity or Complex Infinity
|
|
580
|
+
*
|
|
581
|
+
* @category Expression Properties
|
|
582
|
+
*/
|
|
583
|
+
readonly isInfinity: boolean | undefined;
|
|
584
|
+
/** This expression is a number, but not ±Infinity and not `NaN`
|
|
585
|
+
*
|
|
586
|
+
* @category Expression Properties
|
|
587
|
+
*/
|
|
588
|
+
readonly isFinite: boolean | undefined;
|
|
589
|
+
/**
|
|
590
|
+
* @category Expression Properties
|
|
591
|
+
*/
|
|
592
|
+
readonly isEven: boolean | undefined;
|
|
593
|
+
/**
|
|
594
|
+
* @category Expression Properties
|
|
595
|
+
*/
|
|
596
|
+
readonly isOdd: boolean | undefined;
|
|
597
|
+
/**
|
|
598
|
+
* @category Expression Properties
|
|
599
|
+
*/
|
|
600
|
+
readonly isPrime: boolean | undefined;
|
|
601
|
+
/**
|
|
602
|
+
* @category Expression Properties
|
|
603
|
+
*/
|
|
604
|
+
readonly isComposite: boolean | undefined;
|
|
605
|
+
/**
|
|
606
|
+
* Return the value of this expression, if stored as a machine
|
|
607
|
+
* number.
|
|
396
608
|
*
|
|
397
|
-
* Note it is possible for `machineValue` to be `null`, and for `isNotZero`
|
|
398
|
-
* For example, when a symbol has been defined with an assumption.
|
|
609
|
+
* Note it is possible for `machineValue` to be `null`, and for `isNotZero`
|
|
610
|
+
* to be true. For example, when a symbol has been defined with an assumption.
|
|
399
611
|
*
|
|
400
612
|
* If `machineValue` is not `null`, then `decimalValue`, `rationalValue`
|
|
401
613
|
* and `complexValue` are `null.
|
|
@@ -403,7 +615,7 @@ export interface BoxedExpression {
|
|
|
403
615
|
* @category Numeric Expression
|
|
404
616
|
*
|
|
405
617
|
*/
|
|
406
|
-
|
|
618
|
+
readonly machineValue: number | null;
|
|
407
619
|
/** If the value of this expression is a rational number, return it.
|
|
408
620
|
* Otherwise, return `[null, null]`.
|
|
409
621
|
*
|
|
@@ -413,7 +625,7 @@ export interface BoxedExpression {
|
|
|
413
625
|
* @category Numeric Expression
|
|
414
626
|
*
|
|
415
627
|
*/
|
|
416
|
-
|
|
628
|
+
readonly rationalValue: [numer: number, denom: number] | [null, null];
|
|
417
629
|
/** If the value of this expression is a `Decimal` number, return it.
|
|
418
630
|
* Otherwise, return `null`.
|
|
419
631
|
*
|
|
@@ -425,7 +637,7 @@ export interface BoxedExpression {
|
|
|
425
637
|
* @category Numeric Expression
|
|
426
638
|
*
|
|
427
639
|
*/
|
|
428
|
-
|
|
640
|
+
readonly decimalValue: Decimal | null;
|
|
429
641
|
/** If the value of this expression is a `Complex` number, return it.
|
|
430
642
|
* Otherwise, return `null`.
|
|
431
643
|
*
|
|
@@ -436,7 +648,7 @@ export interface BoxedExpression {
|
|
|
436
648
|
*
|
|
437
649
|
*
|
|
438
650
|
*/
|
|
439
|
-
|
|
651
|
+
readonly complexValue: Complex | null;
|
|
440
652
|
/** Return an approximation of the numeric value of this expression as
|
|
441
653
|
* a 64-bit floating point number.
|
|
442
654
|
*
|
|
@@ -445,10 +657,9 @@ export interface BoxedExpression {
|
|
|
445
657
|
* If the value is a rational number, return the numerator divided by the
|
|
446
658
|
* denominator.
|
|
447
659
|
*
|
|
448
|
-
* If the value is a Decimal number
|
|
449
|
-
* number
|
|
450
|
-
* to
|
|
451
|
-
* numbers.
|
|
660
|
+
* If the value is a Decimal number return an approximation of the decimal
|
|
661
|
+
* number to a machine number. There might be a loss of precision or a
|
|
662
|
+
* round to 0 or Infinity, depending on the value.
|
|
452
663
|
*
|
|
453
664
|
* If the value of this expression cannot be represented by a float,
|
|
454
665
|
* return `null`.
|
|
@@ -457,10 +668,10 @@ export interface BoxedExpression {
|
|
|
457
668
|
*
|
|
458
669
|
*
|
|
459
670
|
*/
|
|
460
|
-
|
|
671
|
+
readonly asFloat: number | null;
|
|
461
672
|
/**
|
|
462
|
-
* If the value of this expression is an integer with a 'small' absolute
|
|
463
|
-
* return this value. Otherwise, return `null`.
|
|
673
|
+
* If the value of this expression is an integer with a 'small' absolute
|
|
674
|
+
* value, return this value. Otherwise, return `null`.
|
|
464
675
|
*
|
|
465
676
|
* Some calculations, for example to put in canonical forms, are only
|
|
466
677
|
* performed if they are safe from overflow. This method makes it easy
|
|
@@ -471,15 +682,15 @@ export interface BoxedExpression {
|
|
|
471
682
|
* @category Numeric Expression
|
|
472
683
|
*
|
|
473
684
|
*/
|
|
474
|
-
|
|
685
|
+
readonly asSmallInteger: number | null;
|
|
475
686
|
/**
|
|
476
687
|
* If the value of this an expression is a small integer or a rational,
|
|
477
|
-
* return this value. Otherwise, return `[null, null
|
|
688
|
+
* return this value. Otherwise, return `[null, null]`.
|
|
478
689
|
*
|
|
479
690
|
* @category Numeric Expression
|
|
480
691
|
*
|
|
481
692
|
*/
|
|
482
|
-
|
|
693
|
+
readonly asRational: [number, number] | [null, null];
|
|
483
694
|
/**
|
|
484
695
|
* Return the following, depending on the value of this expression:
|
|
485
696
|
*
|
|
@@ -502,299 +713,156 @@ export interface BoxedExpression {
|
|
|
502
713
|
* @category Numeric Expression
|
|
503
714
|
*
|
|
504
715
|
*/
|
|
505
|
-
|
|
506
|
-
/** If
|
|
507
|
-
* Otherwise, return `null`.
|
|
716
|
+
readonly sgn: -1 | 0 | 1 | undefined | null;
|
|
717
|
+
/** If the expressions cannot be compared, return `undefined`
|
|
508
718
|
*
|
|
509
|
-
*
|
|
719
|
+
* The numeric value of both expressions are compared.
|
|
510
720
|
*
|
|
721
|
+
* @category Relational Operator
|
|
511
722
|
*/
|
|
512
|
-
|
|
723
|
+
isLess(rhs: BoxedExpression): boolean | undefined;
|
|
513
724
|
/**
|
|
514
|
-
*
|
|
725
|
+
* The numeric value of both expressions are compared.
|
|
726
|
+
* @category Relational Operator
|
|
515
727
|
*/
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
* @category Symbol Expression
|
|
521
|
-
*
|
|
728
|
+
isLessEqual(rhs: BoxedExpression): boolean | undefined;
|
|
729
|
+
/**
|
|
730
|
+
* The numeric value of both expressions are compared.
|
|
731
|
+
* @category Relational Operator
|
|
522
732
|
*/
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
|
|
733
|
+
isGreater(rhs: BoxedExpression): boolean | undefined;
|
|
734
|
+
/**
|
|
735
|
+
* The numeric value of both expressions are compared.
|
|
736
|
+
* @category Relational Operator
|
|
737
|
+
*/
|
|
738
|
+
isGreaterEqual(rhs: BoxedExpression): boolean | undefined;
|
|
739
|
+
/** The numeric value of this expression is > 0, same as `isGreater(0)`
|
|
528
740
|
*
|
|
741
|
+
* @category Expression Properties
|
|
529
742
|
*/
|
|
530
|
-
|
|
531
|
-
/**
|
|
743
|
+
readonly isPositive: boolean | undefined;
|
|
744
|
+
/** The numeric value of this expression is >= 0, same as `isGreaterEqual(0)`
|
|
532
745
|
*
|
|
533
|
-
*
|
|
746
|
+
* @category Expression Properties
|
|
747
|
+
*/
|
|
748
|
+
readonly isNonNegative: boolean | undefined;
|
|
749
|
+
/** The numeric value of this expression is < 0, same as `isLess(0)`
|
|
534
750
|
*
|
|
535
|
-
*
|
|
536
|
-
|
|
751
|
+
* @category Expression Properties
|
|
752
|
+
*/
|
|
753
|
+
readonly isNegative: boolean | undefined;
|
|
754
|
+
/** The numeric value of this expression is <= 0, same as `isLessEqual(0)`
|
|
537
755
|
*
|
|
538
756
|
* @category Expression Properties
|
|
539
757
|
*/
|
|
540
|
-
|
|
541
|
-
/** The
|
|
758
|
+
readonly isNonPositive: boolean | undefined;
|
|
759
|
+
/** The keys of the dictionary.
|
|
542
760
|
*
|
|
761
|
+
* If this expression not a dictionary, return `null`
|
|
543
762
|
*
|
|
544
|
-
* @category Expression
|
|
763
|
+
* @category Dictionary Expression
|
|
545
764
|
*
|
|
546
765
|
*/
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
*
|
|
550
|
-
* Note that every integer is also a rational.
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
* @category Expression Properties
|
|
766
|
+
readonly keys: IterableIterator<string> | null;
|
|
767
|
+
/**
|
|
554
768
|
*
|
|
769
|
+
* @category Dictionary Expression
|
|
555
770
|
*/
|
|
556
|
-
|
|
771
|
+
readonly keysCount: number;
|
|
557
772
|
/**
|
|
558
|
-
*
|
|
559
|
-
* univariate polynomial with rational coefficients.
|
|
560
|
-
*
|
|
561
|
-
* All integers and rational numbers are algebraic.
|
|
562
|
-
*
|
|
563
|
-
* Transcendental numbers, such as \\( \pi \\) or \\( e \\) are not algebraic.
|
|
564
|
-
*
|
|
773
|
+
* If this expression is a dictionary, return the value of the `key` entry.
|
|
565
774
|
*
|
|
566
|
-
* @category Expression
|
|
775
|
+
* @category Dictionary Expression
|
|
567
776
|
*
|
|
568
777
|
*/
|
|
569
|
-
|
|
778
|
+
getKey(key: string): BoxedExpression | undefined;
|
|
570
779
|
/**
|
|
571
|
-
*
|
|
572
|
-
*
|
|
573
|
-
* `isFinite && !isImaginary`
|
|
780
|
+
* If this expression is a dictionary, return true if the
|
|
781
|
+
* dictionary has a `key` entry.
|
|
574
782
|
*
|
|
783
|
+
* @category Dictionary Expression
|
|
575
784
|
*
|
|
576
|
-
* @category Expression Properties
|
|
577
785
|
*/
|
|
578
|
-
|
|
579
|
-
/**
|
|
786
|
+
hasKey(key: string): boolean;
|
|
787
|
+
/** Wikidata identifier.
|
|
580
788
|
*
|
|
581
|
-
* `
|
|
789
|
+
* **Note** `undefined` if not a canonical expression.
|
|
582
790
|
*
|
|
583
791
|
*
|
|
584
|
-
* @category Expression Properties
|
|
585
792
|
*/
|
|
586
|
-
get
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
*
|
|
590
|
-
* `isReal || isImaginary`
|
|
793
|
+
get wikidata(): string | undefined;
|
|
794
|
+
set wikidata(val: string | undefined);
|
|
795
|
+
/** An optional short description if the symbol or function head.
|
|
591
796
|
*
|
|
797
|
+
* May include markdown. Each string is a paragraph.
|
|
592
798
|
*
|
|
593
|
-
*
|
|
799
|
+
* **Note** `undefined` if not a canonical expression.
|
|
594
800
|
*
|
|
595
801
|
*/
|
|
596
|
-
|
|
597
|
-
/**
|
|
802
|
+
readonly description: undefined | string[];
|
|
803
|
+
/** An optional URL pointing to more information about the symbol or
|
|
804
|
+
* function head
|
|
598
805
|
*
|
|
806
|
+
* **Note** `undefined` if not a canonical expression.
|
|
599
807
|
*
|
|
600
|
-
* @category Expression Properties
|
|
601
|
-
*/
|
|
602
|
-
get isExtendedComplex(): boolean | undefined;
|
|
603
|
-
/** The value of this expression is a number with a imaginary part
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
* @category Expression Properties
|
|
607
|
-
*/
|
|
608
|
-
get isImaginary(): boolean | undefined;
|
|
609
|
-
/**
|
|
610
|
-
* @category Expression Properties
|
|
611
808
|
*/
|
|
612
|
-
|
|
613
|
-
/**
|
|
614
|
-
*
|
|
615
|
-
*/
|
|
616
|
-
get isNotZero(): boolean | undefined;
|
|
617
|
-
/**
|
|
618
|
-
* @category Expression Properties
|
|
619
|
-
*/
|
|
620
|
-
get isOne(): boolean | undefined;
|
|
621
|
-
/**
|
|
622
|
-
* @category Expression Properties
|
|
623
|
-
*/
|
|
624
|
-
get isNegativeOne(): boolean | undefined;
|
|
625
|
-
/** ±Infinity or Complex Infinity
|
|
809
|
+
readonly url: string | undefined;
|
|
810
|
+
/** Expressions with a higher complexity score are sorted
|
|
811
|
+
* first in commutative functions
|
|
626
812
|
*
|
|
627
|
-
*
|
|
813
|
+
* **Note** `undefined` if not a canonical expression.
|
|
628
814
|
*/
|
|
629
|
-
|
|
815
|
+
readonly complexity: number | undefined;
|
|
630
816
|
/**
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
* as per the floating point format standard IEEE-754.
|
|
635
|
-
*
|
|
636
|
-
* Note that if `isNaN` is true, `isNumber` is also true (yes, `NaN` is a
|
|
637
|
-
* number).
|
|
817
|
+
* For symbols and functions, a possible definition associated with the
|
|
818
|
+
* expression. `basedDefinition` is the base class of symbol and function
|
|
819
|
+
* definition.
|
|
638
820
|
*
|
|
639
|
-
*
|
|
821
|
+
* **Note** `undefined` if not a canonical expression.
|
|
640
822
|
*
|
|
641
823
|
*/
|
|
642
|
-
|
|
643
|
-
/** This expression is a number, but not ±Infinity and not `NaN`
|
|
644
|
-
*
|
|
645
|
-
* @category Expression Properties
|
|
646
|
-
*/
|
|
647
|
-
get isFinite(): boolean | undefined;
|
|
824
|
+
readonly basedDefinition: BoxedBaseDefinition | undefined;
|
|
648
825
|
/**
|
|
649
|
-
*
|
|
650
|
-
*/
|
|
651
|
-
get isEven(): boolean | undefined;
|
|
652
|
-
/**
|
|
653
|
-
* @category Expression Properties
|
|
654
|
-
*/
|
|
655
|
-
get isOdd(): boolean | undefined;
|
|
656
|
-
/**
|
|
657
|
-
* @category Expression Properties
|
|
658
|
-
*/
|
|
659
|
-
get isPrime(): boolean | undefined;
|
|
660
|
-
/**
|
|
661
|
-
* @category Expression Properties
|
|
662
|
-
*/
|
|
663
|
-
get isComposite(): boolean | undefined;
|
|
664
|
-
/** Structural/symbolic equality (weak equality).
|
|
826
|
+
* For functions, a possible definition associated with the expression.
|
|
665
827
|
*
|
|
666
|
-
* `
|
|
828
|
+
* **Note** `undefined` if not a canonical expression or not a function.
|
|
667
829
|
*
|
|
668
|
-
* @category Relational Operator
|
|
669
830
|
*/
|
|
670
|
-
|
|
831
|
+
readonly functionDefinition: BoxedFunctionDefinition | undefined;
|
|
671
832
|
/**
|
|
672
|
-
*
|
|
673
|
-
*/
|
|
674
|
-
has(v: string | string[]): boolean;
|
|
675
|
-
/** Attempt to match this expression to the `rhs` expression.
|
|
676
|
-
*
|
|
677
|
-
* If `rhs` does not match, return `null`.
|
|
678
|
-
*
|
|
679
|
-
* Otherwise return an object literal.
|
|
680
|
-
*
|
|
681
|
-
* If this expression includes wildcards (symbols with a name that starts
|
|
682
|
-
* with `_`), the object literal will include a prop for each matching named
|
|
683
|
-
* wildcard.
|
|
684
|
-
*
|
|
685
|
-
* If `rhs` matches this pattern but there are no named wildcards, return
|
|
686
|
-
* the empty object literal, `{}`.
|
|
687
|
-
*/
|
|
688
|
-
match(rhs: BoxedExpression, options?: PatternMatchOption): Substitution | null;
|
|
689
|
-
/** Mathematical equality (strong equality), that is the value
|
|
690
|
-
* of this expression and of `rhs` are numerically equal.
|
|
833
|
+
* For symbols, a possible definition associated with the expression.
|
|
691
834
|
*
|
|
692
|
-
*
|
|
835
|
+
* **Note** `undefined` if not a symbol
|
|
693
836
|
*
|
|
694
|
-
* Numbers whose difference is less than `engine.tolerance` are
|
|
695
|
-
* considered equal. This tolerance is set when the `engine.precision` is
|
|
696
|
-
* changed to be such that the last two digits are ignored.
|
|
697
|
-
*
|
|
698
|
-
* @category Relational Operator
|
|
699
837
|
*/
|
|
700
|
-
|
|
701
|
-
/** If the expressions cannot be compared, return `undefined`
|
|
702
|
-
*
|
|
703
|
-
* @category Relational Operator
|
|
704
|
-
*/
|
|
705
|
-
isLess(rhs: BoxedExpression): boolean | undefined;
|
|
706
|
-
/**
|
|
707
|
-
* @category Relational Operator
|
|
708
|
-
*/
|
|
709
|
-
isLessEqual(rhs: BoxedExpression): boolean | undefined;
|
|
838
|
+
readonly symbolDefinition: BoxedSymbolDefinition | undefined;
|
|
710
839
|
/**
|
|
711
|
-
*
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
/**
|
|
715
|
-
* @category Relational Operator
|
|
716
|
-
*/
|
|
717
|
-
isGreaterEqual(rhs: BoxedExpression): boolean | undefined;
|
|
718
|
-
/** The value of this expression is > 0, same as `isGreater(0)`
|
|
840
|
+
* The domain of this expression, without accounting for any inferred domain
|
|
841
|
+
* or `ce.defaultDomain`. If no domain has been explicitly set via assignment
|
|
842
|
+
* or via an `.assume()` directive, the `expr.explicitDomain` is `undefined`.
|
|
719
843
|
*
|
|
720
|
-
*
|
|
721
|
-
*/
|
|
722
|
-
get isPositive(): boolean | undefined;
|
|
723
|
-
/** The value of this expression is >= 0, same as `isGreaterEqual(0)`
|
|
844
|
+
* This is useful to determine if the domain of an expression is inferred.
|
|
724
845
|
*
|
|
725
|
-
*
|
|
726
|
-
*/
|
|
727
|
-
get isNonNegative(): boolean | undefined;
|
|
728
|
-
/** The value of this expression is < 0, same as `isLess(0)`
|
|
846
|
+
* In most cases you'll want to use `expr.domain` instead.
|
|
729
847
|
*
|
|
730
|
-
*
|
|
731
|
-
*/
|
|
732
|
-
get isNegative(): boolean | undefined;
|
|
733
|
-
/** The value of this expression is <= 0, same as `isLessEqual(0)`
|
|
848
|
+
* **Note** `undefined` if not a canonical expression or not a function.
|
|
734
849
|
*
|
|
735
|
-
* @category Expression Properties
|
|
736
850
|
*/
|
|
737
|
-
|
|
738
|
-
/** Wikidata identifier */
|
|
739
|
-
get wikidata(): string;
|
|
740
|
-
set wikidata(val: string);
|
|
741
|
-
/** MathJSON representation of this expression */
|
|
742
|
-
get json(): Expression;
|
|
743
|
-
/** LaTeX representation of this expression */
|
|
744
|
-
get latex(): LatexString;
|
|
745
|
-
set latex(val: string);
|
|
746
|
-
/** Expressions with a higher complexity score are sorted
|
|
747
|
-
* first in commutative functions
|
|
748
|
-
*/
|
|
749
|
-
get complexity(): number;
|
|
750
|
-
/** The domain of this expression. If a function expression, this the domain
|
|
751
|
-
* of the value of the function(the codomain of the function), if a symbol
|
|
752
|
-
* the domain of the value of the symbol.
|
|
753
|
-
*/
|
|
754
|
-
get domain(): BoxedDomain;
|
|
755
|
-
/** Symbols that represent a variable (or a function name), can have their
|
|
756
|
-
* domain modified */
|
|
757
|
-
set domain(domain: BoxedDomain | string);
|
|
851
|
+
readonly explicitDomain: BoxedDomain | undefined;
|
|
758
852
|
/**
|
|
759
|
-
*
|
|
760
|
-
*
|
|
761
|
-
* or via an `.assume()` directive, the `expr.explicitDomain` is `null.
|
|
853
|
+
* Update the definition associated with this expression, taking
|
|
854
|
+
* into account the specified scope.
|
|
762
855
|
*
|
|
763
|
-
*
|
|
856
|
+
* **Note**: applicable only to canonical expressions
|
|
764
857
|
*
|
|
765
|
-
*
|
|
858
|
+
* @internal
|
|
766
859
|
*/
|
|
767
|
-
|
|
768
|
-
/** For symbols and functions, a possible definition associated with the
|
|
769
|
-
* expression. `basedDefinition` is the base class of symbol and function
|
|
770
|
-
* definition. */
|
|
771
|
-
get basedDefinition(): BoxedBaseDefinition | undefined;
|
|
772
|
-
get functionDefinition(): BoxedFunctionDefinition | undefined;
|
|
773
|
-
get symbolDefinition(): BoxedSymbolDefinition | undefined;
|
|
860
|
+
bind(scope: RuntimeScope | null): void;
|
|
774
861
|
/**
|
|
775
|
-
* Return the canonical form of this expression.
|
|
776
|
-
*
|
|
777
|
-
* If a function, consider the function definition flags:
|
|
778
|
-
* - `associative`: \\( f(a, f(b), c) \longrightarrow f(a, b, c) \\)
|
|
779
|
-
* - `idempotent`: \\( f(f(a)) \longrightarrow f(a) \\)
|
|
780
|
-
* - `involution`: \\( f(f(a)) \longrightarrow a \\)
|
|
781
|
-
* - `commutative`: sort the arguments.
|
|
782
|
-
*
|
|
783
|
-
* Additionally, some simplifications involving exact computations on
|
|
784
|
-
* small integers may be performed.
|
|
785
|
-
*
|
|
786
|
-
* For example:
|
|
787
|
-
* - \\( 2 + x + 1 \longrightarrow x + 3 \\)
|
|
788
|
-
* - \\( \sqrt{4} \longrightarrow 2 \\)
|
|
789
|
-
* - \\(\frac{4}{10} \longrightarrow \frac{2}{5} \\).
|
|
790
|
-
*
|
|
791
|
-
* However, no calculation is performed involving floating point numbers, so
|
|
792
|
-
* \\( \sqrt(2) \longrightarrow \sqrt(2) \\).
|
|
793
862
|
*
|
|
794
|
-
*
|
|
795
|
-
* or assumptions about, symbols.
|
|
863
|
+
* @internal
|
|
796
864
|
*/
|
|
797
|
-
|
|
865
|
+
unbind(): void;
|
|
798
866
|
/**
|
|
799
867
|
* Return a simpler form of this expression.
|
|
800
868
|
*
|
|
@@ -854,46 +922,141 @@ export interface BoxedExpression {
|
|
|
854
922
|
N(options?: NOptions): BoxedExpression;
|
|
855
923
|
solve(vars: Iterable<string>): null | BoxedExpression[];
|
|
856
924
|
/**
|
|
857
|
-
* If
|
|
925
|
+
* Synonym for `evaluate()`. If the expression is pure, the value may be
|
|
926
|
+
* cached.
|
|
858
927
|
*
|
|
859
|
-
*
|
|
928
|
+
* It returns `undefined` for expressions that are not pure or that may
|
|
929
|
+
* not be evaluated.
|
|
860
930
|
*
|
|
861
|
-
* If
|
|
862
|
-
|
|
931
|
+
* **Note**: If non-canonical, return the value of its canonical counterpart
|
|
932
|
+
*/
|
|
933
|
+
get value(): BoxedExpression | undefined;
|
|
934
|
+
/** Only the value of variables can be changed (symbols that are not
|
|
935
|
+
* constants).
|
|
863
936
|
*
|
|
864
|
-
* If
|
|
865
|
-
*
|
|
866
|
-
|
|
867
|
-
|
|
937
|
+
* **Note**: If non-canonical, does nothing.
|
|
938
|
+
*
|
|
939
|
+
*/
|
|
940
|
+
set value(value: BoxedExpression | number | undefined);
|
|
941
|
+
/** An approximation of the value of this expression. Floating-point
|
|
942
|
+
* operations may be performed.
|
|
943
|
+
*
|
|
944
|
+
* Just like `this.value`, it returns `undefined` for expressions that are
|
|
945
|
+
* not pure.
|
|
946
|
+
*
|
|
947
|
+
* **Note**: If non-canonical, return the numeric value of its canonical
|
|
948
|
+
* counterpart
|
|
949
|
+
*/
|
|
950
|
+
readonly numericValue: BoxedExpression | undefined;
|
|
951
|
+
/** The domain of the value of this expression.
|
|
952
|
+
*
|
|
953
|
+
* If a function expression, the domain of the value of the function (the codomain of the function).
|
|
954
|
+
*
|
|
955
|
+
* If a symbol the domain of the value of the symbol.
|
|
956
|
+
*
|
|
957
|
+
* Use `expr.head` to determine if an expression is a symbol or function.
|
|
958
|
+
*
|
|
959
|
+
* **Note**: If non-canonical, return the domain of its canonical
|
|
960
|
+
* counterpart
|
|
961
|
+
*/
|
|
962
|
+
get domain(): BoxedDomain;
|
|
963
|
+
/** Modify the domain of a symbol that represent a variable
|
|
964
|
+
* (or a function name).
|
|
965
|
+
*
|
|
966
|
+
* **Note**: If non-canonical, does nothing.
|
|
967
|
+
*
|
|
968
|
+
*/
|
|
969
|
+
set domain(domain: BoxedDomain | string);
|
|
970
|
+
/** `true` if the value of this expression is a number.
|
|
971
|
+
*
|
|
972
|
+
* `isExtendedComplex || isNaN` = `isReal || isImaginary || isInfinity || isNaN`
|
|
973
|
+
*
|
|
974
|
+
* Note that in a fateful twist of cosmic irony, `NaN` ("Not a Number")
|
|
975
|
+
* **is** a number.
|
|
976
|
+
*
|
|
977
|
+
* @category Domain Properties
|
|
978
|
+
*/
|
|
979
|
+
readonly isNumber: boolean | undefined;
|
|
980
|
+
/** The value of this expression is an element of the set ℤ: ...,-2, -1, 0, 1, 2...
|
|
981
|
+
*
|
|
982
|
+
*
|
|
983
|
+
* @category Domain Properties
|
|
984
|
+
*
|
|
985
|
+
*/
|
|
986
|
+
readonly isInteger: boolean | undefined;
|
|
987
|
+
/** The value of this expression is an element of the set ℚ, p/q with p ∈ ℕ, q ∈ ℤ ⃰ q >= 1
|
|
988
|
+
*
|
|
989
|
+
* Note that every integer is also a rational.
|
|
990
|
+
*
|
|
991
|
+
*
|
|
992
|
+
* @category Domain Properties
|
|
993
|
+
*
|
|
994
|
+
*/
|
|
995
|
+
readonly isRational: boolean | undefined;
|
|
868
996
|
/**
|
|
869
|
-
*
|
|
870
|
-
*
|
|
997
|
+
* The value of this expression is a number that is the root of a non-zero
|
|
998
|
+
* univariate polynomial with rational coefficients.
|
|
871
999
|
*
|
|
872
|
-
*
|
|
1000
|
+
* All integers and rational numbers are algebraic.
|
|
1001
|
+
*
|
|
1002
|
+
* Transcendental numbers, such as \\( \pi \\) or \\( e \\) are not algebraic.
|
|
1003
|
+
*
|
|
1004
|
+
*
|
|
1005
|
+
* @category Domain Properties
|
|
873
1006
|
*
|
|
874
|
-
* See also `subs` for a simple substitution.
|
|
875
1007
|
*/
|
|
876
|
-
|
|
1008
|
+
readonly isAlgebraic: boolean | undefined;
|
|
877
1009
|
/**
|
|
878
|
-
*
|
|
1010
|
+
* The value of this expression is real number: finite and not imaginary.
|
|
1011
|
+
*
|
|
1012
|
+
* `isFinite && !isImaginary`
|
|
879
1013
|
*
|
|
880
|
-
* Note the same effect can be achieved with `this.replace()`, but
|
|
881
|
-
* using `this.subs()` is more efficient, and simpler.
|
|
882
1014
|
*
|
|
1015
|
+
* @category Domain Properties
|
|
883
1016
|
*/
|
|
884
|
-
|
|
1017
|
+
readonly isReal: boolean | undefined;
|
|
1018
|
+
/** Real or ±Infinity
|
|
1019
|
+
*
|
|
1020
|
+
* `isReal || isInfinity`
|
|
1021
|
+
*
|
|
1022
|
+
*
|
|
1023
|
+
* @category Domain Properties
|
|
1024
|
+
*/
|
|
1025
|
+
readonly isExtendedReal: boolean | undefined;
|
|
885
1026
|
/**
|
|
886
|
-
*
|
|
887
|
-
*
|
|
1027
|
+
* The value of this expression is a number, but not `NaN` or any Infinity
|
|
1028
|
+
*
|
|
1029
|
+
* `isReal || isImaginary`
|
|
1030
|
+
*
|
|
1031
|
+
*
|
|
1032
|
+
* @category Domain Properties
|
|
888
1033
|
*
|
|
889
|
-
* @internal
|
|
890
1034
|
*/
|
|
891
|
-
|
|
892
|
-
/**
|
|
1035
|
+
readonly isComplex: boolean | undefined;
|
|
1036
|
+
/** `isReal || isImaginary || isInfinity`
|
|
893
1037
|
*
|
|
894
|
-
*
|
|
1038
|
+
*
|
|
1039
|
+
* @category Domain Properties
|
|
895
1040
|
*/
|
|
896
|
-
|
|
1041
|
+
readonly isExtendedComplex: boolean | undefined;
|
|
1042
|
+
/** The value of this expression is a number with a imaginary part
|
|
1043
|
+
*
|
|
1044
|
+
*
|
|
1045
|
+
* @category Domain Properties
|
|
1046
|
+
*/
|
|
1047
|
+
readonly isImaginary: boolean | undefined;
|
|
1048
|
+
/** Mathematical equality (strong equality), that is the value
|
|
1049
|
+
* of this expression and of `rhs` are numerically equal.
|
|
1050
|
+
*
|
|
1051
|
+
* The numeric value of both expressions are compared.
|
|
1052
|
+
*
|
|
1053
|
+
* Numbers whose difference is less than `engine.tolerance` are
|
|
1054
|
+
* considered equal. This tolerance is set when the `engine.precision` is
|
|
1055
|
+
* changed to be such that the last two digits are ignored.
|
|
1056
|
+
*
|
|
1057
|
+
* @category Relational Operator
|
|
1058
|
+
*/
|
|
1059
|
+
isEqual(rhs: BoxedExpression): boolean;
|
|
897
1060
|
}
|
|
898
1061
|
/** A semi boxed expression is an MathJSON expression which can include some
|
|
899
1062
|
* boxed terms.
|
|
@@ -1377,7 +1540,7 @@ export declare type SymbolDefinitionFlags = {
|
|
|
1377
1540
|
*/
|
|
1378
1541
|
constant: boolean;
|
|
1379
1542
|
/**
|
|
1380
|
-
* If false
|
|
1543
|
+
* If `false`, the value of the symbol is substituted during canonicalization
|
|
1381
1544
|
* or simplification.
|
|
1382
1545
|
*
|
|
1383
1546
|
* If true, the value is only replaced during a `ce.N()` or `ce.evaluate()`.
|