nerdamer 1.1.13 → 2.0.0-rc.1
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/LICENSE.md +184 -0
- package/README.md +293 -312
- package/dist/bundle.js +2 -0
- package/dist/bundle.js.LICENSE.txt +7 -0
- package/dist/parser.js +2 -0
- package/dist/parser.js.LICENSE.txt +7 -0
- package/docs-data/parser-functions.json +1960 -0
- package/index.d.ts +10 -426
- package/output/algebra/adapters.d.ts +33 -0
- package/output/algebra/adapters.js +109 -0
- package/output/algebra/algorithms/arith.d.ts +84 -0
- package/output/algebra/algorithms/arith.js +323 -0
- package/output/algebra/algorithms/factor.d.ts +3 -0
- package/output/algebra/algorithms/factor.js +5 -0
- package/output/algebra/algorithms/factorMultivariate.d.ts +23 -0
- package/output/algebra/algorithms/factorMultivariate.js +2393 -0
- package/output/algebra/algorithms/factorUnivariate.d.ts +72 -0
- package/output/algebra/algorithms/factorUnivariate.js +1072 -0
- package/output/algebra/algorithms/gcd.d.ts +22 -0
- package/output/algebra/algorithms/gcd.js +690 -0
- package/output/algebra/algorithms/groebnerBase.d.ts +157 -0
- package/output/algebra/algorithms/groebnerBase.js +1166 -0
- package/output/algebra/algorithms/multiPoly/MultiPoly.d.ts +137 -0
- package/output/algebra/algorithms/multiPoly/MultiPoly.js +346 -0
- package/output/algebra/algorithms/poly.d.ts +228 -0
- package/output/algebra/algorithms/poly.js +1299 -0
- package/output/algebra/algorithms/rational.d.ts +17 -0
- package/output/algebra/algorithms/rational.js +115 -0
- package/output/algebra/factor/factor.d.ts +62 -0
- package/output/algebra/factor/factor.js +158 -0
- package/output/algebra/gcd/gcd.d.ts +29 -0
- package/output/algebra/gcd/gcd.js +141 -0
- package/output/algebra/groebner.d.ts +21 -0
- package/output/algebra/groebner.js +42 -0
- package/output/algebra/partfrac.d.ts +19 -0
- package/output/algebra/partfrac.js +398 -0
- package/output/algebra/polynomialize.d.ts +20 -0
- package/output/algebra/polynomialize.js +24 -0
- package/output/algebra/simplify/complexsimp.d.ts +7 -0
- package/output/algebra/simplify/complexsimp.js +24 -0
- package/output/algebra/simplify/factorCommon.d.ts +13 -0
- package/output/algebra/simplify/factorCommon.js +136 -0
- package/output/algebra/simplify/funcsimp.d.ts +26 -0
- package/output/algebra/simplify/funcsimp.js +633 -0
- package/output/algebra/simplify/invtrigrewrite.d.ts +10 -0
- package/output/algebra/simplify/invtrigrewrite.js +96 -0
- package/output/algebra/simplify/ratsimp.d.ts +21 -0
- package/output/algebra/simplify/ratsimp.js +140 -0
- package/output/algebra/simplify/simplify.d.ts +25 -0
- package/output/algebra/simplify/simplify.js +228 -0
- package/output/algebra/simplify/trigreduce.d.ts +38 -0
- package/output/algebra/simplify/trigreduce.js +424 -0
- package/output/algebra/simplify/trigrewrite.d.ts +17 -0
- package/output/algebra/simplify/trigrewrite.js +156 -0
- package/output/algebra/simplify/trigsimp.d.ts +11 -0
- package/output/algebra/simplify/trigsimp.js +369 -0
- package/output/algebra/simplify/utils.d.ts +32 -0
- package/output/algebra/simplify/utils.js +56 -0
- package/output/algebra/utils.d.ts +32 -0
- package/output/algebra/utils.js +48 -0
- package/output/api/advanced.d.ts +7 -0
- package/output/api/advanced.js +18 -0
- package/output/api/algebra.d.ts +17 -0
- package/output/api/algebra.js +32 -0
- package/output/api/assumptions.d.ts +4 -0
- package/output/api/assumptions.js +11 -0
- package/output/api/calculus.d.ts +9 -0
- package/output/api/calculus.js +21 -0
- package/output/api/core.d.ts +17 -0
- package/output/api/core.js +41 -0
- package/output/api/debug.d.ts +16 -0
- package/output/api/debug.js +23 -0
- package/output/api/parser.d.ts +85 -0
- package/output/api/parser.js +16 -0
- package/output/api/solve.d.ts +10 -0
- package/output/api/solve.js +16 -0
- package/output/api/structures.d.ts +10 -0
- package/output/api/structures.js +22 -0
- package/output/calculus/derivative/diff.d.ts +30 -0
- package/output/calculus/derivative/diff.js +238 -0
- package/output/calculus/fresnel.d.ts +16 -0
- package/output/calculus/fresnel.js +39 -0
- package/output/calculus/integrate/byParts.d.ts +18 -0
- package/output/calculus/integrate/byParts.js +339 -0
- package/output/calculus/integrate/bySubstitution.d.ts +135 -0
- package/output/calculus/integrate/bySubstitution.js +411 -0
- package/output/calculus/integrate/integrate.d.ts +38 -0
- package/output/calculus/integrate/integrate.js +652 -0
- package/output/calculus/integrate/integrationTable.d.ts +2 -0
- package/output/calculus/integrate/integrationTable.js +914 -0
- package/output/calculus/integrate/utils.d.ts +28 -0
- package/output/calculus/integrate/utils.js +96 -0
- package/output/calculus/laplace/ilaplace.d.ts +31 -0
- package/output/calculus/laplace/ilaplace.js +192 -0
- package/output/calculus/laplace/ilaplaceTable.d.ts +2 -0
- package/output/calculus/laplace/ilaplaceTable.js +200 -0
- package/output/calculus/laplace/laplace.d.ts +22 -0
- package/output/calculus/laplace/laplace.js +109 -0
- package/output/calculus/laplace/laplaceTable.d.ts +2 -0
- package/output/calculus/laplace/laplaceTable.js +187 -0
- package/output/calculus/limit/limit.d.ts +35 -0
- package/output/calculus/limit/limit.js +1183 -0
- package/output/calculus/limit/limitsTable.d.ts +2 -0
- package/output/calculus/limit/limitsTable.js +7 -0
- package/output/core/Settings.d.ts +32 -0
- package/output/core/Settings.js +68 -0
- package/output/core/adapters.d.ts +18 -0
- package/output/core/adapters.js +40 -0
- package/output/core/classes/assumption/Assumption.d.ts +218 -0
- package/output/core/classes/assumption/Assumption.js +605 -0
- package/output/core/classes/assumption/assertiveFunctions.d.ts +6 -0
- package/output/core/classes/assumption/assertiveFunctions.js +64 -0
- package/output/core/classes/assumption/assume.d.ts +90 -0
- package/output/core/classes/assumption/assume.js +145 -0
- package/output/core/classes/collection/Collection.d.ts +107 -0
- package/output/core/classes/collection/Collection.js +231 -0
- package/output/core/classes/complex/Complex.d.ts +99 -0
- package/output/core/classes/complex/Complex.js +135 -0
- package/output/core/classes/decimalSet/DecimalSet.d.ts +226 -0
- package/output/core/classes/decimalSet/DecimalSet.js +453 -0
- package/output/core/classes/dictionary/Dictionary.d.ts +102 -0
- package/output/core/classes/dictionary/Dictionary.js +213 -0
- package/output/core/classes/equation/Equation.d.ts +256 -0
- package/output/core/classes/equation/Equation.js +350 -0
- package/output/core/classes/expression/CoeffObject.d.ts +100 -0
- package/output/core/classes/expression/CoeffObject.js +198 -0
- package/output/core/classes/expression/Expression.d.ts +1674 -0
- package/output/core/classes/expression/Expression.js +2332 -0
- package/output/core/classes/expression/analysis.d.ts +25 -0
- package/output/core/classes/expression/analysis.js +218 -0
- package/output/core/classes/expression/collect.d.ts +9 -0
- package/output/core/classes/expression/collect.js +49 -0
- package/output/core/classes/expression/format.d.ts +45 -0
- package/output/core/classes/expression/format.js +217 -0
- package/output/core/classes/expression/products.d.ts +23 -0
- package/output/core/classes/expression/products.js +115 -0
- package/output/core/classes/expression/shortcuts.d.ts +35 -0
- package/output/core/classes/expression/shortcuts.js +129 -0
- package/output/core/classes/expression/traversal.d.ts +31 -0
- package/output/core/classes/expression/traversal.js +216 -0
- package/output/core/classes/expression/trig.d.ts +25 -0
- package/output/core/classes/expression/trig.js +40 -0
- package/output/core/classes/expression/utils.d.ts +52 -0
- package/output/core/classes/expression/utils.js +189 -0
- package/output/core/classes/lookupTable/LookupTable.d.ts +12 -0
- package/output/core/classes/lookupTable/LookupTable.js +55 -0
- package/output/core/classes/matrix/Matrix.d.ts +227 -0
- package/output/core/classes/matrix/Matrix.js +889 -0
- package/output/core/classes/matrix/Sylvester.d.ts +11 -0
- package/output/core/classes/matrix/Sylvester.js +54 -0
- package/output/core/classes/matrix/functions.d.ts +26 -0
- package/output/core/classes/matrix/functions.js +52 -0
- package/output/core/classes/matrix/utils.d.ts +9 -0
- package/output/core/classes/matrix/utils.js +22 -0
- package/output/core/classes/parser/Parser.d.ts +480 -0
- package/output/core/classes/parser/Parser.js +1812 -0
- package/output/core/classes/parser/Token.d.ts +58 -0
- package/output/core/classes/parser/Token.js +137 -0
- package/output/core/classes/parser/constants.d.ts +160 -0
- package/output/core/classes/parser/constants.js +227 -0
- package/output/core/classes/parser/helpers.d.ts +21 -0
- package/output/core/classes/parser/helpers.js +42 -0
- package/output/core/classes/parser/operations/add.d.ts +15 -0
- package/output/core/classes/parser/operations/add.js +238 -0
- package/output/core/classes/parser/operations/comma.d.ts +7 -0
- package/output/core/classes/parser/operations/comma.js +11 -0
- package/output/core/classes/parser/operations/compare.d.ts +21 -0
- package/output/core/classes/parser/operations/compare.js +461 -0
- package/output/core/classes/parser/operations/divide.d.ts +2 -0
- package/output/core/classes/parser/operations/divide.js +72 -0
- package/output/core/classes/parser/operations/functions.d.ts +46 -0
- package/output/core/classes/parser/operations/functions.js +430 -0
- package/output/core/classes/parser/operations/multiply.d.ts +11 -0
- package/output/core/classes/parser/operations/multiply.js +321 -0
- package/output/core/classes/parser/operations/power.d.ts +48 -0
- package/output/core/classes/parser/operations/power.js +673 -0
- package/output/core/classes/parser/operations/subtract.d.ts +3 -0
- package/output/core/classes/parser/operations/subtract.js +35 -0
- package/output/core/classes/parser/preprocess.d.ts +14 -0
- package/output/core/classes/parser/preprocess.js +259 -0
- package/output/core/classes/parser/scripting/controlFlow.d.ts +121 -0
- package/output/core/classes/parser/scripting/controlFlow.js +355 -0
- package/output/core/classes/parser/scripting/evaluate.d.ts +10 -0
- package/output/core/classes/parser/scripting/evaluate.js +112 -0
- package/output/core/classes/parser/scripting/functions.d.ts +14 -0
- package/output/core/classes/parser/scripting/functions.js +59 -0
- package/output/core/classes/parser/scripting/scope.d.ts +35 -0
- package/output/core/classes/parser/scripting/scope.js +155 -0
- package/output/core/classes/parser/types.d.ts +125 -0
- package/output/core/classes/parser/types.js +2 -0
- package/output/core/classes/parser/wrappers/IndexedReference.d.ts +31 -0
- package/output/core/classes/parser/wrappers/IndexedReference.js +68 -0
- package/output/core/classes/parser/wrappers/KeyValuePair.d.ts +24 -0
- package/output/core/classes/parser/wrappers/KeyValuePair.js +51 -0
- package/output/core/classes/polynomial/Polynomial.d.ts +500 -0
- package/output/core/classes/polynomial/Polynomial.js +1149 -0
- package/output/core/classes/polynomial/Term.d.ts +222 -0
- package/output/core/classes/polynomial/Term.js +430 -0
- package/output/core/classes/polynomial/functions.d.ts +69 -0
- package/output/core/classes/polynomial/functions.js +126 -0
- package/output/core/classes/polynomial/utils.d.ts +62 -0
- package/output/core/classes/polynomial/utils.js +206 -0
- package/output/core/classes/rational/Rational.d.ts +504 -0
- package/output/core/classes/rational/Rational.js +779 -0
- package/output/core/classes/seq/SEQ.d.ts +13 -0
- package/output/core/classes/seq/SEQ.js +137 -0
- package/output/core/classes/valuesSet/ValuesSet.d.ts +179 -0
- package/output/core/classes/valuesSet/ValuesSet.js +381 -0
- package/output/core/classes/vector/Vector.d.ts +222 -0
- package/output/core/classes/vector/Vector.js +497 -0
- package/output/core/classes/vector/functions.d.ts +28 -0
- package/output/core/classes/vector/functions.js +47 -0
- package/output/core/common/classes/MathematicalAggregate.d.ts +53 -0
- package/output/core/common/classes/MathematicalAggregate.js +140 -0
- package/output/core/common/classes/Scope.d.ts +62 -0
- package/output/core/common/classes/Scope.js +122 -0
- package/output/core/common/classes/StructuredEntity.d.ts +55 -0
- package/output/core/common/classes/StructuredEntity.js +151 -0
- package/output/core/common/common.d.ts +63 -0
- package/output/core/common/common.js +279 -0
- package/output/core/common/functions/functions.d.ts +14 -0
- package/output/core/common/functions/functions.js +33 -0
- package/output/core/common/functions/structuredEntityUtils.d.ts +27 -0
- package/output/core/common/functions/structuredEntityUtils.js +40 -0
- package/output/core/converters/BaseConverter.d.ts +97 -0
- package/output/core/converters/BaseConverter.js +405 -0
- package/output/core/converters/Converter.d.ts +111 -0
- package/output/core/converters/Converter.js +802 -0
- package/output/core/converters/Pattern.d.ts +71 -0
- package/output/core/converters/Pattern.js +302 -0
- package/output/core/dispatch.d.ts +34 -0
- package/output/core/dispatch.js +304 -0
- package/output/core/errors.d.ts +531 -0
- package/output/core/errors.js +621 -0
- package/output/core/functions/bigint/bigint.d.ts +121 -0
- package/output/core/functions/bigint/bigint.js +392 -0
- package/output/core/functions/bigint/primeFactor.d.ts +49 -0
- package/output/core/functions/bigint/primeFactor.js +267 -0
- package/output/core/functions/bigint/primes.d.ts +1 -0
- package/output/core/functions/bigint/primes.js +11 -0
- package/output/core/functions/build/definitions.d.ts +12 -0
- package/output/core/functions/build/definitions.js +133 -0
- package/output/core/functions/build/index.d.ts +32 -0
- package/output/core/functions/build/index.js +136 -0
- package/output/core/functions/complex.d.ts +90 -0
- package/output/core/functions/complex.js +482 -0
- package/output/core/functions/decimal.d.ts +24 -0
- package/output/core/functions/decimal.js +664 -0
- package/output/core/functions/expand/expand.d.ts +42 -0
- package/output/core/functions/expand/expand.js +376 -0
- package/output/core/functions/fresnelNumeric.d.ts +12 -0
- package/output/core/functions/fresnelNumeric.js +123 -0
- package/output/core/functions/numeric.d.ts +140 -0
- package/output/core/functions/numeric.js +790 -0
- package/output/core/functions/rationalNormalization.d.ts +11 -0
- package/output/core/functions/rationalNormalization.js +117 -0
- package/output/core/functions/setFunction.d.ts +19 -0
- package/output/core/functions/setFunction.js +75 -0
- package/output/core/functions/string.d.ts +26 -0
- package/output/core/functions/string.js +101 -0
- package/output/core/functions/subst.d.ts +90 -0
- package/output/core/functions/subst.js +498 -0
- package/output/core/functions/utils.d.ts +24 -0
- package/output/core/functions/utils.js +51 -0
- package/output/core/types.d.ts +48 -0
- package/output/core/types.js +2 -0
- package/output/index.d.ts +339 -0
- package/output/index.js +715 -0
- package/output/math/defint/defintDecimal.d.ts +37 -0
- package/output/math/defint/defintDecimal.js +320 -0
- package/output/math/defint/defintNative.d.ts +57 -0
- package/output/math/defint/defintNative.js +292 -0
- package/output/math/geometry.d.ts +8 -0
- package/output/math/geometry.js +32 -0
- package/output/math/math.d.ts +655 -0
- package/output/math/math.js +1811 -0
- package/output/math/trig.d.ts +518 -0
- package/output/math/trig.js +1444 -0
- package/output/math/trunc.d.ts +19 -0
- package/output/math/trunc.js +36 -0
- package/output/math/utils.d.ts +60 -0
- package/output/math/utils.js +180 -0
- package/output/solve/classes/DecimalMatrix.d.ts +17 -0
- package/output/solve/classes/DecimalMatrix.js +86 -0
- package/output/solve/classes/FunctionSolver.d.ts +135 -0
- package/output/solve/classes/FunctionSolver.js +433 -0
- package/output/solve/classes/MultivariateSolver.d.ts +84 -0
- package/output/solve/classes/MultivariateSolver.js +240 -0
- package/output/solve/classes/PolynomialSolver.d.ts +85 -0
- package/output/solve/classes/PolynomialSolver.js +292 -0
- package/output/solve/classes/SolutionSet.d.ts +153 -0
- package/output/solve/classes/SolutionSet.js +357 -0
- package/output/solve/classes/Solver.d.ts +17 -0
- package/output/solve/classes/Solver.js +132 -0
- package/output/solve/classes/SymbolicSolver.d.ts +74 -0
- package/output/solve/classes/SymbolicSolver.js +601 -0
- package/output/solve/linsolve.d.ts +51 -0
- package/output/solve/linsolve.js +225 -0
- package/output/solve/solve.d.ts +34 -0
- package/output/solve/solve.js +260 -0
- package/output/solve/solveSystem.d.ts +31 -0
- package/output/solve/solveSystem.js +290 -0
- package/output/solve/utils.d.ts +9 -0
- package/output/solve/utils.js +62 -0
- package/output/utils/array.d.ts +42 -0
- package/output/utils/array.js +98 -0
- package/output/utils/debug.d.ts +131 -0
- package/output/utils/debug.js +295 -0
- package/output/utils/decimal.d.ts +3 -0
- package/output/utils/decimal.js +16 -0
- package/output/utils/numeric.d.ts +14 -0
- package/output/utils/numeric.js +51 -0
- package/output/utils/object.d.ts +26 -0
- package/output/utils/object.js +56 -0
- package/package.json +213 -57
- package/.travis.yml +0 -3
- package/Algebra.js +0 -4568
- package/BREAKING_CHANGES.md +0 -5
- package/CODE_OF_CONDUCT.md +0 -46
- package/CONTRIBUTING.md +0 -14
- package/Calculus.js +0 -2675
- package/Extra.js +0 -622
- package/Solve.js +0 -1783
- package/all.js +0 -16
- package/all.min.js +0 -1
- package/gulpfile.js +0 -16
- package/index.html +0 -158
- package/license.txt +0 -19
- package/nerdamer.core.js +0 -12510
- package/spec/LaTeX.spec.js +0 -302
- package/spec/TeXConvert.spec.js +0 -8
- package/spec/algebra.spec.js +0 -287
- package/spec/basic_parser.spec.js +0 -134
- package/spec/build.spec.js +0 -131
- package/spec/calculus.spec.js +0 -183
- package/spec/core.spec.js +0 -2970
- package/spec/extra.spec.js +0 -54
- package/spec/solve.spec.js +0 -126
- package/spec/support/jasmine.json +0 -11
- package/spec/support/utils.js +0 -42
- package/spec/text.spec.js +0 -132
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contains = contains;
|
|
4
|
+
exports.constantsFreeProduct = constantsFreeProduct;
|
|
5
|
+
exports.splitProductFactors = splitProductFactors;
|
|
6
|
+
const shortcuts_1 = require("./shortcuts");
|
|
7
|
+
/**
|
|
8
|
+
* Similar to hasVariable but is extended to products
|
|
9
|
+
*
|
|
10
|
+
* @param x
|
|
11
|
+
* @param y
|
|
12
|
+
*/
|
|
13
|
+
function contains(x, y) {
|
|
14
|
+
// If it's an integer then it's always true
|
|
15
|
+
let retval = false;
|
|
16
|
+
// If y is a multiple of x's multiplier then return true
|
|
17
|
+
const m = x.getMultiplier().abs();
|
|
18
|
+
const n = y.getMultiplier().abs();
|
|
19
|
+
// The division can only occur if y's multiplier is an integer multiple of x's multiplier
|
|
20
|
+
if (m.isInteger() && n.isInteger() && m.gte(n)) {
|
|
21
|
+
// Multiples of the integers are a good match so we're done.
|
|
22
|
+
if (y.isNUM()) {
|
|
23
|
+
retval = true;
|
|
24
|
+
}
|
|
25
|
+
else if (x.isProduct()) {
|
|
26
|
+
// If it's a variable then just check if it has that variable
|
|
27
|
+
if (y.isVAR()) {
|
|
28
|
+
retval = x.hasVariable(y.value);
|
|
29
|
+
}
|
|
30
|
+
else if (y.isProduct()) {
|
|
31
|
+
// We check each variable granted that
|
|
32
|
+
// 1 - It's not under the denominator
|
|
33
|
+
// 2 - It's of type VAR
|
|
34
|
+
const variables = y.elementsArray();
|
|
35
|
+
for (let i = 0; i < variables.length; i++) {
|
|
36
|
+
const v = variables[i];
|
|
37
|
+
// We check of the above-mentioned conditions. If any of them are true do
|
|
38
|
+
// nothing. Otherwise pass it.
|
|
39
|
+
const p = v.getPower();
|
|
40
|
+
if (v.isVAR() && x.hasVariable(v.value) && p.isInteger() && p.gt((0, shortcuts_1.zero)())) {
|
|
41
|
+
retval = true;
|
|
42
|
+
}
|
|
43
|
+
// If any of the variables doesn't pass then we're done and exit.
|
|
44
|
+
else {
|
|
45
|
+
retval = false;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return retval;
|
|
53
|
+
} /**
|
|
54
|
+
* Removes the multiplier and constants wrt to a given variable
|
|
55
|
+
* @param expression
|
|
56
|
+
* @param wrtVariable
|
|
57
|
+
*/
|
|
58
|
+
function constantsFreeProduct(expression, wrtVariable) {
|
|
59
|
+
// Remove the multiplier
|
|
60
|
+
let constants = expression.getMultiplier(true);
|
|
61
|
+
expression = expression.toUnitMultiplier();
|
|
62
|
+
// Products are always power of one
|
|
63
|
+
// TODO: Move to helper called constantsFree
|
|
64
|
+
if (expression.isProduct() && expression.isLinear()) {
|
|
65
|
+
// Remove the constants
|
|
66
|
+
// e.g. a*(cos(x)+sin(x))
|
|
67
|
+
let constantFree = (0, shortcuts_1.one)();
|
|
68
|
+
expression.each(e => {
|
|
69
|
+
if (!e.hasVariable(wrtVariable)) {
|
|
70
|
+
constants = constants.times(e);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
constantFree = constantFree.times(e);
|
|
74
|
+
}
|
|
75
|
+
expression = constantFree;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
constants,
|
|
80
|
+
expression,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Splits a product into its factors e.g. a^2*b^3 will return [a, a, b, b, b]
|
|
85
|
+
* @param f
|
|
86
|
+
* @param factors
|
|
87
|
+
* @returns
|
|
88
|
+
*/
|
|
89
|
+
function splitProductFactors(f, factors) {
|
|
90
|
+
// Only products need apply
|
|
91
|
+
if (!f.isProduct()) {
|
|
92
|
+
return [f];
|
|
93
|
+
}
|
|
94
|
+
factors ??= [];
|
|
95
|
+
f.each(e => {
|
|
96
|
+
// Check the exponent. If it has a integer multiplier > 1 then split
|
|
97
|
+
const p = e.getPower();
|
|
98
|
+
const pm = p.getMultiplier();
|
|
99
|
+
if (pm.isInteger() && pm.gt((0, shortcuts_1.one)())) {
|
|
100
|
+
const ps = p.toUnitMultiplier();
|
|
101
|
+
// Get the base
|
|
102
|
+
const base = e.toLinearAndUnitMultiplier();
|
|
103
|
+
for (let i = 0; i < Number(pm.numerator); i++) {
|
|
104
|
+
factors.push(base.pow(ps));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (e.isProduct()) {
|
|
108
|
+
splitProductFactors(e, factors);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
factors.push(e);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return factors;
|
|
115
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Expression } from './Expression';
|
|
2
|
+
export declare function zero(): Expression;
|
|
3
|
+
export declare function quarter(): Expression;
|
|
4
|
+
export declare function third(): Expression;
|
|
5
|
+
export declare function half(): Expression;
|
|
6
|
+
export declare function one(): Expression;
|
|
7
|
+
export declare function minusOne(): Expression;
|
|
8
|
+
export declare function two(): Expression;
|
|
9
|
+
export declare function minusTwo(): Expression;
|
|
10
|
+
export declare function three(): Expression;
|
|
11
|
+
export declare function minusThree(): Expression;
|
|
12
|
+
export declare function four(): Expression;
|
|
13
|
+
export declare function five(): Expression;
|
|
14
|
+
export declare function six(): Expression;
|
|
15
|
+
export declare function seven(): Expression;
|
|
16
|
+
export declare function eight(): Expression;
|
|
17
|
+
export declare function sixteen(): Expression;
|
|
18
|
+
export declare function twentySeven(): Expression;
|
|
19
|
+
export declare function twoHundredFiftySix(): Expression;
|
|
20
|
+
export declare function I(): Expression;
|
|
21
|
+
export declare function all(): Expression;
|
|
22
|
+
/**
|
|
23
|
+
* A convenience function for creating simple symbols reducing the reliance on strings
|
|
24
|
+
* @param args A series of string variables
|
|
25
|
+
* @returns An object of created symbols
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const { x, y } = symbols('x', 'y');
|
|
30
|
+
* cos(x.sq()).times(y);
|
|
31
|
+
*
|
|
32
|
+
* // Also available as nerdamer.symbols
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function symbols(...args: string[]): Record<string, Expression>;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zero = zero;
|
|
4
|
+
exports.quarter = quarter;
|
|
5
|
+
exports.third = third;
|
|
6
|
+
exports.half = half;
|
|
7
|
+
exports.one = one;
|
|
8
|
+
exports.minusOne = minusOne;
|
|
9
|
+
exports.two = two;
|
|
10
|
+
exports.minusTwo = minusTwo;
|
|
11
|
+
exports.three = three;
|
|
12
|
+
exports.minusThree = minusThree;
|
|
13
|
+
exports.four = four;
|
|
14
|
+
exports.five = five;
|
|
15
|
+
exports.six = six;
|
|
16
|
+
exports.seven = seven;
|
|
17
|
+
exports.eight = eight;
|
|
18
|
+
exports.sixteen = sixteen;
|
|
19
|
+
exports.twentySeven = twentySeven;
|
|
20
|
+
exports.twoHundredFiftySix = twoHundredFiftySix;
|
|
21
|
+
exports.I = I;
|
|
22
|
+
exports.all = all;
|
|
23
|
+
exports.symbols = symbols;
|
|
24
|
+
const errors_1 = require("../../errors");
|
|
25
|
+
const constants_1 = require("../parser/constants");
|
|
26
|
+
const Expression_1 = require("./Expression");
|
|
27
|
+
const CACHE = {};
|
|
28
|
+
function getFromCacheOrCreate(value) {
|
|
29
|
+
if (CACHE[value] === undefined) {
|
|
30
|
+
const c = Expression_1.Expression.Number(value);
|
|
31
|
+
// Set the power and multiplier since this create problems
|
|
32
|
+
// later when it's requested because we'll be freezing this object
|
|
33
|
+
c.getMultiplier();
|
|
34
|
+
c.getPower();
|
|
35
|
+
Object.freeze(c);
|
|
36
|
+
CACHE[value] = c;
|
|
37
|
+
}
|
|
38
|
+
return CACHE[value];
|
|
39
|
+
}
|
|
40
|
+
function zero() {
|
|
41
|
+
return getFromCacheOrCreate('0');
|
|
42
|
+
}
|
|
43
|
+
function quarter() {
|
|
44
|
+
return getFromCacheOrCreate('1/4');
|
|
45
|
+
}
|
|
46
|
+
function third() {
|
|
47
|
+
return getFromCacheOrCreate('1/3');
|
|
48
|
+
}
|
|
49
|
+
function half() {
|
|
50
|
+
return getFromCacheOrCreate('1/2');
|
|
51
|
+
}
|
|
52
|
+
function one() {
|
|
53
|
+
return getFromCacheOrCreate('1');
|
|
54
|
+
}
|
|
55
|
+
function minusOne() {
|
|
56
|
+
return getFromCacheOrCreate('-1');
|
|
57
|
+
}
|
|
58
|
+
function two() {
|
|
59
|
+
return getFromCacheOrCreate('2');
|
|
60
|
+
}
|
|
61
|
+
function minusTwo() {
|
|
62
|
+
return getFromCacheOrCreate('-2');
|
|
63
|
+
}
|
|
64
|
+
function three() {
|
|
65
|
+
return getFromCacheOrCreate('3');
|
|
66
|
+
}
|
|
67
|
+
function minusThree() {
|
|
68
|
+
return getFromCacheOrCreate('-3');
|
|
69
|
+
}
|
|
70
|
+
function four() {
|
|
71
|
+
return getFromCacheOrCreate('4');
|
|
72
|
+
}
|
|
73
|
+
function five() {
|
|
74
|
+
return getFromCacheOrCreate('5');
|
|
75
|
+
}
|
|
76
|
+
function six() {
|
|
77
|
+
return getFromCacheOrCreate('6');
|
|
78
|
+
}
|
|
79
|
+
function seven() {
|
|
80
|
+
return getFromCacheOrCreate('7');
|
|
81
|
+
}
|
|
82
|
+
function eight() {
|
|
83
|
+
return getFromCacheOrCreate('8');
|
|
84
|
+
}
|
|
85
|
+
function sixteen() {
|
|
86
|
+
return getFromCacheOrCreate('16');
|
|
87
|
+
}
|
|
88
|
+
function twentySeven() {
|
|
89
|
+
return getFromCacheOrCreate('27');
|
|
90
|
+
}
|
|
91
|
+
function twoHundredFiftySix() {
|
|
92
|
+
return getFromCacheOrCreate('256');
|
|
93
|
+
}
|
|
94
|
+
function I() {
|
|
95
|
+
return Expression_1.Expression.Img();
|
|
96
|
+
}
|
|
97
|
+
function all() {
|
|
98
|
+
return Expression_1.Expression.Variable(constants_1.ALL_SYMBOL);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A convenience function for creating simple symbols reducing the reliance on strings
|
|
102
|
+
* @param args A series of string variables
|
|
103
|
+
* @returns An object of created symbols
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* const { x, y } = symbols('x', 'y');
|
|
108
|
+
* cos(x.sq()).times(y);
|
|
109
|
+
*
|
|
110
|
+
* // Also available as nerdamer.symbols
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
function symbols(...args) {
|
|
114
|
+
const created = {};
|
|
115
|
+
for (const x of args) {
|
|
116
|
+
// Must be a plain variable
|
|
117
|
+
const c = Expression_1.Expression.create(x);
|
|
118
|
+
// Trigger creation of multiplier and power.
|
|
119
|
+
c.getMultiplier();
|
|
120
|
+
c.getPower();
|
|
121
|
+
if (!c.isVAR()) {
|
|
122
|
+
throw new errors_1.UnexpectedInputError((0, errors_1.message)('plainVariableExpected'));
|
|
123
|
+
}
|
|
124
|
+
// Make it read-only
|
|
125
|
+
Object.freeze(c);
|
|
126
|
+
created[x] = c;
|
|
127
|
+
}
|
|
128
|
+
return created;
|
|
129
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Expression } from './Expression';
|
|
2
|
+
/**
|
|
3
|
+
* Collects all variables from a set of expressions, sorted alphabetically.
|
|
4
|
+
* @param exprs The array of expression from which the variables will be collect
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare function collectVariablesSet(exprs: Expression[]): string[]; /**
|
|
8
|
+
* Collects all the variables in an expression
|
|
9
|
+
*
|
|
10
|
+
* @param x
|
|
11
|
+
* @param vars
|
|
12
|
+
* @param reserved Names excluded from free-variable collection.
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare function variables(x: Expression, vars: string[] | undefined, reserved: readonly string[]): string[];
|
|
16
|
+
/**
|
|
17
|
+
* Collects the functions in a symbolic expression
|
|
18
|
+
*
|
|
19
|
+
* @param x
|
|
20
|
+
* @param fns
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export declare function functions(x: Expression, fns?: string[], getValues?: boolean): string[];
|
|
24
|
+
export declare function hasFunction(x: Expression, name: string, deep?: boolean): boolean;
|
|
25
|
+
export declare function hasVariable(x: Expression, variable: string): boolean; /**
|
|
26
|
+
* Loops through each elements and rebuilds a new expression
|
|
27
|
+
* @param x
|
|
28
|
+
* @param fn
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
export declare function forEveryElement(x: Expression, fn: (e: Expression) => Expression, isLeaf?: boolean): Expression;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectVariablesSet = collectVariablesSet;
|
|
4
|
+
exports.variables = variables;
|
|
5
|
+
exports.functions = functions;
|
|
6
|
+
exports.hasFunction = hasFunction;
|
|
7
|
+
exports.hasVariable = hasVariable;
|
|
8
|
+
exports.forEveryElement = forEveryElement;
|
|
9
|
+
const shortcuts_1 = require("./shortcuts");
|
|
10
|
+
function collect(x, condition, action, values) {
|
|
11
|
+
values ??= [];
|
|
12
|
+
if (condition(x, values)) {
|
|
13
|
+
action(x, values);
|
|
14
|
+
}
|
|
15
|
+
// Apply it to function arguments
|
|
16
|
+
if (x.args) {
|
|
17
|
+
for (const e of x.args) {
|
|
18
|
+
collect(e, condition, action, values);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// Search the sub-elements
|
|
22
|
+
if (x.elements) {
|
|
23
|
+
for (const e in x.elements) {
|
|
24
|
+
collect(x.elements[e], condition, action, values);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// Search the power
|
|
28
|
+
if (x.isEXP()) {
|
|
29
|
+
// Check target value. It's difficult to know if it's a variable so the best way is to parse and check.
|
|
30
|
+
// The unfortunate consequence is that we create a reliance on Parser.parse but target is a very tricky
|
|
31
|
+
// issue to solve. Consider (x+1)^x. A link to the previous type can be created but then if it gets
|
|
32
|
+
// raised again (x+1)^x^x then we have two links in which case we're not searching the chain.
|
|
33
|
+
// Is it better to rely on parse? Or a reference to target class and introduce a `searchChain` method for instance.
|
|
34
|
+
collect(x.getBase(), condition, action, values);
|
|
35
|
+
// Check the power
|
|
36
|
+
collect(x.getPower(), condition, action, values);
|
|
37
|
+
}
|
|
38
|
+
return values;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Collects all variables from a set of expressions, sorted alphabetically.
|
|
42
|
+
* @param exprs The array of expression from which the variables will be collect
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
function collectVariablesSet(exprs) {
|
|
46
|
+
const varSet = new Set();
|
|
47
|
+
for (const expr of exprs) {
|
|
48
|
+
const v = expr.variables();
|
|
49
|
+
for (const name of v) {
|
|
50
|
+
varSet.add(name);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return Array.from(varSet).sort();
|
|
54
|
+
} /**
|
|
55
|
+
* Collects all the variables in an expression
|
|
56
|
+
*
|
|
57
|
+
* @param x
|
|
58
|
+
* @param vars
|
|
59
|
+
* @param reserved Names excluded from free-variable collection.
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
function variables(x, vars, reserved) {
|
|
63
|
+
// Must be of type VAR, cannot be the imaginary unit or a reserved variable, and cannot have been encountered before
|
|
64
|
+
const condition = (x, vars) => {
|
|
65
|
+
return (x.isVAR() &&
|
|
66
|
+
!x.isI() &&
|
|
67
|
+
!vars.includes(x.value) &&
|
|
68
|
+
!reserved.includes(x.value));
|
|
69
|
+
};
|
|
70
|
+
const action = (x, vars) => {
|
|
71
|
+
vars.push(x.value);
|
|
72
|
+
};
|
|
73
|
+
return collect(x, condition, action, vars);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Collects the functions in a symbolic expression
|
|
77
|
+
*
|
|
78
|
+
* @param x
|
|
79
|
+
* @param fns
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
function functions(x, fns, getValues) {
|
|
83
|
+
// The name property is guaranteed on the FUN type.
|
|
84
|
+
const condition = (x, fns) => {
|
|
85
|
+
return x.isFunction() && !fns.includes(getValues === true ? x.value : x.name);
|
|
86
|
+
};
|
|
87
|
+
const action = (x, fns) => {
|
|
88
|
+
if (getValues === true) {
|
|
89
|
+
fns.push(x.value);
|
|
90
|
+
}
|
|
91
|
+
else if (x.isFunction()) {
|
|
92
|
+
fns.push(x.name);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return collect(x, condition, action, fns);
|
|
96
|
+
}
|
|
97
|
+
function hasFunction(x, name, deep = false) {
|
|
98
|
+
if (x.isFunction() && x.name === name) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
// Search the function arguments
|
|
102
|
+
if (deep && x.args) {
|
|
103
|
+
for (const e of x.args) {
|
|
104
|
+
if (hasFunction(e, name, deep)) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Search the sub-elements
|
|
110
|
+
if (x.elements) {
|
|
111
|
+
for (const e in x.elements) {
|
|
112
|
+
if (hasFunction(x.elements[e], name, deep)) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Search the power
|
|
118
|
+
if (deep && x.isEXP()) {
|
|
119
|
+
// Check x value. It's difficult to know if it's a variable
|
|
120
|
+
// so the best way is to parse and check.
|
|
121
|
+
// Creating a new instance seems like overkill
|
|
122
|
+
if (hasFunction(x.getBase(), name, deep)) {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
// Check the power
|
|
126
|
+
if (hasFunction(x.getPower(), name, deep)) {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
function hasVariable(x, variable) {
|
|
133
|
+
// Only VAR is a variable so we want its value.
|
|
134
|
+
if (x.isVAR() && x.value === variable) {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
// Search the function arguments
|
|
138
|
+
if (x.args) {
|
|
139
|
+
for (const e of x.args) {
|
|
140
|
+
if (hasVariable(e, variable)) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Search the sub-elements
|
|
146
|
+
if (x.elements) {
|
|
147
|
+
const elements = x.getElements();
|
|
148
|
+
for (const e in elements) {
|
|
149
|
+
if (hasVariable(elements[e], variable)) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// Search the power
|
|
155
|
+
if (x.isEXP()) {
|
|
156
|
+
// Check x value. It's difficult to know if it's a variable
|
|
157
|
+
// so the best way is to parse and check.
|
|
158
|
+
// TODO: See if x still makes sense. Creating a new instance seems like overkill
|
|
159
|
+
if (hasVariable(x.getBase(), variable)) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
// Check the power
|
|
163
|
+
if (hasVariable(x.getPower(), variable)) {
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
} /**
|
|
169
|
+
* Loops through each elements and rebuilds a new expression
|
|
170
|
+
* @param x
|
|
171
|
+
* @param fn
|
|
172
|
+
* @returns
|
|
173
|
+
*/
|
|
174
|
+
function forEveryElement(x, fn, isLeaf = false) {
|
|
175
|
+
// There's nothing to iterate over for these types so done.
|
|
176
|
+
if (x.isNUM() || x.isVAR()) {
|
|
177
|
+
return x;
|
|
178
|
+
}
|
|
179
|
+
const m = x.getMultiplier();
|
|
180
|
+
let p = x.getPower();
|
|
181
|
+
// Call it on p if it's an EXP
|
|
182
|
+
if (x.isEXP()) {
|
|
183
|
+
p = forEveryElement(p, fn, true);
|
|
184
|
+
}
|
|
185
|
+
// Don't call it again if it was called from inside forEveryElement and trust that it was
|
|
186
|
+
// properly processed
|
|
187
|
+
const exp = fn(x.toLinearAndUnitMultiplier());
|
|
188
|
+
let retval;
|
|
189
|
+
if (exp.isFunction()) {
|
|
190
|
+
exp.args = exp.getArguments().map(e => {
|
|
191
|
+
if (isLeaf) {
|
|
192
|
+
return fn(e);
|
|
193
|
+
}
|
|
194
|
+
return forEveryElement(e, fn, true);
|
|
195
|
+
});
|
|
196
|
+
retval = exp;
|
|
197
|
+
}
|
|
198
|
+
else if (exp.isProduct()) {
|
|
199
|
+
retval = (0, shortcuts_1.one)();
|
|
200
|
+
for (let e of exp.elementsArray()) {
|
|
201
|
+
e = fn(e);
|
|
202
|
+
retval = retval.times(forEveryElement(e, fn, true));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else if (exp.isSum()) {
|
|
206
|
+
retval = (0, shortcuts_1.zero)();
|
|
207
|
+
for (let e of exp.elementsArray()) {
|
|
208
|
+
e = fn(e);
|
|
209
|
+
retval = retval.plus(forEveryElement(e, fn, true));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
retval = fn(exp);
|
|
214
|
+
}
|
|
215
|
+
return retval.pow(p).times(m);
|
|
216
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Expression } from './Expression';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a function is a trig function
|
|
4
|
+
* @param f
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare function isTrig(f: Expression): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Checks if a function is a inverse trig function
|
|
10
|
+
* @param f
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export declare function isInverseTrig(f: Expression): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if a function is a hyperbolic trig function
|
|
16
|
+
* @param f
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export declare function isHyperbolicTrig(f: Expression): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if a function is a hyperbolic trig function
|
|
22
|
+
* @param f
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export declare function isInverseHyperbolicTrig(f: Expression): boolean;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTrig = isTrig;
|
|
4
|
+
exports.isInverseTrig = isInverseTrig;
|
|
5
|
+
exports.isHyperbolicTrig = isHyperbolicTrig;
|
|
6
|
+
exports.isInverseHyperbolicTrig = isInverseHyperbolicTrig;
|
|
7
|
+
const constants_1 = require("../parser/constants");
|
|
8
|
+
// Trig helpers
|
|
9
|
+
/**
|
|
10
|
+
* Checks if a function is a trig function
|
|
11
|
+
* @param f
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
function isTrig(f) {
|
|
15
|
+
return f.isFunction() && constants_1.TRIG.includes(f.name);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Checks if a function is a inverse trig function
|
|
19
|
+
* @param f
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
function isInverseTrig(f) {
|
|
23
|
+
return f.isFunction() && constants_1.INVERSE_TRIG.includes(f.name);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Checks if a function is a hyperbolic trig function
|
|
27
|
+
* @param f
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
function isHyperbolicTrig(f) {
|
|
31
|
+
return f.isFunction() && constants_1.HYPERBOLIC_TRIG.includes(f.name);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Checks if a function is a hyperbolic trig function
|
|
35
|
+
* @param f
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
function isInverseHyperbolicTrig(f) {
|
|
39
|
+
return f.isFunction() && constants_1.INVERSE_HYPERBOLIC_TRIG.includes(f.name);
|
|
40
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Expression } from './Expression';
|
|
2
|
+
import type { OptionsObject } from '../parser/types';
|
|
3
|
+
export type conditionType = (x: Expression, values: string[]) => boolean;
|
|
4
|
+
export type actionType = (x: Expression, values: string[]) => void;
|
|
5
|
+
type ExpressionTuplesObj = {
|
|
6
|
+
num: Expression[];
|
|
7
|
+
den: Expression[];
|
|
8
|
+
power?: ExpressionTuplesObj;
|
|
9
|
+
args?: ExpressionTuplesObj[];
|
|
10
|
+
};
|
|
11
|
+
export type termType = {
|
|
12
|
+
type: number;
|
|
13
|
+
num: Expression[];
|
|
14
|
+
den: Expression[];
|
|
15
|
+
name?: string;
|
|
16
|
+
power?: termType;
|
|
17
|
+
elements?: termType[];
|
|
18
|
+
args?: termType[];
|
|
19
|
+
};
|
|
20
|
+
/** Multiplies a series of Expressions into one product. */
|
|
21
|
+
export declare function product(...args: Expression[]): Expression;
|
|
22
|
+
/** Adds a series of Expressions into one sum. */
|
|
23
|
+
export declare function sum(...args: Expression[]): Expression;
|
|
24
|
+
/** Removes the power from an Expression. The original object is unchanged. */
|
|
25
|
+
export declare function stripPower(x: Expression): Expression;
|
|
26
|
+
/**
|
|
27
|
+
* Copies over all the properties of the provided symbolic essentially cloning it to x.
|
|
28
|
+
*
|
|
29
|
+
* @param sym
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
export declare function copyOver(src: Expression, target: Expression, options?: OptionsObject): Expression;
|
|
33
|
+
/**
|
|
34
|
+
* This function converts the expression in a collection of arrays
|
|
35
|
+
*
|
|
36
|
+
* @param x
|
|
37
|
+
* @param arrayObj
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
export declare function toArrays(x: Expression, arrayObj?: ExpressionTuplesObj): ExpressionTuplesObj;
|
|
41
|
+
/**
|
|
42
|
+
* Gets the max between two or more Expressions. Just know that if two variable arguments are provided,
|
|
43
|
+
* it will not be able to know with any certainty which is bigger so the first one will be returned.
|
|
44
|
+
*
|
|
45
|
+
* @param x
|
|
46
|
+
* @param args
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
export declare function largestPower(x: Expression, ...args: Expression[]): Expression;
|
|
50
|
+
export declare function assertPlainVariableAndGetString(x: Expression): string;
|
|
51
|
+
export declare function getNumericOrAssumedValue(x: Expression): Expression | undefined;
|
|
52
|
+
export {};
|