nerdamer 2.0.0-rc.2 → 2.0.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.
Files changed (69) hide show
  1. package/README.md +11 -5
  2. package/dist/bundle.js +1 -1
  3. package/dist/bundle.js.LICENSE.txt +6 -6
  4. package/output/algebra/dispatch.js +1 -1
  5. package/output/algebra/partfrac.js +1 -1
  6. package/output/algebra/simplify/funcsimp.js +1 -1
  7. package/output/algebra/simplify/ratsimp.js +1 -1
  8. package/output/algebra/utils.d.ts +1 -1
  9. package/output/algebra/utils.js +3 -3
  10. package/output/api/algebra.d.ts +19 -2
  11. package/output/api/algebra.js +18 -2
  12. package/output/api/assumptions.d.ts +1 -1
  13. package/output/api/assumptions.js +2 -1
  14. package/output/api/core.d.ts +28 -7
  15. package/output/api/core.js +28 -2
  16. package/output/calculus/derivative/diff.js +1 -1
  17. package/output/calculus/dispatch.js +2 -2
  18. package/output/calculus/integrate/integrate.js +4 -4
  19. package/output/calculus/integrate/integrationTable.js +16 -16
  20. package/output/calculus/laplace/ilaplace.js +1 -1
  21. package/output/calculus/laplace/ilaplaceTable.js +18 -17
  22. package/output/calculus/laplace/laplaceTable.js +3 -2
  23. package/output/calculus/limit/limit.js +1 -1
  24. package/output/core/classes/assumption/assume.d.ts +6 -0
  25. package/output/core/classes/assumption/assume.js +9 -0
  26. package/output/core/classes/expression/CoeffObject.d.ts +1 -1
  27. package/output/core/classes/expression/Expression.d.ts +8 -16
  28. package/output/core/classes/expression/Expression.js +11 -33
  29. package/output/core/classes/matrix/Matrix.d.ts +2 -3
  30. package/output/core/classes/matrix/Matrix.js +7 -16
  31. package/output/core/classes/matrix/dispatch.js +1 -1
  32. package/output/core/classes/parser/Parser.d.ts +17 -4
  33. package/output/core/classes/parser/Parser.js +312 -450
  34. package/output/core/classes/parser/operations/functions.d.ts +3 -4
  35. package/output/core/classes/parser/operations/functions.js +35 -97
  36. package/output/core/classes/parser/operations/power.js +2 -2
  37. package/output/core/classes/parser/preprocess.js +14 -7
  38. package/output/core/classes/parser/scripting/controlFlow.js +49 -25
  39. package/output/core/classes/parser/scripting/deferred.d.ts +1 -1
  40. package/output/core/classes/parser/scripting/deferred.js +1 -1
  41. package/output/core/classes/parser/scripting/scope.js +38 -19
  42. package/output/core/classes/parser/types.d.ts +0 -5
  43. package/output/core/classes/parser/wrappers/IndexedReference.d.ts +4 -3
  44. package/output/core/classes/parser/wrappers/IndexedReference.js +8 -0
  45. package/output/core/classes/parser/wrappers/KeyValuePair.d.ts +2 -2
  46. package/output/core/classes/polynomial/Polynomial.js +1 -1
  47. package/output/core/classes/polynomial/SparsePolynomial.d.ts +11 -11
  48. package/output/core/classes/polynomial/SparsePolynomial.js +65 -65
  49. package/output/core/classes/vector/Vector.d.ts +2 -3
  50. package/output/core/classes/vector/Vector.js +6 -14
  51. package/output/core/common/classes/StructuredEntity.d.ts +0 -17
  52. package/output/core/common/classes/StructuredEntity.js +3 -64
  53. package/output/core/converters/BaseConverter.js +2 -1
  54. package/output/core/fullFunctions.js +14 -14
  55. package/output/core/functions/bigint/bigint.d.ts +1 -1
  56. package/output/core/functions/numeric.d.ts +1 -1
  57. package/output/core/parserFunctions.js +10 -10
  58. package/output/index.d.ts +29 -29
  59. package/output/index.js +124 -20
  60. package/output/math/dispatch.js +1 -1
  61. package/output/math/math.js +21 -21
  62. package/output/math/trig.js +4 -4
  63. package/output/solve/solve.js +1 -1
  64. package/package.json +34 -15
  65. package/dist/parser.js +0 -2
  66. package/dist/parser.js.LICENSE.txt +0 -7
  67. package/docs-data/parser-functions.json +0 -2248
  68. package/output/core/classes/parser/operations/comma.d.ts +0 -7
  69. package/output/core/classes/parser/operations/comma.js +0 -11
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * decimal.js v10.6.0
3
- * An arbitrary-precision Decimal type for JavaScript.
4
- * https://github.com/MikeMcl/decimal.js
5
- * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
6
- * MIT Licence
7
- */
2
+ * decimal.js v10.6.0
3
+ * An arbitrary-precision Decimal type for JavaScript.
4
+ * https://github.com/MikeMcl/decimal.js
5
+ * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
6
+ * MIT Licence
7
+ */
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadAlgebraFunctions = loadAlgebraFunctions;
4
- const dispatch_1 = require("../core/dispatch");
5
4
  const constants_1 = require("../core/classes/parser/constants");
5
+ const dispatch_1 = require("../core/dispatch");
6
6
  const adapters_1 = require("./adapters");
7
7
  const factor_1 = require("./factor/factor");
8
8
  const gcd_1 = require("./gcd/gcd");
@@ -344,7 +344,7 @@ function solveLinearSystem(A, b) {
344
344
  if (pivot === -1) {
345
345
  continue;
346
346
  }
347
- if (!aug.elements[i][pivot].eq('1')) {
347
+ if (!aug.elements[i][pivot].eq((0, shortcuts_1.one)())) {
348
348
  return undefined;
349
349
  }
350
350
  if (pivotCols.has(pivot)) {
@@ -337,7 +337,7 @@ function simplifyLogs(x) {
337
337
  // Principal-log identities such as log(a)+log(b)=log(a*b) and
338
338
  // c*log(a)=log(a^c) are only branch-safe when the log arguments are
339
339
  // provably positive real values. Preserve unknown-sign terms unchanged.
340
- const transformableLogTerms = logTerms.filter(t => !t.arg.isComplex() && t.arg.gt(0));
340
+ const transformableLogTerms = logTerms.filter(t => !t.arg.isComplex() && t.arg.gt((0, shortcuts_1.zero)()));
341
341
  if (transformableLogTerms.length === 0) {
342
342
  return x;
343
343
  }
@@ -72,7 +72,7 @@ function simplifyRadicals(x) {
72
72
  // Principal radicals can be combined when both radicands are known nonnegative.
73
73
  // Reciprocals still require a strictly signed base because a zero denominator
74
74
  // cannot be admitted by the sign proof for a negative power.
75
- if (!u.isComplex() && !v.isComplex() && u.gte(0) && v.gte(0)) {
75
+ if (!u.isComplex() && !v.isComplex() && u.gte((0, shortcuts_1.zero)()) && v.gte((0, shortcuts_1.zero)())) {
76
76
  const multiplier = a.getMultiplier().times(b.getMultiplier());
77
77
  if (u.isNUM() && v.isNUM()) {
78
78
  // Preserve exact numeric reduction when the combined radicand is numeric.
@@ -1,6 +1,6 @@
1
1
  import { Expression } from '../core/classes/expression/Expression';
2
2
  import type { ExpressionInput } from '../core/types';
3
- /** Components of a quadratic rewritten by {@link sqcomp}. */
3
+ /** Components of a quadratic rewritten in completed-square form. */
4
4
  export interface CompleteSquareResult {
5
5
  /** Original quadratic coefficient. */
6
6
  a: Expression;
@@ -38,11 +38,11 @@ function sqcomp(expr, variable) {
38
38
  const b = c.hasPower(1) ? c.getPower(1) : (0, shortcuts_1.zero)();
39
39
  const k0 = c.hasPower(0) ? c.getPower(0) : (0, shortcuts_1.zero)();
40
40
  // h = b / (2a)
41
- const h = b.div(a.times(2));
41
+ const h = b.div(a.times((0, shortcuts_1.two)()));
42
42
  // k = c - b² / (4a)
43
- const k = k0.minus(b.pow(2).div(a.times(4)));
43
+ const k = k0.minus(b.pow((0, shortcuts_1.two)()).div(a.times((0, shortcuts_1.four)())));
44
44
  // Build a*(variable + h)^2 + k
45
45
  const x = Expression_1.Expression.create(variable);
46
- const expression = a.times(x.plus(h).pow(2)).plus(k);
46
+ const expression = a.times(x.plus(h).pow((0, shortcuts_1.two)())).plus(k);
47
47
  return { a, h, k, variable, expression };
48
48
  }
@@ -1,10 +1,27 @@
1
- /** Public symbolic algebra and polynomial APIs. */
1
+ import type { CompleteSquareResult } from '../algebra/utils';
2
+ import type { ExpressionInput } from '../core/types';
2
3
  export { factor, pfactor, pfactord, polyFactors } from '../algebra/factor/factor';
3
4
  export { gcd, lcm } from '../algebra/gcd/gcd';
4
5
  export { groebner } from '../algebra/groebner';
5
6
  export { partfrac } from '../algebra/partfrac';
6
7
  export { simplify } from '../algebra/simplify/simplify';
7
- export { sqcomp as completeSquare } from '../algebra/utils';
8
+ /**
9
+ * Completes the square for a quadratic expression.
10
+ *
11
+ * For `a*x^2+b*x+c`, the returned expression has the form
12
+ * `a*(x+h)^2+k`, with `h=b/(2*a)` and `k=c-b^2/(4*a)`.
13
+ *
14
+ * @param expr - Quadratic expression to rewrite.
15
+ * @param variable - Variable to use. Defaults to the first variable in the expression.
16
+ * @returns The quadratic coefficient, shift, remainder, selected variable, and rewritten expression.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const result = completeSquare('x^2+6*x+1');
21
+ * result.expression.text({ sort: true }); // "(3+x)^2-8"
22
+ * ```
23
+ */
24
+ export declare const completeSquare: (expr: ExpressionInput, variable?: string) => CompleteSquareResult;
8
25
  export type { CompleteSquareResult } from '../algebra/utils';
9
26
  export { CoeffObject } from '../core/classes/expression/CoeffObject';
10
27
  export { coeffs, content, deg } from '../core/classes/polynomial/functions';
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isPrime = exports.uUnSub = exports.uSub = exports.Term = exports.Polynomial = exports.deg = exports.content = exports.coeffs = exports.CoeffObject = exports.completeSquare = exports.simplify = exports.partfrac = exports.groebner = exports.lcm = exports.gcd = exports.polyFactors = exports.pfactord = exports.pfactor = exports.factor = void 0;
4
4
  /** Public symbolic algebra and polynomial APIs. */
5
+ const utils_1 = require("../algebra/utils");
5
6
  var factor_1 = require("../algebra/factor/factor");
6
7
  Object.defineProperty(exports, "factor", { enumerable: true, get: function () { return factor_1.factor; } });
7
8
  Object.defineProperty(exports, "pfactor", { enumerable: true, get: function () { return factor_1.pfactor; } });
@@ -16,8 +17,23 @@ var partfrac_1 = require("../algebra/partfrac");
16
17
  Object.defineProperty(exports, "partfrac", { enumerable: true, get: function () { return partfrac_1.partfrac; } });
17
18
  var simplify_1 = require("../algebra/simplify/simplify");
18
19
  Object.defineProperty(exports, "simplify", { enumerable: true, get: function () { return simplify_1.simplify; } });
19
- var utils_1 = require("../algebra/utils");
20
- Object.defineProperty(exports, "completeSquare", { enumerable: true, get: function () { return utils_1.sqcomp; } });
20
+ /**
21
+ * Completes the square for a quadratic expression.
22
+ *
23
+ * For `a*x^2+b*x+c`, the returned expression has the form
24
+ * `a*(x+h)^2+k`, with `h=b/(2*a)` and `k=c-b^2/(4*a)`.
25
+ *
26
+ * @param expr - Quadratic expression to rewrite.
27
+ * @param variable - Variable to use. Defaults to the first variable in the expression.
28
+ * @returns The quadratic coefficient, shift, remainder, selected variable, and rewritten expression.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const result = completeSquare('x^2+6*x+1');
33
+ * result.expression.text({ sort: true }); // "(3+x)^2-8"
34
+ * ```
35
+ */
36
+ exports.completeSquare = utils_1.sqcomp;
21
37
  var CoeffObject_1 = require("../core/classes/expression/CoeffObject");
22
38
  Object.defineProperty(exports, "CoeffObject", { enumerable: true, get: function () { return CoeffObject_1.CoeffObject; } });
23
39
  var functions_1 = require("../core/classes/polynomial/functions");
@@ -1,4 +1,4 @@
1
- export { assume, clearAssumptions, forgetAssumptionFor, getAssumptionFor, } from '../core/classes/assumption/assume';
1
+ export { assume, clearAssumptions, forgetAssumptionFor, getAssumptionFor, getAssumptions, } from '../core/classes/assumption/assume';
2
2
  /** Public process-wide assumption APIs. */
3
3
  export { Assumption } from '../core/classes/assumption/Assumption';
4
4
  export type { AssumptionComparison, AssumptionValue, Bound, ParsedAssumption, } from '../core/classes/assumption/Assumption';
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Assumption = exports.getAssumptionFor = exports.forgetAssumptionFor = exports.clearAssumptions = exports.assume = void 0;
3
+ exports.Assumption = exports.getAssumptions = exports.getAssumptionFor = exports.forgetAssumptionFor = exports.clearAssumptions = exports.assume = void 0;
4
4
  var assume_1 = require("../core/classes/assumption/assume");
5
5
  Object.defineProperty(exports, "assume", { enumerable: true, get: function () { return assume_1.assume; } });
6
6
  Object.defineProperty(exports, "clearAssumptions", { enumerable: true, get: function () { return assume_1.clearAssumptions; } });
7
7
  Object.defineProperty(exports, "forgetAssumptionFor", { enumerable: true, get: function () { return assume_1.forgetAssumptionFor; } });
8
8
  Object.defineProperty(exports, "getAssumptionFor", { enumerable: true, get: function () { return assume_1.getAssumptionFor; } });
9
+ Object.defineProperty(exports, "getAssumptions", { enumerable: true, get: function () { return assume_1.getAssumptions; } });
9
10
  /** Public process-wide assumption APIs. */
10
11
  var Assumption_1 = require("../core/classes/assumption/Assumption");
11
12
  Object.defineProperty(exports, "Assumption", { enumerable: true, get: function () { return Assumption_1.Assumption; } });
@@ -1,9 +1,4 @@
1
- /**
2
- * Core Nerdamer object model and shared public types.
3
- *
4
- * Import from `nerdamer/core` when working directly with Nerdamer values rather
5
- * than through the callable compatibility root.
6
- */
1
+ import type { ExpressionInput } from '../core/types';
7
2
  export { Equation } from '../core/classes/equation/Equation';
8
3
  export { CoeffObject } from '../core/classes/expression/CoeffObject';
9
4
  export { Expression } from '../core/classes/expression/Expression';
@@ -13,5 +8,31 @@ export type { JsFunction, OptionValue, OptionsObject, ParserConstants, ParserVal
13
8
  export { Rational } from '../core/classes/rational/Rational';
14
9
  export { Converter } from '../core/converters/Converter';
15
10
  export { AssignmentError, DimensionError, DivisionByZeroError, MathError, MissingReferenceError, NaNError, NotImplementedError, OperatorError, ParserError, ParserSyntaxError, PolynomialError, UndefinedError, UnexpectedDataType, UnexpectedInputError, UnexpectedTokenError, UnsupportedOperationError, ZeroToZeroPowerError, } from '../core/errors';
16
- export { build as buildFunction } from '../core/functions/build';
11
+ /**
12
+ * Compiles an expression into a native JavaScript-number function for repeated evaluation.
13
+ *
14
+ * @remarks
15
+ * Function calls are linked to Nerdamer's numerical implementations, including any dependencies
16
+ * they require. The compiler supports scalar JavaScript-number arithmetic rather than Nerdamer's
17
+ * full symbolic or structured value model. Symbolic-only operations such as indexed sums,
18
+ * products, solvers, and matrix operations are rejected if they remain in the expression.
19
+ *
20
+ * `buildFunction` uses `new Function`, so it may be unavailable under a Content Security Policy
21
+ * that forbids dynamic JavaScript evaluation. When `argsArray` is omitted, free variables are
22
+ * sorted alphabetically.
23
+ *
24
+ * @param x - The expression to compile.
25
+ * @param argsArray - Variable names in the positional order expected by the compiled function.
26
+ * @returns The compiled JavaScript-number function.
27
+ * @throws {@link core!UnsupportedOperationError} If the expression contains the imaginary unit or a
28
+ * function for which no matching JavaScript-number implementation is registered.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * buildFunction('x-y')(9, 7); // 2
33
+ * buildFunction('x-y', ['y', 'x'])(9, 7); // -2
34
+ * buildFunction('erf(x)+2')(9); // 3
35
+ * ```
36
+ */
37
+ export declare const buildFunction: (x: ExpressionInput, argsArray?: string[]) => (...args: number[]) => number;
17
38
  export type { ExpressionInput, NerdamerInput, ParserEntity, StructuredEntityType, } from '../core/types';
@@ -7,6 +7,7 @@ exports.buildFunction = exports.ZeroToZeroPowerError = exports.UnsupportedOperat
7
7
  * Import from `nerdamer/core` when working directly with Nerdamer values rather
8
8
  * than through the callable compatibility root.
9
9
  */
10
+ const build_1 = require("../core/functions/build");
10
11
  var Equation_1 = require("../core/classes/equation/Equation");
11
12
  Object.defineProperty(exports, "Equation", { enumerable: true, get: function () { return Equation_1.Equation; } });
12
13
  var CoeffObject_1 = require("../core/classes/expression/CoeffObject");
@@ -37,5 +38,30 @@ Object.defineProperty(exports, "UnexpectedInputError", { enumerable: true, get:
37
38
  Object.defineProperty(exports, "UnexpectedTokenError", { enumerable: true, get: function () { return errors_1.UnexpectedTokenError; } });
38
39
  Object.defineProperty(exports, "UnsupportedOperationError", { enumerable: true, get: function () { return errors_1.UnsupportedOperationError; } });
39
40
  Object.defineProperty(exports, "ZeroToZeroPowerError", { enumerable: true, get: function () { return errors_1.ZeroToZeroPowerError; } });
40
- var build_1 = require("../core/functions/build");
41
- Object.defineProperty(exports, "buildFunction", { enumerable: true, get: function () { return build_1.build; } });
41
+ /**
42
+ * Compiles an expression into a native JavaScript-number function for repeated evaluation.
43
+ *
44
+ * @remarks
45
+ * Function calls are linked to Nerdamer's numerical implementations, including any dependencies
46
+ * they require. The compiler supports scalar JavaScript-number arithmetic rather than Nerdamer's
47
+ * full symbolic or structured value model. Symbolic-only operations such as indexed sums,
48
+ * products, solvers, and matrix operations are rejected if they remain in the expression.
49
+ *
50
+ * `buildFunction` uses `new Function`, so it may be unavailable under a Content Security Policy
51
+ * that forbids dynamic JavaScript evaluation. When `argsArray` is omitted, free variables are
52
+ * sorted alphabetically.
53
+ *
54
+ * @param x - The expression to compile.
55
+ * @param argsArray - Variable names in the positional order expected by the compiled function.
56
+ * @returns The compiled JavaScript-number function.
57
+ * @throws {@link core!UnsupportedOperationError} If the expression contains the imaginary unit or a
58
+ * function for which no matching JavaScript-number implementation is registered.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * buildFunction('x-y')(9, 7); // 2
63
+ * buildFunction('x-y', ['y', 'x'])(9, 7); // -2
64
+ * buildFunction('erf(x)+2')(9); // 3
65
+ * ```
66
+ */
67
+ exports.buildFunction = build_1.build;
@@ -95,7 +95,7 @@ function diff(x, variable, n) {
95
95
  const n = nth ? Number(nth) - 1 : 0;
96
96
  // Pull the derivate of the outside. At this point we've already performed all the required checks.
97
97
  const m = x.getMultiplier().times(x.getPower());
98
- const p = x.getPower().minus('1');
98
+ const p = x.getPower().minus((0, shortcuts_1.one)());
99
99
  const f = Expression_1.Expression.create(x.value);
100
100
  const fp = p.isZero() ? m : f.pow(p).times(m);
101
101
  // Pull the derivative of the inside
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadCalculusFunctions = loadCalculusFunctions;
4
+ const constants_1 = require("../core/classes/parser/constants");
4
5
  const dispatch_1 = require("../core/dispatch");
5
- const math_1 = require("../math/math");
6
6
  const defint_1 = require("../math/defint/defint");
7
+ const math_1 = require("../math/math");
7
8
  const adapters_1 = require("./adapters");
8
9
  const fresnel_1 = require("./fresnel");
9
10
  const ilaplace_1 = require("./laplace/ilaplace");
10
11
  const laplace_1 = require("./laplace/laplace");
11
- const constants_1 = require("../core/classes/parser/constants");
12
12
  function loadCalculusFunctions() {
13
13
  Object.assign(dispatch_1.mathFunctionRegistry, {
14
14
  diff: (0, dispatch_1.systemFunction)({ fn: adapters_1.differentiate, minArgs: 1, maxArgs: 3, equationArgs: [0], distElWise: true }),
@@ -293,7 +293,7 @@ function tryIntegrateSqrtQuadratic(expr, dx) {
293
293
  return undefined;
294
294
  }
295
295
  if (a.lt((0, shortcuts_1.zero)()) && k.gt((0, shortcuts_1.zero)())) {
296
- const sqrtNegA = a.times('-1').pow((0, shortcuts_1.half)());
296
+ const sqrtNegA = a.times((0, shortcuts_1.minusOne)()).pow((0, shortcuts_1.half)());
297
297
  const sqrtK = k.pow((0, shortcuts_1.half)());
298
298
  const arg = sqrtNegA.times(u).div(sqrtK);
299
299
  return leadingTerm.plus(k.div((0, shortcuts_1.two)().times(sqrtNegA)).times(Expression_1.Expression.toFunction(constants_1.ASIN, [arg])));
@@ -412,10 +412,10 @@ function tryIntegrateLinearOverQuadratic(expr, dx) {
412
412
  return result;
413
413
  }
414
414
  const twoAxPlusB = (0, shortcuts_1.two)().times(a).times(x).plus(b);
415
- const delta = (0, shortcuts_1.four)().times(a).times(c).minus(b.pow('2'));
415
+ const delta = (0, shortcuts_1.four)().times(a).times(c).minus(b.pow((0, shortcuts_1.two)()));
416
416
  let reciprocalIntegral;
417
417
  if (delta.isZero()) {
418
- reciprocalIntegral = (0, shortcuts_1.two)().times('-1').div(twoAxPlusB);
418
+ reciprocalIntegral = (0, shortcuts_1.two)().times((0, shortcuts_1.minusOne)()).div(twoAxPlusB);
419
419
  }
420
420
  else if (delta.gt((0, shortcuts_1.zero)())) {
421
421
  const sqrtDelta = delta.pow((0, shortcuts_1.half)());
@@ -425,7 +425,7 @@ function tryIntegrateLinearOverQuadratic(expr, dx) {
425
425
  .times(Expression_1.Expression.toFunction(constants_1.ATAN, [arg]));
426
426
  }
427
427
  else if (delta.lt((0, shortcuts_1.zero)())) {
428
- const sqrtNegDelta = delta.times('-1').pow((0, shortcuts_1.half)());
428
+ const sqrtNegDelta = delta.times((0, shortcuts_1.minusOne)()).pow((0, shortcuts_1.half)());
429
429
  const ratio = twoAxPlusB.minus(sqrtNegDelta).div(twoAxPlusB.plus(sqrtNegDelta));
430
430
  reciprocalIntegral = (0, math_1.log)(ratio).div(sqrtNegDelta);
431
431
  }
@@ -407,7 +407,7 @@ const hyperbolicTrigTable = {
407
407
  if (p.get('n2').isOne()) {
408
408
  return p.fromPattern('(a1*atan(sinh(a2*x1)))/a2');
409
409
  }
410
- else if (p.get('n2').eq(2)) {
410
+ else if (p.get('n2').eq((0, shortcuts_1.two)())) {
411
411
  return p.fromPattern('(a1*tanh(a2*x1))/a2');
412
412
  }
413
413
  }
@@ -418,7 +418,7 @@ const hyperbolicTrigTable = {
418
418
  if (p.get('n2').isOne()) {
419
419
  return p.fromPattern('(a1*log(tanh((a2*x1)/2)))/a2');
420
420
  }
421
- else if (p.get('n2').eq(2)) {
421
+ else if (p.get('n2').eq((0, shortcuts_1.two)())) {
422
422
  return p.fromPattern('-(a1*coth(a2*x1))/a2');
423
423
  }
424
424
  }
@@ -461,7 +461,7 @@ const hyperbolicTrigTable = {
461
461
  if (p.get('n3').isOne()) {
462
462
  return p.fromPattern('(a1*atan(sinh(a2*(a3*x1+a4))))/(a2*a3)');
463
463
  }
464
- else if (p.get('n3').eq(2)) {
464
+ else if (p.get('n3').eq((0, shortcuts_1.two)())) {
465
465
  return p.fromPattern('(a1*tanh(a2*(a3*x1+a4)))/(a2*a3)');
466
466
  }
467
467
  }
@@ -472,7 +472,7 @@ const hyperbolicTrigTable = {
472
472
  if (p.get('n3').isOne()) {
473
473
  return p.fromPattern('(a1*log(tanh((a2*(a3*x1+a4))/2)))/(a2*a3)');
474
474
  }
475
- else if (p.get('n3').eq(2)) {
475
+ else if (p.get('n3').eq((0, shortcuts_1.two)())) {
476
476
  return p.fromPattern('-(a1*coth(a2*(a3*x1+a4)))/(a2*a3)');
477
477
  }
478
478
  }
@@ -538,7 +538,7 @@ const hyperbolicTrigTable = {
538
538
  if (n4.isOne()) {
539
539
  return p.fromPattern('-(a1*sech(a2*x1)^n2)/(a2*n2)');
540
540
  }
541
- if (n2.eq(2)) {
541
+ if (n2.eq((0, shortcuts_1.two)())) {
542
542
  return p.fromPattern('(a1*tanh(a2*x1)^(n4+1))/(a2*(n4+1))');
543
543
  }
544
544
  if (n4.isOdd()) {
@@ -563,7 +563,7 @@ const hyperbolicTrigTable = {
563
563
  if (n2.isOne()) {
564
564
  return p.fromPattern('-(a1*csch(a2*x1)^n4)/(a2*n4)');
565
565
  }
566
- if (n4.eq(2)) {
566
+ if (n4.eq((0, shortcuts_1.two)())) {
567
567
  return p.fromPattern('-(a1*coth(a2*x1)^(n2+1))/(a2*(n2+1))');
568
568
  }
569
569
  if (n2.isOdd()) {
@@ -847,49 +847,49 @@ const specialFunctionTable = {
847
847
  const knownIntegralsTable = {
848
848
  // sqrt(a-b*x^2)
849
849
  'a1*(-a2*x1^n1+a3)^n2': p => {
850
- if (p.get('n1').eq(2) && p.get('n2').isHalf()) {
850
+ if (p.get('n1').eq((0, shortcuts_1.two)()) && p.get('n2').isHalf()) {
851
851
  return p.fromPattern('(a1*x1*(-a2*x1^2+a3)^(1/2))/2+(a1*a3*asin((a2^(1/2)*x1)/(a3^(1/2))))/(2*a2^(1/2))');
852
852
  }
853
853
  },
854
854
  // diff(atanh(x)) and diff(asin(x))
855
855
  'a1/((-a2*x1^n1+a3)^n2)': p => {
856
- if (p.get('n1').eq(2) && p.get('n2').isOne()) {
856
+ if (p.get('n1').eq((0, shortcuts_1.two)()) && p.get('n2').isOne()) {
857
857
  return p.fromPattern('(a1/(a2^(1/2)*a3^(1/2)))*atanh((a2^(1/2)*x1)/(a3^(1/2)))');
858
858
  }
859
- else if (p.get('n1').eq(2) && p.get('n2').isHalf()) {
859
+ else if (p.get('n1').eq((0, shortcuts_1.two)()) && p.get('n2').isHalf()) {
860
860
  return p.fromPattern('(a1/a2^(1/2))*asin((a2^(1/2)*x1)/(a3^(1/2)))');
861
861
  }
862
862
  },
863
863
  // diff(acos(x))
864
864
  '-a1/((-a2*x1^n1+a3)^n2)': p => {
865
- if (p.get('n1').eq(2) && p.get('n2').isHalf()) {
865
+ if (p.get('n1').eq((0, shortcuts_1.two)()) && p.get('n2').isHalf()) {
866
866
  return p.fromPattern('(a1/a2^(1/2))*acos((a2^(1/2)*x1)/(a3^(1/2)))');
867
867
  }
868
868
  },
869
869
  // diff(atan(x)) and diff(asinh(x))
870
870
  'a1/((a2*x1^n1+a3)^n2)': p => {
871
- if (p.get('n1').eq(2) && p.get('n2').isOne()) {
871
+ if (p.get('n1').eq((0, shortcuts_1.two)()) && p.get('n2').isOne()) {
872
872
  return p.fromPattern('(a1/(a2^(1/2)*a3^(1/2)))*atan((a2^(1/2)*x1)/(a3^(1/2)))');
873
873
  }
874
- else if (p.get('n1').eq(2) && p.get('n2').isHalf()) {
874
+ else if (p.get('n1').eq((0, shortcuts_1.two)()) && p.get('n2').isHalf()) {
875
875
  return p.fromPattern('(a1/a2^(1/2))*asinh((a2^(1/2)*x1)/(a3^(1/2)))');
876
876
  }
877
877
  },
878
878
  // diff(acot(x))
879
879
  '-a1/((a2*x1^n1+a3)^n2)': p => {
880
- if (p.get('n1').eq(2) && p.get('n2').isOne()) {
880
+ if (p.get('n1').eq((0, shortcuts_1.two)()) && p.get('n2').isOne()) {
881
881
  return p.fromPattern('(a1/(a2^(1/2)*a3^(1/2)))*acot((a2^(1/2)*x1)/(a3^(1/2)))');
882
882
  }
883
883
  },
884
884
  // diff(asec(x))
885
885
  'a1/(x1^n1*(-a2/x1^n2+a3)^n3)': p => {
886
- if (p.get('n1').isOne() && p.get('n2').eq(2) && p.get('n3').isHalf()) {
886
+ if (p.get('n1').isOne() && p.get('n2').eq((0, shortcuts_1.two)()) && p.get('n3').isHalf()) {
887
887
  return p.fromPattern('(a1/a3^(1/2))*asec((a3^(1/2)*x1)/(a2^(1/2)))');
888
888
  }
889
889
  },
890
890
  // diff(acsc(x))
891
891
  '-a1/(x1^n1*(-a2/x1^n2+a3)^n3)': p => {
892
- if (p.get('n1').isOne() && p.get('n2').eq(2) && p.get('n3').isHalf()) {
892
+ if (p.get('n1').isOne() && p.get('n2').eq((0, shortcuts_1.two)()) && p.get('n3').isHalf()) {
893
893
  return p.fromPattern('(a1/a3^(1/2))*acsc((a3^(1/2)*x1)/(a2^(1/2)))');
894
894
  }
895
895
  },
@@ -897,7 +897,7 @@ const knownIntegralsTable = {
897
897
  // -1/(x*sqrt(1+1/x^2)) -> -acsch(x^-1)
898
898
  // after constant stripping: 1/(x*sqrt(1+1/x^2))
899
899
  'a1/(x1^n1*(a2/x1^n2+a3)^n3)': p => {
900
- if (p.get('n1').isOne() && p.get('n2').eq(2) && p.get('n3').eq(1 / 2)) {
900
+ if (p.get('n1').isOne() && p.get('n2').eq((0, shortcuts_1.two)()) && p.get('n3').eq((0, shortcuts_1.half)())) {
901
901
  return p.fromPattern('a1*acsch((sqrt(a2/a3))/x1)/sqrt(a2*a3)');
902
902
  }
903
903
  },
@@ -99,7 +99,7 @@ function ilaplace(expr, s, t) {
99
99
  const hasShiftedSquare = den.isSum() &&
100
100
  den
101
101
  .elementsArray()
102
- .some(term => term.getPower().eq(2) && term.getBase().isSum());
102
+ .some(term => term.getPower().eq((0, shortcuts_1.two)()) && term.getBase().isSum());
103
103
  if (!h.isZero() && !hasShiftedSquare) {
104
104
  const constant = numCoeffs.hasPower(0) ? numCoeffs.getPower(0) : (0, shortcuts_1.zero)();
105
105
  const linear = numCoeffs.hasPower(1) ? numCoeffs.getPower(1) : (0, shortcuts_1.zero)();
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tableOfInverseTransforms = void 0;
4
+ const shortcuts_1 = require("../../core/classes/expression/shortcuts");
4
5
  const LookupTable_1 = require("../../core/classes/lookupTable/LookupTable");
5
6
  const Pattern_1 = require("../../core/converters/Pattern");
6
7
  const ilaplaceTable = {
@@ -27,10 +28,10 @@ const ilaplaceTable = {
27
28
  if (n1.isOne()) {
28
29
  return p.fromPattern('(a1*t^(n2-1)*e^((-a3/a2)*t))/(a2^n2*gamma(n2))');
29
30
  }
30
- if (n1.eq(2) && n2.isOne()) {
31
+ if (n1.eq((0, shortcuts_1.two)()) && n2.isOne()) {
31
32
  return p.fromPattern('(a1*sin((a3^(1/2)*t)/(a2^(1/2))))/(a2^(1/2)*a3^(1/2))');
32
33
  }
33
- if (n1.eq(2) && n2.eq(2)) {
34
+ if (n1.eq((0, shortcuts_1.two)()) && n2.eq((0, shortcuts_1.two)())) {
34
35
  return p
35
36
  .fromPattern('(a1*sin((a3^(1/2)*t)/(a2^(1/2))))/(2*a2^(1/2)*a3^(3/2))')
36
37
  .minus(p.fromPattern('(a1*t*cos((a3^(1/2)*t)/(a2^(1/2))))/(2*a2*a3)'));
@@ -45,18 +46,18 @@ const ilaplaceTable = {
45
46
  // (a1*t*sin((a3^(1/2)*t)/(a2^(1/2)))) / (2*a2^(3/2)*a3^(1/2))
46
47
  '(a1*x1^n1)/((a2*x1^n2+a3)^n3)': p => {
47
48
  const { n1, n2, n3 } = p.references;
48
- if (!n2.eq(2)) {
49
+ if (!n2.eq((0, shortcuts_1.two)())) {
49
50
  return undefined;
50
51
  }
51
52
  if (n1.isOne()) {
52
53
  if (n3.isOne()) {
53
54
  return p.fromPattern('(a1*cos((a3^(1/2)*t)/(a2^(1/2))))/a2');
54
55
  }
55
- if (n3.eq(2)) {
56
+ if (n3.eq((0, shortcuts_1.two)())) {
56
57
  return p.fromPattern('(a1*t*sin((a3^(1/2)*t)/(a2^(1/2))))/(2*a2^(3/2)*a3^(1/2))');
57
58
  }
58
59
  }
59
- if (n1.eq(2) && n3.eq(2)) {
60
+ if (n1.eq((0, shortcuts_1.two)()) && n3.eq((0, shortcuts_1.two)())) {
60
61
  return p
61
62
  .fromPattern('(a1*sin((a3^(1/2)*t)/(a2^(1/2))))/(2*a2^(1/2)*a3^(1/2))')
62
63
  .plus(p.fromPattern('(a1*t*cos((a3^(1/2)*t)/(a2^(1/2))))/(2*a2)'));
@@ -68,7 +69,7 @@ const ilaplaceTable = {
68
69
  // 1 / (((s-b)^2 + c^2)^n) and 1 / (((s-b)^2 - c^2)^n)
69
70
  'a1/((a2*(a3*x1^n1+a4)^n2+a5)^n3)': p => {
70
71
  const { n1, n2, n3, a5 } = p.references;
71
- if (!n1.isOne() || !n2.eq(2)) {
72
+ if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)())) {
72
73
  return undefined;
73
74
  }
74
75
  // Hyperbolic branch: a5 < 0
@@ -76,7 +77,7 @@ const ilaplaceTable = {
76
77
  if (n3.isOne()) {
77
78
  return p.fromPattern('(a1*e^((-a4/a3)*t)*sinh((((-a5)^(1/2))*t)/(a2^(1/2)*a3)))/(a2^(1/2)*a3*((-a5)^(1/2)))');
78
79
  }
79
- if (n3.eq(2)) {
80
+ if (n3.eq((0, shortcuts_1.two)())) {
80
81
  return p.fromPattern('(a1*e^((-a4/a3)*t)*((((-a5)^(1/2))*t*cosh((((-a5)^(1/2))*t)/(a2^(1/2)*a3)))/(a2^(1/2)*a3)-sinh((((-a5)^(1/2))*t)/(a2^(1/2)*a3))))/(2*a2^(1/2)*a3*((-a5)^(3/2)))');
81
82
  }
82
83
  return undefined;
@@ -85,7 +86,7 @@ const ilaplaceTable = {
85
86
  if (n3.isOne()) {
86
87
  return p.fromPattern('(a1*e^((-a4/a3)*t)*sin((a5^(1/2)*t)/(a2^(1/2)*a3)))/(a2^(1/2)*a3*a5^(1/2))');
87
88
  }
88
- if (n3.eq(2)) {
89
+ if (n3.eq((0, shortcuts_1.two)())) {
89
90
  return p.fromPattern('(a1*e^((-a4/a3)*t)*(sin((a5^(1/2)*t)/(a2^(1/2)*a3))-(a5^(1/2)*t*cos((a5^(1/2)*t)/(a2^(1/2)*a3)))/(a2^(1/2)*a3)))/(2*a2^(1/2)*a3*a5^(3/2))');
90
91
  }
91
92
  return undefined;
@@ -98,7 +99,7 @@ const ilaplaceTable = {
98
99
  // (c*(s-a)) / ((b*(d*(s-a))^2 + e)^n)
99
100
  '(a1*((a6*x1^n4+a7)^n5))/((a2*(a3*x1^n1+a4)^n2+a5)^n3)': p => {
100
101
  const { n1, n2, n3, n4, n5, a3, a4, a5, a6, a7 } = p.references;
101
- if (!n1.isOne() || !n2.eq(2) || !n4.isOne() || !n5.isOne()) {
102
+ if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)()) || !n4.isOne() || !n5.isOne()) {
102
103
  return undefined;
103
104
  }
104
105
  // numerator affine term must be a scalar multiple of denominator affine term
@@ -110,7 +111,7 @@ const ilaplaceTable = {
110
111
  if (n3.isOne()) {
111
112
  return p.fromPattern('(a1*a6*e^((-a4/a3)*t)*cosh((((-a5)^(1/2))*t)/(a2^(1/2)*a3)))/(a2*a3^2)');
112
113
  }
113
- if (n3.eq(2)) {
114
+ if (n3.eq((0, shortcuts_1.two)())) {
114
115
  return p.fromPattern('(a1*a6*t*e^((-a4/a3)*t)*sinh((((-a5)^(1/2))*t)/(a2^(1/2)*a3)))/(2*a2^(3/2)*a3^3*((-a5)^(1/2)))');
115
116
  }
116
117
  return undefined;
@@ -119,7 +120,7 @@ const ilaplaceTable = {
119
120
  if (n3.isOne()) {
120
121
  return p.fromPattern('(a1*a6*e^((-a4/a3)*t)*cos((a5^(1/2)*t)/(a2^(1/2)*a3)))/(a2*a3^2)');
121
122
  }
122
- if (n3.eq(2)) {
123
+ if (n3.eq((0, shortcuts_1.two)())) {
123
124
  return p.fromPattern('(a1*a6*t*e^((-a4/a3)*t)*sin((a5^(1/2)*t)/(a2^(1/2)*a3)))/(2*a2^(3/2)*a3^3*a5^(1/2))');
124
125
  }
125
126
  return undefined;
@@ -127,7 +128,7 @@ const ilaplaceTable = {
127
128
  // ((c*(s-a))^2) / ((b*(d*(s-a))^2 + e)^2)
128
129
  '(a1*(a6*x1^n4+a7)^n5)/((a2*(a3*x1^n1+a4)^n2+a5)^n3)': p => {
129
130
  const { n1, n2, n3, n4, n5, a3, a4, a5, a6, a7 } = p.references;
130
- if (!n1.isOne() || !n2.eq(2) || !n3.eq(2) || !n4.isOne() || !n5.eq(2)) {
131
+ if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)()) || !n3.eq((0, shortcuts_1.two)()) || !n4.isOne() || !n5.eq((0, shortcuts_1.two)())) {
131
132
  return undefined;
132
133
  }
133
134
  // numerator affine term must be a scalar multiple of denominator affine term
@@ -144,7 +145,7 @@ const ilaplaceTable = {
144
145
  // a / ((s-b)^2 - c^2)
145
146
  'a1/(a2*(a3*x1^n1+a4)^n2-a5)': p => {
146
147
  const { n1, n2 } = p.references;
147
- if (!n1.isOne() || !n2.eq(2)) {
148
+ if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)())) {
148
149
  return undefined;
149
150
  }
150
151
  return p.fromPattern('(a1*e^((-a4/a3)*t)*sinh((a5^(1/2)*t)/(a2^(1/2)*a3)))/(a2^(1/2)*a3*a5^(1/2))');
@@ -152,7 +153,7 @@ const ilaplaceTable = {
152
153
  // (s-b) / ((s-b)^2 - c^2)
153
154
  '(a1*(a6*x1^n3+a7)^n4)/(a2*(a3*x1^n1+a4)^n2-a5)': p => {
154
155
  const { n1, n2, n3, n4 } = p.references;
155
- if (!n1.isOne() || !n2.eq(2) || !n3.isOne() || !n4.isOne()) {
156
+ if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)()) || !n3.isOne() || !n4.isOne()) {
156
157
  return undefined;
157
158
  }
158
159
  return p.fromPattern('(a1*e^((-a4/a3)*t)*cosh((a5^(1/2)*t)/(a2^(1/2)*a3)))/(a2*a3^2)');
@@ -160,7 +161,7 @@ const ilaplaceTable = {
160
161
  // a / (((s-b)^2 - c^2)^2)
161
162
  'a1/((a2*(a3*x1^n1+a4)^n2-a5)^n3)': p => {
162
163
  const { n1, n2, n3 } = p.references;
163
- if (!n1.isOne() || !n2.eq(2) || !n3.eq(2)) {
164
+ if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)()) || !n3.eq((0, shortcuts_1.two)())) {
164
165
  return undefined;
165
166
  }
166
167
  return p.fromPattern('(a1*e^((-a4/a3)*t)*(a5^(1/2)*t*cosh((a5^(1/2)*t)/(a2^(1/2)*a3))-a2^(1/2)*a3*sinh((a5^(1/2)*t)/(a2^(1/2)*a3))))/(2*a2*a3^2*a5^(3/2))');
@@ -168,7 +169,7 @@ const ilaplaceTable = {
168
169
  // (s-b) / (((s-b)^2 - c^2)^2)
169
170
  '(a1*(a6*x1^n3+a7)^n4)/((a2*(a3*x1^n1+a4)^n2-a5)^n5)': p => {
170
171
  const { n1, n2, n3, n4, n5 } = p.references;
171
- if (!n1.isOne() || !n2.eq(2) || !n3.isOne() || !n4.isOne() || !n5.eq(2)) {
172
+ if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)()) || !n3.isOne() || !n4.isOne() || !n5.eq((0, shortcuts_1.two)())) {
172
173
  return undefined;
173
174
  }
174
175
  return p.fromPattern('(a1*t*e^((-a4/a3)*t)*sinh((a5^(1/2)*t)/(a2^(1/2)*a3)))/(2*a2^(1/2)*a3*a5^(1/2))');
@@ -176,7 +177,7 @@ const ilaplaceTable = {
176
177
  // (A*(B*(s-a)^2+C)) / ((D*(s-a)^2+E)^2)
177
178
  '(a1*((a2*(a3*x1^n1+a4)^n2+a5)^n3))/((a6*(a7*x1^n4+a8)^n5+a9)^n6)': p => {
178
179
  const { n1, n2, n3, n4, n5, n6, _a2, a3, a4, _a6, a7, a8, _a9 } = p.references;
179
- if (!n1.isOne() || !n2.eq(2) || !n3.isOne() || !n4.isOne() || !n5.eq(2) || !n6.eq(2)) {
180
+ if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)()) || !n3.isOne() || !n4.isOne() || !n5.eq((0, shortcuts_1.two)()) || !n6.eq((0, shortcuts_1.two)())) {
180
181
  return undefined;
181
182
  }
182
183
  if (!a3.eq(a7) || !a4.eq(a8)) {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tableOfTransforms = void 0;
4
+ const shortcuts_1 = require("../../core/classes/expression/shortcuts");
4
5
  const LookupTable_1 = require("../../core/classes/lookupTable/LookupTable");
5
6
  const diff_1 = require("../derivative/diff");
6
7
  const laplaceTable = {
@@ -12,7 +13,7 @@ const laplaceTable = {
12
13
  'a1*x1^n1': p => {
13
14
  const { n1 } = p.references;
14
15
  // Reject Gamma poles: n1 = -1, -2, -3, ...
15
- if (n1.isNegative() && n1.plus(1).isInteger()) {
16
+ if (n1.isNegative() && n1.plus((0, shortcuts_1.one)()).isInteger()) {
16
17
  return undefined;
17
18
  }
18
19
  return p.fromPattern('a1*gamma(n1+1)/s^(n1+1)');
@@ -45,7 +46,7 @@ const laplaceTable = {
45
46
  return undefined;
46
47
  }
47
48
  // Reject the pole at Gamma(0), Gamma(-1), ...
48
- if (n2.isNegative() && n2.plus(1).isInteger()) {
49
+ if (n2.isNegative() && n2.plus((0, shortcuts_1.one)()).isInteger()) {
49
50
  return undefined;
50
51
  }
51
52
  return p.fromPattern('a1*gamma(n2+1)/(s-log(a2)*a3)^(n2+1)');
@@ -923,7 +923,7 @@ function tryComposition(expr, x, val, dir, depth) {
923
923
  const gPrime = (0, diff_1.diff)(g, x);
924
924
  if (!gPrime.isZero()) {
925
925
  // L'Hôpital on f/(1/g): result = -f'·g²/g'
926
- let lhopitalExpr = (0, simplify_1.simplify)(fPrime.times(g.pow(2)).div(gPrime).neg());
926
+ let lhopitalExpr = (0, simplify_1.simplify)(fPrime.times(g.pow((0, shortcuts_1.two)())).div(gPrime).neg());
927
927
  // Multiply back any remaining factors
928
928
  for (let i = 0; i < factors.length; i++) {
929
929
  if (i !== zeroIdx && i !== infIdx) {