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,17 @@
|
|
|
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
|
+
*/
|
|
7
|
+
export { Equation } from '../core/classes/equation/Equation';
|
|
8
|
+
export { CoeffObject } from '../core/classes/expression/CoeffObject';
|
|
9
|
+
export { Expression } from '../core/classes/expression/Expression';
|
|
10
|
+
export type { ElementsSortType } from '../core/classes/expression/Expression';
|
|
11
|
+
export { symbols } from '../core/classes/expression/shortcuts';
|
|
12
|
+
export type { JsFunction, OptionValue, OptionsObject, ParserConstants, ParserValuesObject, TextOptions, } from '../core/classes/parser/types';
|
|
13
|
+
export { Rational } from '../core/classes/rational/Rational';
|
|
14
|
+
export { Converter } from '../core/converters/Converter';
|
|
15
|
+
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';
|
|
17
|
+
export type { ExpressionInput, NerdamerInput, ParserEntity, StructuredEntityType, } from '../core/types';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildFunction = exports.ZeroToZeroPowerError = exports.UnsupportedOperationError = exports.UnexpectedTokenError = exports.UnexpectedInputError = exports.UnexpectedDataType = exports.UndefinedError = exports.PolynomialError = exports.ParserSyntaxError = exports.ParserError = exports.OperatorError = exports.NotImplementedError = exports.NaNError = exports.MissingReferenceError = exports.MathError = exports.DivisionByZeroError = exports.DimensionError = exports.AssignmentError = exports.Converter = exports.Rational = exports.symbols = exports.Expression = exports.CoeffObject = exports.Equation = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Core Nerdamer object model and shared public types.
|
|
6
|
+
*
|
|
7
|
+
* Import from `nerdamer/core` when working directly with Nerdamer values rather
|
|
8
|
+
* than through the callable compatibility root.
|
|
9
|
+
*/
|
|
10
|
+
var Equation_1 = require("../core/classes/equation/Equation");
|
|
11
|
+
Object.defineProperty(exports, "Equation", { enumerable: true, get: function () { return Equation_1.Equation; } });
|
|
12
|
+
var CoeffObject_1 = require("../core/classes/expression/CoeffObject");
|
|
13
|
+
Object.defineProperty(exports, "CoeffObject", { enumerable: true, get: function () { return CoeffObject_1.CoeffObject; } });
|
|
14
|
+
var Expression_1 = require("../core/classes/expression/Expression");
|
|
15
|
+
Object.defineProperty(exports, "Expression", { enumerable: true, get: function () { return Expression_1.Expression; } });
|
|
16
|
+
var shortcuts_1 = require("../core/classes/expression/shortcuts");
|
|
17
|
+
Object.defineProperty(exports, "symbols", { enumerable: true, get: function () { return shortcuts_1.symbols; } });
|
|
18
|
+
var Rational_1 = require("../core/classes/rational/Rational");
|
|
19
|
+
Object.defineProperty(exports, "Rational", { enumerable: true, get: function () { return Rational_1.Rational; } });
|
|
20
|
+
var Converter_1 = require("../core/converters/Converter");
|
|
21
|
+
Object.defineProperty(exports, "Converter", { enumerable: true, get: function () { return Converter_1.Converter; } });
|
|
22
|
+
var errors_1 = require("../core/errors");
|
|
23
|
+
Object.defineProperty(exports, "AssignmentError", { enumerable: true, get: function () { return errors_1.AssignmentError; } });
|
|
24
|
+
Object.defineProperty(exports, "DimensionError", { enumerable: true, get: function () { return errors_1.DimensionError; } });
|
|
25
|
+
Object.defineProperty(exports, "DivisionByZeroError", { enumerable: true, get: function () { return errors_1.DivisionByZeroError; } });
|
|
26
|
+
Object.defineProperty(exports, "MathError", { enumerable: true, get: function () { return errors_1.MathError; } });
|
|
27
|
+
Object.defineProperty(exports, "MissingReferenceError", { enumerable: true, get: function () { return errors_1.MissingReferenceError; } });
|
|
28
|
+
Object.defineProperty(exports, "NaNError", { enumerable: true, get: function () { return errors_1.NaNError; } });
|
|
29
|
+
Object.defineProperty(exports, "NotImplementedError", { enumerable: true, get: function () { return errors_1.NotImplementedError; } });
|
|
30
|
+
Object.defineProperty(exports, "OperatorError", { enumerable: true, get: function () { return errors_1.OperatorError; } });
|
|
31
|
+
Object.defineProperty(exports, "ParserError", { enumerable: true, get: function () { return errors_1.ParserError; } });
|
|
32
|
+
Object.defineProperty(exports, "ParserSyntaxError", { enumerable: true, get: function () { return errors_1.ParserSyntaxError; } });
|
|
33
|
+
Object.defineProperty(exports, "PolynomialError", { enumerable: true, get: function () { return errors_1.PolynomialError; } });
|
|
34
|
+
Object.defineProperty(exports, "UndefinedError", { enumerable: true, get: function () { return errors_1.UndefinedError; } });
|
|
35
|
+
Object.defineProperty(exports, "UnexpectedDataType", { enumerable: true, get: function () { return errors_1.UnexpectedDataType; } });
|
|
36
|
+
Object.defineProperty(exports, "UnexpectedInputError", { enumerable: true, get: function () { return errors_1.UnexpectedInputError; } });
|
|
37
|
+
Object.defineProperty(exports, "UnexpectedTokenError", { enumerable: true, get: function () { return errors_1.UnexpectedTokenError; } });
|
|
38
|
+
Object.defineProperty(exports, "UnsupportedOperationError", { enumerable: true, get: function () { return errors_1.UnsupportedOperationError; } });
|
|
39
|
+
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; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contributor-facing diagnostic inspection helpers.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This module exposes plain-data views of Nerdamer parser and expression internals for
|
|
6
|
+
* debugging tools, issue reports, and visual inspectors. The shapes reflect Nerdamer's
|
|
7
|
+
* implementation and may change between releases; they are not part of the mathematical
|
|
8
|
+
* compatibility surface provided by the ordinary package APIs.
|
|
9
|
+
*
|
|
10
|
+
* Import these helpers from `nerdamer/debug`. Loading this subpath does not add them to
|
|
11
|
+
* the browser UMD bundle or the root `nerdamer` callable.
|
|
12
|
+
*
|
|
13
|
+
* @module debug
|
|
14
|
+
*/
|
|
15
|
+
export { inspectEntity, inspectExpressionData as inspectExpression, inspectParse, inspectPolynomialData as inspectPolynomial, inspectTermData as inspectTerm, } from '../utils/debug';
|
|
16
|
+
export type { DebugCollection, DebugDictionary, DebugDictionaryEntry, DebugEntity, DebugEquation, DebugExpression, DebugMatrix, DebugPolynomial, DebugScope, DebugScopeItem, DebugTerm, DebugToken, DebugValuesSet, DebugVector, ParseInspection, } from '../utils/debug';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inspectTerm = exports.inspectPolynomial = exports.inspectParse = exports.inspectExpression = exports.inspectEntity = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Contributor-facing diagnostic inspection helpers.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This module exposes plain-data views of Nerdamer parser and expression internals for
|
|
9
|
+
* debugging tools, issue reports, and visual inspectors. The shapes reflect Nerdamer's
|
|
10
|
+
* implementation and may change between releases; they are not part of the mathematical
|
|
11
|
+
* compatibility surface provided by the ordinary package APIs.
|
|
12
|
+
*
|
|
13
|
+
* Import these helpers from `nerdamer/debug`. Loading this subpath does not add them to
|
|
14
|
+
* the browser UMD bundle or the root `nerdamer` callable.
|
|
15
|
+
*
|
|
16
|
+
* @module debug
|
|
17
|
+
*/
|
|
18
|
+
var debug_1 = require("../utils/debug");
|
|
19
|
+
Object.defineProperty(exports, "inspectEntity", { enumerable: true, get: function () { return debug_1.inspectEntity; } });
|
|
20
|
+
Object.defineProperty(exports, "inspectExpression", { enumerable: true, get: function () { return debug_1.inspectExpressionData; } });
|
|
21
|
+
Object.defineProperty(exports, "inspectParse", { enumerable: true, get: function () { return debug_1.inspectParse; } });
|
|
22
|
+
Object.defineProperty(exports, "inspectPolynomial", { enumerable: true, get: function () { return debug_1.inspectPolynomialData; } });
|
|
23
|
+
Object.defineProperty(exports, "inspectTerm", { enumerable: true, get: function () { return debug_1.inspectTermData; } });
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { ParserConstants, ParserValuesObject } from '../core/classes/parser/types';
|
|
2
|
+
import type { SettingsType } from '../core/Settings';
|
|
3
|
+
import type { ExpressionInput, ParserEntity } from '../core/types';
|
|
4
|
+
type BooleanSettingName = {
|
|
5
|
+
[K in keyof SettingsType]: SettingsType[K] extends boolean ? K : never;
|
|
6
|
+
}[keyof SettingsType];
|
|
7
|
+
/**
|
|
8
|
+
* Supported high-level parser surface.
|
|
9
|
+
*
|
|
10
|
+
* Tokenization, RPN conversion, and parser-stack machinery remain internal
|
|
11
|
+
* implementation details even though Nerdamer itself uses them across modules.
|
|
12
|
+
*/
|
|
13
|
+
export interface ParserAPI {
|
|
14
|
+
/** Creates another parser facade backed by the shared parser configuration. */
|
|
15
|
+
create(): ParserAPI;
|
|
16
|
+
/**
|
|
17
|
+
* Parses and evaluates Nerdamer notation with optional substitutions.
|
|
18
|
+
* @param str - Nerdamer notation or expression-compatible input.
|
|
19
|
+
* @param values - Values substituted by name while parsing.
|
|
20
|
+
*/
|
|
21
|
+
evaluate(str: string, values?: ParserValuesObject): ParserEntity;
|
|
22
|
+
/**
|
|
23
|
+
* Returns one shared parser setting with the value type associated with that setting.
|
|
24
|
+
*/
|
|
25
|
+
get<K extends keyof SettingsType>(setting: K): SettingsType[K];
|
|
26
|
+
/** Returns the symbol currently used for the imaginary unit. */
|
|
27
|
+
getI(): string;
|
|
28
|
+
/** Returns the active Decimal precision. */
|
|
29
|
+
getPrecision(): number;
|
|
30
|
+
/**
|
|
31
|
+
* Parses Nerdamer notation with optional substitutions.
|
|
32
|
+
* @param str - Nerdamer notation or expression-compatible input.
|
|
33
|
+
* @param values - Values substituted by name while parsing.
|
|
34
|
+
*/
|
|
35
|
+
parse(str: ExpressionInput, values?: ParserValuesObject): ParserEntity;
|
|
36
|
+
/**
|
|
37
|
+
* Temporarily changes one Boolean parser setting while a callback runs.
|
|
38
|
+
* @param setting - Boolean setting name to change.
|
|
39
|
+
* @param value - Temporary value for that setting.
|
|
40
|
+
* @param callback - Work to perform before restoring the previous setting.
|
|
41
|
+
*/
|
|
42
|
+
scopedBlock<K extends BooleanSettingName>(setting: K, value: SettingsType[K], callback: () => ParserEntity): ParserEntity;
|
|
43
|
+
/**
|
|
44
|
+
* Changes one shared parser setting and returns the parser for chaining.
|
|
45
|
+
* @param setting - Supported parser setting name.
|
|
46
|
+
* @param value - Value associated with that setting.
|
|
47
|
+
*/
|
|
48
|
+
set<K extends keyof SettingsType>(setting: K, value: SettingsType[K]): ParserAPI;
|
|
49
|
+
/**
|
|
50
|
+
* Changes several supported parser settings and returns the parser for chaining.
|
|
51
|
+
* @param settings - Partial set of supported parser settings.
|
|
52
|
+
*/
|
|
53
|
+
set(settings: Partial<SettingsType>): ParserAPI;
|
|
54
|
+
/**
|
|
55
|
+
* Registers or removes parser constants.
|
|
56
|
+
* @param constants - Constant names mapped to values or deletion markers.
|
|
57
|
+
*/
|
|
58
|
+
setConstants(constants: ParserConstants): void;
|
|
59
|
+
/**
|
|
60
|
+
* Changes the symbol used for the imaginary unit.
|
|
61
|
+
* @param variable - New imaginary-unit symbol.
|
|
62
|
+
*/
|
|
63
|
+
setI(variable: string): ParserAPI;
|
|
64
|
+
/**
|
|
65
|
+
* Alias for {@link ParserAPI.setI}.
|
|
66
|
+
* @param variable - New imaginary-unit symbol.
|
|
67
|
+
*/
|
|
68
|
+
setImaginary(variable: string): ParserAPI;
|
|
69
|
+
/**
|
|
70
|
+
* Changes the Decimal precision used by numerical calculations.
|
|
71
|
+
* @param precision - Significant decimal digits to retain.
|
|
72
|
+
*/
|
|
73
|
+
setPrecision(precision: number): void;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Shared parser exposed through the supported high-level interface.
|
|
77
|
+
*
|
|
78
|
+
* The implementation accepts a broader compatibility settings bag; this facade exposes
|
|
79
|
+
* only the named settings defined by {@link SettingsType}.
|
|
80
|
+
*/
|
|
81
|
+
export declare const Parser: ParserAPI;
|
|
82
|
+
export type { JsFunction, Operation, OptionValue, OptionsObject, ParserConstants, ParserValuesObject, PostFixFunction, PreFixFunction, } from '../core/classes/parser/types';
|
|
83
|
+
export type { BinaryArithmeticOperation, ComparisonOperation, Operator, OperatorAction, OperatorDefinition, } from '../core/common/common';
|
|
84
|
+
export type { Language } from '../core/errors';
|
|
85
|
+
export type { SettingsType } from '../core/Settings';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Parser = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Supported high-level parser APIs and parser configuration types.
|
|
6
|
+
*
|
|
7
|
+
* @module parser
|
|
8
|
+
*/
|
|
9
|
+
const Parser_1 = require("../core/classes/parser/Parser");
|
|
10
|
+
/**
|
|
11
|
+
* Shared parser exposed through the supported high-level interface.
|
|
12
|
+
*
|
|
13
|
+
* The implementation accepts a broader compatibility settings bag; this facade exposes
|
|
14
|
+
* only the named settings defined by {@link SettingsType}.
|
|
15
|
+
*/
|
|
16
|
+
exports.Parser = Parser_1.Parser;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { FunctionSolverOptions, Root } from '../solve/classes/FunctionSolver';
|
|
2
|
+
/** Public symbolic and polynomial solver APIs. */
|
|
3
|
+
export { MultivariateSolver } from '../solve/classes/MultivariateSolver';
|
|
4
|
+
export type { MultivariateSolverOptions } from '../solve/classes/MultivariateSolver';
|
|
5
|
+
export { PolynomialSolver } from '../solve/classes/PolynomialSolver';
|
|
6
|
+
export { SolutionSet } from '../solve/classes/SolutionSet';
|
|
7
|
+
export type { SolutionForm, SolutionsType } from '../solve/classes/SolutionSet';
|
|
8
|
+
export { SymbolicSolver } from '../solve/classes/SymbolicSolver';
|
|
9
|
+
export { solve } from '../solve/solve';
|
|
10
|
+
export { solveSystem } from '../solve/solveSystem';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.solveSystem = exports.solve = exports.SymbolicSolver = exports.SolutionSet = exports.PolynomialSolver = exports.MultivariateSolver = void 0;
|
|
4
|
+
/** Public symbolic and polynomial solver APIs. */
|
|
5
|
+
var MultivariateSolver_1 = require("../solve/classes/MultivariateSolver");
|
|
6
|
+
Object.defineProperty(exports, "MultivariateSolver", { enumerable: true, get: function () { return MultivariateSolver_1.MultivariateSolver; } });
|
|
7
|
+
var PolynomialSolver_1 = require("../solve/classes/PolynomialSolver");
|
|
8
|
+
Object.defineProperty(exports, "PolynomialSolver", { enumerable: true, get: function () { return PolynomialSolver_1.PolynomialSolver; } });
|
|
9
|
+
var SolutionSet_1 = require("../solve/classes/SolutionSet");
|
|
10
|
+
Object.defineProperty(exports, "SolutionSet", { enumerable: true, get: function () { return SolutionSet_1.SolutionSet; } });
|
|
11
|
+
var SymbolicSolver_1 = require("../solve/classes/SymbolicSolver");
|
|
12
|
+
Object.defineProperty(exports, "SymbolicSolver", { enumerable: true, get: function () { return SymbolicSolver_1.SymbolicSolver; } });
|
|
13
|
+
var solve_1 = require("../solve/solve");
|
|
14
|
+
Object.defineProperty(exports, "solve", { enumerable: true, get: function () { return solve_1.solve; } });
|
|
15
|
+
var solveSystem_1 = require("../solve/solveSystem");
|
|
16
|
+
Object.defineProperty(exports, "solveSystem", { enumerable: true, get: function () { return solveSystem_1.solveSystem; } });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Public structured-value and finite-set APIs. */
|
|
2
|
+
export { Collection } from '../core/classes/collection/Collection';
|
|
3
|
+
export { Dictionary } from '../core/classes/dictionary/Dictionary';
|
|
4
|
+
export { determinant, nullspace } from '../core/classes/matrix/functions';
|
|
5
|
+
export { Matrix } from '../core/classes/matrix/Matrix';
|
|
6
|
+
export { imatrix } from '../core/classes/matrix/utils';
|
|
7
|
+
export { ValuesSet } from '../core/classes/valuesSet/ValuesSet';
|
|
8
|
+
export { cross, dot } from '../core/classes/vector/functions';
|
|
9
|
+
export { Vector } from '../core/classes/vector/Vector';
|
|
10
|
+
export type { StructuredEntityType } from '../core/types';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Vector = exports.dot = exports.cross = exports.ValuesSet = exports.imatrix = exports.Matrix = exports.nullspace = exports.determinant = exports.Dictionary = exports.Collection = void 0;
|
|
4
|
+
/** Public structured-value and finite-set APIs. */
|
|
5
|
+
var Collection_1 = require("../core/classes/collection/Collection");
|
|
6
|
+
Object.defineProperty(exports, "Collection", { enumerable: true, get: function () { return Collection_1.Collection; } });
|
|
7
|
+
var Dictionary_1 = require("../core/classes/dictionary/Dictionary");
|
|
8
|
+
Object.defineProperty(exports, "Dictionary", { enumerable: true, get: function () { return Dictionary_1.Dictionary; } });
|
|
9
|
+
var functions_1 = require("../core/classes/matrix/functions");
|
|
10
|
+
Object.defineProperty(exports, "determinant", { enumerable: true, get: function () { return functions_1.determinant; } });
|
|
11
|
+
Object.defineProperty(exports, "nullspace", { enumerable: true, get: function () { return functions_1.nullspace; } });
|
|
12
|
+
var Matrix_1 = require("../core/classes/matrix/Matrix");
|
|
13
|
+
Object.defineProperty(exports, "Matrix", { enumerable: true, get: function () { return Matrix_1.Matrix; } });
|
|
14
|
+
var utils_1 = require("../core/classes/matrix/utils");
|
|
15
|
+
Object.defineProperty(exports, "imatrix", { enumerable: true, get: function () { return utils_1.imatrix; } });
|
|
16
|
+
var ValuesSet_1 = require("../core/classes/valuesSet/ValuesSet");
|
|
17
|
+
Object.defineProperty(exports, "ValuesSet", { enumerable: true, get: function () { return ValuesSet_1.ValuesSet; } });
|
|
18
|
+
var functions_2 = require("../core/classes/vector/functions");
|
|
19
|
+
Object.defineProperty(exports, "cross", { enumerable: true, get: function () { return functions_2.cross; } });
|
|
20
|
+
Object.defineProperty(exports, "dot", { enumerable: true, get: function () { return functions_2.dot; } });
|
|
21
|
+
var Vector_1 = require("../core/classes/vector/Vector");
|
|
22
|
+
Object.defineProperty(exports, "Vector", { enumerable: true, get: function () { return Vector_1.Vector; } });
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Expression } from '../../core/classes/expression/Expression';
|
|
2
|
+
import type { ExpressionInput } from '../../core/types';
|
|
3
|
+
/**
|
|
4
|
+
* Differentiates an expression symbolically.
|
|
5
|
+
*
|
|
6
|
+
* The chain, product, sum, and power rules are applied recursively, together
|
|
7
|
+
* with the built-in derivative table for recognized functions. An omitted
|
|
8
|
+
* variable is inferred as the first variable in the expression. Existing
|
|
9
|
+
* Expression input is reused during normalization.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* `n` requests a repeated derivative. A non-integer order, a non-variable
|
|
13
|
+
* differentiation target, or an unsupported derivative is preserved as an
|
|
14
|
+
* unevaluated `diff(...)` expression. Constants and expressions independent of
|
|
15
|
+
* the selected variable differentiate to zero.
|
|
16
|
+
*
|
|
17
|
+
* @param x - Expression to differentiate.
|
|
18
|
+
* @param variable - Variable with respect to which the derivative is taken.
|
|
19
|
+
* @param n - Positive integer derivative order. Defaults to the first derivative.
|
|
20
|
+
* @returns The symbolic derivative, or an unevaluated `diff(...)` call when the
|
|
21
|
+
* requested operation cannot be resolved.
|
|
22
|
+
* @throws {@link core!UnsupportedOperationError} If `variable` is numeric.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* diff('sin(x^2)', 'x').text();
|
|
27
|
+
* diff('x^4', 'x', 2).text();
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function diff(x: ExpressionInput, variable?: ExpressionInput, n?: Expression | number): Expression;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.diff = diff;
|
|
4
|
+
const Expression_1 = require("../../core/classes/expression/Expression");
|
|
5
|
+
const shortcuts_1 = require("../../core/classes/expression/shortcuts");
|
|
6
|
+
const constants_1 = require("../../core/classes/parser/constants");
|
|
7
|
+
const helpers_1 = require("../../core/classes/parser/helpers");
|
|
8
|
+
const errors_1 = require("../../core/errors");
|
|
9
|
+
const math_1 = require("../../math/math");
|
|
10
|
+
/**
|
|
11
|
+
* Applies the product rule to an expression
|
|
12
|
+
*
|
|
13
|
+
* @param expression
|
|
14
|
+
* @param variable
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
function productRule(expression, variable) {
|
|
18
|
+
//grab all the symbols within the CB symbol
|
|
19
|
+
const elements = expression.elementsArray();
|
|
20
|
+
let result = (0, shortcuts_1.zero)();
|
|
21
|
+
//loop over all the symbols
|
|
22
|
+
for (let i = 0; i < elements.length; i++) {
|
|
23
|
+
let df = diff(elements[i], variable);
|
|
24
|
+
for (let j = 0; j < elements.length; j++) {
|
|
25
|
+
//skip the symbol of which we just pulled the derivative
|
|
26
|
+
if (i !== j) {
|
|
27
|
+
//multiply out the remaining symbols
|
|
28
|
+
df = df.times(elements[j]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//add the derivative to the result
|
|
32
|
+
result = result.plus(df);
|
|
33
|
+
}
|
|
34
|
+
return result; //done
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Differentiates an expression symbolically.
|
|
38
|
+
*
|
|
39
|
+
* The chain, product, sum, and power rules are applied recursively, together
|
|
40
|
+
* with the built-in derivative table for recognized functions. An omitted
|
|
41
|
+
* variable is inferred as the first variable in the expression. Existing
|
|
42
|
+
* Expression input is reused during normalization.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* `n` requests a repeated derivative. A non-integer order, a non-variable
|
|
46
|
+
* differentiation target, or an unsupported derivative is preserved as an
|
|
47
|
+
* unevaluated `diff(...)` expression. Constants and expressions independent of
|
|
48
|
+
* the selected variable differentiate to zero.
|
|
49
|
+
*
|
|
50
|
+
* @param x - Expression to differentiate.
|
|
51
|
+
* @param variable - Variable with respect to which the derivative is taken.
|
|
52
|
+
* @param n - Positive integer derivative order. Defaults to the first derivative.
|
|
53
|
+
* @returns The symbolic derivative, or an unevaluated `diff(...)` call when the
|
|
54
|
+
* requested operation cannot be resolved.
|
|
55
|
+
* @throws {@link core!UnsupportedOperationError} If `variable` is numeric.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* diff('sin(x^2)', 'x').text();
|
|
60
|
+
* diff('x^4', 'x', 2).text();
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
function diff(x, variable, n) {
|
|
64
|
+
x = Expression_1.Expression.create(x);
|
|
65
|
+
const variables = x.variables();
|
|
66
|
+
// Set the variable if none was provided
|
|
67
|
+
variable ??= Expression_1.Expression.Variable(variables[0]);
|
|
68
|
+
variable = Expression_1.Expression.create(variable);
|
|
69
|
+
const nth = typeof n === 'number' ? Expression_1.Expression.create(n) : n;
|
|
70
|
+
// If the variable is a number then complain
|
|
71
|
+
if (variable?.isNUM()) {
|
|
72
|
+
throw new errors_1.UnsupportedOperationError((0, errors_1.message)('unsupportedOperation'));
|
|
73
|
+
}
|
|
74
|
+
let retval;
|
|
75
|
+
if (variables.length === 0 || !x.hasVariable(variable.value) || x.isConstant()) {
|
|
76
|
+
retval = (0, shortcuts_1.zero)();
|
|
77
|
+
}
|
|
78
|
+
// If the variable is not of type VAR or nth is not an integer then return it untouched until either or both are resolved
|
|
79
|
+
else if ((variable && !variable.isVAR()) || (nth && !nth.isInteger())) {
|
|
80
|
+
retval = Expression_1.Expression.toFunction(constants_1.DIFF, [x, variable, nth]);
|
|
81
|
+
}
|
|
82
|
+
else if (x.isEXP()) {
|
|
83
|
+
// Apply rule a^x*(d/dx x*log(a))
|
|
84
|
+
const a = (0, math_1.log)(x.getBase());
|
|
85
|
+
const p = x.getPower();
|
|
86
|
+
const dx = diff(a.times(p), variable);
|
|
87
|
+
retval = x.times(dx);
|
|
88
|
+
}
|
|
89
|
+
// If the expression doesn't have a variable or if it's a constant then we're done
|
|
90
|
+
else {
|
|
91
|
+
// Reduce the nth call of the derivative
|
|
92
|
+
const n = nth ? Number(nth) - 1 : 0;
|
|
93
|
+
// Pull the derivate of the outside. At this point we've already performed all the required checks.
|
|
94
|
+
const m = x.getMultiplier().times(x.getPower());
|
|
95
|
+
const p = x.getPower().minus('1');
|
|
96
|
+
const f = Expression_1.Expression.create(x.value);
|
|
97
|
+
const fp = f.pow(p).times(m);
|
|
98
|
+
// Pull the derivative of the inside
|
|
99
|
+
if (f.isVAR()) {
|
|
100
|
+
retval = (0, shortcuts_1.one)();
|
|
101
|
+
}
|
|
102
|
+
else if (f.isSum()) {
|
|
103
|
+
let sum = (0, shortcuts_1.zero)();
|
|
104
|
+
f.elementsArray().forEach(e => {
|
|
105
|
+
sum = sum.plus(diff(e, variable));
|
|
106
|
+
});
|
|
107
|
+
retval = sum;
|
|
108
|
+
}
|
|
109
|
+
else if (f.isProduct()) {
|
|
110
|
+
retval = productRule(f, variable);
|
|
111
|
+
}
|
|
112
|
+
else if (f.isFunction()) {
|
|
113
|
+
const x = f.getArguments()[0];
|
|
114
|
+
const m = f.getMultiplier();
|
|
115
|
+
switch (f.name) {
|
|
116
|
+
case constants_1.LOG:
|
|
117
|
+
retval = (0, helpers_1._)(`(${m})/(${x})`);
|
|
118
|
+
break;
|
|
119
|
+
case constants_1.COS:
|
|
120
|
+
retval = (0, helpers_1._)(`-sin(${x})`);
|
|
121
|
+
break;
|
|
122
|
+
case constants_1.SIN:
|
|
123
|
+
retval = (0, helpers_1._)(`cos(${x})`);
|
|
124
|
+
break;
|
|
125
|
+
case constants_1.TAN:
|
|
126
|
+
retval = (0, helpers_1._)(`sec(${x})^2`);
|
|
127
|
+
break;
|
|
128
|
+
case constants_1.SEC:
|
|
129
|
+
retval = (0, helpers_1._)(`tan(${x})*sec(${x})`);
|
|
130
|
+
break;
|
|
131
|
+
case constants_1.CSC:
|
|
132
|
+
retval = (0, helpers_1._)(`-cot(${x})*csc(${x})`);
|
|
133
|
+
break;
|
|
134
|
+
case constants_1.COT:
|
|
135
|
+
retval = (0, helpers_1._)(`-csc(${x})^2`);
|
|
136
|
+
break;
|
|
137
|
+
case constants_1.ACOS:
|
|
138
|
+
retval = (0, helpers_1._)(`-1/sqrt(1-(${x})^2)`);
|
|
139
|
+
break;
|
|
140
|
+
case constants_1.ASIN:
|
|
141
|
+
retval = (0, helpers_1._)(`1/sqrt(1-(${x})^2)`);
|
|
142
|
+
break;
|
|
143
|
+
case constants_1.ATAN:
|
|
144
|
+
retval = (0, helpers_1._)(`1/(1+(${x})^2)`);
|
|
145
|
+
break;
|
|
146
|
+
case constants_1.ASEC:
|
|
147
|
+
retval = (0, helpers_1._)(`1/(sqrt(1-1/(${x})^2)*(${x})^2)`);
|
|
148
|
+
break;
|
|
149
|
+
case constants_1.ACSC:
|
|
150
|
+
retval = (0, helpers_1._)(`-1/(sqrt(1-1/(${x})^2)*(${x})^2)`);
|
|
151
|
+
break;
|
|
152
|
+
case constants_1.ACOT:
|
|
153
|
+
retval = (0, helpers_1._)(`-1/(1+(${x})^2)`);
|
|
154
|
+
break;
|
|
155
|
+
case constants_1.COSH:
|
|
156
|
+
retval = (0, helpers_1._)(`sinh(${x})`);
|
|
157
|
+
break;
|
|
158
|
+
case constants_1.SINH:
|
|
159
|
+
retval = (0, helpers_1._)(`cosh(${x})`);
|
|
160
|
+
break;
|
|
161
|
+
case constants_1.TANH:
|
|
162
|
+
retval = (0, helpers_1._)(`sech(${x})^2`);
|
|
163
|
+
break;
|
|
164
|
+
case constants_1.SECH:
|
|
165
|
+
retval = (0, helpers_1._)(`-sech(${x})*tanh(${x})`);
|
|
166
|
+
break;
|
|
167
|
+
case constants_1.CSCH:
|
|
168
|
+
retval = (0, helpers_1._)(`-coth(${x})*csch(${x})`);
|
|
169
|
+
break;
|
|
170
|
+
case constants_1.COTH:
|
|
171
|
+
retval = (0, helpers_1._)(`-csch(${x})^2`);
|
|
172
|
+
break;
|
|
173
|
+
case constants_1.ASINH:
|
|
174
|
+
retval = (0, helpers_1._)(`1/sqrt(1+(${x})^2)`);
|
|
175
|
+
break;
|
|
176
|
+
case constants_1.ACOSH:
|
|
177
|
+
retval = (0, helpers_1._)(`1/(sqrt(-1+(${x}))*sqrt(1+(${x})))`);
|
|
178
|
+
break;
|
|
179
|
+
case constants_1.ATANH:
|
|
180
|
+
retval = (0, helpers_1._)(`1/(1-(${x})^2)`);
|
|
181
|
+
break;
|
|
182
|
+
case constants_1.ASECH:
|
|
183
|
+
retval = (0, helpers_1._)(`-1/(sqrt(-1+1/(${x}))*sqrt(1+1/(${x}))*(${x})^2)`);
|
|
184
|
+
break;
|
|
185
|
+
case constants_1.ACSCH:
|
|
186
|
+
retval = (0, helpers_1._)(`-1/(sqrt(1+1/(${x})^2)*(${x})^2)`);
|
|
187
|
+
break;
|
|
188
|
+
case constants_1.ACOTH:
|
|
189
|
+
retval = (0, helpers_1._)(`1/(1-(${x})^2)`);
|
|
190
|
+
break;
|
|
191
|
+
case constants_1.ABS:
|
|
192
|
+
// d/dx abs(u) = sign(u) * u'
|
|
193
|
+
retval = (0, helpers_1._)(`sign(${x})`);
|
|
194
|
+
break;
|
|
195
|
+
case constants_1.CI:
|
|
196
|
+
retval = (0, helpers_1._)(`cos(${x})/${x}`);
|
|
197
|
+
break;
|
|
198
|
+
case constants_1.CHI:
|
|
199
|
+
retval = (0, helpers_1._)(`cosh(${x})/${x}`);
|
|
200
|
+
break;
|
|
201
|
+
case constants_1.SI:
|
|
202
|
+
retval = (0, helpers_1._)(`sin(${x})/${x}`);
|
|
203
|
+
break;
|
|
204
|
+
case constants_1.SHI:
|
|
205
|
+
retval = (0, helpers_1._)(`sinh(${x})/${x}`);
|
|
206
|
+
break;
|
|
207
|
+
case constants_1.EI:
|
|
208
|
+
retval = (0, helpers_1._)(`e^(${x})/${x}`);
|
|
209
|
+
break;
|
|
210
|
+
case constants_1.LI:
|
|
211
|
+
retval = (0, helpers_1._)(`1/${constants_1.LOG}(${x})`);
|
|
212
|
+
break;
|
|
213
|
+
case constants_1.ERF:
|
|
214
|
+
retval = (0, helpers_1._)(`(2*e^(-(${x})^2))/sqrt(pi)`);
|
|
215
|
+
break;
|
|
216
|
+
case constants_1.SGN:
|
|
217
|
+
retval = (0, shortcuts_1.zero)();
|
|
218
|
+
break;
|
|
219
|
+
// Missing: S, Si, Shi, Ci, Chi, Ei, Li, erf, atan2, sinc, heaviside
|
|
220
|
+
// case '':
|
|
221
|
+
// retval = _(``);
|
|
222
|
+
// break;
|
|
223
|
+
}
|
|
224
|
+
// Multiply times the derivative of the inside
|
|
225
|
+
if (retval) {
|
|
226
|
+
retval = retval.times(diff(x, variable));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (retval) {
|
|
230
|
+
retval = retval.times(fp);
|
|
231
|
+
}
|
|
232
|
+
// Pull the nth -1 derivative if that was requested
|
|
233
|
+
if (n > 0 && retval) {
|
|
234
|
+
retval = diff(retval, variable, Expression_1.Expression.Number(n));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return retval || Expression_1.Expression.toFunction(constants_1.DIFF, [x, variable, nth]);
|
|
238
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Expression } from '../core/classes/expression/Expression';
|
|
2
|
+
import type { ExpressionInput } from '../core/types';
|
|
3
|
+
/**
|
|
4
|
+
* Computes the normalized Fresnel sine integral
|
|
5
|
+
* `S(x) = integral(sin(pi*t^2/2), t, 0, x)`.
|
|
6
|
+
*
|
|
7
|
+
* Numeric real arguments are evaluated numerically. Symbolic arguments remain as `S(x)`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function S(x: ExpressionInput): Expression;
|
|
10
|
+
/**
|
|
11
|
+
* Computes the normalized Fresnel cosine integral
|
|
12
|
+
* `C(x) = integral(cos(pi*t^2/2), t, 0, x)`.
|
|
13
|
+
*
|
|
14
|
+
* Numeric real arguments are evaluated numerically. Symbolic arguments remain as `C(x)`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function C(x: ExpressionInput): Expression;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.S = S;
|
|
4
|
+
exports.C = C;
|
|
5
|
+
const Expression_1 = require("../core/classes/expression/Expression");
|
|
6
|
+
const constants_1 = require("../core/classes/parser/constants");
|
|
7
|
+
const fresnelNumeric_1 = require("../core/functions/fresnelNumeric");
|
|
8
|
+
/** Evaluates a Fresnel integral numerically when the argument can be resolved to a real number. */
|
|
9
|
+
function fresnel(x, name) {
|
|
10
|
+
const argument = Expression_1.Expression.create(x);
|
|
11
|
+
const evaluated = argument.isNUM() ? argument : argument.evaluate();
|
|
12
|
+
let retval;
|
|
13
|
+
if (evaluated.isNUM()) {
|
|
14
|
+
const value = Number(evaluated.getMultiplier().toDecimal());
|
|
15
|
+
retval = Expression_1.Expression.create(name === constants_1.FRESNEL_S ? (0, fresnelNumeric_1.fresnelS)(value) : (0, fresnelNumeric_1.fresnelC)(value));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
retval = Expression_1.Expression.toFunction(name, [argument]);
|
|
19
|
+
}
|
|
20
|
+
return retval;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Computes the normalized Fresnel sine integral
|
|
24
|
+
* `S(x) = integral(sin(pi*t^2/2), t, 0, x)`.
|
|
25
|
+
*
|
|
26
|
+
* Numeric real arguments are evaluated numerically. Symbolic arguments remain as `S(x)`.
|
|
27
|
+
*/
|
|
28
|
+
function S(x) {
|
|
29
|
+
return fresnel(x, constants_1.FRESNEL_S);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Computes the normalized Fresnel cosine integral
|
|
33
|
+
* `C(x) = integral(cos(pi*t^2/2), t, 0, x)`.
|
|
34
|
+
*
|
|
35
|
+
* Numeric real arguments are evaluated numerically. Symbolic arguments remain as `C(x)`.
|
|
36
|
+
*/
|
|
37
|
+
function C(x) {
|
|
38
|
+
return fresnel(x, constants_1.FRESNEL_C);
|
|
39
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Expression } from '../../core/classes/expression/Expression';
|
|
2
|
+
import type { ExpressionInput } from '../../core/types';
|
|
3
|
+
/**
|
|
4
|
+
* Attempts integration by parts for a product with two variable-dependent factors.
|
|
5
|
+
*
|
|
6
|
+
* LIATE priority selects `u`; independent multipliers are preserved separately.
|
|
7
|
+
* Category-specific progress checks and a dedicated recursion bound reject
|
|
8
|
+
* cyclic or increasingly complex decompositions.
|
|
9
|
+
*
|
|
10
|
+
* @param x - Product integrand.
|
|
11
|
+
* @param v - Integration variable.
|
|
12
|
+
* @param integrate - Recursive integration strategy supplied by the caller.
|
|
13
|
+
* @param depth - Current outer integration depth.
|
|
14
|
+
* @param ibpDepth - Current integration-by-parts depth.
|
|
15
|
+
* @returns An antiderivative when the transformation makes progress, otherwise
|
|
16
|
+
* `undefined` so another strategy can run.
|
|
17
|
+
*/
|
|
18
|
+
export declare function tryIntegrationByParts(x: Expression, v: string, integrate: (f: ExpressionInput, dx: ExpressionInput, depth: number) => Expression, depth?: number, ibpDepth?: number): Expression | undefined;
|