mathjs 11.12.0 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HISTORY.md +54 -2
- package/README.md +1 -1
- package/lib/browser/math.js +1 -1
- package/lib/browser/math.js.LICENSE.txt +2 -2
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesEigs.generated.js +4 -0
- package/lib/cjs/entry/pureFunctionsAny.generated.js +2 -0
- package/lib/cjs/expression/embeddedDocs/function/arithmetic/round.js +2 -2
- package/lib/cjs/expression/embeddedDocs/function/matrix/eigs.js +2 -2
- package/lib/cjs/expression/node/AssignmentNode.js +1 -1
- package/lib/cjs/expression/node/FunctionAssignmentNode.js +1 -1
- package/lib/cjs/function/algebra/derivative.js +8 -31
- package/lib/cjs/function/arithmetic/gcd.js +4 -5
- package/lib/cjs/function/arithmetic/mod.js +2 -9
- package/lib/cjs/function/arithmetic/round.js +59 -16
- package/lib/cjs/function/matrix/eigs/complexEigs.js +73 -68
- package/lib/cjs/function/matrix/eigs/{realSymetric.js → realSymmetric.js} +57 -51
- package/lib/cjs/function/matrix/eigs.js +118 -45
- package/lib/cjs/function/probability/pickRandom.js +2 -2
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/type/number.js +2 -2
- package/lib/cjs/utils/number.js +1 -1
- package/lib/cjs/utils/snapshot.js +6 -6
- package/lib/cjs/version.js +1 -1
- package/lib/esm/entry/dependenciesAny/dependenciesEigs.generated.js +4 -0
- package/lib/esm/entry/pureFunctionsAny.generated.js +2 -0
- package/lib/esm/expression/embeddedDocs/function/arithmetic/round.js +2 -2
- package/lib/esm/expression/embeddedDocs/function/matrix/eigs.js +2 -2
- package/lib/esm/expression/node/AssignmentNode.js +1 -1
- package/lib/esm/expression/node/FunctionAssignmentNode.js +1 -1
- package/lib/esm/function/algebra/derivative.js +8 -31
- package/lib/esm/function/arithmetic/mod.js +2 -9
- package/lib/esm/function/arithmetic/round.js +40 -17
- package/lib/esm/function/matrix/eigs/complexEigs.js +73 -68
- package/lib/esm/function/matrix/eigs/{realSymetric.js → realSymmetric.js} +55 -51
- package/lib/esm/function/matrix/eigs.js +119 -47
- package/lib/esm/function/probability/pickRandom.js +2 -2
- package/lib/esm/type/number.js +2 -2
- package/lib/esm/utils/number.js +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +14 -14
- package/types/EXPLANATION.md +54 -0
- package/types/index.d.ts +6825 -6483
| @@ -1,12 +1,13 @@ | |
| 1 | 
            +
            import _extends from "@babel/runtime/helpers/extends";
         | 
| 1 2 | 
             
            import { factory } from '../../utils/factory.js';
         | 
| 2 3 | 
             
            import { format } from '../../utils/string.js';
         | 
| 3 4 | 
             
            import { createComplexEigs } from './eigs/complexEigs.js';
         | 
| 4 | 
            -
            import { createRealSymmetric } from './eigs/ | 
| 5 | 
            +
            import { createRealSymmetric } from './eigs/realSymmetric.js';
         | 
| 5 6 | 
             
            import { typeOf, isNumber, isBigNumber, isComplex, isFraction } from '../../utils/is.js';
         | 
| 6 7 | 
             
            var name = 'eigs';
         | 
| 7 8 |  | 
| 8 9 | 
             
            // The absolute state of math.js's dependency system:
         | 
| 9 | 
            -
            var dependencies = ['config', 'typed', 'matrix', 'addScalar', 'equal', 'subtract', 'abs', 'atan', 'cos', 'sin', 'multiplyScalar', 'divideScalar', 'inv', 'bignumber', 'multiply', 'add', 'larger', 'column', 'flatten', 'number', 'complex', 'sqrt', 'diag', 'qr', 'usolve', 'usolveAll', 'im', 're', 'smaller', 'matrixFromColumns', 'dot'];
         | 
| 10 | 
            +
            var dependencies = ['config', 'typed', 'matrix', 'addScalar', 'equal', 'subtract', 'abs', 'atan', 'cos', 'sin', 'multiplyScalar', 'divideScalar', 'inv', 'bignumber', 'multiply', 'add', 'larger', 'column', 'flatten', 'number', 'complex', 'sqrt', 'diag', 'size', 'reshape', 'qr', 'usolve', 'usolveAll', 'im', 're', 'smaller', 'matrixFromColumns', 'dot'];
         | 
| 10 11 | 
             
            export var createEigs = /* #__PURE__ */factory(name, dependencies, _ref => {
         | 
| 11 12 | 
             
              var {
         | 
| 12 13 | 
             
                config,
         | 
| @@ -32,6 +33,8 @@ export var createEigs = /* #__PURE__ */factory(name, dependencies, _ref => { | |
| 32 33 | 
             
                complex,
         | 
| 33 34 | 
             
                sqrt,
         | 
| 34 35 | 
             
                diag,
         | 
| 36 | 
            +
                size,
         | 
| 37 | 
            +
                reshape,
         | 
| 35 38 | 
             
                qr,
         | 
| 36 39 | 
             
                usolve,
         | 
| 37 40 | 
             
                usolveAll,
         | 
| @@ -41,7 +44,7 @@ export var createEigs = /* #__PURE__ */factory(name, dependencies, _ref => { | |
| 41 44 | 
             
                matrixFromColumns,
         | 
| 42 45 | 
             
                dot
         | 
| 43 46 | 
             
              } = _ref;
         | 
| 44 | 
            -
              var  | 
| 47 | 
            +
              var doRealSymmetric = createRealSymmetric({
         | 
| 45 48 | 
             
                config,
         | 
| 46 49 | 
             
                addScalar,
         | 
| 47 50 | 
             
                subtract,
         | 
| @@ -71,6 +74,8 @@ export var createEigs = /* #__PURE__ */factory(name, dependencies, _ref => { | |
| 71 74 | 
             
                abs,
         | 
| 72 75 | 
             
                bignumber,
         | 
| 73 76 | 
             
                diag,
         | 
| 77 | 
            +
                size,
         | 
| 78 | 
            +
                reshape,
         | 
| 74 79 | 
             
                qr,
         | 
| 75 80 | 
             
                inv,
         | 
| 76 81 | 
             
                usolve,
         | 
| @@ -84,26 +89,54 @@ export var createEigs = /* #__PURE__ */factory(name, dependencies, _ref => { | |
| 84 89 | 
             
              });
         | 
| 85 90 |  | 
| 86 91 | 
             
              /**
         | 
| 87 | 
            -
               * Compute eigenvalues and eigenvectors of a matrix. | 
| 88 | 
            -
               *  | 
| 89 | 
            -
               *  | 
| 90 | 
            -
               *  | 
| 92 | 
            +
               * Compute eigenvalues and optionally eigenvectors of a square matrix.
         | 
| 93 | 
            +
               * The eigenvalues are sorted by their absolute value, ascending, and
         | 
| 94 | 
            +
               * returned as a vector in the `values` property of the returned project.
         | 
| 95 | 
            +
               * An eigenvalue with algebraic multiplicity k will be listed k times, so
         | 
| 96 | 
            +
               * that the returned `values` vector always has length equal to the size
         | 
| 97 | 
            +
               * of the input matrix.
         | 
| 98 | 
            +
               *
         | 
| 99 | 
            +
               * The `eigenvectors` property of the return value provides the eigenvectors.
         | 
| 100 | 
            +
               * It is an array of plain objects: the `value` property of each gives the
         | 
| 101 | 
            +
               * associated eigenvalue, and the `vector` property gives the eigenvector
         | 
| 102 | 
            +
               * itself. Note that the same `value` property will occur as many times in
         | 
| 103 | 
            +
               * the list provided by `eigenvectors` as the geometric multiplicity of
         | 
| 104 | 
            +
               * that value.
         | 
| 105 | 
            +
               *
         | 
| 106 | 
            +
               * If the algorithm fails to converge, it will throw an error –
         | 
| 107 | 
            +
               * in that case, however, you may still find useful information
         | 
| 91 108 | 
             
               * in `err.values` and `err.vectors`.
         | 
| 92 109 | 
             
               *
         | 
| 110 | 
            +
               * Note that the 'precision' option does not directly specify the _accuracy_
         | 
| 111 | 
            +
               * of the returned eigenvalues. Rather, it determines how small an entry
         | 
| 112 | 
            +
               * of the iterative approximations to an upper triangular matrix must be
         | 
| 113 | 
            +
               * in order to be considered zero. The actual accuracy of the returned
         | 
| 114 | 
            +
               * eigenvalues may be greater or less than the precision, depending on the
         | 
| 115 | 
            +
               * conditioning of the matrix and how far apart or close the actual
         | 
| 116 | 
            +
               * eigenvalues are. Note that currently, relatively simple, "traditional"
         | 
| 117 | 
            +
               * methods of eigenvalue computation are being used; this is not a modern,
         | 
| 118 | 
            +
               * high-precision eigenvalue computation. That said, it should typically
         | 
| 119 | 
            +
               * produce fairly reasonable results.
         | 
| 120 | 
            +
               *
         | 
| 93 121 | 
             
               * Syntax:
         | 
| 94 122 | 
             
               *
         | 
| 95 123 | 
             
               *     math.eigs(x, [prec])
         | 
| 124 | 
            +
               *     math.eigs(x, {options})
         | 
| 96 125 | 
             
               *
         | 
| 97 126 | 
             
               * Examples:
         | 
| 98 127 | 
             
               *
         | 
| 99 | 
            -
               *     const { eigs, multiply, column, transpose } = math
         | 
| 128 | 
            +
               *     const { eigs, multiply, column, transpose, matrixFromColumns } = math
         | 
| 100 129 | 
             
               *     const H = [[5, 2.3], [2.3, 1]]
         | 
| 101 | 
            -
               *     const ans = eigs(H) // returns {values: [E1,E2...sorted],  | 
| 130 | 
            +
               *     const ans = eigs(H) // returns {values: [E1,E2...sorted], eigenvectors: [{value: E1, vector: v2}, {value: e, vector: v2}, ...]
         | 
| 102 131 | 
             
               *     const E = ans.values
         | 
| 103 | 
            -
               *     const  | 
| 104 | 
            -
               *     multiply(H,  | 
| 105 | 
            -
               *     const  | 
| 106 | 
            -
               *      | 
| 132 | 
            +
               *     const V = ans.eigenvectors
         | 
| 133 | 
            +
               *     multiply(H, V[0].vector)) // returns multiply(E[0], V[0].vector))
         | 
| 134 | 
            +
               *     const U = matrixFromColumns(...V.map(obj => obj.vector))
         | 
| 135 | 
            +
               *     const UTxHxU = multiply(transpose(U), H, U) // diagonalizes H if possible
         | 
| 136 | 
            +
               *     E[0] == UTxHxU[0][0]  // returns true always
         | 
| 137 | 
            +
               *
         | 
| 138 | 
            +
               *     // Compute only approximate eigenvalues:
         | 
| 139 | 
            +
               *     const {values} = eigs(H, {eigenvectors: false, precision: 1e-6})
         | 
| 107 140 | 
             
               *
         | 
| 108 141 | 
             
               * See also:
         | 
| 109 142 | 
             
               *
         | 
| @@ -111,59 +144,98 @@ export var createEigs = /* #__PURE__ */factory(name, dependencies, _ref => { | |
| 111 144 | 
             
               *
         | 
| 112 145 | 
             
               * @param {Array | Matrix} x  Matrix to be diagonalized
         | 
| 113 146 | 
             
               *
         | 
| 114 | 
            -
               * @param {number | BigNumber} [ | 
| 115 | 
            -
               * @return {{values: Array|Matrix,  | 
| 147 | 
            +
               * @param {number | BigNumber | OptsObject} [opts] Object with keys `precision`, defaulting to config.epsilon, and `eigenvectors`, defaulting to true and specifying whether to compute eigenvectors. If just a number, specifies precision.
         | 
| 148 | 
            +
               * @return {{values: Array|Matrix, eigenvectors?: Array<EVobj>}} Object containing an array of eigenvalues and an array of {value: number|BigNumber, vector: Array|Matrix} objects. The eigenvectors property is undefined if eigenvectors were not requested.
         | 
| 116 149 | 
             
               *
         | 
| 117 150 | 
             
               */
         | 
| 118 151 | 
             
              return typed('eigs', {
         | 
| 152 | 
            +
                // The conversion to matrix in the first two implementations,
         | 
| 153 | 
            +
                // just to convert back to an array right away in
         | 
| 154 | 
            +
                // computeValuesAndVectors, is unfortunate, and should perhaps be
         | 
| 155 | 
            +
                // streamlined. It is done because the Matrix object carries some
         | 
| 156 | 
            +
                // type information about its entries, and so constructing the matrix
         | 
| 157 | 
            +
                // is a roundabout way of doing type detection.
         | 
| 119 158 | 
             
                Array: function Array(x) {
         | 
| 120 | 
            -
                   | 
| 121 | 
            -
                  return computeValuesAndVectors(mat);
         | 
| 159 | 
            +
                  return doEigs(matrix(x));
         | 
| 122 160 | 
             
                },
         | 
| 123 161 | 
             
                'Array, number|BigNumber': function ArrayNumberBigNumber(x, prec) {
         | 
| 124 | 
            -
                   | 
| 125 | 
            -
             | 
| 162 | 
            +
                  return doEigs(matrix(x), {
         | 
| 163 | 
            +
                    precision: prec
         | 
| 164 | 
            +
                  });
         | 
| 165 | 
            +
                },
         | 
| 166 | 
            +
                'Array, Object'(x, opts) {
         | 
| 167 | 
            +
                  return doEigs(matrix(x), opts);
         | 
| 126 168 | 
             
                },
         | 
| 127 169 | 
             
                Matrix: function Matrix(mat) {
         | 
| 128 | 
            -
                   | 
| 129 | 
            -
                     | 
| 130 | 
            -
             | 
| 131 | 
            -
                  } = computeValuesAndVectors(mat);
         | 
| 132 | 
            -
                  return {
         | 
| 133 | 
            -
                    values: matrix(values),
         | 
| 134 | 
            -
                    vectors: matrix(vectors)
         | 
| 135 | 
            -
                  };
         | 
| 170 | 
            +
                  return doEigs(mat, {
         | 
| 171 | 
            +
                    matricize: true
         | 
| 172 | 
            +
                  });
         | 
| 136 173 | 
             
                },
         | 
| 137 174 | 
             
                'Matrix, number|BigNumber': function MatrixNumberBigNumber(mat, prec) {
         | 
| 138 | 
            -
                   | 
| 139 | 
            -
                     | 
| 140 | 
            -
                     | 
| 141 | 
            -
                  } | 
| 142 | 
            -
             | 
| 143 | 
            -
             | 
| 144 | 
            -
             | 
| 175 | 
            +
                  return doEigs(mat, {
         | 
| 176 | 
            +
                    precision: prec,
         | 
| 177 | 
            +
                    matricize: true
         | 
| 178 | 
            +
                  });
         | 
| 179 | 
            +
                },
         | 
| 180 | 
            +
                'Matrix, Object': function MatrixObject(mat, opts) {
         | 
| 181 | 
            +
                  var useOpts = {
         | 
| 182 | 
            +
                    matricize: true
         | 
| 145 183 | 
             
                  };
         | 
| 184 | 
            +
                  _extends(useOpts, opts);
         | 
| 185 | 
            +
                  return doEigs(mat, useOpts);
         | 
| 146 186 | 
             
                }
         | 
| 147 187 | 
             
              });
         | 
| 148 | 
            -
              function  | 
| 149 | 
            -
                 | 
| 150 | 
            -
             | 
| 188 | 
            +
              function doEigs(mat) {
         | 
| 189 | 
            +
                var _opts$precision;
         | 
| 190 | 
            +
                var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
         | 
| 191 | 
            +
                var computeVectors = 'eigenvectors' in opts ? opts.eigenvectors : true;
         | 
| 192 | 
            +
                var prec = (_opts$precision = opts.precision) !== null && _opts$precision !== void 0 ? _opts$precision : config.epsilon;
         | 
| 193 | 
            +
                var result = computeValuesAndVectors(mat, prec, computeVectors);
         | 
| 194 | 
            +
                if (opts.matricize) {
         | 
| 195 | 
            +
                  result.values = matrix(result.values);
         | 
| 196 | 
            +
                  if (computeVectors) {
         | 
| 197 | 
            +
                    result.eigenvectors = result.eigenvectors.map(_ref2 => {
         | 
| 198 | 
            +
                      var {
         | 
| 199 | 
            +
                        value,
         | 
| 200 | 
            +
                        vector
         | 
| 201 | 
            +
                      } = _ref2;
         | 
| 202 | 
            +
                      return {
         | 
| 203 | 
            +
                        value,
         | 
| 204 | 
            +
                        vector: matrix(vector)
         | 
| 205 | 
            +
                      };
         | 
| 206 | 
            +
                    });
         | 
| 207 | 
            +
                  }
         | 
| 208 | 
            +
                }
         | 
| 209 | 
            +
                if (computeVectors) {
         | 
| 210 | 
            +
                  Object.defineProperty(result, 'vectors', {
         | 
| 211 | 
            +
                    enumerable: false,
         | 
| 212 | 
            +
                    // to make sure that the eigenvectors can still be
         | 
| 213 | 
            +
                    // converted to string.
         | 
| 214 | 
            +
                    get: () => {
         | 
| 215 | 
            +
                      throw new Error('eigs(M).vectors replaced with eigs(M).eigenvectors');
         | 
| 216 | 
            +
                    }
         | 
| 217 | 
            +
                  });
         | 
| 151 218 | 
             
                }
         | 
| 152 | 
            -
                 | 
| 153 | 
            -
             | 
| 154 | 
            -
             | 
| 219 | 
            +
                return result;
         | 
| 220 | 
            +
              }
         | 
| 221 | 
            +
              function computeValuesAndVectors(mat, prec, computeVectors) {
         | 
| 222 | 
            +
                var arr = mat.toArray(); // NOTE: arr is guaranteed to be unaliased
         | 
| 223 | 
            +
                // and so safe to modify in place
         | 
| 224 | 
            +
                var asize = mat.size();
         | 
| 225 | 
            +
                if (asize.length !== 2 || asize[0] !== asize[1]) {
         | 
| 226 | 
            +
                  throw new RangeError("Matrix must be square (size: ".concat(format(asize), ")"));
         | 
| 155 227 | 
             
                }
         | 
| 156 | 
            -
                var  | 
| 157 | 
            -
                var N = size[0];
         | 
| 228 | 
            +
                var N = asize[0];
         | 
| 158 229 | 
             
                if (isReal(arr, N, prec)) {
         | 
| 159 | 
            -
                  coerceReal(arr, N);
         | 
| 230 | 
            +
                  coerceReal(arr, N); // modifies arr by side effect
         | 
| 231 | 
            +
             | 
| 160 232 | 
             
                  if (isSymmetric(arr, N, prec)) {
         | 
| 161 | 
            -
                    var _type = coerceTypes(mat, arr, N);
         | 
| 162 | 
            -
                    return  | 
| 233 | 
            +
                    var _type = coerceTypes(mat, arr, N); // modifies arr by side effect
         | 
| 234 | 
            +
                    return doRealSymmetric(arr, N, prec, _type, computeVectors);
         | 
| 163 235 | 
             
                  }
         | 
| 164 236 | 
             
                }
         | 
| 165 | 
            -
                var type = coerceTypes(mat, arr, N);
         | 
| 166 | 
            -
                return doComplexEigs(arr, N, prec, type);
         | 
| 237 | 
            +
                var type = coerceTypes(mat, arr, N); // modifies arr by side effect
         | 
| 238 | 
            +
                return doComplexEigs(arr, N, prec, type, computeVectors);
         | 
| 167 239 | 
             
              }
         | 
| 168 240 |  | 
| 169 241 | 
             
              /** @return {boolean} */
         | 
| @@ -52,8 +52,8 @@ export var createPickRandom = /* #__PURE__ */factory(name, dependencies, _ref => | |
| 52 52 | 
             
               * @param {Array | Matrix} array     A one dimensional array
         | 
| 53 53 | 
             
               * @param {Int} number               An int or float
         | 
| 54 54 | 
             
               * @param {Array | Matrix} weights   An array of ints or floats
         | 
| 55 | 
            -
               * @return {number | Array}          Returns a single random value from array when number is  | 
| 56 | 
            -
               *                                   Returns an array with the configured number of elements when number is  | 
| 55 | 
            +
               * @return {number | Array}          Returns a single random value from array when number is undefined.
         | 
| 56 | 
            +
               *                                   Returns an array with the configured number of elements when number is defined.
         | 
| 57 57 | 
             
               */
         | 
| 58 58 | 
             
              return typed(name, {
         | 
| 59 59 | 
             
                'Array | Matrix': function ArrayMatrix(possibles) {
         | 
    
        package/lib/esm/type/number.js
    CHANGED
    
    | @@ -43,7 +43,7 @@ function makeNumberFromNonDecimalParts(parts) { | |
| 43 43 | 
             
              }
         | 
| 44 44 | 
             
              var result = n + f;
         | 
| 45 45 | 
             
              if (isNaN(result)) {
         | 
| 46 | 
            -
                throw new SyntaxError('String "' + parts.input + '" is  | 
| 46 | 
            +
                throw new SyntaxError('String "' + parts.input + '" is not a valid number');
         | 
| 47 47 | 
             
              }
         | 
| 48 48 | 
             
              return result;
         | 
| 49 49 | 
             
            }
         | 
| @@ -99,7 +99,7 @@ export var createNumber = /* #__PURE__ */factory(name, dependencies, _ref => { | |
| 99 99 | 
             
                  }
         | 
| 100 100 | 
             
                  var num = Number(x);
         | 
| 101 101 | 
             
                  if (isNaN(num)) {
         | 
| 102 | 
            -
                    throw new SyntaxError('String "' + x + '" is  | 
| 102 | 
            +
                    throw new SyntaxError('String "' + x + '" is not a valid number');
         | 
| 103 103 | 
             
                  }
         | 
| 104 104 | 
             
                  if (wordSizeSuffixMatch) {
         | 
| 105 105 | 
             
                    // x is a signed bin, oct, or hex literal
         | 
    
        package/lib/esm/utils/number.js
    CHANGED
    
    | @@ -583,7 +583,7 @@ export function nearlyEqual(x, y, epsilon) { | |
| 583 583 | 
             
              if (isFinite(x) && isFinite(y)) {
         | 
| 584 584 | 
             
                // check numbers are very close, needed when comparing numbers near zero
         | 
| 585 585 | 
             
                var diff = Math.abs(x - y);
         | 
| 586 | 
            -
                if (diff  | 
| 586 | 
            +
                if (diff <= DBL_EPSILON) {
         | 
| 587 587 | 
             
                  return true;
         | 
| 588 588 | 
             
                } else {
         | 
| 589 589 | 
             
                  // use relative error
         | 
    
        package/lib/esm/version.js
    CHANGED
    
    
    
        package/package.json
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            {
         | 
| 2 2 | 
             
              "name": "mathjs",
         | 
| 3 | 
            -
              "version": " | 
| 3 | 
            +
              "version": "12.1.0",
         | 
| 4 4 | 
             
              "description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
         | 
| 5 5 | 
             
              "author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
         | 
| 6 6 | 
             
              "homepage": "https://mathjs.org",
         | 
| @@ -36,29 +36,29 @@ | |
| 36 36 | 
             
                "typed-function": "^4.1.1"
         | 
| 37 37 | 
             
              },
         | 
| 38 38 | 
             
              "devDependencies": {
         | 
| 39 | 
            -
                "@babel/core": "7.23. | 
| 40 | 
            -
                "@babel/plugin-transform-object-assign": "7. | 
| 41 | 
            -
                "@babel/plugin-transform-runtime": "7.23. | 
| 42 | 
            -
                "@babel/preset-env": "7.23. | 
| 39 | 
            +
                "@babel/core": "7.23.3",
         | 
| 40 | 
            +
                "@babel/plugin-transform-object-assign": "7.23.3",
         | 
| 41 | 
            +
                "@babel/plugin-transform-runtime": "7.23.3",
         | 
| 42 | 
            +
                "@babel/preset-env": "7.23.3",
         | 
| 43 43 | 
             
                "@babel/register": "7.22.15",
         | 
| 44 | 
            -
                "@types/assert": "1.5. | 
| 45 | 
            -
                "@types/mocha": "10.0. | 
| 46 | 
            -
                "@typescript-eslint/eslint-plugin": "6. | 
| 47 | 
            -
                "@typescript-eslint/parser": "6. | 
| 44 | 
            +
                "@types/assert": "1.5.9",
         | 
| 45 | 
            +
                "@types/mocha": "10.0.4",
         | 
| 46 | 
            +
                "@typescript-eslint/eslint-plugin": "6.11.0",
         | 
| 47 | 
            +
                "@typescript-eslint/parser": "6.11.0",
         | 
| 48 48 | 
             
                "assert": "2.1.0",
         | 
| 49 49 | 
             
                "babel-loader": "9.1.3",
         | 
| 50 50 | 
             
                "benchmark": "2.1.4",
         | 
| 51 51 | 
             
                "c8": "8.0.1",
         | 
| 52 52 | 
             
                "codecov": "3.8.3",
         | 
| 53 | 
            -
                "core-js": "3.33. | 
| 53 | 
            +
                "core-js": "3.33.2",
         | 
| 54 54 | 
             
                "del": "6.1.1",
         | 
| 55 55 | 
             
                "dtslint": "4.2.1",
         | 
| 56 | 
            -
                "eslint": "8. | 
| 56 | 
            +
                "eslint": "8.53.0",
         | 
| 57 57 | 
             
                "eslint-config-prettier": "9.0.0",
         | 
| 58 58 | 
             
                "eslint-config-standard": "17.1.0",
         | 
| 59 59 | 
             
                "eslint-plugin-import": "2.29.0",
         | 
| 60 60 | 
             
                "eslint-plugin-mocha": "10.2.0",
         | 
| 61 | 
            -
                "eslint-plugin-n": "16. | 
| 61 | 
            +
                "eslint-plugin-n": "16.3.1",
         | 
| 62 62 | 
             
                "eslint-plugin-prettier": "5.0.1",
         | 
| 63 63 | 
             
                "eslint-plugin-promise": "6.1.1",
         | 
| 64 64 | 
             
                "expect-type": "0.17.3",
         | 
| @@ -85,7 +85,7 @@ | |
| 85 85 | 
             
                "ndarray-pack": "1.2.1",
         | 
| 86 86 | 
             
                "numericjs": "1.2.6",
         | 
| 87 87 | 
             
                "pad-right": "0.2.2",
         | 
| 88 | 
            -
                "prettier": "3.0 | 
| 88 | 
            +
                "prettier": "3.1.0",
         | 
| 89 89 | 
             
                "process": "0.11.10",
         | 
| 90 90 | 
             
                "sylvester": "0.0.21",
         | 
| 91 91 | 
             
                "ts-node": "10.9.1",
         | 
| @@ -169,7 +169,7 @@ | |
| 169 169 | 
             
                "mathjs": "./bin/cli.js"
         | 
| 170 170 | 
             
              },
         | 
| 171 171 | 
             
              "engines": {
         | 
| 172 | 
            -
                "node": ">=  | 
| 172 | 
            +
                "node": ">= 18"
         | 
| 173 173 | 
             
              },
         | 
| 174 174 | 
             
              "bugs": {
         | 
| 175 175 | 
             
                "url": "https://github.com/josdejong/mathjs/issues"
         | 
| @@ -0,0 +1,54 @@ | |
| 1 | 
            +
            # Mathjs TypeScript types
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            The code base of Mathjs is writting in JavaScript. The TypeScript definitions are maintained separately. 
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Library structure
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            The over all structure is:
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            - The library exports the core function `create` which creates a MathJS instance and returns `MathJsInstance`.
         | 
| 10 | 
            +
            - Mathjs has a special function `chain`, which allows you to use the functions in a chained way, like `chain(2).add(3).done()`. The function `chain` returns an interface `MathJsChain`, which contains all mathjs functions and constants as a method. Unlike the static functions, these methods are defined with the chain instance `this` as first argument.
         | 
| 11 | 
            +
            - The library exports collections with factory functions of all functions and their dependencies. To create an instance of the function `add`, one can do `create(addDependencies)` for example. To import all functions, one can do `create(all)`.
         | 
| 12 | 
            +
            - The library also returns a static instance, which can directly be used like `import { add } from 'mathjs'`.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            ## Defining the types of a new function
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            Maintaining the TypeScript types is done manually. When adding a function, one has to create the following TypeScript definitions:
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            1. Add a normal definition inside `interface MathJsInstance {...}`
         | 
| 19 | 
            +
            2. Add a chained definition inside `interface MathJsChain {...}`
         | 
| 20 | 
            +
            3. Add a static definition inside `export const {...} : MathJsInstance`
         | 
| 21 | 
            +
            4. Add a dependencies definition inside `export const {...} : Record<string, FactoryFunctionMap>`
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            For exampe for the function `add`, we can have the following definitions:
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            ```ts 
         | 
| 26 | 
            +
            // instance
         | 
| 27 | 
            +
            export interface MathJsInstance extends MathJsFactory {
         | 
| 28 | 
            +
              //...
         | 
| 29 | 
            +
              add<T extends MathType>(x: T, y: T): T
         | 
| 30 | 
            +
              //...
         | 
| 31 | 
            +
            }
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            // chain
         | 
| 34 | 
            +
            export interface MathJsChain<TValue> {
         | 
| 35 | 
            +
              //...  
         | 
| 36 | 
            +
              add<T extends MathType>(this: MathJsChain<T>, y: T): MathJsChain<T>
         | 
| 37 | 
            +
              //...
         | 
| 38 | 
            +
            }
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            // static
         | 
| 41 | 
            +
            export const {
         | 
| 42 | 
            +
              // ...
         | 
| 43 | 
            +
              add,
         | 
| 44 | 
            +
              // ...
         | 
| 45 | 
            +
            } : MathJsInstance
         | 
| 46 | 
            +
             | 
| 47 | 
            +
             | 
| 48 | 
            +
            // dependencies
         | 
| 49 | 
            +
            export const {
         | 
| 50 | 
            +
              // ...
         | 
| 51 | 
            +
              addDependencies,
         | 
| 52 | 
            +
              // ...
         | 
| 53 | 
            +
            } : Record<string, FactoryFunctionMap>
         | 
| 54 | 
            +
            ```
         |