mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
Minor tweaks in the docs
This commit is contained in:
parent
dff0a57219
commit
8b5eb89a02
@ -75,8 +75,8 @@ See the [Getting Started](http://mathjs.org/docs/getting_started.html) for a mor
|
||||
|
||||
Math.js works on any ES5 compatible JavaScript engine: node.js 4 or newer, Chrome, Firefox, Safari, Edge, and IE11.
|
||||
|
||||
Though there is no official support for older browsers,
|
||||
math.js should still work when using the [es5-shim](https://github.com/kriskowal/es5-shim).
|
||||
Though there is no official support for older browsers, math.js should still work on older browsers
|
||||
when using the [es5-shim](https://github.com/kriskowal/es5-shim).
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
@ -13,7 +13,7 @@ Math.js types can be serialized using JavaScript's built-in `JSON.stringify`
|
||||
function:
|
||||
|
||||
```js
|
||||
const x = math.complex('2 + 3i')
|
||||
const x = math.complex('2 + 3i')
|
||||
const str = JSON.stringify(x)
|
||||
console.log(str)
|
||||
// outputs a string '{"mathjs":"Complex","re":2,"im":3}'
|
||||
@ -25,7 +25,7 @@ be called with the reviver function of math.js:
|
||||
|
||||
```js
|
||||
const json = '{"mathjs":"Unit","value":5,"unit":"cm","fixPrefix":false}'
|
||||
const x = JSON.parse(json, math.json.reviver) // Unit 5 cm
|
||||
const x = JSON.parse(json, math.json.reviver) // Unit 5 cm
|
||||
```
|
||||
|
||||
Note that if math.js is used in conjunction with other data types, it is
|
||||
|
||||
@ -159,10 +159,10 @@ Returns the comparision result of two complex number:
|
||||
|
||||
Example:
|
||||
```js
|
||||
var a = math.complex(2, 3); // Complex 2 + 3i
|
||||
var b = math.complex(2, 1); // Complex 2 + 1i
|
||||
math.type.Complex.compare(a,b); // returns 1
|
||||
const a = math.complex(2, 3) // Complex 2 + 3i
|
||||
const b = math.complex(2, 1) // Complex 2 + 1i
|
||||
math.type.Complex.compare(a,b) // returns 1
|
||||
|
||||
//create from json
|
||||
var c = math.type.Complex.fromJSON({mathjs: 'Complex', re: 4, im: 3}); // Complex 4 + 3i
|
||||
const c = math.type.Complex.fromJSON({mathjs: 'Complex', re: 4, im: 3}) // Complex 4 + 3i
|
||||
```
|
||||
|
||||
@ -35,4 +35,4 @@ highlight the syntax or change the default layout (e.g. spaces around operators)
|
||||
-`math-round-parenthesis` (`(` and `)`)
|
||||
-`math-square-parenthesis` (`[` and `]`)
|
||||
-`math-curly-parenthesis` (`{` and `}`)
|
||||
- `math-separator` (<28>,`, `;` and `<br />`)
|
||||
- `math-separator` (<28>,`, `;` and <code><br /></code>)
|
||||
@ -278,7 +278,7 @@ When outputting results, the function `math.format` can be used to hide
|
||||
these round-off errors when outputting results for the user:
|
||||
|
||||
```js
|
||||
const ans = math.eval('0.1 + 0.2') // 0.30000000000000004
|
||||
const ans = math.eval('0.1 + 0.2') // 0.30000000000000004
|
||||
math.format(ans, {precision: 14}) // "0.3"
|
||||
```
|
||||
|
||||
@ -370,7 +370,7 @@ math.eval('5.4 kg') // Unit, 5.4 kg
|
||||
// convert a unit
|
||||
math.eval('2 inch to cm') // Unit, 5.08 cm
|
||||
math.eval('20 celsius in fahrenheit') // Unit, ~68 fahrenheit
|
||||
math.eval('90 km/h to m/s'); // Unit, 25 m / s
|
||||
math.eval('90 km/h to m/s') // Unit, 25 m / s
|
||||
|
||||
// convert a unit to a number
|
||||
// A second parameter with the unit for the exported number must be provided
|
||||
|
||||
@ -21,6 +21,18 @@ and instantiated. When creating an instance, one can optionally provide
|
||||
configuration options as described in
|
||||
[Configuration](configuration.md).
|
||||
|
||||
### ES6 modules
|
||||
|
||||
Load math.js using ES6 import:
|
||||
|
||||
```js
|
||||
// load math.js
|
||||
import * as math from 'mathjs'
|
||||
|
||||
// use math.js
|
||||
math.sqrt(-4) // 2i
|
||||
```
|
||||
|
||||
### Node.js
|
||||
|
||||
Load math.js in [node.js](http://nodejs.org/):
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
# Unit reference
|
||||
|
||||
The unit reference has been moved to [Units](../datatypes/units.md).
|
||||
@ -26,7 +26,7 @@ print(math.bignumber('1.2e+500')) // BigNumber, 1.2e+500
|
||||
console.log()
|
||||
|
||||
console.log('BigNumbers still have a limited precision and are no silve bullet')
|
||||
const third = math.divide(math.bignumber(1), math.bignumber(3));
|
||||
const third = math.divide(math.bignumber(1), math.bignumber(3))
|
||||
const total = math.add(third, third, third)
|
||||
print(total) // BigNumber, 0.99999999999999999999
|
||||
console.log()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user