nerdamer 1.1.13 → 2.0.0-rc.2
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/BREAKING_CHANGES.md +244 -5
- package/LICENSE.md +184 -0
- package/README.md +232 -318
- 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 +2248 -0
- package/index.d.ts +10 -426
- package/output/algebra/adapters.d.ts +3 -0
- package/output/algebra/adapters.js +11 -0
- package/output/algebra/algorithms/arith.d.ts +84 -0
- package/output/algebra/algorithms/arith.js +324 -0
- package/output/algebra/algorithms/groebnerBase.d.ts +161 -0
- package/output/algebra/algorithms/groebnerBase.js +929 -0
- package/output/algebra/dispatch.d.ts +1 -0
- package/output/algebra/dispatch.js +25 -0
- package/output/algebra/factor/factor.d.ts +77 -0
- package/output/algebra/factor/factor.js +245 -0
- package/output/algebra/gcd/gcd.d.ts +30 -0
- package/output/algebra/gcd/gcd.js +95 -0
- package/output/algebra/groebner.d.ts +21 -0
- package/output/algebra/groebner.js +36 -0
- package/output/algebra/partfrac.d.ts +19 -0
- package/output/algebra/partfrac.js +365 -0
- package/output/algebra/polynomial/ModularSparsePolynomial.d.ts +131 -0
- package/output/algebra/polynomial/ModularSparsePolynomial.js +378 -0
- package/output/algebra/polynomial/ModularSparsePolynomialFactor.d.ts +40 -0
- package/output/algebra/polynomial/ModularSparsePolynomialFactor.js +661 -0
- package/output/algebra/polynomial/SparsePolynomialFactor.d.ts +64 -0
- package/output/algebra/polynomial/SparsePolynomialFactor.js +492 -0
- package/output/algebra/polynomial/SparsePolynomialGcd.d.ts +29 -0
- package/output/algebra/polynomial/SparsePolynomialGcd.js +259 -0
- package/output/algebra/polynomial/SparsePolynomialMultivariateFactor.d.ts +82 -0
- package/output/algebra/polynomial/SparsePolynomialMultivariateFactor.js +604 -0
- package/output/algebra/polynomial/modularGcd.d.ts +40 -0
- package/output/algebra/polynomial/modularGcd.js +365 -0
- package/output/algebra/polynomialize.d.ts +20 -0
- package/output/algebra/polynomialize.js +26 -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 +237 -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 +8 -0
- package/output/api/advanced.js +18 -0
- package/output/api/algebra.d.ts +17 -0
- package/output/api/algebra.js +35 -0
- package/output/api/assumptions.d.ts +4 -0
- package/output/api/assumptions.js +11 -0
- package/output/api/calculus.d.ts +10 -0
- package/output/api/calculus.js +22 -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/languages/deu.d.ts +3 -0
- package/output/api/languages/deu.js +266 -0
- package/output/api/languages/fra.d.ts +3 -0
- package/output/api/languages/fra.js +266 -0
- package/output/api/languages/ita.d.ts +3 -0
- package/output/api/languages/ita.js +266 -0
- package/output/api/languages/nld.d.ts +3 -0
- package/output/api/languages/nld.js +266 -0
- package/output/api/languages/por.d.ts +3 -0
- package/output/api/languages/por.js +266 -0
- package/output/api/languages/spa.d.ts +3 -0
- package/output/api/languages/spa.js +266 -0
- package/output/api/parser.d.ts +93 -0
- package/output/api/parser.js +18 -0
- package/output/api/solve.d.ts +10 -0
- package/output/api/solve.js +17 -0
- package/output/api/structures.d.ts +10 -0
- package/output/api/structures.js +23 -0
- package/output/calculus/adapters.d.ts +8 -0
- package/output/calculus/adapters.js +41 -0
- package/output/calculus/derivative/diff.d.ts +30 -0
- package/output/calculus/derivative/diff.js +241 -0
- package/output/calculus/dispatch.d.ts +1 -0
- package/output/calculus/dispatch.js +25 -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/classes/assumption/Assumption.d.ts +218 -0
- package/output/core/classes/assumption/Assumption.js +609 -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/assumption/dispatch.d.ts +1 -0
- package/output/core/classes/assumption/dispatch.js +11 -0
- package/output/core/classes/collection/Collection.d.ts +107 -0
- package/output/core/classes/collection/Collection.js +240 -0
- package/output/core/classes/complex/Complex.d.ts +109 -0
- package/output/core/classes/complex/Complex.js +153 -0
- package/output/core/classes/decimalSet/DecimalSet.d.ts +226 -0
- package/output/core/classes/decimalSet/DecimalSet.js +454 -0
- package/output/core/classes/dictionary/Dictionary.d.ts +102 -0
- package/output/core/classes/dictionary/Dictionary.js +216 -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 +197 -0
- package/output/core/classes/expression/Expression.d.ts +1691 -0
- package/output/core/classes/expression/Expression.js +2381 -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 +54 -0
- package/output/core/classes/expression/format.js +340 -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 +61 -0
- package/output/core/classes/expression/utils.js +235 -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 +901 -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/dispatch.d.ts +1 -0
- package/output/core/classes/matrix/dispatch.js +19 -0
- package/output/core/classes/matrix/functions.d.ts +28 -0
- package/output/core/classes/matrix/functions.js +57 -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 +493 -0
- package/output/core/classes/parser/Parser.js +1863 -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 +162 -0
- package/output/core/classes/parser/constants.js +229 -0
- package/output/core/classes/parser/controlFlowSignals.d.ts +38 -0
- package/output/core/classes/parser/controlFlowSignals.js +60 -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 +236 -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 +474 -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 +438 -0
- package/output/core/classes/parser/operations/multiply.d.ts +11 -0
- package/output/core/classes/parser/operations/multiply.js +328 -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 +36 -0
- package/output/core/classes/parser/preprocess.d.ts +7 -0
- package/output/core/classes/parser/preprocess.js +246 -0
- package/output/core/classes/parser/scripting/controlFlow.d.ts +23 -0
- package/output/core/classes/parser/scripting/controlFlow.js +279 -0
- package/output/core/classes/parser/scripting/deferred.d.ts +4 -0
- package/output/core/classes/parser/scripting/deferred.js +65 -0
- package/output/core/classes/parser/scripting/dispatch.d.ts +1 -0
- package/output/core/classes/parser/scripting/dispatch.js +62 -0
- package/output/core/classes/parser/scripting/evaluate.d.ts +23 -0
- package/output/core/classes/parser/scripting/evaluate.js +128 -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 +8 -0
- package/output/core/classes/parser/scripting/scope.js +132 -0
- package/output/core/classes/parser/types.d.ts +130 -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 +504 -0
- package/output/core/classes/polynomial/Polynomial.js +1195 -0
- package/output/core/classes/polynomial/SparsePolynomial.d.ts +221 -0
- package/output/core/classes/polynomial/SparsePolynomial.js +824 -0
- package/output/core/classes/polynomial/SparsePolynomialAdapter.d.ts +56 -0
- package/output/core/classes/polynomial/SparsePolynomialAdapter.js +241 -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/adapters.d.ts +18 -0
- package/output/core/classes/polynomial/adapters.js +33 -0
- package/output/core/classes/polynomial/dispatch.d.ts +1 -0
- package/output/core/classes/polynomial/dispatch.js +14 -0
- package/output/core/classes/polynomial/functions.d.ts +77 -0
- package/output/core/classes/polynomial/functions.js +189 -0
- package/output/core/classes/polynomial/utils.d.ts +62 -0
- package/output/core/classes/polynomial/utils.js +207 -0
- package/output/core/classes/rational/Rational.d.ts +501 -0
- package/output/core/classes/rational/Rational.js +829 -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 +187 -0
- package/output/core/classes/valuesSet/ValuesSet.js +399 -0
- package/output/core/classes/vector/Vector.d.ts +222 -0
- package/output/core/classes/vector/Vector.js +501 -0
- package/output/core/classes/vector/dispatch.d.ts +1 -0
- package/output/core/classes/vector/dispatch.js +11 -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 +149 -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 +62 -0
- package/output/core/common/common.js +74 -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 +806 -0
- package/output/core/converters/Pattern.d.ts +71 -0
- package/output/core/converters/Pattern.js +302 -0
- package/output/core/dispatch.d.ts +52 -0
- package/output/core/dispatch.js +26 -0
- package/output/core/errors.d.ts +316 -0
- package/output/core/errors.js +349 -0
- package/output/core/fullFunctions.d.ts +7 -0
- package/output/core/fullFunctions.js +31 -0
- package/output/core/functions/bigint/bigint.d.ts +133 -0
- package/output/core/functions/bigint/bigint.js +444 -0
- package/output/core/functions/bigint/primeFactor.d.ts +51 -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 +139 -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.dispatch.d.ts +1 -0
- package/output/core/functions/complex.dispatch.js +16 -0
- package/output/core/functions/complex.js +482 -0
- package/output/core/functions/decimal.d.ts +24 -0
- package/output/core/functions/decimal.js +665 -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 +102 -0
- package/output/core/functions/subst.d.ts +90 -0
- package/output/core/functions/subst.js +506 -0
- package/output/core/functions/utils.d.ts +24 -0
- package/output/core/functions/utils.js +51 -0
- package/output/core/parserFunctions.d.ts +7 -0
- package/output/core/parserFunctions.js +25 -0
- package/output/core/types.d.ts +48 -0
- package/output/core/types.js +2 -0
- package/output/index.d.ts +359 -0
- package/output/index.js +739 -0
- package/output/math/defint/defint.d.ts +18 -0
- package/output/math/defint/defint.js +60 -0
- package/output/math/defint/defintDecimal.d.ts +37 -0
- package/output/math/defint/defintDecimal.js +321 -0
- package/output/math/defint/defintNative.d.ts +57 -0
- package/output/math/defint/defintNative.js +281 -0
- package/output/math/dispatch.d.ts +1 -0
- package/output/math/dispatch.js +101 -0
- package/output/math/geometry.d.ts +12 -0
- package/output/math/geometry.js +55 -0
- package/output/math/math.d.ts +695 -0
- package/output/math/math.js +1955 -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 +66 -0
- package/output/math/utils.js +219 -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 +104 -0
- package/output/solve/classes/PolynomialSolver.js +492 -0
- package/output/solve/classes/SolutionSet.d.ts +172 -0
- package/output/solve/classes/SolutionSet.js +434 -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/dispatch.d.ts +1 -0
- package/output/solve/dispatch.js +13 -0
- package/output/solve/linsolve.d.ts +53 -0
- package/output/solve/linsolve.js +233 -0
- package/output/solve/solve.d.ts +44 -0
- package/output/solve/solve.js +368 -0
- package/output/solve/solveSystem.d.ts +31 -0
- package/output/solve/solveSystem.js +266 -0
- package/output/solve/utils.d.ts +10 -0
- package/output/solve/utils.js +58 -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 +296 -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 +178 -57
- package/.travis.yml +0 -3
- package/Algebra.js +0 -4568
- 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
package/README.md
CHANGED
|
@@ -1,427 +1,341 @@
|
|
|
1
|
-
|
|
1
|
+
# Nerdamer
|
|
2
2
|
|
|
3
|
-
Nerdamer
|
|
4
|
-
========
|
|
3
|
+
Nerdamer is a symbolic mathematics library and computer algebra system for JavaScript and TypeScript.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
Nerdamer 2.0 is a TypeScript rewrite of Nerdamer. The familiar string-based API remains available, while the package also exposes typed modules for direct use of the symbolic engine, algebra, calculus, solving, structures, assumptions, parser APIs, and advanced algorithms.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
This branch prepares `2.0.0-rc.2`.
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
## Install
|
|
11
10
|
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
<!-- This the core and the only file needed if all you'll be doing is evaluating expresssions -->
|
|
15
|
-
<script src="nerdamer.core.js"></script>
|
|
16
|
-
<!-- LOAD ADD-ONS. These files contain extended functions. See documentation -->
|
|
17
|
-
<!-- again assuming you've saved the files in root -->
|
|
18
|
-
<script src="Algebra.js"></script>
|
|
19
|
-
<script src="Calculus.js"></script>
|
|
20
|
-
<script src="Solve.js"></script>
|
|
21
|
-
<script src="Extra.js"></script>
|
|
22
|
-
```
|
|
23
|
-
Or import everything
|
|
24
|
-
```html
|
|
25
|
-
<script src="all.min.js"></script> <!-- assuming you've saved the file in the root -->
|
|
11
|
+
```bash
|
|
12
|
+
npm install nerdamer@next
|
|
26
13
|
```
|
|
27
|
-
|
|
14
|
+
|
|
15
|
+
The release candidate is published under npm's `next` tag until the final 2.0 release.
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
28
18
|
|
|
29
19
|
```javascript
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
require('nerdamer/Solve');
|
|
36
|
-
require('nerdamer/Extra');
|
|
37
|
-
```
|
|
38
|
-
Or do a single import to import everything
|
|
39
|
-
```javascript
|
|
40
|
-
const nerdamer = require("nerdamer/all.min")
|
|
20
|
+
const nerdamer = require('nerdamer');
|
|
21
|
+
|
|
22
|
+
const expression = nerdamer('x^2+2*(cos(x)+x*x)');
|
|
23
|
+
console.log(expression.text());
|
|
24
|
+
// 2*cos(x)+3*x^2
|
|
41
25
|
```
|
|
42
26
|
|
|
43
|
-
|
|
27
|
+
TypeScript:
|
|
44
28
|
|
|
45
|
-
|
|
29
|
+
```typescript
|
|
30
|
+
import nerdamer from 'nerdamer';
|
|
46
31
|
|
|
47
|
-
|
|
32
|
+
const expression = nerdamer('(x+1)^3').expand();
|
|
33
|
+
console.log(expression.text({ sort: true }));
|
|
34
|
+
// x^3+3*x^2+3*x+1
|
|
35
|
+
```
|
|
48
36
|
|
|
49
|
-
|
|
37
|
+
TypeScript projects compiling to CommonJS should enable `esModuleInterop`.
|
|
50
38
|
|
|
51
|
-
|
|
39
|
+
## Full package and parser package
|
|
52
40
|
|
|
53
|
-
|
|
54
|
-
var e = nerdamer('x^2+2*(cos(x)+x*x)');
|
|
55
|
-
console.log(e.text());
|
|
41
|
+
The normal `nerdamer` entry point assembles the complete CAS. It registers the parser/core and math functions together with algebra, calculus, and solving.
|
|
56
42
|
|
|
57
|
-
//result:
|
|
58
|
-
//2*cos(x)+3*x^2
|
|
59
|
-
```
|
|
60
|
-
It is also possible to use `nerdamer` functions directly within the need for string manipulation of the input. The input will be parsed and the output will of type `Expression`. For example:
|
|
61
43
|
```javascript
|
|
62
|
-
|
|
63
|
-
console.log(ans.text());
|
|
64
|
-
// -1-10*x^2-5*x^4+10*x^3+5*x+x^5
|
|
44
|
+
const nerdamer = require('nerdamer');
|
|
65
45
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
46
|
+
nerdamer.factor('x^2-1').text();
|
|
47
|
+
nerdamer.diff('x^3', 'x').text();
|
|
48
|
+
nerdamer.solve('x^2-4', 'x').text();
|
|
69
49
|
```
|
|
70
50
|
|
|
71
|
-
|
|
51
|
+
Nerdamer 2.0 also has a separate parser entry point. It contains the symbolic parser, scripting, assumptions, structures, complex and polynomial operations, and general math functions without loading the higher-level algebra, calculus, and solver domains.
|
|
72
52
|
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
console.log(e.text());
|
|
53
|
+
```typescript
|
|
54
|
+
import { Parser } from 'nerdamer/parser';
|
|
76
55
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
As you can see only the substitution is performed. To evaluate the result just call evaluate.
|
|
83
|
-
Note that evaluate returns a text string or a number not an object.
|
|
56
|
+
const expression = Parser.parse('sqrt(x^2+1)');
|
|
57
|
+
console.log(expression.text());
|
|
58
|
+
```
|
|
84
59
|
|
|
85
|
-
|
|
86
|
-
var e = nerdamer('x^2+2*(cos(x)+x*x)',{x:6}).evaluate();
|
|
87
|
-
console.log(e.text());
|
|
60
|
+
This separation is also reflected in the browser builds:
|
|
88
61
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
To get back the text as a fraction, call the text method and pass in the string 'fractions'.
|
|
62
|
+
- `dist/bundle.js` — complete Nerdamer package;
|
|
63
|
+
- `dist/parser.js` — parser-focused browser bundle.
|
|
93
64
|
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
|
|
65
|
+
```html
|
|
66
|
+
<script src="./node_modules/nerdamer/dist/bundle.js"></script>
|
|
67
|
+
<script>
|
|
68
|
+
console.log(nerdamer('factor(x^2-1)').text());
|
|
69
|
+
</script>
|
|
70
|
+
```
|
|
97
71
|
|
|
98
|
-
|
|
99
|
-
//429607273/3908351
|
|
100
|
-
```
|
|
101
|
-
You can get your expression back as LaTeX by calling the toTeX method
|
|
102
|
-
```javascript
|
|
103
|
-
var LaTeX = nerdamer('x^2+2*(cos(x)+x*x)',{x:0.25}).toTeX();
|
|
104
|
-
console.log(LaTeX);
|
|
72
|
+
The parser bundle exposes `nerdamerParser` rather than the complete `nerdamer` API.
|
|
105
73
|
|
|
106
|
-
|
|
107
|
-
//2 \cdot \mathrm{cos}\left(\frac{1}{4}\right)+\frac{3}{16}
|
|
108
|
-
```
|
|
74
|
+
## Package entry points
|
|
109
75
|
|
|
110
|
-
|
|
76
|
+
The npm package exports the complete callable API plus typed module entry points:
|
|
111
77
|
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
|
|
78
|
+
```typescript
|
|
79
|
+
import nerdamer from 'nerdamer';
|
|
80
|
+
import { Expression, Rational, type TextOptions } from 'nerdamer/core';
|
|
81
|
+
import { Polynomial, gcd, lcm, partfrac } from 'nerdamer/algebra';
|
|
82
|
+
import { diff, integrate, limit } from 'nerdamer/calculus';
|
|
83
|
+
import { solve, PolynomialSolver } from 'nerdamer/solve';
|
|
84
|
+
import { Matrix, Vector, ValuesSet } from 'nerdamer/structures';
|
|
85
|
+
import { assume, clearAssumptions } from 'nerdamer/assumptions';
|
|
86
|
+
import { Parser } from 'nerdamer/parser';
|
|
87
|
+
```
|
|
115
88
|
|
|
116
|
-
|
|
117
|
-
//2 \cdot \mathrm{cos}\left(0.25\right)+0.1875
|
|
118
|
-
```
|
|
89
|
+
Additional supported entry points are `nerdamer/advanced` and `nerdamer/debug`.
|
|
119
90
|
|
|
120
|
-
|
|
91
|
+
## Parser results
|
|
121
92
|
|
|
122
|
-
|
|
123
|
-
var e = nerdamer('x^2+2*(cos(x)+x*x)',{x:'x^2+1'});
|
|
124
|
-
console.log(e.text());
|
|
93
|
+
`nerdamer(...)` returns the Nerdamer entity represented by the input. Scalar symbolic input normally returns an `Expression`; equations and structured notation can return `Equation`, `Vector`, `Matrix`, `Collection`, `ValuesSet`, or `Dictionary`.
|
|
125
94
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
95
|
+
```javascript
|
|
96
|
+
const scalar = nerdamer('x^2+1');
|
|
97
|
+
const equation = nerdamer('x^2=1');
|
|
98
|
+
const vector = nerdamer('[x, y, 3]');
|
|
99
|
+
```
|
|
129
100
|
|
|
130
|
-
|
|
131
|
-
nerdamer.expressions().
|
|
101
|
+
This is intentional. Nerdamer 2.0 does not wrap every parser result in a compatibility `Expression` object.
|
|
132
102
|
|
|
133
|
-
|
|
134
|
-
var knownValues = {x:'x^2+1'};
|
|
135
|
-
nerdamer('x^2+2*(cos(x)+x*x)').evaluate(knownValues);
|
|
136
|
-
nerdamer('sin(x)^2+cos(x)^2').evaluate(knownValues);
|
|
103
|
+
## Substitution and evaluation
|
|
137
104
|
|
|
138
|
-
|
|
105
|
+
Values supplied to `nerdamer(...)` are substitutions. They do not imply numerical evaluation.
|
|
139
106
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
107
|
+
```javascript
|
|
108
|
+
const substituted = nerdamer('x^2+cos(x)', { x: 6 });
|
|
109
|
+
const evaluated = substituted.evaluate();
|
|
110
|
+
```
|
|
143
111
|
|
|
144
|
-
|
|
145
|
-
situations as the numbering starts at 1;
|
|
112
|
+
Values can themselves be symbolic expressions:
|
|
146
113
|
|
|
147
|
-
```javascript
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
nerdamer('sin(x)^2+cos(x)^2', knownValues );
|
|
114
|
+
```javascript
|
|
115
|
+
nerdamer('x^2+1', { x: 'y+1' }).text();
|
|
116
|
+
```
|
|
151
117
|
|
|
152
|
-
|
|
118
|
+
## Text and TeX output
|
|
153
119
|
|
|
154
|
-
|
|
155
|
-
//'2': 'cos(1+x^(2))^(2)+sin(1+x^(2))^(2)' }
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
Functions aren't always immediately parsed to numbers. For example
|
|
120
|
+
`text()` returns Nerdamer notation. Term ordering can be requested per call:
|
|
159
121
|
|
|
160
122
|
```javascript
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
123
|
+
const expression = nerdamer('x^2+2*x+1');
|
|
124
|
+
|
|
125
|
+
expression.text();
|
|
126
|
+
// 1+2*x+x^2
|
|
127
|
+
|
|
128
|
+
expression.text({ sort: true });
|
|
129
|
+
// x^2+2*x+1
|
|
164
130
|
```
|
|
165
|
-
|
|
131
|
+
|
|
132
|
+
The full package also supplies `toText()` and TeX conversion:
|
|
166
133
|
|
|
167
134
|
```javascript
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
135
|
+
expression.toText();
|
|
136
|
+
expression.toTeX();
|
|
137
|
+
nerdamer.convertToTeX('sqrt(x^2+1)');
|
|
138
|
+
nerdamer.convertFromLaTeX('\\frac{x^2+1}{2}');
|
|
171
139
|
```
|
|
172
|
-
|
|
140
|
+
|
|
141
|
+
`convertToLaTeX()` remains as a deprecated compatibility alias.
|
|
142
|
+
|
|
143
|
+
Scientific formatting can be requested through `text()` without changing the underlying expression:
|
|
173
144
|
|
|
174
145
|
```javascript
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
//0.960170286650366
|
|
146
|
+
nerdamer('1200').text({ scientific: 4 });
|
|
147
|
+
// 1.200e3
|
|
178
148
|
```
|
|
179
|
-
|
|
180
|
-
|
|
149
|
+
|
|
150
|
+
## Algebra
|
|
181
151
|
|
|
182
152
|
```javascript
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
153
|
+
nerdamer.expand('(x+1)^4').text();
|
|
154
|
+
nerdamer.factor('x^4-1').text();
|
|
155
|
+
nerdamer.simplify('sin(x)^2+cos(x)^2').text();
|
|
156
|
+
nerdamer.gcd('x^2-1', 'x^2-2*x+1').text();
|
|
157
|
+
nerdamer.partfrac('1/(x^2-1)', 'x').text();
|
|
186
158
|
```
|
|
187
|
-
The above expample now returns zero whereas in previous version the result would be 4.440892098500626e-16. Same goes for 0.1+0.2.
|
|
188
159
|
|
|
189
|
-
|
|
160
|
+
The 2.0 algebra implementation includes the rewritten polynomial GCD/factorization path, partial fractions, polynomial solving support, and direct polynomial APIs.
|
|
161
|
+
|
|
162
|
+
Prime factorization has two explicit forms:
|
|
190
163
|
|
|
191
164
|
```javascript
|
|
192
|
-
nerdamer(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
165
|
+
nerdamer.pfactor(100).text();
|
|
166
|
+
// [2,2,5,5]
|
|
167
|
+
|
|
168
|
+
nerdamer.pfactord(100).text();
|
|
169
|
+
// {2=>2,5=>2}
|
|
196
170
|
```
|
|
197
171
|
|
|
198
|
-
|
|
172
|
+
## Calculus
|
|
199
173
|
|
|
200
174
|
```javascript
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
175
|
+
nerdamer.diff('x^3+sin(x)', 'x').text();
|
|
176
|
+
nerdamer.integrate('x^2', 'x').text();
|
|
177
|
+
nerdamer.limit('sin(x)/x', 'x', '0').text();
|
|
178
|
+
nerdamer.laplace('t', 't', 's').text();
|
|
204
179
|
```
|
|
205
180
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
```javascript
|
|
209
|
-
nerdamer('x^
|
|
210
|
-
nerdamer('sin(x)^0.25+cos(x)^0.5' );
|
|
211
|
-
var asObject = true;
|
|
212
|
-
var asLaTeX = true;
|
|
213
|
-
console.log(nerdamer.expressions(asObject, asLaTeX));
|
|
214
|
-
|
|
215
|
-
/*{ '1': '2 \\cdot \\mathrm{cos}\\left(x\\right)+3 \\cdot x^{2}',
|
|
216
|
-
'2': '\\sqrt{\\mathrm{cos}\\left(x\\right)}+\\mathrm{sin}\\left(x\\right)^{\\frac{1}{4}}' }*/
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
You can specify a particular location when adding an expression, which is specified with the third parameter.
|
|
221
|
-
|
|
222
|
-
```javascript
|
|
223
|
-
nerdamer('x^2+2*(cos(x)+x*x)');
|
|
224
|
-
nerdamer('sin(x)^0.25+cos(x)^0.5' );
|
|
225
|
-
nerdamer('expr-override', undefined, 2 );
|
|
226
|
-
var asObject = false;
|
|
227
|
-
var asLaTeX = true;
|
|
228
|
-
console.log(nerdamer.expressions(asObject, asLaTeX));
|
|
229
|
-
|
|
230
|
-
/* [ '2 \\cdot \\mathrm{cos}\\left(x\\right)+3 \\cdot x^{2}',
|
|
231
|
-
'\\sqrt{\\mathrm{cos}\\left(x\\right)}+\\mathrm{sin}\\left(x\\right)^{\\frac{1}{4}}',
|
|
232
|
-
'expr-override' ]
|
|
233
|
-
*/
|
|
181
|
+
The same functions can be used in Nerdamer notation:
|
|
182
|
+
|
|
183
|
+
```javascript
|
|
184
|
+
nerdamer('diff(x^3,x)').text();
|
|
234
185
|
```
|
|
235
186
|
|
|
236
|
-
|
|
187
|
+
## Solving
|
|
237
188
|
|
|
238
|
-
|
|
239
|
-
var reserved = nerdamer.reserved();
|
|
240
|
-
console.log(reserved);
|
|
241
|
-
//result:
|
|
242
|
-
/* csc, sec, cot, erf, fact, mod, GCD, QGCD, LCM, pow, PI, E, cos, sin, tan, acos, asin, atan, sinh, cosh, tanh, asinh, acosh, atanh, exp, min, max, floor, ceil, round, vector, matrix, parens, sqrt, log, expand, abs, invert, transpose, dot */
|
|
189
|
+
Single-variable solving returns a `SolutionSet`:
|
|
243
190
|
|
|
244
|
-
|
|
191
|
+
```javascript
|
|
192
|
+
const roots = nerdamer.solve('x^2-1', 'x');
|
|
193
|
+
console.log(roots.text());
|
|
194
|
+
```
|
|
245
195
|
|
|
246
|
-
|
|
247
|
-
console.log(reserved);
|
|
248
|
-
//result:
|
|
249
|
-
/* [ 'csc', 'sec', 'cot', 'erf', 'fact', 'mod', 'GCD', 'QGCD', 'LCM', 'pow', 'PI', 'E', 'cos', 'sin', 'tan', 'acos', 'asin', 'atan', 'sinh', 'cosh', 'tanh', 'asinh', 'acosh', 'atanh', 'exp', 'min', 'max', 'floor', 'ceil', 'round', 'vector', 'matrix',
|
|
250
|
-
'parens', 'sqrt', 'log', 'expand', 'abs', 'invert', 'transpose', 'dot' ] */
|
|
251
|
-
```
|
|
196
|
+
System solving returns Nerdamer structures rather than legacy JavaScript arrays:
|
|
252
197
|
|
|
253
|
-
|
|
198
|
+
```javascript
|
|
199
|
+
const solutions = nerdamer.solveSystem(
|
|
200
|
+
['x+y=3', 'x-y=1'],
|
|
201
|
+
['x', 'y']
|
|
202
|
+
);
|
|
254
203
|
|
|
255
|
-
|
|
256
|
-
|
|
204
|
+
console.log(solutions.text());
|
|
205
|
+
```
|
|
257
206
|
|
|
258
|
-
|
|
207
|
+
The legacy `solveeqs` name is retained as the compatibility alias for system solving. `solveEquations` is not part of the 2.0 public API.
|
|
259
208
|
|
|
260
|
-
|
|
261
|
-
//-2*sin(x)+6*x
|
|
262
|
-
```
|
|
263
|
-
|
|
209
|
+
## Matrices, vectors, sets, and dictionaries
|
|
264
210
|
|
|
265
|
-
|
|
266
|
-
The runtime functions do have symbolic capabilities and support for imaginary numbers.
|
|
267
|
-
The setfunction method is used as follows:
|
|
211
|
+
Structured values are first-class parser entities:
|
|
268
212
|
|
|
269
|
-
|
|
213
|
+
```javascript
|
|
214
|
+
nerdamer('matrix([1,2],[3,4])').text();
|
|
215
|
+
nerdamer('[1,x,3]').text();
|
|
216
|
+
nerdamer('{1,2,x}').text();
|
|
217
|
+
```
|
|
270
218
|
|
|
271
|
-
|
|
219
|
+
The corresponding TypeScript classes are exported from `nerdamer/structures`.
|
|
272
220
|
|
|
273
|
-
|
|
274
|
-
//generate some points
|
|
275
|
-
var f = function(x) { return 5*x-1; }
|
|
276
|
-
console.log(f(1)); //4
|
|
277
|
-
console.log(f(2)); //9 - value to be found
|
|
278
|
-
console.log(f(7)); //34
|
|
221
|
+
## Scripting
|
|
279
222
|
|
|
280
|
-
|
|
281
|
-
var answer = nerdamer('interpolate(4,1,34,7,2)').evaluate();
|
|
223
|
+
Nerdamer notation includes a symbolic scripting layer with assignments, user functions, local bindings, conditionals, loops, blocks, logical operations, `return`, `break`, `continue`, and error-handling helpers.
|
|
282
224
|
|
|
283
|
-
|
|
225
|
+
```javascript
|
|
226
|
+
const result = nerdamer(`
|
|
227
|
+
f(x):=x^2+1;
|
|
228
|
+
f(12)
|
|
229
|
+
`);
|
|
284
230
|
|
|
285
|
-
|
|
231
|
+
console.log(result.text());
|
|
286
232
|
```
|
|
287
233
|
|
|
288
|
-
|
|
234
|
+
Control-flow operations that intentionally produce no mathematical value use an internal null signal. That signal is distinct from legitimate values such as an empty vector and is not exposed as a normal parser entity.
|
|
235
|
+
|
|
236
|
+
## Runtime functions, constants, and settings
|
|
289
237
|
|
|
290
238
|
```javascript
|
|
291
|
-
nerdamer('
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
//result: 5
|
|
239
|
+
nerdamer.setFunction('line', ['x', 'm', 'b'], 'm*x+b');
|
|
240
|
+
nerdamer.setConstant('g', 9.81);
|
|
241
|
+
nerdamer.setVar('a', 5);
|
|
295
242
|
```
|
|
296
243
|
|
|
244
|
+
Settings remain shared by the package instance:
|
|
297
245
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
var weight = nerdamer('100*g').text();
|
|
303
|
-
console.log(weight);
|
|
304
|
-
//result:
|
|
305
|
-
//981
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
To delete just set it to delete
|
|
309
|
-
|
|
310
|
-
```javascript
|
|
311
|
-
nerdamer.setConstant( 'g', 9.81);
|
|
312
|
-
var weight = nerdamer('100*g').text();
|
|
313
|
-
console.log(weight);
|
|
314
|
-
//981
|
|
315
|
-
nerdamer.setConstant( 'g', 'delete');
|
|
316
|
-
var weight = nerdamer('100*g').text();
|
|
317
|
-
console.log(weight);
|
|
318
|
-
//100*g
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
You also have the option of exporting your function to a javascript function which can be useful if you need some
|
|
322
|
-
filtering from user input. Do keep in mind that the parameters are sorted alphabetically for more than one
|
|
323
|
-
parameter. To use it add the expression to nerdamer and use the buildFunction method.
|
|
324
|
-
|
|
325
|
-
```javascript
|
|
326
|
-
var f = nerdamer('x^2+5').buildFunction();
|
|
327
|
-
console.log(f(9));
|
|
328
|
-
|
|
329
|
-
//result:
|
|
330
|
-
//86
|
|
331
|
-
```
|
|
332
|
-
If you have a particular order in which you need the parameters to be set, then you pass in an array with the variables in the order in which you want them for instance:
|
|
246
|
+
```javascript
|
|
247
|
+
nerdamer.set('LANGUAGE', 'spa');
|
|
248
|
+
nerdamer.set('LANGUAGE', 'eng');
|
|
249
|
+
```
|
|
333
250
|
|
|
334
|
-
|
|
335
|
-
var f = nerdamer('z+x^2+y').buildFunction(['y', 'x', 'z']);
|
|
336
|
-
console.log(f(9,2,1));
|
|
337
|
-
//result
|
|
338
|
-
//14
|
|
339
|
-
```
|
|
251
|
+
Built-in error messages are available in English, Spanish, French, German, Portuguese, Italian, and Dutch.
|
|
340
252
|
|
|
341
|
-
|
|
342
|
-
the 'expressions' method. To delete an expression use the 'clear' method and pass in the expression you want to delete.
|
|
343
|
-
To clear everything pass in the string 'all'.
|
|
253
|
+
## Assumptions
|
|
344
254
|
|
|
345
|
-
```
|
|
346
|
-
nerdamer
|
|
347
|
-
nerdamer
|
|
348
|
-
nerdamer('G*m1*m2/d^2');
|
|
255
|
+
```typescript
|
|
256
|
+
import nerdamer from 'nerdamer';
|
|
257
|
+
import { assume, clearAssumptions } from 'nerdamer/assumptions';
|
|
349
258
|
|
|
350
|
-
|
|
259
|
+
assume('x > 0');
|
|
260
|
+
console.log(nerdamer('sqrt(x^2)').text());
|
|
261
|
+
// x
|
|
262
|
+
clearAssumptions();
|
|
263
|
+
```
|
|
351
264
|
|
|
352
|
-
|
|
265
|
+
Repeated assumptions for a symbol are intersected. Contradictory assumptions are rejected.
|
|
353
266
|
|
|
354
|
-
|
|
355
|
-
//{ '1': 'R*T*n*v^(-1)', '2': 'G*d^(-2)*m1*m2' }
|
|
267
|
+
## Building JavaScript functions
|
|
356
268
|
|
|
357
|
-
|
|
358
|
-
console.log(nerdamer.expressions(true));
|
|
359
|
-
//result:
|
|
360
|
-
//{}
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
If you need go get the variables of an expression use the variables method. This method can be called after
|
|
364
|
-
nerdamer was provided an expression. For example
|
|
269
|
+
Scalar expressions can be compiled to native JavaScript-number functions:
|
|
365
270
|
|
|
366
271
|
```javascript
|
|
367
|
-
|
|
368
|
-
console.log(
|
|
369
|
-
//
|
|
370
|
-
//[ 'no_boring_x', 'x', 'y' ]
|
|
272
|
+
const f = nerdamer('x^2+5').buildFunction();
|
|
273
|
+
console.log(f(9));
|
|
274
|
+
// 86
|
|
371
275
|
```
|
|
372
276
|
|
|
373
|
-
|
|
374
|
-
sake of simplicity we'll just assume that there is no particular order
|
|
277
|
+
`buildFunction()` uses dynamic JavaScript function construction. Applications whose Content Security Policy blocks dynamic code generation should use Nerdamer's symbolic or numeric evaluation APIs instead. Structured parser results cannot be compiled as scalar functions.
|
|
375
278
|
|
|
376
|
-
|
|
279
|
+
## Numeric behavior
|
|
280
|
+
|
|
281
|
+
Nerdamer preserves exact integer and rational arithmetic where possible. Large integers use native `BigInt`; decimal arithmetic uses Decimal.js. Complex arithmetic is represented by Nerdamer's numeric types rather than JavaScript's native `Number` alone.
|
|
377
282
|
|
|
378
|
-
Using the solver
|
|
379
|
-
===============
|
|
380
|
-
To solve equations first load Solve.js. Just remember that Solve also required Algebra.js and Calculus.js to be loaded. You can then solve equations using nerdamer. Important: State the variable for which you are trying to solve.
|
|
381
283
|
```javascript
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
//1+i,-i+1,-1
|
|
284
|
+
nerdamer('0.1+0.2').text();
|
|
285
|
+
nerdamer('sqrt(2)').evaluate().text();
|
|
385
286
|
```
|
|
386
287
|
|
|
387
|
-
|
|
288
|
+
## Building from source
|
|
388
289
|
|
|
389
|
-
|
|
390
|
-
```javascript
|
|
391
|
-
var e = nerdamer.solveEquations('x^2+4-y', 'y');
|
|
392
|
-
console.log(e[0].text());
|
|
393
|
-
//4+x^2
|
|
394
|
-
```
|
|
290
|
+
Install dependencies and run the normal checks:
|
|
395
291
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
//0.5*((-4*y-7)^0.5+1),0.5*(-(-4*y-7)^0.5+1)
|
|
292
|
+
```bash
|
|
293
|
+
npm install
|
|
294
|
+
npm run typecheck
|
|
295
|
+
npm test
|
|
401
296
|
```
|
|
402
|
-
You can do up to 3rd order polynomials for multivariate polynomials
|
|
403
297
|
|
|
404
|
-
|
|
298
|
+
Build the complete package:
|
|
405
299
|
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
console.log(sol.toString());
|
|
409
|
-
//5.7981235959208695,0.4850617112587174
|
|
300
|
+
```bash
|
|
301
|
+
npm run build
|
|
410
302
|
```
|
|
411
|
-
To solve a system of linear equations pass them in as an array. For example
|
|
412
303
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
```
|
|
418
|
-
In version 0.7.2 and up the solver can additionally be used in the following way
|
|
419
|
-
```javascript
|
|
420
|
-
//first parse the equation
|
|
421
|
-
var x = nerdamer('x^2+2=y-7*a');
|
|
422
|
-
//You can make substitutions to the equation
|
|
423
|
-
x = x.evaluate({a: 'x^2-3'});
|
|
424
|
-
console.log(x.toString()); //2+x^2=-7*x^2+21+y
|
|
425
|
-
var solutions = x.solveFor('x');
|
|
426
|
-
console.log(solutions.toString()); //(1/16)*sqrt(32*y+608),(-1/16)*sqrt(32*y+608)
|
|
304
|
+
Build the parser-only browser bundle:
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
npm run build:parser
|
|
427
308
|
```
|
|
309
|
+
|
|
310
|
+
The webpack build also accepts a language selection (`eng`, `spa`, `fra`, `deu`, `por`, `ita`, `nld`, or `all`) for browser bundles. English is the default.
|
|
311
|
+
|
|
312
|
+
Before publishing, the package runs type checking, tests, coverage, both browser builds, parser documentation generation, TypeDoc validation, and packed-package validation through `prepublishOnly`.
|
|
313
|
+
|
|
314
|
+
## Migrating from Nerdamer 1.x
|
|
315
|
+
|
|
316
|
+
Nerdamer 2.0 keeps much of the familiar expression-oriented API, but it is a new implementation. Important migration areas include:
|
|
317
|
+
|
|
318
|
+
- the old `Algebra`, `Calculus`, `Solve`, and `Extra` side-effect imports are replaced by the complete package and supported module entry points;
|
|
319
|
+
- the third and fourth arguments to `nerdamer(...)` are gone;
|
|
320
|
+
- global parsed-expression history is gone;
|
|
321
|
+
- parser results can be structured Nerdamer entities instead of always being wrapped as an `Expression`;
|
|
322
|
+
- system-solving results use `Vector`/`Dictionary` structures;
|
|
323
|
+
- lower-level 1.x extension hooks such as `getCore()` and `register()` are not restored;
|
|
324
|
+
- several compatibility functions were restored explicitly rather than by exposing every parser function on the root object;
|
|
325
|
+
- internal numeric, parser, solver, polynomial, assumptions, set, and scripting implementations have changed substantially.
|
|
326
|
+
|
|
327
|
+
See [BREAKING_CHANGES.md](BREAKING_CHANGES.md) and [Moving from Nerdamer 1.x to 2.0](docs/MIGRATING_FROM_1X.md) before upgrading an existing application.
|
|
328
|
+
|
|
329
|
+
## Documentation
|
|
330
|
+
|
|
331
|
+
- Website: https://nerdamer.com/
|
|
332
|
+
- Documentation: https://nerdamer.com/documentation
|
|
333
|
+
- Migration guide: `docs/MIGRATING_FROM_1X.md`
|
|
334
|
+
- 2.0 release notes: `docs/RELEASE_NOTES_2.md`
|
|
335
|
+
- Parser conventions: `docs/PARSER_CONVENTIONS.md`
|
|
336
|
+
- Source repository: https://github.com/jiggzson/nerdamer
|
|
337
|
+
- Issues: https://github.com/jiggzson/nerdamer/issues
|
|
338
|
+
|
|
339
|
+
## License
|
|
340
|
+
|
|
341
|
+
Nerdamer 2.0 is licensed under the Apache License 2.0.
|