mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
Publish mathjs@6.1.0
This commit is contained in:
parent
b7c8c0a033
commit
ecef173a24
@ -8,7 +8,7 @@ Math.js is a large library containing many data types and functions.
|
||||
It is well possible that you only need a small portion of the library.
|
||||
Math.js allows for picking just the functions and data types you need.
|
||||
This gives faster load times and smaller browser bundles. Math.js uses
|
||||
ES6 modules, and creating small bundles using tree-shaking works out of
|
||||
ES modules, and creating small bundles using tree-shaking works out of
|
||||
the box when using Webpack for example.
|
||||
|
||||
This page describes:
|
||||
|
||||
@ -15,7 +15,7 @@ the code server side.
|
||||
A user could try to inject malicious JavaScript code via the expression
|
||||
parser. The expression parser of mathjs offers a sandboxed environment
|
||||
to execute expressions which should make this impossible. It's possible
|
||||
though that there are unknown security vulnerabilties, so it's important
|
||||
though that there are unknown security vulnerabilities, so it's important
|
||||
to be careful, especially when allowing server side execution of
|
||||
arbitrary expressions.
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ and instantiated. When creating an instance, one can optionally provide
|
||||
configuration options as described in
|
||||
[Configuration](core/configuration.html).
|
||||
|
||||
<h3 id="es6-modules">ES6 modules <a href="#es6-modules" title="Permalink">#</a></h3>
|
||||
<h3 id="es-modules">ES modules <a href="#es-modules" title="Permalink">#</a></h3>
|
||||
|
||||
Load the functions you need and use them:
|
||||
|
||||
|
||||
@ -180,6 +180,7 @@ Function | Description
|
||||
Function | Description
|
||||
---- | -----------
|
||||
[math.combinations(n, k)](functions/combinations.html) | Compute the number of ways of picking `k` unordered outcomes from `n` possibilities.
|
||||
[math.combinationsWithRep(n, k)](functions/combinationsWithRep.html) | Compute the number of ways of picking `k` unordered outcomes from `n` possibilities, allowing individual outcomes to be repeated more than once.
|
||||
[math.factorial(n)](functions/factorial.html) | Compute the factorial of a value Factorial only supports an integer value as argument.
|
||||
[math.gamma(n)](functions/gamma.html) | Compute the gamma function of a value using Lanczos approximation for small values, and an extended Stirling approximation for large values.
|
||||
[math.kldivergence(x, y)](functions/kldivergence.html) | Calculate the Kullback-Leibler (KL) divergence between two distributions.
|
||||
|
||||
@ -42,5 +42,6 @@ math.combinations(7, 5) // returns 21
|
||||
|
||||
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
|
||||
|
||||
[combinationsWithRep](combinationsWithRep.html),
|
||||
[permutations](permutations.html),
|
||||
[factorial](factorial.html)
|
||||
|
||||
47
docs/reference/functions/combinationsWithRep.md
Normal file
47
docs/reference/functions/combinationsWithRep.md
Normal file
@ -0,0 +1,47 @@
|
||||
---
|
||||
layout: default
|
||||
---
|
||||
|
||||
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|
||||
|
||||
<h1 id="function-combinationswithrep">Function combinationsWithRep <a href="#function-combinationswithrep" title="Permalink">#</a></h1>
|
||||
|
||||
Compute the number of ways of picking `k` unordered outcomes from `n`
|
||||
possibilities, allowing individual outcomes to be repeated more than once.
|
||||
|
||||
CombinationsWithRep only takes integer arguments.
|
||||
The following condition must be enforced: k <= n + k -1.
|
||||
|
||||
|
||||
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
|
||||
|
||||
```js
|
||||
math.combinationsWithRep(n, k)
|
||||
```
|
||||
|
||||
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
|
||||
|
||||
Parameter | Type | Description
|
||||
--------- | ---- | -----------
|
||||
`n` | number | BigNumber | Total number of objects in the set
|
||||
`k` | number | BigNumber | Number of objects in the subset
|
||||
|
||||
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
|
||||
|
||||
Type | Description
|
||||
---- | -----------
|
||||
number | BigNumber | Number of possible combinations with replacement.
|
||||
|
||||
|
||||
<h2 id="examples">Examples <a href="#examples" title="Permalink">#</a></h2>
|
||||
|
||||
```js
|
||||
math.combinationsWithRep(7, 5) // returns 462
|
||||
```
|
||||
|
||||
|
||||
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
|
||||
|
||||
[combinations](combinations.html),
|
||||
[permutations](permutations.html),
|
||||
[factorial](factorial.html)
|
||||
@ -42,5 +42,6 @@ math.factorial(3) // returns 6
|
||||
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
|
||||
|
||||
[combinations](combinations.html),
|
||||
[combinationsWithRep](combinationsWithRep.html),
|
||||
[gamma](gamma.html),
|
||||
[permutations](permutations.html)
|
||||
|
||||
@ -45,4 +45,5 @@ math.permutations(5, 3) // 60
|
||||
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
|
||||
|
||||
[combinations](combinations.html),
|
||||
[combinationsWithRep](combinationsWithRep.html),
|
||||
[factorial](factorial.html)
|
||||
|
||||
12
download.md
12
download.md
@ -29,7 +29,7 @@ Math.js can be downloaded or linked from various content delivery networks:
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>unpkg</td>
|
||||
<td><a href="https://unpkg.com/mathjs@6.0.3/">https://unpkg.com/mathjs@6.0.3/</a></td>
|
||||
<td><a href="https://unpkg.com/mathjs@6.1.0/">https://unpkg.com/mathjs@6.1.0/</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>cdnjs</td>
|
||||
@ -47,18 +47,18 @@ Here some direct download links from [unpkg](https://unpkg.com):
|
||||
<table class="download">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="https://unpkg.com/mathjs@6.0.3/dist/math.js">
|
||||
Development (version 6.0.3)
|
||||
<a href="https://unpkg.com/mathjs@6.1.0/dist/math.js">
|
||||
Development (version 6.1.0)
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<span id="development-size">1827 kB</span>, uncompressed with comments
|
||||
<span id="development-size">1829 kB</span>, uncompressed with comments
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="https://unpkg.com/mathjs@6.0.3/dist/math.min.js">
|
||||
Production (version 6.0.3)
|
||||
<a href="https://unpkg.com/mathjs@6.1.0/dist/math.min.js">
|
||||
Production (version 6.1.0)
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@ -93,6 +93,6 @@ console.log(math.integrate(f, 0, 1)) // outputs 0.6667254718034714
|
||||
console.log(math.evaluate('integrate(x^0.5, x, 0, 1)')) // outputs 0.6667254718034714
|
||||
|
||||
// use the function via the expression parser (2)
|
||||
let scope = {}
|
||||
const scope = {}
|
||||
math.evaluate('f(x) = 2 * x', scope)
|
||||
console.log(math.evaluate('integrate(f(x), x, 0, 2)', scope)) // outputs 4.000000000000003
|
||||
|
||||
@ -102,7 +102,7 @@ console.log(math.integrate(f, 0, 1)) // outputs 0.6667254718034714
|
||||
console.log(math.evaluate('integrate(x^0.5, x, 0, 1)')) // outputs 0.6667254718034714
|
||||
|
||||
// use the function via the expression parser (2)
|
||||
let scope = {}
|
||||
const scope = {}
|
||||
math.evaluate('f(x) = 2 * x', scope)
|
||||
console.log(math.evaluate('integrate(f(x), x, 0, 2)', scope)) // outputs 4.000000000000003
|
||||
|
||||
|
||||
62
examples/advanced/custom_relational_functions.js
Normal file
62
examples/advanced/custom_relational_functions.js
Normal file
@ -0,0 +1,62 @@
|
||||
const { create, all, factory } = require('../..')
|
||||
|
||||
// First let's see what the default behavior is:
|
||||
// strings are compared by their numerical value
|
||||
console.log('default (compare string by their numerical value)')
|
||||
const { evaluate } = create(all)
|
||||
evaluateAndLog(evaluate, '2 < 10') // true
|
||||
evaluateAndLog(evaluate, '"2" < "10"') // true
|
||||
evaluateAndLog(evaluate, '"a" == "b"') // Error: Cannot convert "a" to a number
|
||||
evaluateAndLog(evaluate, '"a" == "a"') // Error: Cannot convert "a" to a number
|
||||
console.log('')
|
||||
|
||||
// Suppose we want different behavior for string comparisons. To achieve
|
||||
// this we can replace the factory functions for all relational functions
|
||||
// with our own. In this simple example we use the JavaScript implementation.
|
||||
console.log('custom (compare strings lexically)')
|
||||
|
||||
const allWithCustomFunctions = {
|
||||
...all,
|
||||
|
||||
createEqual: factory('equal', [], () => function equal (a, b) {
|
||||
return a === b
|
||||
}),
|
||||
|
||||
createUnequal: factory('unequal', [], () => function unequal (a, b) {
|
||||
return a !== b
|
||||
}),
|
||||
|
||||
createSmaller: factory('smaller', [], () => function smaller (a, b) {
|
||||
return a < b
|
||||
}),
|
||||
|
||||
createSmallerEq: factory('smallerEq', [], () => function smallerEq (a, b) {
|
||||
return a <= b
|
||||
}),
|
||||
|
||||
createLarger: factory('larger', [], () => function larger (a, b) {
|
||||
return a > b
|
||||
}),
|
||||
|
||||
createLargerEq: factory('largerEq', [], () => function largerEq (a, b) {
|
||||
return a >= b
|
||||
}),
|
||||
|
||||
createCompare: factory('compare', [], () => function compare (a, b) {
|
||||
return a > b ? 1 : a < b ? -1 : 0
|
||||
})
|
||||
}
|
||||
const evaluateCustom = create(allWithCustomFunctions).evaluate
|
||||
evaluateAndLog(evaluateCustom, '2 < 10') // true
|
||||
evaluateAndLog(evaluateCustom, '"2" < "10"') // false
|
||||
evaluateAndLog(evaluateCustom, '"a" == "b"') // false
|
||||
evaluateAndLog(evaluateCustom, '"a" == "a"') // true
|
||||
|
||||
// helper function to evaluate an expression and print the results
|
||||
function evaluateAndLog (evaluate, expression) {
|
||||
try {
|
||||
console.log(expression, evaluate(expression))
|
||||
} catch (err) {
|
||||
console.error(expression, err.toString())
|
||||
}
|
||||
}
|
||||
76
examples/advanced/custom_relational_functions.js.md
Normal file
76
examples/advanced/custom_relational_functions.js.md
Normal file
@ -0,0 +1,76 @@
|
||||
---
|
||||
layout: default
|
||||
---
|
||||
|
||||
# Custom relational functions
|
||||
|
||||
File: [custom_relational_functions.js](custom_relational_functions.js) (click for a live demo)
|
||||
|
||||
```js
|
||||
const { create, all, factory } = require('../..')
|
||||
|
||||
// First let's see what the default behavior is:
|
||||
// strings are compared by their numerical value
|
||||
console.log('default (compare string by their numerical value)')
|
||||
const { evaluate } = create(all)
|
||||
evaluateAndLog(evaluate, '2 < 10') // true
|
||||
evaluateAndLog(evaluate, '"2" < "10"') // true
|
||||
evaluateAndLog(evaluate, '"a" == "b"') // Error: Cannot convert "a" to a number
|
||||
evaluateAndLog(evaluate, '"a" == "a"') // Error: Cannot convert "a" to a number
|
||||
console.log('')
|
||||
|
||||
// Suppose we want different behavior for string comparisons. To achieve
|
||||
// this we can replace the factory functions for all relational functions
|
||||
// with our own. In this simple example we use the JavaScript implementation.
|
||||
console.log('custom (compare strings lexically)')
|
||||
|
||||
const allWithCustomFunctions = {
|
||||
...all,
|
||||
|
||||
createEqual: factory('equal', [], () => function equal (a, b) {
|
||||
return a === b
|
||||
}),
|
||||
|
||||
createUnequal: factory('unequal', [], () => function unequal (a, b) {
|
||||
return a !== b
|
||||
}),
|
||||
|
||||
createSmaller: factory('smaller', [], () => function smaller (a, b) {
|
||||
return a < b
|
||||
}),
|
||||
|
||||
createSmallerEq: factory('smallerEq', [], () => function smallerEq (a, b) {
|
||||
return a <= b
|
||||
}),
|
||||
|
||||
createLarger: factory('larger', [], () => function larger (a, b) {
|
||||
return a > b
|
||||
}),
|
||||
|
||||
createLargerEq: factory('largerEq', [], () => function largerEq (a, b) {
|
||||
return a >= b
|
||||
}),
|
||||
|
||||
createCompare: factory('compare', [], () => function compare (a, b) {
|
||||
return a > b ? 1 : a < b ? -1 : 0
|
||||
})
|
||||
}
|
||||
const evaluateCustom = create(allWithCustomFunctions).evaluate
|
||||
evaluateAndLog(evaluateCustom, '2 < 10') // true
|
||||
evaluateAndLog(evaluateCustom, '"2" < "10"') // false
|
||||
evaluateAndLog(evaluateCustom, '"a" == "b"') // false
|
||||
evaluateAndLog(evaluateCustom, '"a" == "a"') // true
|
||||
|
||||
// helper function to evaluate an expression and print the results
|
||||
function evaluateAndLog (evaluate, expression) {
|
||||
try {
|
||||
console.log(expression, evaluate(expression))
|
||||
} catch (err) {
|
||||
console.error(expression, err.toString())
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
<!-- Note: This file is automatically generated. Changes made in this file will be overridden. -->
|
||||
|
||||
@ -24,12 +24,12 @@ const math = create(all)
|
||||
const limitedEvaluate = math.evaluate
|
||||
|
||||
math.import({
|
||||
'import': function () { throw new Error('Function import is disabled') },
|
||||
'createUnit': function () { throw new Error('Function createUnit is disabled') },
|
||||
'evaluate': function () { throw new Error('Function evaluate is disabled') },
|
||||
'parse': function () { throw new Error('Function parse is disabled') },
|
||||
'simplify': function () { throw new Error('Function simplify is disabled') },
|
||||
'derivative': function () { throw new Error('Function derivative is disabled') }
|
||||
import: function () { throw new Error('Function import is disabled') },
|
||||
createUnit: function () { throw new Error('Function createUnit is disabled') },
|
||||
evaluate: function () { throw new Error('Function evaluate is disabled') },
|
||||
parse: function () { throw new Error('Function parse is disabled') },
|
||||
simplify: function () { throw new Error('Function simplify is disabled') },
|
||||
derivative: function () { throw new Error('Function derivative is disabled') }
|
||||
}, { override: true })
|
||||
|
||||
console.log(limitedEvaluate('sqrt(16)')) // Ok, 4
|
||||
|
||||
@ -33,12 +33,12 @@ const math = create(all)
|
||||
const limitedEvaluate = math.evaluate
|
||||
|
||||
math.import({
|
||||
'import': function () { throw new Error('Function import is disabled') },
|
||||
'createUnit': function () { throw new Error('Function createUnit is disabled') },
|
||||
'evaluate': function () { throw new Error('Function evaluate is disabled') },
|
||||
'parse': function () { throw new Error('Function parse is disabled') },
|
||||
'simplify': function () { throw new Error('Function simplify is disabled') },
|
||||
'derivative': function () { throw new Error('Function derivative is disabled') }
|
||||
import: function () { throw new Error('Function import is disabled') },
|
||||
createUnit: function () { throw new Error('Function createUnit is disabled') },
|
||||
evaluate: function () { throw new Error('Function evaluate is disabled') },
|
||||
parse: function () { throw new Error('Function parse is disabled') },
|
||||
simplify: function () { throw new Error('Function simplify is disabled') },
|
||||
derivative: function () { throw new Error('Function derivative is disabled') }
|
||||
}, { override: true })
|
||||
|
||||
console.log(limitedEvaluate('sqrt(16)')) // Ok, 4
|
||||
|
||||
@ -15,7 +15,7 @@ const math = create(all)
|
||||
function noImport () {
|
||||
throw new Error('function import is disabled.')
|
||||
}
|
||||
math.import({ 'import': noImport }, { override: true })
|
||||
math.import({ import: noImport }, { override: true })
|
||||
|
||||
/**
|
||||
* Evaluate an expression
|
||||
|
||||
@ -6,7 +6,7 @@ const math = create(all)
|
||||
function noImport () {
|
||||
throw new Error('function import is disabled.')
|
||||
}
|
||||
math.import({ 'import': noImport }, { override: true })
|
||||
math.import({ import: noImport }, { override: true })
|
||||
|
||||
/**
|
||||
* Evaluate an expression
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ File: [angle_configuration.html](angle_configuration.html) (click for a live dem
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | basic usage</title>
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ File: [basic_usage.html](basic_usage.html) (click for a live demo)
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | basic usage</title>
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | currency conversion</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
|
||||
<style>
|
||||
body,
|
||||
|
||||
@ -13,7 +13,7 @@ File: [currency_conversion.html](currency_conversion.html) (click for a live dem
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | currency conversion</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
|
||||
<style>
|
||||
body,
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ File: [custom_separators.html](custom_separators.html) (click for a live demo)
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | plot</title>
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
|
||||
<script src="https://cdn.plot.ly/plotly-1.35.2.min.js"></script>
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ File: [plot.html](plot.html) (click for a live demo)
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | plot</title>
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
|
||||
<script src="https://cdn.plot.ly/plotly-1.35.2.min.js"></script>
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | pretty printing with MathJax</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.3/MathJax.js?config=TeX-AMS-MML_HTMLorMML.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -13,7 +13,7 @@ File: [pretty_printing_with_mathjax.html](pretty_printing_with_mathjax.html) (cl
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | pretty printing with MathJax</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.3/MathJax.js?config=TeX-AMS-MML_HTMLorMML.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | printing HTML</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
|
||||
@ -13,7 +13,7 @@ File: [printing_html.html](printing_html.html) (click for a live demo)
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | printing HTML</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
<script>
|
||||
// load math.js using require.js
|
||||
require(['https://unpkg.com/mathjs@6.0.3/dist/math.min.js'], function (math) {
|
||||
require(['https://unpkg.com/mathjs@6.1.0/dist/math.min.js'], function (math) {
|
||||
// evaluate some expression
|
||||
const result = math.evaluate('1.2 * (2 + 4.5)')
|
||||
document.write(result)
|
||||
|
||||
@ -18,7 +18,7 @@ File: [requirejs_loading.html](requirejs_loading.html) (click for a live demo)
|
||||
|
||||
<script>
|
||||
// load math.js using require.js
|
||||
require(['https://unpkg.com/mathjs@6.0.3/dist/math.min.js'], function (math) {
|
||||
require(['https://unpkg.com/mathjs@6.1.0/dist/math.min.js'], function (math) {
|
||||
// evaluate some expression
|
||||
const result = math.evaluate('1.2 * (2 + 4.5)')
|
||||
document.write(result)
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | rocket trajectory optimization</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -13,7 +13,7 @@ File: [rocket_trajectory_optimization.html](rocket_trajectory_optimization.html)
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | rocket trajectory optimization</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@6.0.3/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@6.1.0/dist/math.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -92,7 +92,7 @@ File: [webworkers.html](webworkers.html) (click for a live demo)
|
||||
File: [worker.js](worker.js) (click for a live demo)
|
||||
|
||||
```js
|
||||
importScripts('https://unpkg.com/mathjs@6.0.3/dist/math.min.js')
|
||||
importScripts('https://unpkg.com/mathjs@6.1.0/dist/math.min.js')
|
||||
|
||||
// create a parser
|
||||
const parser = self.math.parser()
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
importScripts('https://unpkg.com/mathjs@6.0.3/dist/math.min.js')
|
||||
importScripts('https://unpkg.com/mathjs@6.1.0/dist/math.min.js')
|
||||
|
||||
// create a parser
|
||||
const parser = self.math.parser()
|
||||
|
||||
@ -36,7 +36,7 @@ print(math.evaluate([
|
||||
|
||||
// provide a scope (just a regular JavaScript Object)
|
||||
console.log('\nevaluate expressions providing a scope with variables and functions')
|
||||
let scope = {
|
||||
const scope = {
|
||||
a: 3,
|
||||
b: 4
|
||||
}
|
||||
@ -84,7 +84,7 @@ console.log('\nprovide a scope')
|
||||
const node2 = math.parse('x^a')
|
||||
const code2 = node2.compile()
|
||||
print(node2.toString()) // "x ^ a"
|
||||
let scope2 = {
|
||||
const scope2 = {
|
||||
x: 3,
|
||||
a: 2
|
||||
}
|
||||
@ -115,7 +115,7 @@ print(code3.evaluate()) // 5
|
||||
// provide a scope for the variable assignment
|
||||
console.log('\nprovide a scope')
|
||||
const code4 = math.compile('a = a + 3')
|
||||
let scope3 = {
|
||||
const scope3 = {
|
||||
a: 7
|
||||
}
|
||||
code4.evaluate(scope3)
|
||||
|
||||
@ -45,7 +45,7 @@ print(math.evaluate([
|
||||
|
||||
// provide a scope (just a regular JavaScript Object)
|
||||
console.log('\nevaluate expressions providing a scope with variables and functions')
|
||||
let scope = {
|
||||
const scope = {
|
||||
a: 3,
|
||||
b: 4
|
||||
}
|
||||
@ -93,7 +93,7 @@ console.log('\nprovide a scope')
|
||||
const node2 = math.parse('x^a')
|
||||
const code2 = node2.compile()
|
||||
print(node2.toString()) // "x ^ a"
|
||||
let scope2 = {
|
||||
const scope2 = {
|
||||
x: 3,
|
||||
a: 2
|
||||
}
|
||||
@ -124,7 +124,7 @@ print(code3.evaluate()) // 5
|
||||
// provide a scope for the variable assignment
|
||||
console.log('\nprovide a scope')
|
||||
const code4 = math.compile('a = a + 3')
|
||||
let scope3 = {
|
||||
const scope3 = {
|
||||
a: 7
|
||||
}
|
||||
code4.evaluate(scope3)
|
||||
|
||||
@ -37,6 +37,7 @@ layout: default
|
||||
- [Custom argument parsing](advanced/custom_argument_parsing.js.html)
|
||||
- [Custom datatype](advanced/custom_datatype.js.html)
|
||||
- [Custom loading](advanced/custom_loading.js.html)
|
||||
- [Custom relational functions](advanced/custom_relational_functions.js.html)
|
||||
- [Expression trees](advanced/expression_trees.js.html)
|
||||
- [Function transform](advanced/function_transform.js.html)
|
||||
- [More secure eval](advanced/more_secure_eval.js.html)
|
||||
|
||||
@ -10,7 +10,7 @@ print(evaluate('{"name": "John"}')) // {"name": "John"}
|
||||
// create an object containing an object
|
||||
print(evaluate('{a: 2, b: {c: 3, d: 4}}')) // {"a": 2, "b": {"c": 3, "d": 4}}
|
||||
|
||||
let scope = {
|
||||
const scope = {
|
||||
obj: {
|
||||
prop: 42
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ print(evaluate('{"name": "John"}')) // {"name": "John"}
|
||||
// create an object containing an object
|
||||
print(evaluate('{a: 2, b: {c: 3, d: 4}}')) // {"a": 2, "b": {"c": 3, "d": 4}}
|
||||
|
||||
let scope = {
|
||||
const scope = {
|
||||
obj: {
|
||||
prop: 42
|
||||
}
|
||||
|
||||
13
history.md
13
history.md
@ -5,6 +5,17 @@ layout: default
|
||||
<h1 id="history">History <a href="#history" title="Permalink">#</a></h1>
|
||||
|
||||
|
||||
<h1 id="20190817-version-610">2019-08-17, version 6.1.0 <a href="#20190817-version-610" title="Permalink">#</a></h1>
|
||||
|
||||
- Implemented function `combinationsWithRep` (see <a href="https://github.com/josdejong/mathjs/issues/1329">#1329</a>). Thanks <a href="https://github.com/waseemyusuf">@waseemyusuf</a>.
|
||||
|
||||
|
||||
<h1 id="20190805-version-604">2019-08-05, version 6.0.4 <a href="#20190805-version-604" title="Permalink">#</a></h1>
|
||||
|
||||
- Fixed <a href="https://github.com/josdejong/mathjs/issues/1554">#1554</a>, <a href="https://github.com/josdejong/mathjs/issues/1565">#1565</a>: ES Modules where not transpiled to ES5, giving issues on
|
||||
old browsers. Thanks <a href="https://github.com/mockdeep">@mockdeep</a> for helping to find a solution.
|
||||
|
||||
|
||||
<h1 id="20190707-version-603">2019-07-07, version 6.0.3 <a href="#20190707-version-603" title="Permalink">#</a></h1>
|
||||
|
||||
- Add `unpkg` and `jsdelivr` fields in package.json pointing to UMD build.
|
||||
@ -31,7 +42,7 @@ layout: default
|
||||
|
||||
<h3 id="most-notable-changes">Most notable changes <a href="#most-notable-changes" title="Permalink">#</a></h3>
|
||||
|
||||
1. Full support for **ES6 modules**. Support for tree-shaking out of the box.
|
||||
1. Full support for **ES modules**. Support for tree-shaking out of the box.
|
||||
|
||||
Load all functions:
|
||||
|
||||
|
||||
4772
js/lib/math.js
4772
js/lib/math.js
File diff suppressed because it is too large
Load Diff
8
js/lib/math.min.js
vendored
8
js/lib/math.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
36
package-lock.json
generated
36
package-lock.json
generated
@ -1773,13 +1773,13 @@
|
||||
}
|
||||
},
|
||||
"gulp-header": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/gulp-header/-/gulp-header-2.0.7.tgz",
|
||||
"integrity": "sha512-qppGkYGQZnt/mRJiiR5wYZIUwNUn47Xpg4+6tHYDVeAW5IDLbHBQwbw7axfMLWGE+gKQpB+yXLeslHMw1/Haog==",
|
||||
"version": "2.0.9",
|
||||
"resolved": "https://registry.npmjs.org/gulp-header/-/gulp-header-2.0.9.tgz",
|
||||
"integrity": "sha512-LMGiBx+qH8giwrOuuZXSGvswcIUh0OiioNkUpLhNyvaC6/Ga8X6cfAeme2L5PqsbXMhL8o8b/OmVqIQdxprhcQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"concat-with-sourcemaps": "^1.1.0",
|
||||
"lodash.template": "^4.4.0",
|
||||
"lodash.template": "^4.5.0",
|
||||
"map-stream": "0.0.7",
|
||||
"through2": "^2.0.0"
|
||||
}
|
||||
@ -2233,22 +2233,22 @@
|
||||
"dev": true
|
||||
},
|
||||
"lodash.template": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.4.0.tgz",
|
||||
"integrity": "sha1-5zoDhcg1VZF0bgILmWecaQ5o+6A=",
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.5.0.tgz",
|
||||
"integrity": "sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"lodash._reinterpolate": "~3.0.0",
|
||||
"lodash._reinterpolate": "^3.0.0",
|
||||
"lodash.templatesettings": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"lodash.templatesettings": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz",
|
||||
"integrity": "sha1-K01OlbpEDZFf8IvImeRVNmZxMxY=",
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz",
|
||||
"integrity": "sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"lodash._reinterpolate": "~3.0.0"
|
||||
"lodash._reinterpolate": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"make-iterator": {
|
||||
@ -2317,9 +2317,9 @@
|
||||
}
|
||||
},
|
||||
"mathjs": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/mathjs/-/mathjs-6.0.3.tgz",
|
||||
"integrity": "sha512-BkXSjaWg0Dkwf6S3Cs7bLorei96ltYtCxNoTaLCZcH7OK+T+RgpobH86bTKD9oRI1hABXfuom/vf/RGI9CTfHA==",
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/mathjs/-/mathjs-6.1.0.tgz",
|
||||
"integrity": "sha512-rYxlGCTyCQ8dTLT4kGZZE88cOO3mrri1ObiJwUTLBIfABqk5G/LxGCDbTgEIzRUga194HvS8eHKQUKdoEGKsJA==",
|
||||
"requires": {
|
||||
"complex.js": "2.0.11",
|
||||
"decimal.js": "10.2.0",
|
||||
@ -2953,9 +2953,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"rimraf": {
|
||||
"version": "2.6.3",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
|
||||
"integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.0.tgz",
|
||||
"integrity": "sha512-NDGVxTsjqfunkds7CqsOiEnxln4Bo7Nddl3XhS4pXg5OzwkLqJ971ZVAAnB+DDLnF76N+VnDEiBHaVV8I06SUg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"glob": "^7.1.3"
|
||||
|
||||
@ -6,17 +6,17 @@
|
||||
"url": "https://github.com/josdejong/mathjs.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"mathjs": "6.0.3"
|
||||
"mathjs": "6.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"fancy-log": "1.3.3",
|
||||
"glob": "7.1.4",
|
||||
"gulp": "4.0.2",
|
||||
"gulp-header": "2.0.7",
|
||||
"gulp-header": "2.0.9",
|
||||
"gulp-rename": "1.4.0",
|
||||
"gulp-replace": "1.0.0",
|
||||
"handlebars": "4.1.2",
|
||||
"rimraf": "2.6.3"
|
||||
"rimraf": "3.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gulp"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user