HISTORY.md
Ah (#3617). Thanks @adrfantini.num and den functions returning the parts of
a fraction (#3605). Thanks @AnslemHack.compareNatural (#3632). Thanks @Dheemanth07.setDistinct sorts the elements (see #3602).isFinite and isBounded (#3554, #3553).
Thanks @gwhitney.bernoulli to calculate Bernoulli numbers (#3551).
Thanks @gwhitney.object?.key (#3547).
Thanks @NilsDietrich.?.., allow optional function calls, throw errors on invalid uses
of ?. (#3585). Thanks @AnslemHack.isInteger (#3575).
Thanks @gwhitney.!!! BE CAREFUL: BREAKING CHANGES !!!
%), and raise the former (#3432).
Thanks @kiprobinsonknack.% as unary only when not followed by a term (#3505).
Thanks @gwhitney.size to always return an Array (#3535).SparseMatrix (#3536).v14.8.2 under v14.9.0.map with multiple arguments (#3526).
Thanks @dvd101x.map when passing a unary
function (#3546). Thanks @dvd101x.abs(complex) which returns a number
(#3543). Thanks @joshkel.ctranspose (#3545). Thanks @joshkel.config printing a warning when using { number: 'bigint' }
(#3540).?? in the
expression parser (#3497). Thanks @ikemHood.DenseMatrix symbol iterator (#3521). Thanks @dvd101x.Parser, fixing #3509 (#3525).printTransformDependencies not exported in the type definitions.diff (#3520). Thanks @dodokw.range.core-js (#3524).toBest(unit, unitList, offset), and corresponding
method unit.toBest(...) (#3484). Thanks @Mundi93, @EliaAlesiani, and
@HeavyRainLQ.sign of zero not returning zero in case of a fraction (#3513).
Thanks @kyle-compute. as white space
(#3487). Thanks donmccurdy.scope (#3490). Thanks @JayChang4w.unit(number) (#3495). Thanks @mrft.unit.to(unit) (#3495).
Thanks @mrft.add and multiply to not allow zero
or one argument (#3495). Thanks @mrft.coulomb,
see #3472.ResultSet interface and improve isResultSet typing
(#3481). Thanks @ranidam.BigInt when loading in
specific environments.numeric (see #3448).coulomb to coulombConstant. The old
name is still available for backward compatibility.map and forEach methods of
DenseMatrix (#3446). Thanks @dvd101x.subset (#3467). Thanks @dvd101x.compile, evaluate, parse, and parser,
and add tests for the examples in embedded docs (#3413). Thanks @dvd101x.(lbf in) (#3476). Thanks @costerwi.flatten (#3400). Thanks @dvd101x.map and forEach (#3409).
Thanks @dvd101x.nthRoots latex function template string (#3427).
Thanks @aitee.@babel/runtime.flatten (#3354). Thanks @dvd101x.DenseMatrix Symbol.iterator (#3395).
Thanks @dvd101x.map and forEach (#3399).
Thanks @dvd101x.multiply (#3408). Thanks @orelbn.math.isNaN for consistent max and min results
(#3389). Thanks @orelbn.@lambdatest/node-tunnel.apply to mapSlices (#3357). Function
apply is still available but is now marked deprecated. Thanks @gwhitney.bigint support in functions log, log2, log10,
larger, smaller, max, min (#3345). Thanks @gwhitney.bigint (#3348).randomInt() not working (#3345).sign in the embedded docs (#3338).
Thanks @witer33.Fraction type from the fraction.js library instead of
using a custom interface (#3330). Thanks @fchu.!!! BE CAREFUL: BREAKING CHANGES !!!
fraction.js@5, using bigint under the hood (#3283).Unit in functions ceil, floor, and fix.
Possible breaking changes in the type definitions of arrays and matrices
due to the introduction of generics (#3269). Thanks @orelbn.log(x: Fraction, base: Fraction).% (mod) being higher than * and / (#3311).
Thanks @nkumawat34.math.import(...) from overriding units unless you
specify { override: true } (#3225).dotDivide, dotPow, bitXor, xor, equal,
larger, largerEq, smaller, smallerEq, and unequal return a sparse
matrix when the input is two sparse matrices (#3307). Thanks @Aakash-Rana.map, filter, and forEach.clone.in is incorrect
(#3315). Thanks @nkumawat34.complex.js.Index.dimension(dim) accepting non-numeric input.Parser.set (#3308).
Thanks @nkumawat34.map, filter and forEach (#3256).
Thanks @dvd101x.map() and forEach()
of DenseMatrix (#3251). Thanks @Galm007.derivative.ConstantNode to support all data
types (#3257). Thanks @smith120bh.symbolicEqual missing in the TypeScript definitions.leafCount missing in the TypeScript definitions.in.map and forEach in the expression parser
(#3272). Thanks @dvd101x.import, createUnit and reviver, allowing to get access to the internal
math namespace and allowing arbitrary code execution. Thanks @StarlightPWN.rawArgs function with a
non-rawArgs function, it was still called with raw arguments. This was both
a functional issue and a security issue. Thanks @StarlightPWN.ObjectWrappingMap cannot delete
unsafe properties. Thanks @StarlightPWN.map (#3228, #3196).
Thanks @dvd101x.isMap, isPartitionedMap, and
isObjectWrappingMap.map not always working with matrices (#3242).
Thanks @dvd101x.ResultSet in the docs about classes.evaluate (see #3238).scope and fix the example
custom_scope_objects.js (#3150)format to support notations
hex, bin, and oct.quantileSeq (#3223).
Thanks @domdomegg.catch blocks without parameters.Parser methods (#3226).
Thanks @orelbn.Breaking changes:
isZero, isPositive, and isNegative to respect config.epsilon
(#3139, #2838). Thanks @dvd101x.nearlyEqual to align with Python and
Julia (#3152, #2838). Thanks @dvd101x.[email protected],
see https://github.com/rawify/Fraction.js/issues/68.bigint, or are not actively maintained. ES2020 is now the minimum required
EcmaScript version.Non-breaking changes:
bigint (#3207, #3207)config.numberFallback needed for bigint
(#3207).%. See #3189.quantileSeq type definitions (#3198). Thanks @domdomegg.isNaN returns false for NaN units in a matrix or
array (#3193). Thanks @lgerin.add and multiply to allow
more than two arguments.traverse returning void (#3177).
Thanks @rohildshah."true and true".toTex wrongly returning Infinity for large BigNumbers.math.Unit.deleteUnit.pretty_printing_with_mathjax.html (#3167). Thanks @SukkaW.multiply a lot by adding matrix type
inferencing (#3149). Thanks @RandomGamingDev.round not handling round-off errors (#3136).
Thanks @BrianFugate.PartitionedMap and ObjectWrappingMap missing a property
Symbol.iterator, causing problems when trying new Map(scope) (#3156).mode (#3153). Thanks @rich-martinez.getAllAsMap in the Parser docs (#3158, #3157).
Thanks @dvd101x.and and or inside a function definition.
Regression since v12.1.0 (#3150).ArrayNode, FunctionNode,
IndexNode, OperatorNode, and RelationalNode (#3123). Thanks @sylee957./* #__PURE__ */
annotations.format:
precision, wordSize, lowerExp, upperExp. Support BigNumber values
for the option wordSize in the functions hex, bin, and oct.hypot (#3144).
Thanks @silentmissile.help(config) altering the actual config when evaluating the
examples.ronna (R), quetta (Q),
ronto (r), and quecto (q) (#3113, #3112). Thanks @AlexEdgcomb.toSI() wrongly converting degC (#3118). Thanks @costerwi.Node.toHTML not accepting a custom handler.and, or, &, | (#3090, #3101,
#2766). Thanks @smith120bh.round with support for units (#2761, #3095).mod with support for negative divisors in when
using BigNumber or Fraction (#3087).derivative mutates the input expression when it fails.Breaking changes:
Fix #2879, #2927, #3014: change the confusing interface of eigs (#3037),
thanks @gwhitney.
Before, functions eigs returned an object:
{ values: MathCollection; vectors: MathCollection }
where vectors was a 2d matrix of which the columns contained the vectors.
This is changed to eigs returning an object:
{
values: MathCollection
eigenvectors: Array<{
value: number | BigNumber
vector: MathCollection
}>
}
Where eigenvectors is an array containing an object with the corresponding
eigenvalue and vector.
Refactored the TypeScript type definitions to make them work with a NodeNext
module resolution (#3079, #2919).
MathJsStatic is renamed to MathJsInstance.FactoryDependencies is deprecated, use MathJsFactory instead, and
import dependency maps directly from the library.Change the assignment operator of .toTex() output from := to = (see
#2980, #2987).
Drop official support for Node.js 14 and 16.
Features:
eigs now has an option to turn off calculation of eigenvectors
(#3057, #2180). Thanks @gwhitney.Fixes:
subtractScalar (#3081, #2643), thanks @vrushaket.clone not throwing an error when passing an unsupported
type like a function.symbolicEqual (#3035),
thanks @juancodeaudio.corr (#3030). Thanks @vrushaket.max in derivative.to or mod as property name.print in the parser (#3009).
Thanks @dvd101x.mod sometimes giving wrong results due to internal round-off
errors (#3011). Thanks @praisennamonu1.quantileSeq, and fixed the embedded help (#3003).
Thanks @dvd101x.corr to calculate the correlation between two matrices
(#3015, #2624). Thanks @vrushaket.fraction.js at version 4.3.4 for now, see #3024, 3022,
https://github.com/rawify/Fraction.js/issues/68.[email protected], see #3022.lruQueue using the global hasOwnProperty which may be
polluted.erg, and restrict prefixes of the
unit joule to only long prefixes like kilo and no short prefixes
like k (#3019). Thanks @costerwi.examples/browser/lorenz.html that uses solveODE
and plots the result in a chart (#3018). Thanks @dvd101x.quantileSeq with support for a dimension (#3002).
Thanks @dvd101x.a[[true, false, true]] and a[a > 2] (#2994). Thanks @dvd101x.zeta (#2950, #2975, #2904). Thanks @Bobingstern.DenseMatrix can mutate input arrays (#2991).FunctionNode and SymbolNode allowing
arbitrary code execution via math.evaluate. Thanks Harry Chen.new Function(...) (CSP issue).solveODE (#2958). Thanks @dvd101x.zpk2tf and freqz (#2988, #2969). Thanks @alykhaled.range (#2997). Thanks @dvd101x.simplify puts plus and minus signs next to each other (#2981).
Thanks @MaybePixem.range, reducing the amount of code (#2995).
Thanks @dvd101x.min, max, mean,
median, mode, std, sum, prod, variance. Fixes a regression
introduced in v11.8.1.Unit.divide(Unit) have a wrong return type.distance when calculate the distance from
a point to a line (#2965). Thanks @Kiku-CN.math.format not working correctly for engineering notation when using
BigNumbers and for fixed notation with precision: 0 configured (#2956).
Thanks @mgreminger.cbrt.min and max (#2955). Thanks @Maxim-Mazurok.fraction, bignumber, and number with support for
units, see #2918 (#2926).amp and amps for unit ampere (#2917).
Thanks @veggiesaurus.gcd (#2922). Thanks @brunoSnoww.distance (#2924). Thanks @tmtron.gcd (#2878).
Thanks @jakubriegel.partitionSelect, diff, expm1, round, nthRoots, sign,
rigthArithShift, setIsSubset, setSize, and the docs about units.
Thanks @tmtron.add, dotDivide, dotMultiply, dotPow, gcd, lcm, mod,
nthRoot, subtract, bitAnd, bitOr, bitXor, leftShift,
rightArithShift, rightLogShift, and, or, xor, compare,
compareText, equal, larger, largerEq, smaller, smallerEq,
unequal, atan2 and to (#2895, #2753). Thanks @dvd101x.unit to allow creating a
unit from a fraction or complex number.sort.column and row sometimes returning a scalar number.intersect as optional
in the TypeScript definitions. Thanks @wodndb.prob (see #2902).to, distance, getMatrixDataType,
subset, and max (see #2902).rotationMatrix (#2860).
Thanks @brunoSnoww.lusolve(LUDecomposition, ...) (#2864).
Thanks @evanmiller.pow and some other
functions.complex for one numeric input (#2886),
thanks @ariymarkowitz.map() and forEach() (#2887), thanks @xiaohk.dotMultiply, dotPow and
dotDivide (#2890). Thanks @brunoSnoww.simplify rule matches in non-commutative contexts (#2841).
Thanks @samueltlg.reshape mutating the input in case of a matrix (see #2854).multiply() with number[] and number[][]
(#2852). Thanks @hfhchan.simplify, making it easier
for example to describe unary minus (#1915). Thanks @thatcomputerguy0101.schur, sylvester, and lyap (#2646).
Thanks @egidioln.polynomialRoot, and use it in a benchmark (#2839).
Thanks @gwhitney.Node.traverse and
Node.forEach, they do return void.SparseMatrix from a
DenseMatrix (#2836). Thanks @AlexandreAlvesDB.FunctionNode, introduced
in v11.3.2. See #2733. Thanks @dsteve.kelvin, rankine,
celsius, and fahrenheit (#2824). Thanks @jfeistdecimal.js to version 10.4.2.Node in TypeScript (#2772).
Note that this disables being able to narrow MathNodes by using the .type
property. Use typeguards like isOperatorNode(...) instead (see #2810).
Thanks @mattvague.flatten() cloning entries of array/Matrix (#2799).pinv missing (#2804).
Thanks @HanchaiN.[email protected].isRelationalNode (#2731). Thanks @isaacbyr.'largerEq' and 'or' in OperatorNodeMap in the
TypeScript definitions. Thanks @ajinkyac03.pickRandom. Thanks @mattvague.min which means minutes, not minim (#2773).
Thanks @jasonhornsby.examples/advanced/custom_loading.js was broken.replacer function missing in the TypeScript definitions.
Thanks @mattvague.[email protected] and [email protected].simplifyConstant and simplifyCore
not having a return type defined.!!! BE CAREFUL: BREAKING CHANGES !!!
Breaking changes:
typed-function@3, see josdejong/typed-function/HISTORY.md. Thanks @gwhitney. Most importantly:
any.this variable is no longer bound to the typed function itself.typed.types, typed.conversions, and typed.ignore
have been removed.typed.referTo,
typed.referToSelf, typed.addTypes, typed.addConversions.-, +, ~),
and (b) the denominator is a constant. For example: formerly -1 / 2 x was
interpreted as -1 / (2 * x) and now it is interpreted as (-1 / 2) * x.
Thanks @gwhitney.math.map(matrix, fn).
Thanks @gwhitney.add(2, x) will now be simplified into 2 + x (#2415, #2466).
Thanks @gwhitney.number to string (#2482).
Thanks @gwhitney.diff return an empty matrix when the input contains
only one element (#2422).simplifyCore logic (#2490, #2484, #2459).
The function simplifyCore will no longer (partially) merge constants, that
behavior has been moved to simplifyConstant. The combination of
simplifyConstant and simplifyCore is still close to the old behavior
of simplifyCore, but there are some differences. To reproduce the same
behavior as the old simplifyCore, you can use
math.simplify(expr, [math.simplifyCore, math.simplifyConstant]).
Thanks to the refactoring, simplify is more thorough in reducing constants.
Thanks @gwhitney.math.chain(3).max(4, 2).done() will now throw
an error rather than return 4, because the rest parameter of
math.max(...number) has been split between the contents of the chain and
the arguments to the max call. Thanks @gwhitney.typeOf now returns function (lowercase) for a function instead
of Function (#2560). Thanks @gwhitney.Non-breaking changes:
simplify.
Thanks @laureen-m and @mattvague.createUnit. Thanks @egziko.epsilon
when using BigNumbers.get and set in the docs.math.rationalize in the docs (#2616). Thanks @nukisman.count (#2622). Thanks @Hansuku.multiply (#2623). Thanks @Windrill.factory function, thanks @mattvague.factory applied in v10.6.2,
they give some complications.ParenthesisNode. Thanks @mattvague.MathNodeCommon['type'] into a less
strict string, so it is possible to extend with new Node classes.
Thanks @mattvague.factory function, thanks @mattvague.OperatorNode: you can now define generic
types like OperatorNode<'+', 'add'>. Thanks @mattvague.fft and ifft (#2540).
Thanks @HanchaiN.clone and cloneDeep
(#2572). Thanks @mattvague.derivative holding the expression not correctly
being converted when using .toTex() (#2564). Thanks @mattvague.@types/mocha defined in dependencies instead of
devDependencies, causing problems in projects that use a different version
of this dependency. Thanks @Kolahzary.examples/node_modules folder from the npm package.SymbolNode.onUndefinedSymbol and
FunctionNode.onUndefinedFunction.round, fix,
floor, ceil, and nthRoot, and improved the number only implementations
of those functions (#2531, #2539). Thanks @simlaticak and @gwhitney.end not working when used inside
a sub-expression.resolve (#2536). Thanks @mattvague.pinv, Moore–Penrose inverse (#2521).
Thanks @HanchaiN.det for integers by switching to the Bareiss algorithm:
no more round-off errors for integer input (#2516). Thanks @HanchaiN.lgamma function (defined as log(gamma(z))) for number and
Complex types. Supersedes #320. (#2417). Thanks @yifanwww.sin(z) for small
im(z) (#2525). Thanks @gwhitney.ceil (#2531). Thanks @simlaticakbase in the number implementation
of function log (#2515). Thanks @gwhitney.; (#2512). Thanks @gwhitney.log() for complex numbers in which the imaginary
part is much larger in absolute value than the real part, fixed in
[email protected] (#2505), thanks @gwhitney, @infusion.forEach example in embedded docs (#2507). Thanks @dvd101x.unit (#2479).
Thanks @SinanAkkoyun.std and variance
(make dimension parameter optional, #2474). Thanks @NattapongSiri.isMatrix etc: Provide TypeScript definitions of "is" functions and
make them type guards. (#2432). Thanks @ChristopherChudzicki.simplifyCore recurses over all binary nodes (#2462).
Thanks @gwhitney.std and variance
(#2455). Thanks @NattapongSiri.cumsum function generating cumulative sums of a list
of values or a matrix. (#1870). Thanks @hjonasson.Fraction.js, having more strict input,
only accepting an integer numerator and denominator. See #2427.format. (#2468) Thanks @abranhe.symbolicEqual (#2424). Thanks @gwhitney.complexEigs in which real-valued norms were
inadvertently being typed as complex numbers (#2445). Thanks @gwhitney.map (#2457).
Thanks @gwhitney.simplify,
see #2399, #2391. Thanks @gwhitney.leafCount as a first simple measure of the complexity
of an expression, see #2411, #2389. Thanks @gwhitney.combinations to return an integer result without rounding
errors for larger values, see #2414. Thanks @gwhitney.rotate missing in TypeScript definitions.
Thanks @DIVYA-19.math.unit and add TypeScript
types for Unit.simplify and Unit.units (#2353). Thanks @joshhansen.simplify (#2405). Thanks @gwhitney.simplify, thanks @gwhitney:
simplify('2-(x+1)').consoleDebug to simplify to see what is going on.ConfigOptions, which was missing option
predictable.invmod, see #2368, #1744. Thanks @thetazero.simplify, thanks @gwhitney:
print.forEach.-1 / (-x) to 1/x. Thanks @ony3000.intersect.
Thanks @thetazero.SparseMatrix when replacing a subset of a matrix with
a non-consecutive index. Thanks @Al-0.gamma giving inaccurate complex results in some cases.
Thanks @kmdrGroch.!!! BE CAREFUL: BREAKING CHANGES IN THE TYPESCRIPT DEFINITIONS !!!
Improvements to the Typescript typings (commit fc5c202e). Thanks @joshhansen. First introduced in v9.5.1, but reverted because it contains breaking changes.
Breaking changes: interface MathNode is now renamed to MathNodeCommon
and the related interfaces are structured in a different way.
Fixed a typo in the TypeScript definition of toHTML. Thanks @TheToto.
Parser.evaluate consistent with math.evaluate:
support a list with expressions as input.setCartesian. Thanks @fieldfoxWim.Node.equals by improving the internal
function deepStrictEqual. Thanks @tomlarkworthy.hasNumericValue. Thanks @write2kcl.MathNode.isRelationalNode. Thanks @m93a.MathNode.isConditionalNode. Thanks @m93a.ArrayNode.toTex(): remove the row delimiter on the last row,
see #2267. Thanks @davidtranhq.intersect not returning null for matrix input. Thanks @m93a.Symbol. The browser bundle now includes the necessary polyfills (it is
larger now because of that, see also #2266). Thanks @m93a.[email protected], [email protected])Decimal prototype. Thanks @m93a.e.floor, #2159, #2246. Thanks @write2kcl.simplify, see #2252. Thanks @nitroin.[email protected]eigs, making it much more
robust. See #2179, #2237. Thanks @m93a.parse. Thanks @OpportunityLiu.eigs. Thanks @andrebianchessi.[email protected]Map interface as scope,
see #2143, #2166. Thanks @jhugman.eigs to support general complex matrices, see #1741. Thanks @m93a.matrixFromRows, matrixFromColumns, and
matrixFromFunction, see #2155, #2153. Thanks @m93a.@types/mathjs, and making it easier to improve the definitions. See #2187,
#2192. Thanks @CatsMiaow.[email protected] (fixing #2211). Thanks @infusion[email protected] (pow now supporting rational exponents).pickRandom having no name. Thanks @HK-SHAO.row and column.@babel/runtime dependency.
Regression introduced in v9.3.1.isPrime, see #2139.
Thanks @Yaffle.FunctionNode.onUndefinedFunction(name)
and SymbolNode.onUndefinedSymbol(name), allowing to override the behavior.
By default, an Error is thrown.luSolveAll and usolveAll.count to count the total elements in a matrix,
see #2085. Thanks @Josef37.crypto.reshape with support for a wildcard -1 to automatically
calculate the remaining size, like reshape([1, 2, 3, 4, 5, 6], [-1, 2])
which will output [[0, 1], [2, 3], [4, 5]]. See #2075. Thanks @Josef37.simplify ignores second argument of log, for example
in simplify('log(e, 9)') . Thanks @quentintruong.0b, 0c, and 0x arei16 or i32.format now supports more notations: bin, 'hex', and oct,
for example format(255, {notation: "hex"}).format, bin, hex, oct now allow specifying a wordSize,
like bin(10, 32) and format(10, {notation: "bin", wordSize: 32}).fraction.js to v4.0.13.kilogramforce (kgf). Thanks @rnd-debug.fractionsLimit for function simplify,
defaulting to Infinity.clone. Thanks @redbar0n.!!! BE CAREFUL: BREAKING CHANGES !!!
/lib: the browser bundle is moved from
/dist to /lib/browser, ES module files are moved to /lib/esm,
and commonjs files are moved to /lib/cjs. Thanks @GreenImp.dist/math.js is no longer provided. Either use the
minified bundle, or create a bundle yourself.seed-random with seedrandom, see #1955.
Thanks @poppinlp.pickRandom, see #1990, #1976.
Will no longer return the input matrix when the given number is greater than the length of the provided possibles. Instead, the function always returns results with the requested number of picks.
Will now return a Matrix as output when input was a Matrix.
Introduced a new syntax:
math.pickRandom(array, { weights, number, elementWise })
Introduced a new option elementWise, which is true by default.
When setting elementWise to false, an array containing arrays will return
random pick of arrays instead of the elements inside of the nested arrays.
rotate(w, theta). See #1992, #1160. Thanks @rnd-debug.Unit.isValidAlpha.
See #1663, #2000. Thanks @rnd-debug.math.config. Thanks Snyk.pickRandom now allows randomly picking elements from matrices
with 2 or more dimensions instead of only from a vector, see #1974.
Thanks @KonradLinkowski.ceil, floor,
and fix, similar to round, see #1967, #1901. Thanks @rnd-debug.rotationMatrix, see #1160, #1984. Thanks @rnd-debug.sqrtm with a matrix having
more than two dimensions. Thanks @KonradLinkowski.decimal.js to 10.2.1.usolveAll and lsolveAll, see #1916. Thanks @m93a.std and variance, see #1950.
Thanks @rnd-debug.bin, oct, and hex for
formatting. Thanks @clnhlzmn.BigNumber and Fraction. Thanks @ovk.diff, see #1634, #1920. Thanks @Veeloxfire.norm.
Thanks @rnd-debug.[email protected]. This fixes #1885: functions which where
extended with a new data type did not always work. Thanks @nickewing.math.expression.node.* instead of math.*.DenseMatrix.resize and SparseMatrix.resize accept
DenseMatrix and SparseMatrix as inputs too, not only Array.sum, prod, min, and max not throwing a conversion error
when passing a single string, like sum("abc").eigs. Thanks @Lazersmoke.math.nthRoots(x).Breaking changes:
dot product of complex values.
The first argument is now conjugated. See #1761. Thanks @m93a.Infinity cannot be serialized and deserialized.
This is solved now with a new math.replacer function used as
JSON.stringify(value, math.replacer).Infinity not turned into the latex symbol \\infty.format,
sometimes resulting in needless trailing zeros..toNumber() and .toNumeric() not working on a
unitless unit.mod, and, not, or,
xor, to, in as object keys. Thanks @Veeloxfire.eigs not using config.epsilon.eigs not calculating with BigNumber precision
when input contains BigNumbers.prepare, so you can use the library
directly when installing directly from git. See #1751. Thanks @cinderblock.a/(b/c). Thanks @dbramwell.row and column.eigs, see #1705, #542 #1175. Thanks @arkajitmandal.DenseMatrix using
fromJSON.DenseMatrix.map copying the size and datatype from the original
matrix instead of checking the returned dimensions and type of the callback.^1.2.3) to allow downstream updates
without having to await a new release of mathjs.baseName option for createUnit, see #1707.
Thanks @ericman314.dimension with support for n-dimensional points.
Thanks @Veeloxfire.factorial for BigNumber up to a factor two,
see #1687. Thanks @kmdrGroch.IndexNode using a hardcoded, one-based implementation of index,
making it impossible to instantiate a zero-based version of the expression
parser. See #782.sign(0) returns complex NaN.
Thanks @harrysarson.mean not working for units. Thanks @clintonc.min listed twice in the "See also" section of the
embedded docs of function std.isPrime, see #1641. Thanks @arguiot.map and clone not copying the dotNotation property of
IndexNode. Thanks @rianmcguire.toHTML. Thanks @maytanthegeek.isNumeric.0.format not working for expressions.combinationsWithRep. Thanks @waseemyusuf.bit and byte.bit and byte instead of bits and bytes.[email protected].combinationsWithRep (see #1329). Thanks @waseemyusuf.unpkg and jsdelivr fields in package.json pointing to UMD build.
Thanks @tmcw.import
(regression since v6.0.0).evaluate and parse missing in generated docs.!!! BE CAREFUL: BREAKING CHANGES !!!
Full support for ES modules. Support for tree-shaking out of the box.
Load all functions:
import * as math from 'mathjs'
Use a few functions:
import { add, multiply } from 'mathjs'
Load all functions with custom configuration:
import { create, all } from 'mathjs'
const config = { number: 'BigNumber' }
const math = create(all, config)
Load a few functions with custom configuration:
import { create, addDependencies, multiplyDependencies } from 'mathjs'
const config = { number: 'BigNumber' }
const { add, multiply } = create({
addDependencies,
multiplyDependencies
}, config)
Support for lightweight, number-only implementations of all functions:
import { add, multiply } from 'mathjs/number'
New dependency injection solution used under the hood.
Node 6 is no longer supported.
Functions config and import are not available anymore in the global
context:
// v5
import * as mathjs from 'mathjs'
mathjs.config(...) // error in v6.0.0
mathjs.import(...) // error in v6.0.0
Instead, create your own mathjs instance and pass config and imports there:
// v6
import { create, all } from 'mathjs'
const config = { number: 'BigNumber' }
const mathjs = create(all, config)
mathjs.import(...)
Renamed function typeof to typeOf, var to variance,
and eval to evaluate. (the old function names are reserved keywords
which can not be used as a variable name).
Deprecated the Matrix.storage function. Use math.matrix instead to create
a matrix.
Deprecated function math.expression.parse, use math.parse instead.
Was used before for example to customize supported characters by replacing
math.parse.isAlpha.
Moved all classes like math.type.Unit and math.expression.Parser to
math.Unit and math.Parser respectively.
Fixed #1428: transform iterating over replaced nodes. New behavior is that it stops iterating when a node is replaced.
Dropped support for renaming factory functions when importing them.
Dropped fake BigNumber support of function erf.
Removed all index.js files used to load specific functions instead of all, like:
// v5
// ... set up empty instance of mathjs, then load a set of functions:
math.import(require('mathjs/lib/function/arithmetic'))
Individual functions are now loaded simply like:
// v6
import { add, multiply } from 'mathjs'
To set a specific configuration on the functions:
// v6
import { create, addDependencies, multiplyDependencies } from 'mathjs'
const config = { number: 'BigNumber' }
const math = create({ addDependencies, multiplyDependencies }, config)
See example advanced/custom_loading.js.
Updated the values of all physical units to their latest official values. See #1529. Thanks @ericman314.
t, tonne, bel, decibel, dB, and prefixes
for candela. Thanks @mcvladthegoat.epsilon setting being applied globally to Complex numbers.math.simplify('add(2, 3)') throwing an error.lowerExp and upperExp
and after that rounded the value instead of the other way around.'use strict' in every file, not needed anymore.del being a dependency instead of devDependency.typeOf.js and typeof.js.
Solved by properly cleaning all build folders before building.engineering can give wrong results
when the value has less significant digits than the number of digits in
the output.lib/header.js not having filled in date and version. Thanks @kevjin.[email protected], fixing an issue on node.js 12.row and column (see #1413). Thanks @SzechuanSage.engineering notation of function format not available
for BigNumber.node.toHTML() not correct for unary operators like
factorial.apply. Thanks @bnlcas.dimension argument to std and var.
Thanks @bnlcas.pow() in derivative. Thanks @sam-19.map and forEach of SparseMatrix not working
correctly when indexes are unordered.math.format not working for BigNumbers with a precision above
1025 digits (see #1385). Thanks @ericman314.RelationalNode. Thanks @rianmcguire.map, forEach, traverse, and transform
of FunctionNode.Unit.format and Unit.toString,
making changes to the unit on execution. Thanks @ericman314.mm instead
of m. Thanks @ericman314.hasNumericValue. Thanks @Sathish-kumar-Subramani.math.format not working correctly with { precision: 0 }.
Thanks @dkenul.escape-latex giving issues in some
specific cases. Thanks @dangmai.bitNot, see #1299. Thanks @FSMaxB.pow not supporting inputs pow(Unit, BigNumber).[email protected])rod being defined as 5.02921 instead of 5.0292.
Thanks @ericman314.[email protected])@babel/[email protected], [email protected],
[email protected]).10 < x <= 50.
Thanks @ericman314.BigInt in mathjs.parse. Thanks @mathiasvr.subset.quantileSeq has inconsistent return.[email protected])babel@7, [email protected],
[email protected], [email protected], [email protected], [email protected])isNumeric now recognizes more types.sqrt, max, min, var, std, mode, mad,
median, and partitionSelect not neatly handling NaN inputs. In some
cases (median, mad, and partitionSelect) this resulted in an infinite
loop.[email protected])[email protected])getMatrixDataType. Thanks @JasonShin.options argument in simplify. Thanks @paulobuchsbaum.rationalize, see #1173. Thanks @paulobuchsbaum.factorial for numbers.
This improves performance of functions gamma, permutation, and
combination too. See #1170. Thanks @honeybar.reshape, thanks to a
friend of @honeybar.add and subtract) not working
with matrices having a datatype defined.format with engineering notation in outputting
the correct number of significant figures. Thanks @ericman314.parse into a functional approach.
Thanks @harrysarson.decimal.js import to ES6. Thanks @weinshel.simplify unnecessarily replacing implicit multiplication with
explicit multiplication.rationalize throwing exceptions for some input with decimals.
Thanks @maruta.rawArgs functions.add_new_datatypes.[email protected], [email protected]).[email protected], [email protected],
[email protected], [email protected]).kerma, uglify-js, webpack).!!! BE CAREFUL: BREAKING CHANGES !!!
math.ctranspose. See #1097.
Thanks @jackschmidt.A' (transpose) in the expression parser to
calculate the complex conjugate transpose. See #1097. Thanks @jackschmidt.complex({abs: 1, arg: 1}), and improved the docs on
complex numbers. Thanks @ssaket.eye to identity, see #1054.lib
to src, and lib now contains the compiled ES5 code.decimal.js from 9.0.1 to 10.0.1npm test.
See #1110.Number, Boolean, and
String from functions clone and typeof.toTex on node that contains derivative causing
an exception. Thanks @joelhoover.det. Thanks @ericman314.compareNatural and clarified the behavior for strings.inv (since v4.4.1).
Thanks @ericman314.inv when dealing with values close to zero.
Thanks @ericman314.equalText and compareText. See #1085.math.expm. Thanks @ericman314.complex.js from v2.0.2 to v2.0.10.fraction.js from v4.0.4 to v4.0.8.mocha, uglify-js, webpack).[email protected].dist/math.js being minified.math.sqrtm. Thanks @ferrolho.math.log2, math.log1p, and math.expm1.
Thanks @BigFav and @harrysarson.decades, centuries,
and millennia.decade and watt having a wrong name when stringifying.
Thanks @ericman314.math.derivative('-x', 'x').math.print with support for arrays and matrices.
Thanks @jean-emmanuel.math.typeof with support for ResultSet and nodes
like SymbolNode.bar
(i.e. millibar and mbar).math.unit not accepting input like 1/s.!!! BE CAREFUL: BREAKING CHANGES !!!
Breaking changes (see also #682):
New expression compiler
The compiler of the expression parser is replaced with one that doesn't use
eval internally. See #1019. This means:
a slightly improved performance on most browsers.
less risk of security exploits.
the code of the new compiler is easier to understand, maintain, and debug.
Breaking change here: When using custom nodes in the expression parser,
the syntax of _compile has changed. This is an undocumented feature though.
Parsed expressions
The class ConstantNode is changed such that it just holds a value
instead of holding a stringified value and it's type.
ConstantNode(valueStr, valueType) is now ConstantNode(value)
Stringification uses math.format, which may result in differently
formatted numeric output.
The constants true, false, null, undefined, NaN, Infinity,
and uninitialized are now parsed as ConstantNodes instead of
SymbolNodes in the expression parser. See #833.
Implicit multiplication
Changed the behavior of implicit multiplication to have higher
precedence than explicit multiplication and division, except in
a number of specific cases. This gives a more natural behavior
for implicit multiplications. For example 24h / 6h now returns 4,
whilst 1/2 kg evaluates to 0.5 kg. Thanks @ericman314. See: #792.
Detailed documentation: https://github.com/josdejong/mathjs/blob/v4/docs/expressions/syntax.md#implicit-multiplication.
Immediately invoking a function returned by a function like partialAdd(2)(3)
is no longer supported, instead these expressions are evaluated as
an implicit multiplication partialAdd(2) * (3). See #1035.
String formatting
In function math.format, the options {exponential: {lower: number, upper: number}}
(where lower and upper are values) are replaced with {lowerExp: number, upperExp: number}
(where lowerExp and upperExp are exponents). See #676. For example:
math.format(2000, {exponential: {lower: 1e-2, upper: 1e2}})
is now:
math.format(2000, {lowerExp: -2, upperExp: 2})
In function math.format, the option notation: 'fixed' no longer rounds to
zero digits when no precision is specified: it leaves the digits as is.
See #676.
String comparison
Changed the behavior of relational functions (compare, equal,
equalScalar, larger, largerEq, smaller, smallerEq, unequal)
to compare strings by their numeric value they contain instead of
alphabetically. This also impacts functions deepEqual, sort, min,
max, median, and partitionSelect. Use compareNatural if you
need to sort an array with text. See #680.
Angle units
Changed rad, deg, and grad to have short prefixes,
and introduced radian, degree, and gradian and their plurals
having long prefixes. See #749.
Null
null is no longer implicitly casted to a number 0, so input like
math.add(2, null) is no longer supported. See #830, #353.
Dropped constant uninitialized, which was used to initialize
leave new entries undefined when resizing a matrix is removed.
Use undefined instead to indicate entries that are not explicitly
set. See #833.
New typed-function library
typed-function library used to check the input types
of functions is completely rewritten and doesn't use eval under
the hood anymore. This means a reduced security risk, and easier
to debug code. The API is the same, but error messages may differ
a bit. Performance is comparable but may differ in specific
use cases and browsers.Non breaking changes:
typed-function implementation,
mathjs doesn't use JavaScript's eval anymore under the hood.
This allows using mathjs in environments with security restrictions.
See #401.isUnary() and isBinary() on
OperatorNode. See #1025.derivative silently dropping additional arguments
from operator nodes with more than two arguments.[email protected] (bug-fix release).implicit not being copied from an OperatorNode
when applying function map. Thanks @HarrySarson.toTex(). Thanks @FSMaxB.simplifyCore failing in some cases with parentheses.
Thanks @firepick1.+ and * in
derivative. Thanks @HarrySarson. See #1002.simplify evalution of simplify of functions with more than two
arguments wrongly: simplify('f(x, y, z)') evaluated tof(f(x, y), z)instead off(x, y, z)`. Thanks @joelhoover.simplify throwing an error in some cases when simplifying unknown
functions, for example simplify('f(4)'). Thanks @joelhoover.simplify wrongly simplifing some expressions containing unary
minus, like 0 - -x. Thanks @joelhoover.xor. Thanks @denisx.distance and intersect with support for BigNumbers.
Thanks @ovk.simplify: added a rule that allows combining
of like terms in embedded quantities. Thanks @joelhoover.Implemented function rationalize. Thanks @paulobuchsbaum.
Upgraded dependencies:
decimal.js 7.2.3 → 9.0.1 (no breaking changes affecting mathjs)
fraction.js 4.0.2 → 4.0.4
tiny-emitter 2.0.0 → 2.0.2
Upgraded dev dependencies.
Fixed #975: a wrong example in the docs of lusolve.
Fixed #983: pickRandom returning an array instead of single value
when input was an array with just one value. Clarified docs.
Fixed #969: preven issues with yarn autoclean by renaming an interally used folder "docs" to "embeddedDocs".
simplify for nested exponentiations. Thanks @IvanVergiliev.typed-function allowing arbitrary code execution
in the JavaScript engine by creating a typed function with JavaScript code
in the name. Thanks Masato Kinugawa.add and multiply not working when
passing three or more arrays or matrices.simplify returning wrong results or
running into an infinite recursive loop. Thanks @ericman314.simplify reordering operations. Thanks @firepick1.isNaN returning wrong result for complex
numbers having just one of their parts (re/im) being NaN.FibonacciHeap.isEmpty returning wrong result.simplify not accepting the signature
simplify(expr, rules, scope) anymore. Thanks @firepick1.isComplex(x) instead of duck type checking
like x && x.isComplex === true.unit.toNumeric().
Thanks @AlexanderBeyn.toString of a parsed expression tree containing an
immediately invoked function assignment not being wrapped in
parenthesis (for example (f(x) = x^2)(4)).math.simplify.
Thanks @firepick1.math.simplify, optionally pass a scope with
variables which are resolved, see #907. Thanks @firepick1.$ in symbol names (see #895).map, forEach, and filter
when used in the expression parser:
map
and forEach.map and filter.[email protected][email protected], there is an issue with 4.0.1
in the browser.setCartesian, setDifference,
setDistinct, setIntersect, setIsSubset, setPowerset,
setSize. Thanks @Nekomajin42.toHTML on nodes. Thanks @Nekomajin42.compareNatural and sort([...], 'natural').[email protected][email protected][email protected][email protected]splitUnit can now deal with round-off errors.
Thanks @ericman314.erg. Thanks @pjhampton.intersection of line and plane.
Thanks @viclai.chain inside the expression parser for security
reasons (it's not needed there anyway).subset not returning non-primitive scalars
from Arrays correctly. (like math.eval('arr[1]', {arr: [math.bignumber(2)]}).mathjs 1+2. Thanks @slavaGanzin.derivative now supports abs. Thanks @tetslee.simplify now supports BigNumbers. Thanks @tetslee.simplify. Thanks @tetslee.simplify converting small numbers to inexact
Fractions. Thanks @tetslee.simplify now supports constants like e.
Thanks @tetslee.Infinity. Thanks @HarrySarson.math.qr. Thanks @HarrySarson.math.random() freezes IE and node.js.v3.10.2.xgcd for negative values. Thanks @litmit.reshape. Thanks @patgrasso and @ericman314.seedRandom for deterministic random
numbers. Thanks @morsecodist.math.round not accepting inputs NaN, Infinity, -Infinity.string to BigNumber,
Fraction, or Complex number.scope to functions having rawArgs = true.simplify and
derivative. Thanks @ericman314, @tetslee, and @BigFav.kron. Thanks @adamisntdead.FunctionNode not accepting a string as function name anymore.FunctionAssignmentNode.toString() returning a string
incompatible with the function assignment syntax.mad (median absolute deviation). Thanks @ruhleder.add and multiply now accept more than two arguments. See #739.OperatorNode now supports more than two arguments. See #739. Thanks @FSMaxB.Node.cloneDeep for the expression nodes. See #745.Node.clone() not cloning implicit multiplication correctly.
Thanks @FSMaxB.1 cm when close enough,
instead of returning 10 mm. Thanks @ericman314.\u2126.rad, deg, and grad can now have prefixes like millirad.Node.equals(other) for all nodes of the expression parser.arg().erf(). THanks @patgrasso.cross() to support n-d vectors. Thanks @patgrasso.pickRandom with the option to pick multiple values from
an array and give the values weights: pickRandom(possibles, number, weights).
Thanks @woylie.isAlpha which can be replaced in
order to adjust the allowed characters in variables names (See #715).-2 2 and 2^3 4 (right after the second value of an operator).2.).2.) not being supported by
the parser, solved the underlying ambiguity in the parser. See #707, #711.print not accepting an Object with formatting options as
third parameter Thanks @ThomasBrierley.2..dist/math.js, dist/math.min.js).createUnit. Thanks @ericman314.splitUnits. Thanks @ericman314.isPrime. Thanks @MathBunny.isNaN.math.filter now passes three arguments to the callback function:
value, index, and array.map, forEach, and filter now invoke callbacks
which are a typed-function with the correct number of arguments.Parser.getAll() to retrieve all defined variables.toTex templates, reckon with number of arguments.engineering notation of function
math.format.Math.sinh, Math.cbrt, Math.sign, etc when
available.weeks, months, and years where missing.Node.toString options where not passed to function arguments.math.sinh for values between -1 and 1.in (inch) not always working due to ambiguity with
the operator a in b (alias of a to b).(2)(3)+4.nthRoot of zero with a negative root returned 0 instead of
Infinity.min, max, mean, or median are invoked
with multiple matrices as arguments (see #598).toTex and toString
for implicit multiplications. Implemented and option to output the operator.kip and alias kips. Thanks @hgupta9.mol and mole. Thanks @stu-blair.2(3+4) and (2+3)(4+5).boolean and null to Fraction,
and conversions from Fraction to Complex.More restricted support for implicit multiplication in the expression
parser: (...)(...) is now evaluated as a function invocation,
and [...][...] as a matrix subset.
Matrix multiplication no longer squeezes scalar outputs to a scalar value, but leaves them as they are: a vector or matrix containing a single value. See #529.
Assignments in the expression parser now return the assigned value rather than the created or updated object (see #533). Example:
A = eye(3)
A[1,1] = 2 # this assignment now returns 2 instead of A
Expression parser now supports objects. This involves a refactoring and extension in expression nodes:
ObjectNode.AssignmentNode, UpdateNode, and IndexNode are refactored
into AccessorNode, AssignmentNode, and IndexNode having a different API.Upgraded the used BigNumber library decimal.js to v5. Replaced the
trigonometric functions of math.js with those provided in decimal.js v5.
This can give slightly different behavior qua round-off errors.
Replaced the internal Complex.js class with the complex.js library
created by @infusion.
Entries in a matrix (typically numbers, BigNumbers, Units, etc) are now considered immutable, they are no longer copied when performing operations on the entries, improving performance.
Implemented nearly equal comparison for relational functions (equal,
larger, smaller, etc.) when using BigNumbers.
Changed the casing of the configuration options matrix (Array or Matrix)
and number (number, BigNumber, Fraction) such that they now match
the type returned by math.typeof. Wrong casing gives a console warning but
will still work.
Changed the default config value for epsilon from 1e-14 to 1e-12,
see #561.
pow to return the real root for cubic roots of negative
numbers. See #525, #482, #567.math.format.math.fraction now supports BigNumber, and function
math.bignumber now supports Fraction.A[x=2] or a > 2 ? b="ok" : b="fail".acre, hectare, torr, bar, mmHg, mmH2O, cmH2O,
and added new aliases acres, hectares, sqfeet, sqyard, sqmile,
sqmiles, mmhg, mmh2o, cmh2o. Thanks @hgupta9.deg, rad, grad, cycle, arcsec, and arcmin not
being defined as BigNumbers when configuring to use BigNumbers.secs, mins, hr, hrs. See #551.Fractions and BigNumbers.math.intersect() returning null in some cases. Thanks @void42.VA and VAR.engineering in function math.format.
Thanks @johnmarinelli.Fraction and BigNumber in units.toNumeric for units.arcsec, arcsecond, arcmin, arcminute.
Thanks @devdevdata222.Herts (Hz). Thanks @SwamWithTurtles.number didn't support Fraction as input.format in some JavaScript engines.import as
property, as this gives issues with old JavaScript engines.nthRoot not working on Internet Explorer (up to IE11).nthRoot returning an error for negative values like
nthRoot(-2, 3).combinations did not throw an exception for
non-integer values of k.import did not override typed functions when the option
override was set true.math.sparse and math.index to the reference docs,
they where missing.gamma and factorial functions, this
could blow up memory.distance with more signatures. Thanks @kv-kunalvyas.sin and cos, which gave wrong results for
BigNumber integer values around multiples of tau (i.e. sin(bignumber(7))).stone. Thanks @Esvandiary for finding the error.distance. Thanks @devanp92.lcm. Thanks @infusion.cbrt for numbers, complex numbers, BigNumbers, Units.hypot.m^2 and s^-1) now output with the best prefix.abs, cube, sign, sqrt, square.
Thanks @ericman314.catalan (Combinatorics). Thanks @devanp92.canDefineProperty check to return false in case of IE8, which
has a broken implementation of defineProperty. Thanks @golmansax.to not working in case of a simplified unit.lup, also affecting lusolve.speedOfLight, molarMassC12,
and magneticFluxQuantum. Thanks @ericman314 for finding two of them.110 km/h in m/s). Thanks @ericman314.speedOfLight, gravity, etc.kldivergence (Kullback-Leibler divergence).
Thanks @saromanov.mode. Thanks @kv-kunalvyas.Unit.parse and Complex.parse now throw an Error
instead of returning null when passing invalid input.typed-function and are extensiblefraction.js.lup and lusolve). Thanks @rjbaucells.predictable, which can be set to
true in order to ensure predictable function output types.intersect. Thanks @kv-kunalvyas.toTex properties to custom functions.
Thanks @FSMaxB.nthRoot. Thanks @gangachris.isInteger, isNegative, isNumeric,
isPositive, and isZero.index does no longer accept an array [start, end, step], but
instead accepts an array with arbitrary index values. It also accepts
a Range object as input.typeof no longer returns lower case names, but now returns lower
case names for primitives (like number, boolean, string), and
upper-camel-case for non-primitives (like Array, Complex, Function).import no longer supports a module name as argument. Instead,
modules can be loaded using require: math.import(require('module-name')).import has a new option silent to ignore errors, and throws
errors on duplicates by default.Node.compile() no longer needs math to be passed as argument.Node.eval([scope]).sum now returns zero when input is an empty array. Thanks @FSMAxB.quantileSeq and partitionSelect. Thanks @BigFav.stirlingS2, bellNumbers, composition, and
multinomial. Thanks @devanp92.median (see #373). Thanks @BigFav.mode option to output either
the expressions result, string representation, or tex representation.
Thanks @FSMaxB.Node.transform not recursing over replaced parts of the
node tree (see #349).randomInt.toTex. Thanks @FSMaxB.abs(0 + 0i) evaluated to NaN.1 KiB == 1024 B, 1 kB == 1000 B).stone (6.35 kg).atan2. Thanks @BigFav.Node.toString and
Node.toTex functions. Thanks @FSMaxB.format sometimes returning exponential notation when
it should return a fixed notation.acosh, acoth, acsch, asech, asinh, atanh, acot, acsc, asec.
Thanks @BigFav.cot, csc, sec, coth,
csch, sech. Thanks @BigFav.norm() and abs() for large complex numbers.
Thanks @rjbaucells.sin,
cos, tan, asin, acos, atan, cosh, sinh, tanh. Thanks @BigFav.trace. Thanks @pcorey.pi and e.NaN and Infinity not being BigNumber objects when
BigNumbers are configured.toTex representation of function
permutations.bitAnd, bitNot, bitOr, bitXor,
leftShift, rightArithShift, and rightLogShift. Thanks @BigFav.and, not, or, xor. Thanks @BigFav.gamma function. Thanks @BigFav.inch in cm will return 2.54 cm instead of cm.sinh and complex cos and sin. Thanks @pavpanchekha.select to chain. The old function select will remain
functional until math.js v2.0.pow.dot (dot product), cross (cross product), and
nthRoot.clone, map, forEach, traverse,
transform, and filter for expression trees.index in the callbacks of map and forEach are now cloned
for every callback.params to args and vice versa to make things consistent.Block.nodes to Block.blocks.FunctionNode now has a name: string instead of a symbol: SymbolNode.RangeNode to
new RangeNode(start: Node, end: Node [, step: Node]).BlockNode must now be passed via the constructor instead
of via a function add.2e giving a syntax error instead of being parsed as 2 * e.filter(x, test).math.distribution for now, needs some rethinking.math.number can convert units to numbers (requires a second argument)sort(x [, compare]) and flatten(x).null in all functions.wrap of function math.import to false.math.uninitialized
as default value.__transform__ to transform, and documented
the transform feature.math.import not applying options when passing a module name.index consists of
scalar values, and no longer for ranges resolving into a single value.math([options]),
to prevent side effects from math being a function instead of an object.
Instead, use the function math.create([options]) to create a new instance.BigNumber support for all constants: pi, tau, e, phi,
E, LN2, LN10, LOG2E, LOG10E, PI, SQRT1_2, and SQRT2.BigNumber support for functions gcd, xgcd, and lcm.gxcd returning an Array when math.js was configured
as {matrix: 'matrix'}.ResultSet instead of an Array.concat, min, max,
and mean expect an one-based dimension number.map and forEach invoke the callback with one-based indices
when used from within the expression parser.concat not accepting a BigNumber for parameter dim.squeeze now squeezes both inner and outer singleton dimensions.FunctionNode to FunctionAssignmentNode, and renamed ParamsNode
to FunctionNode for more clarity.The library now immediately returns a default instance of mathjs, there is no need to instantiate math.js in a separate step unless one ones to set configuration options:
// instead of:
var mathjs = require('mathjs'), // load math.js
math = mathjs(); // create an instance
// just do:
var math = require('mathjs');
Implemented support for implicit multiplication, like math.eval('2a', {a:3})
and math.eval('(2+3)(1-3)'). This changes behavior of matrix indexes as
well: an expression like [...][...] is not evaluated as taking a subset of
the first matrix, but as an implicit multiplication of two matrices.
Removed utility function ifElse. This function is redundant now the
expression parser has a conditional operator a ? b : c.
Fixed a bug with multiplying a number with a temperature,
like math.eval('10 * celsius').
Fixed a bug with symbols having value undefined not being evaluated.
null.equal and unequal support null and undefined now.typeof now recognizes regular expressions as well.Complex, Unit, and Help now return their string representation
when calling .valueOf().null and undefined as
function arguments.Renamed some functions (everything now has a logical, camel case name):
edivide, emultiply, and epow to dotDivide,
dotMultiply, and dotPow respectively.smallereq and largereq to smallerEq and largerEq.unary to unaryMinus and added support for strings.end is now a reserved keyword which cannot be used as function or symbol
name in the expression parser, and is not allowed in the scope against which
an expression is evaluated.
Implemented function unaryPlus and unary plus operator.
Implemented function deepEqual for matrix comparisons.
Added constant phi, the golden ratio (phi = 1.618...).
Added constant version, returning the version number of math.js as string.
Added unit drop (gtt).
Fixed not being able to load math.js using AMD/require.js.
Changed signature of math.parse(expr, nodes) to math.parse(expr, options)
where options: {nodes: Object.<String, Node>}
Removed matrix support from conditional function ifElse.
Removed automatic assignment of expression results to variable ans.
This functionality can be restored by pre- or postprocessing every evaluation,
something like:
function evalWithAns (expr, scope) {
var ans = math.eval(expr, scope);
if (scope) {
scope.ans = ans;
}
return ans;
}
5 * cm).crypto library from the bundle.Parser.parse and Parser.compile. Use
math.parse and math.compile instead.add not adding strings and matrices element wise.2^-3, and a transpose followed by an index like [3]'[1].cosh, coth, csch,
sech, sinh, tanh. Thanks Rogelio J. Baucells (@rjbaucells).type to all expression nodes in an expression tree.log, log10, pow, and sqrt not supporting complex
results from BigNumber input (like sqrt(bignumber(-4))).decimal.js for BigNumber support, instead of
bignumber.js.Complex datatype.
Thanks Finn Pauls (@finnp).exp, log, and log10.a ? b : c in expression parser.epsilon.
Thanks Rogelio J. Baucells (@rjbaucells).norm. Thanks Rogelio J. Baucells (@rjbaucells).ifElse, is now specified for special data types too.det. Thanks Bryan Cuccioli (@bcuccioli).BigNumber support for functions det and diag.lbs (pound mass).decimals to precision (applies to BigNumbers
only).compare, sum, prod, var, std, median.ifElse Thanks @mtraynham.feet.compile (shortcut for parsing and then compiling).pow for matrices. Thanks @hamadu.combinations for large numbers, and
improved performance of both functions combinations and permutations.A[1, 1:3] instead of A(1, 1:3).function keyword for function assignments in the
expression parser, you can define a function now like f(x) = x^2.in to to. Operator in is
still available in the expression parser as an alias for to. Added unit
in, an abbreviation for inch. Thanks Elijah Insua (@tmpvar).includeEnd for function range (false by default).permutations and combinations.
Thanks Daniel Levin (@daniel-levin).l for unit litre.m2 and cubic meter m3.number.defaultType is now number.number.precision is now decimals.matrix.defaultType is now matrix.multiply now consistently outputs a complex number on complex input.mod and in not working as function (only as operator).number.defaultType and number.precision to configure
big numbers.isScalar, toScalar, isVector, toVector
from Matrix and Range. Use math.squeeze and math.size instead.get and set on Matrix, for easier and faster
retrieval/replacement of elements in a matrix.resize, handling matrices, scalars, and strings.ones and zeros now return an empty matrix instead of a
number 1 or 0 when no arguments are provided.min and max for Range and Index.resize now has an extra optional
parameter defaultValue.: in expression parser has been given a higher precedence.config(options. Options are no longer accessible via math.options.scientific notation to exponential in function format.format outputs exponential notation with positive exponents now
always with + sign, so outputs 2.1e+3 instead of 2.1e3.squeeze not being able squeeze into a scalar.resize and subset
functions.size now adheres to the option matrix.defaultType for scalar
input.var math = require('mathjs')();var math = mathjs();format now support various options: precision, different
notations (fixed, scientific, auto), and more.format for Matrix, Complex, Unit, Range,
and Selector to format using options.format does only stringify values now, and has a new parameter
precision to round to a specific number of digits.math.options.precision,
use math.format(value [, precision]) instead.print to interpolate values in a template string,
this functionality was moved from the function format.mean. Thanks Guillermo Indalecio Fernandez
(@guillermobox).max and min for multi dimensional matrices: they now
return the maximum and minimum of the flattened array. An optional second
argument dim allows to calculate the max or min for specified dimension.math.options.matrix.default to
math.options.matrix.defaultType.smaller,
smallereq, larger, largereq. Complex numbers cannot be ordered.math.options.matrix.default which can have values
matrix (default) or array. This option is used by the functions eye,
ones, range, and zeros, to determine the type of matrix output.concat.[...] in the expression parser now creates 1 dimensional
matrices by default. math.eval('[1,2,3,4]') returns a matrix with
size [4], math.eval('[1,2;3,4]') returns a matrix with size [2,2].mod (modulus operator).map and forEach. Thanks Sebastien Piquemal (@sebpic).subset, it now only supports
Array, Matrix, and String.get and set from a selector, they are a duplicate
of the function subset.get and set of Matrix with a single function
subset.math.expr to math.expression (contains Scope, Parser,
node objects).math.docs to math.expression.docs.math.expr.Selector to math.chaining.Selector.lcm and xgcd.random([min, max]), randomInt([min, max]),
pickRandom(array). Thanks Sebastien Piquemal (@sebpic).distribution(name), generating a distribution object
with functions random, randomInt, pickRandom for different
distributions. Currently supporting uniform and normal.range to exclude the upper bound, so range(1, 4)
now returns [1, 2, 3] instead of [1, 2, 3, 4].range, which is now range(start, end [, step])
instead of range(start, [step, ] end).ones and zeros to geometric dimensions, for
example ones(3) returns a vector with length 3, filled with ones, and
ones(3,3) returns a 2D array with size [3, 3].ones and zeros: they now return an Array when
arguments are Numbers or an Array, and returns a Matrix when the argument
is a Matrix.A[0, 0:3].concat is now zero-based.true and false.boolean.select not accepting 0 as input.
Thanks Elijah Manor (@elijahmanor).[[], []].2i * 2i now returns a
Number -4 instead of a Complex -4 + 0i).help function.size and squeeze now return a Matrix instead of an Array as
output on Matrix input.unaryminus to unary.emultiply (x .* y),
edivide (x ./ y), epow (x .^ y).Infinity and NaN.math.parse(expr [,scope]). Optional parameter scope can
be a plain JavaScript Object containing variables.math.expr(expr [, scope]) with an additional parameter
scope, similar to parse. Example: math.eval('x^a', {x:3, a:2});.subset, to get or set a subset from a matrix, string,
or other data types.det. Thanks Bryan Cuccioli (@bcuccioli).end keyword for index operator, and added support for implicit
start and end (expressions like a(2,:) and b(2:end,3:end-1) are supported
now).2.3.4.math.eval, which uses a readonly parser to evaluate
expressions.xgcd (extended eucledian algorithm). Thanks Bart Kiers
(@bkiers).math.format(math.pi)
returns 3.1416).math.select(3).add(4).subtract(2).done() will return 5.Unit.in(unit), which creates a clone of the unit with a
fixed representation. For example math.unit('5.08 cm').in('inch') will
return a unit which string representation always is in inch, thus 2 inch.
Unit.in(unit) is the same as method math.in(x, unit).Unit.toNumber(unit), which returns the value of the unit when
represented with given unit. For example
math.unit('5.08 cm').toNumber('inch') returns the number 2, as the
representation of the unit in inches has 2 as value.math.in(x, unit) now supports a string as second parameter,
for example math.in(math.unit('5.08 cm'), 'inch').:, and transpose operator ' in parser.math.complex(2, 3) instead of new math.Complex(2, 3), and a parser
is now created with math.parser() instead of new math.parser.Parser().2^3^4 is now calculated as 2^(3^4).-3^2 is
now calculated as -(3^2).