mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
Release mathjs@5.2.0
This commit is contained in:
parent
fa15efab9e
commit
849e28c8ce
@ -649,6 +649,35 @@ const node3 = new math.expression.node.RangeNode(one, ten)
|
||||
const node4 = new math.expression.node.RangeNode(zero, ten, two)
|
||||
```
|
||||
|
||||
<h3 id="relationalnode">RelationalNode <a href="#relationalnode" title="Permalink">#</a></h3>
|
||||
|
||||
Construction:
|
||||
|
||||
```
|
||||
new RelationalNode(conditionals: string[], params: Node[])
|
||||
```
|
||||
|
||||
`conditionals` is an array of strings, each of which may be 'smaller', 'larger', 'smallerEq', 'largerEq', 'equal', or 'unequal'. The `conditionals` array must contain exactly one fewer item than `params`.
|
||||
|
||||
Properties:
|
||||
|
||||
- `conditionals: string[]`
|
||||
- `params: Node[]`
|
||||
|
||||
A `RelationalNode` efficiently represents a chained conditional expression with two or more comparison operators, such as `10 < x <= 50`. The expression is equivalent to `10 < x and x <= 50`, except that `x` is evaluated only once, and evaluation stops (is "short-circuited") once any condition tests false. Operators that are subject to chaining are `<`, `>`, `<=`, `>=`, `==`, and `!=`. For backward compatibility, `math.parse` will return an `OperatorNode` if only a single conditional is present (such as `x > 2`).
|
||||
|
||||
Examples:
|
||||
|
||||
```js
|
||||
|
||||
const ten = new Math.expression.node.ConstantNode(10)
|
||||
const x = new Math.expression.node.SymbolNode('x')
|
||||
const fifty = new Math.expression.node.ConstantNode(50)
|
||||
|
||||
const node1 = new math.expression.node.RelationalNode(['smaller', 'smallerEq'], [ten, x, fifty])
|
||||
const node2 = math.parse('10 < x <= 50')
|
||||
```
|
||||
|
||||
|
||||
<h3 id="symbolnode">SymbolNode <a href="#symbolnode" title="Permalink">#</a></h3>
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ the lower level syntax of math.js. Differences are:
|
||||
- Some operators are different. For example `^` is used for exponentiation,
|
||||
not bitwise xor.
|
||||
- Implicit multiplication, like `2 pi`, is supported and has special rules.
|
||||
- Relational operators (`<`, `>`, `<=`, `>=`, `==`, and `!=`) are chained, so the expression `5 < x < 10` is equivalent to `5 < x and x < 10`.
|
||||
|
||||
|
||||
<h2 id="operators">Operators <a href="#operators" title="Permalink">#</a></h2>
|
||||
|
||||
14
download.md
14
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@5.1.2/">https://unpkg.com/mathjs@5.1.2/</a></td>
|
||||
<td><a href="https://unpkg.com/mathjs@5.2.0/">https://unpkg.com/mathjs@5.2.0/</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>cdnjs</td>
|
||||
@ -47,22 +47,22 @@ Here some direct download links from [unpkg](https://unpkg.com):
|
||||
<table class="download">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="https://unpkg.com/mathjs@5.1.2/dist/math.js">
|
||||
Development (version 5.1.2)
|
||||
<a href="https://unpkg.com/mathjs@5.2.0/dist/math.js">
|
||||
Development (version 5.2.0)
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<span id="development-size">1690 kB</span>, uncompressed with comments
|
||||
<span id="development-size">1699 kB</span>, uncompressed with comments
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="https://unpkg.com/mathjs@5.1.2/dist/math.min.js">
|
||||
Production (version 5.1.2)
|
||||
<a href="https://unpkg.com/mathjs@5.2.0/dist/math.min.js">
|
||||
Production (version 5.2.0)
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<span id="production-size">135 kB</span>, minified and gzipped
|
||||
<span id="production-size">136 kB</span>, minified and gzipped
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
56
examples/advanced/use_bigint.js
Normal file
56
examples/advanced/use_bigint.js
Normal file
@ -0,0 +1,56 @@
|
||||
// This example demonstrates how you could integrate support for BigInt
|
||||
// in mathjs. It's just a proof of concept, for full support you will
|
||||
// have to defined more functions and define conversions from and to
|
||||
// other data types.
|
||||
|
||||
const math = require('../../index')
|
||||
|
||||
math.import({
|
||||
name: 'BigInt',
|
||||
path: 'type', // will be imported into math.type.BigInt
|
||||
factory: (type, config, load, typed) => {
|
||||
typed.addType({
|
||||
name: 'BigInt',
|
||||
test: (x) => typeof x === 'bigint' // eslint-disable-line
|
||||
})
|
||||
|
||||
// we can also add conversions here from number or string to BigInt
|
||||
// and vice versa using typed.addConversion(...)
|
||||
|
||||
return BigInt // eslint-disable-line
|
||||
},
|
||||
|
||||
// disable lazy loading as this factory has side
|
||||
// effects: it adds a type and a conversion.
|
||||
lazy: false
|
||||
})
|
||||
|
||||
math.import({
|
||||
name: 'bigint',
|
||||
factory: (type, config, load, typed) => {
|
||||
return typed('bigint', {
|
||||
'number | string ': (x) => BigInt(x) // eslint-disable-line
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
math.import({
|
||||
name: 'add',
|
||||
factory: (type, config, load, typed) => {
|
||||
return typed('add', {
|
||||
'BigInt, BigInt': (a, b) => a + b
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
math.import({
|
||||
name: 'pow',
|
||||
factory: (type, config, load, typed) => {
|
||||
return typed('pow', {
|
||||
'BigInt, BigInt': (a, b) => a ** b
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
console.log(math.eval('bigint(4349) + bigint(5249)'))
|
||||
console.log(math.eval('bigint(4349) ^ bigint(5249)'))
|
||||
70
examples/advanced/use_bigint.js.md
Normal file
70
examples/advanced/use_bigint.js.md
Normal file
@ -0,0 +1,70 @@
|
||||
---
|
||||
layout: default
|
||||
---
|
||||
|
||||
# Use bigint
|
||||
|
||||
File: [use_bigint.js](use_bigint.js) (click for a live demo)
|
||||
|
||||
```js
|
||||
// This example demonstrates how you could integrate support for BigInt
|
||||
// in mathjs. It's just a proof of concept, for full support you will
|
||||
// have to defined more functions and define conversions from and to
|
||||
// other data types.
|
||||
|
||||
const math = require('../../index')
|
||||
|
||||
math.import({
|
||||
name: 'BigInt',
|
||||
path: 'type', // will be imported into math.type.BigInt
|
||||
factory: (type, config, load, typed) => {
|
||||
typed.addType({
|
||||
name: 'BigInt',
|
||||
test: (x) => typeof x === 'bigint' // eslint-disable-line
|
||||
})
|
||||
|
||||
// we can also add conversions here from number or string to BigInt
|
||||
// and vice versa using typed.addConversion(...)
|
||||
|
||||
return BigInt // eslint-disable-line
|
||||
},
|
||||
|
||||
// disable lazy loading as this factory has side
|
||||
// effects: it adds a type and a conversion.
|
||||
lazy: false
|
||||
})
|
||||
|
||||
math.import({
|
||||
name: 'bigint',
|
||||
factory: (type, config, load, typed) => {
|
||||
return typed('bigint', {
|
||||
'number | string ': (x) => BigInt(x) // eslint-disable-line
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
math.import({
|
||||
name: 'add',
|
||||
factory: (type, config, load, typed) => {
|
||||
return typed('add', {
|
||||
'BigInt, BigInt': (a, b) => a + b
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
math.import({
|
||||
name: 'pow',
|
||||
factory: (type, config, load, typed) => {
|
||||
return typed('pow', {
|
||||
'BigInt, BigInt': (a, b) => a ** b
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
console.log(math.eval('bigint(4349) + bigint(5249)'))
|
||||
console.log(math.eval('bigint(4349) ^ bigint(5249)'))
|
||||
|
||||
```
|
||||
|
||||
<!-- Note: This file is automatically generated. Changes made in this file will be overridden. -->
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ File: [angle_configuration.html](angle_configuration.html) (click for a live dem
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>math.js | basic usage</title>
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ File: [basic_usage.html](basic_usage.html) (click for a live demo)
|
||||
<html>
|
||||
<head>
|
||||
<title>math.js | basic usage</title>
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>math.js | currency conversion</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
|
||||
<style>
|
||||
body,
|
||||
|
||||
@ -12,7 +12,7 @@ File: [currency_conversion.html](currency_conversion.html) (click for a live dem
|
||||
<head>
|
||||
<title>math.js | currency conversion</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
|
||||
<style>
|
||||
body,
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ File: [custom_separators.html](custom_separators.html) (click for a live demo)
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-shim.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-sham.min.js"></script>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ File: [old_browsers.html](old_browsers.html) (click for a live demo)
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-shim.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-sham.min.js"></script>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>math.js | plot</title>
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
|
||||
<script src="https://cdn.plot.ly/plotly-1.35.2.min.js"></script>
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ File: [plot.html](plot.html) (click for a live demo)
|
||||
<html>
|
||||
<head>
|
||||
<title>math.js | plot</title>
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
|
||||
<script src="https://cdn.plot.ly/plotly-1.35.2.min.js"></script>
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>math.js | pretty printing with MathJax</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/mathjax/2.3/MathJax.js?config=TeX-AMS-MML_HTMLorMML.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -12,7 +12,7 @@ File: [pretty_printing_with_mathjax.html](pretty_printing_with_mathjax.html) (cl
|
||||
<head>
|
||||
<title>math.js | pretty printing with MathJax</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/mathjax/2.3/MathJax.js?config=TeX-AMS-MML_HTMLorMML.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>math.js | printing HTML</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
|
||||
@ -12,7 +12,7 @@ File: [printing_html.html](printing_html.html) (click for a live demo)
|
||||
<head>
|
||||
<title>math.js | printing HTML</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
<script>
|
||||
// load math.js using require.js
|
||||
require(['https://unpkg.com/mathjs@5.1.2/dist/math.min.js'], function (math) {
|
||||
require(['https://unpkg.com/mathjs@5.2.0/dist/math.min.js'], function (math) {
|
||||
// evaluate some expression
|
||||
const result = math.eval('1.2 * (2 + 4.5)')
|
||||
document.write(result)
|
||||
|
||||
@ -17,7 +17,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@5.1.2/dist/math.min.js'], function (math) {
|
||||
require(['https://unpkg.com/mathjs@5.2.0/dist/math.min.js'], function (math) {
|
||||
// evaluate some expression
|
||||
const result = math.eval('1.2 * (2 + 4.5)')
|
||||
document.write(result)
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>math.js | rocket trajectory optimization</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -12,7 +12,7 @@ File: [rocket_trajectory_optimization.html](rocket_trajectory_optimization.html)
|
||||
<head>
|
||||
<title>math.js | rocket trajectory optimization</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@5.1.2/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@5.2.0/dist/math.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -91,7 +91,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@5.1.2/dist/math.min.js')
|
||||
importScripts('https://unpkg.com/mathjs@5.2.0/dist/math.min.js')
|
||||
|
||||
// create a parser
|
||||
const parser = self.math.parser()
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
importScripts('https://unpkg.com/mathjs@5.1.2/dist/math.min.js')
|
||||
importScripts('https://unpkg.com/mathjs@5.2.0/dist/math.min.js')
|
||||
|
||||
// create a parser
|
||||
const parser = self.math.parser()
|
||||
|
||||
@ -41,6 +41,7 @@ layout: default
|
||||
- [Expression trees](advanced/expression_trees.js.html)
|
||||
- [Function transform](advanced/function_transform.js.html)
|
||||
- [More secure eval](advanced/more_secure_eval.js.html)
|
||||
- [Use bigint](advanced/use_bigint.js.html)
|
||||
- [Web server](advanced/web_server/index.html)
|
||||
|
||||
<!-- Note: This file is automatically generated. Changes made in this file will be overridden. -->
|
||||
|
||||
@ -4,6 +4,15 @@ layout: default
|
||||
|
||||
<h1 id="history">History <a href="#history" title="Permalink">#</a></h1>
|
||||
|
||||
<h1 id="20181005-version-520">2018-10-05, version 5.2.0 <a href="#20181005-version-520" title="Permalink">#</a></h1>
|
||||
|
||||
- Implemented support for chained conditionals like `10 < x <= 50`.
|
||||
Thanks <a href="https://github.com/ericman314">@ericman314</a>.
|
||||
- Add an example showing a proof of concept of using `BigInt` in mathjs.
|
||||
- Fixed <a href="https://github.com/josdejong/mathjs/issues/1269">#1269</a>: Bugfix for BigNumber divided by unit. Thanks <a href="https://github.com/ericman314">@ericman314</a>.
|
||||
- Fixed <a href="https://github.com/josdejong/mathjs/issues/1240">#1240</a>: allow units having just a value and no unit.
|
||||
Thanks <a href="https://github.com/ericman314">@ericman314</a>.
|
||||
|
||||
|
||||
<h2 id="20180909-version-512">2018-09-09, version 5.1.2 <a href="#20180909-version-512" title="Permalink">#</a></h2>
|
||||
|
||||
|
||||
5666
js/lib/math.js
5666
js/lib/math.js
File diff suppressed because it is too large
Load Diff
10
js/lib/math.min.js
vendored
10
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
6
package-lock.json
generated
6
package-lock.json
generated
@ -1621,9 +1621,9 @@
|
||||
}
|
||||
},
|
||||
"mathjs": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/mathjs/-/mathjs-5.1.2.tgz",
|
||||
"integrity": "sha512-ewA6m6omkS+VPkU6Qd60T2oPVvACG4r8ajD6M6OaWbO0nMQ4wr0ZHFHRjfuzpTb96Y5HT82rTeNqGGktBa5G/w==",
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/mathjs/-/mathjs-5.2.0.tgz",
|
||||
"integrity": "sha512-TwiegJ/k9zXRhyYFjeuBB5Nmw+GXDq4pRC9bcRhRlq654DZLv4QAvp24l9dEk2G2QiU1PfzvP1dd/CCEqsMZ+w==",
|
||||
"requires": {
|
||||
"complex.js": "2.0.11",
|
||||
"decimal.js": "10.0.1",
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
"url": "https://github.com/josdejong/mathjs.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"mathjs": "5.1.2"
|
||||
"mathjs": "5.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"glob": "^7.1.2",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user