Numeric JavaScript

1.2.6 · abandoned · verified Sun Apr 19

Numeric JavaScript is a legacy library for performing numerical analysis within JavaScript environments, including matrix operations, solving linear systems, finding eigenvalues, and optimization problems. Despite its capabilities, the package's last stable version (1.2.6) was published in December 2012, indicating it is no longer actively maintained. Its core differentiators were performing complex calculations directly in the browser, reducing server load. Due to its age, it lacks modern JavaScript features, performance optimizations, and official TypeScript support, making it generally unsuitable for new projects. Developers seeking numerical analysis in contemporary JavaScript should consider actively maintained alternatives like `math.js` or `ndarray`.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates fundamental numerical operations: matrix multiplication, generating an identity matrix, solving a linear system of equations, and computing eigenvalues and eigenvectors.

const numeric = require('numeric');

// 1. Matrix Multiplication (dot product)
const A = [[1, 2], [3, 4]];
const B = [[5, 6], [7, 8]];
const C = numeric.dot(A, B);
console.log('Matrix C (A * B):', C); // Expected: [[19, 22], [43, 50]]

// 2. Identity Matrix
const I = numeric.identity(3);
console.log('3x3 Identity Matrix:', I);

// 3. Solving a Linear System (Ax = b)
// A = [[2, 1], [1, 3]], b = [4, 7]
const solve_A = [[2, 1], [1, 3]];
const solve_b = [4, 7];
const x = numeric.solve(solve_A, solve_b);
console.log('Solution x for Ax=b:', x); // Expected: [1, 2]

// 4. Eigenvalues (for a symmetric matrix)
const eigen_matrix = [[2, 0], [0, 3]];
const eigenvalues = numeric.eig(eigen_matrix);
// The real parts of the eigenvalues (lambda.x) and eigenvectors (E.x)
console.log('Eigenvalues (real parts):', eigenvalues.lambda.x); // Expected: [2, 3]
console.log('Eigenvectors (real parts):', eigenvalues.E.x);

view raw JSON →