2013-02-17 01:14:29 +01:00
2013-02-16 21:41:44 +01:00
2013-02-16 21:42:04 +01:00
2013-02-16 14:23:37 +01:00
2013-02-16 21:42:04 +01:00
2013-02-16 14:23:37 +01:00
2013-02-16 21:41:44 +01:00
2013-02-16 21:41:44 +01:00
2013-02-16 21:42:04 +01:00
2013-02-17 01:14:29 +01:00
2013-02-17 01:14:29 +01:00

Math2

https://github.com/josdejong/math2

Math2 is an extended math library for JavaScript, compatible with the standard Math library of JavaScript. Math2 supports real values, complex values, units, strings, and matrices. It contains an extensive set of built-in functions, and comes with a flexible expression parser. Powerful and easy to use.

Install

Math2 can be installed via npm.

npm install math2

Alternatively, the library can be downloaded from github: math2.js, or minified: math2.min.js.

Use

Node

Math2 can be loaded via require:

var math2 = require('math2'),
    Complex = math2.type.Complex,
    Unit = math2.type.Unit;

console.log(math2.sqrt(25));           // 5

var c = new Complex(3, -4);
console.log(math2.sqrt(c).toString()); // 2 - i

var u = new Unit(45, 'deg');
console.log(math2.sin(math2.pi / 4));  // 0.7071067811865475
console.log(math2.sin(u));             // 0.7071067811865475

Browser

Math2 can be loaded as a regular JavaScript file in the browser:

<!DOCTYPE html>
<html>
<head>
    <script src="math2.js" type="text/javascript"></script>
</head>
<body>
    <script>
        var Complex = math2.type.Complex;
        var Unit = math2.type.Unit;

        console.log(math2.sqrt(25));           // 5

        var c = new Complex(3, -4);
        console.log(math2.sqrt(c).toString()); // 2 - i

        var u = new Unit(45, 'deg');
        console.log(math2.sin(math2.pi / 4));  // 0.7071067811865475
        console.log(math2.sin(u));             // 0.7071067811865475
    </script>
</body>
</html>

Build

To clone the project from github:

git clone git://github.com/josdejong/math2.git

To build the project, jake must be installed globally. Next, install all dependencies using npm. Then build the project using jake.

cd math2
sudo npm install -g jake
npm install
jake

License

Math2 is licensed under the Apache 2.0 license.

Copyright (C) 2013 Jos de Jong <wjosdejong@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Description
An extensive math library for JavaScript and Node.js
Readme Pixar 107 MiB
Languages
JavaScript 97.9%
TypeScript 1.9%