mathjs v6.0.0 Release Notes

Release Date: 2019-06-08 // almost 5 years ago
  • !!! BE CAREFUL: BREAKING CHANGES !!!

    Most notable changes

    1. Full support for ES6 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)
      
    2. Support for lightweight, number-only implementations of all functions:

      import { add, multiply } from 'mathjs/number'
      
    3. New dependency injection solution used under the hood.

    ๐Ÿ’ฅ Breaking changes

    • ๐Ÿ‘ 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.

    Non breaking changes

    • ๐Ÿ›  Implemented units t, tonne, bel, decibel, dB, and prefixes for candela. Thanks @mcvladthegoat.
    • ๐Ÿ›  Fixed epsilon setting being applied globally to Complex numbers.
    • ๐Ÿ›  Fix math.simplify('add(2, 3)') throwing an error.
    • ๐Ÿ›  Fix #1530: number formatting first applied lowerExp and upperExp and after that rounded the value instead of the other way around.
    • ๐Ÿ›  Fix #1473: remove 'use strict' in every file, not needed anymore.