Comparing version 0.2.0 to 0.3.0
@@ -5,2 +5,9 @@ # math.js changelog | ||
## 2013-03-09, version 0.3.0 | ||
- Implemented Workspace | ||
- Implemented methods cot, csc, sec. | ||
- Implemented Array support for methods with one parameter. | ||
## 2013-02-25, version 0.2.0 | ||
@@ -7,0 +14,0 @@ |
{ | ||
"name": "mathjs", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "An extensive math library for JavaScript and Node.js. Includes an advanced expression parser. Supports numbers, complex numbers, units, strings, and matrices. Contains a large set of functions and constants.", | ||
@@ -36,3 +36,4 @@ "author": "Jos de Jong <wjosdejong@gmail.com>", | ||
"scripts": { | ||
"prepublish": "jake" | ||
"prepublish": "jake", | ||
"test": "jake test" | ||
}, | ||
@@ -39,0 +40,0 @@ "main": "./math.js", |
142
README.md
@@ -23,13 +23,14 @@ ![math.js](https://raw.github.com/josdejong/mathjs/master/img/mathjs.png) | ||
Math.js can be installed with [npm](https://npmjs.org/). | ||
Math.js can be installed with [npm](https://npmjs.org/): | ||
npm install mathjs | ||
Alternatively, the library can be downloaded from github: | ||
[math.js](https://raw.github.com/josdejong/mathjs/master/math.js), or minified: | ||
[math.min.js](https://raw.github.com/josdejong/mathjs/master/math.min.js). | ||
Alternatively, the latest stable version of math.js can be downloaded from github: | ||
- [math.js](https://raw.github.com/josdejong/mathjs/master/math.js) | ||
- [math.min.js](https://raw.github.com/josdejong/mathjs/master/math.min.js) (minified) | ||
## Use | ||
## Load | ||
### Node.js | ||
@@ -41,21 +42,6 @@ | ||
```js | ||
var math = require('mathjs'), | ||
Complex = math.Complex, | ||
Unit = math.Unit; | ||
var math = require('mathjs'); | ||
// use methods and types available in the math object | ||
var a = math.sin(math.pi / 4); | ||
var b = math.pow(a, 2); | ||
console.log('sin(pi / 4) ^ 2 = ' + math.round(b, 3)); // 'sin(pi / 4) ^ 2 = 0.5' | ||
var c = new Complex(3, -4); | ||
var d = math.sqrt(c); | ||
console.log('sqrt(3 - 4i) = ' + d); // 'sqrt(3 - 4i) = 2 - i' | ||
var e = math.sqrt(-4); | ||
console.log('sqrt(-4) = ' + e); // 'sqrt(-4) = 2i' | ||
var f = new Unit(60, 'deg'); | ||
var g = math.cos(f); | ||
console.log('cos(60 deg) = ' + math.round(g, 3)); // 'cos(60 deg) = 0.5' | ||
var a = math.sqrt(-4); | ||
console.log('a = ' + a); // 'a = 2i' | ||
``` | ||
@@ -75,8 +61,4 @@ | ||
<script type="text/javascript"> | ||
// the math object is available here | ||
var a = math.sqrt(-4); | ||
console.log('sqrt(-4) = ' + a); // 'sqrt(-4) = 2i' | ||
// ... | ||
document.write('a = ' + a); // 'a = 2i' | ||
</script> | ||
@@ -87,3 +69,32 @@ </body> | ||
<!-- TODO: Describe how to load using require.js --> | ||
## Use | ||
Math.js can be used similar to Javascript's built-in Math library. | ||
```js | ||
var math = require('mathjs'), | ||
Complex = math.Complex, | ||
Unit = math.Unit; | ||
// use methods and types available in the math object | ||
var a = math.sin(math.pi / 4); | ||
var b = math.pow(a, 2); | ||
console.log('b = ' + math.round(b, 3)); // 'b = 0.5' | ||
var c = new Complex(3, -4); | ||
var d = math.sqrt(c); | ||
console.log('d = ' + d); // 'd = 2 - i' | ||
var e = math.sqrt(-4); | ||
console.log('e = ' + e); // 'e = 2i' | ||
var f = new Unit(60, 'deg'); | ||
var g = math.cos(f); | ||
console.log('g = ' + math.round(g, 3)); // 'g = 0.5' | ||
``` | ||
## Parser | ||
@@ -101,2 +112,3 @@ | ||
```js | ||
// load math.js | ||
var math = require('mathjs'); | ||
@@ -109,5 +121,5 @@ | ||
var a = parser.eval('sqrt(3^2 + 4^2)'); // 5 | ||
var d = parser.eval('sqrt(-4)'); // 2i | ||
var b = parser.eval('2 inch in cm'); // 5.08 cm | ||
var c = parser.eval('cos(45 deg)'); // 0.7071067811865476 | ||
var b = parser.eval('sqrt(-4)'); // 2i | ||
var c = parser.eval('2 inch in cm'); // 5.08 cm | ||
var d = parser.eval('cos(45 deg)'); // 0.7071067811865476 | ||
@@ -135,2 +147,51 @@ // define variables and functions | ||
Available methods: | ||
var result = parser.eval(expr); // evaluate an expression | ||
var value = parser.get(name); // retrieve a variable from the parser | ||
parser.put(name, value); // put a variable in the parser | ||
var node = parser.parse(expr); // parse an expression into a node tree | ||
var result = node.eval(); // evaluate a node | ||
## Workspace | ||
Math.js features a workspace, which manages a set of expressions. | ||
Expressions can be added, replace, deleted, and inserted in the workspace. | ||
The workspace keeps track on the dependencies between the expressions, | ||
and automatically updates results of depending expressions when variables | ||
or function definitions are changed in the workspace. | ||
```js | ||
// load math.js | ||
var math = require('mathjs'); | ||
// create a new workspace | ||
var workspace = new math.parser.Workspace(); | ||
// add expressions to the workspace | ||
var id0 = workspace.append('a = 3/4'); | ||
var id1 = workspace.append('a + 2'); | ||
console.log('a + 2 = ' + workspace.getResult(id1)); | ||
// replace expressions in the workspace | ||
workspace.replace('a=5/2', id0); | ||
console.log('a + 2 = ' + workspace.getResult(id1)); | ||
``` | ||
Available methods: | ||
var id = workspace.append(expr); | ||
var id = workspace.insertBefore(expr, beforeId); | ||
var id = workspace.insertAfter(expr, afterId); | ||
workspace.replace(expr, id); | ||
workspace.remove(id); | ||
workspace.clear(); | ||
var expr = workspace.getExpr(id); | ||
var result = workspace.getResult(id); | ||
var deps = workspace.getDependencies(id); | ||
var changes = workspace.getChanges(updateSeq); | ||
## Data types | ||
@@ -266,2 +327,5 @@ | ||
- math.cos(x) | ||
- math.cot(x) | ||
- math.csc(x) | ||
- math.sec(x) | ||
- math.sin(x) | ||
@@ -348,2 +412,9 @@ - math.tan(x) | ||
## Test | ||
To execute tests for the library, run: | ||
npm test | ||
## Roadmap | ||
@@ -359,7 +430,8 @@ | ||
- Implement Workspace | ||
- Implement more methods | ||
- Build a website | ||
- Version 0.4.0: | ||
- Implement Arrays and Matrices | ||
- Version 1.0.0 | ||
- Extensive testing | ||
- Build a website | ||
- Version 0.4.0: Implement Arrays and Matrices | ||
- Version 0.5.0: Implement more methods | ||
- ... | ||
@@ -366,0 +438,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
262293
5968
444