{"id":11470,"library":"numeric","title":"Numeric JavaScript","description":"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`.","status":"abandoned","version":"1.2.6","language":"javascript","source_language":"en","source_url":"https://github.com/sloisel/numeric","tags":["javascript","numeric","analysis","math"],"install":[{"cmd":"npm install numeric","lang":"bash","label":"npm"},{"cmd":"yarn add numeric","lang":"bash","label":"yarn"},{"cmd":"pnpm add numeric","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only. Direct 'import' statements will fail in ESM environments without specific build tool configuration.","wrong":"import numeric from 'numeric';","symbol":"numeric","correct":"const numeric = require('numeric');"},{"note":"In a browser, load the script tag. The library exposes a global 'numeric' object.","symbol":"numeric (browser global)","correct":"<script src=\"path/to/numeric.js\"></script>\n// 'numeric' object is now globally available"},{"note":"This package predates widespread TypeScript adoption and does not ship with its own type definitions. Using it in a TypeScript project requires manual type declarations or a community-maintained `@types` package (if available and up-to-date).","symbol":"Type definitions","correct":"// No official types are shipped. Consider community-maintained @types/numeric or manual declaration."}],"quickstart":{"code":"const numeric = require('numeric');\n\n// 1. Matrix Multiplication (dot product)\nconst A = [[1, 2], [3, 4]];\nconst B = [[5, 6], [7, 8]];\nconst C = numeric.dot(A, B);\nconsole.log('Matrix C (A * B):', C); // Expected: [[19, 22], [43, 50]]\n\n// 2. Identity Matrix\nconst I = numeric.identity(3);\nconsole.log('3x3 Identity Matrix:', I);\n\n// 3. Solving a Linear System (Ax = b)\n// A = [[2, 1], [1, 3]], b = [4, 7]\nconst solve_A = [[2, 1], [1, 3]];\nconst solve_b = [4, 7];\nconst x = numeric.solve(solve_A, solve_b);\nconsole.log('Solution x for Ax=b:', x); // Expected: [1, 2]\n\n// 4. Eigenvalues (for a symmetric matrix)\nconst eigen_matrix = [[2, 0], [0, 3]];\nconst eigenvalues = numeric.eig(eigen_matrix);\n// The real parts of the eigenvalues (lambda.x) and eigenvectors (E.x)\nconsole.log('Eigenvalues (real parts):', eigenvalues.lambda.x); // Expected: [2, 3]\nconsole.log('Eigenvectors (real parts):', eigenvalues.E.x);","lang":"javascript","description":"This quickstart demonstrates fundamental numerical operations: matrix multiplication, generating an identity matrix, solving a linear system of equations, and computing eigenvalues and eigenvectors."},"warnings":[{"fix":"Avoid using 'numeric' for new projects. Consider actively maintained alternatives such as 'math.js', 'ndarray', or specialized scientific computing libraries.","message":"The 'numeric' package is effectively abandoned, with its last update over a decade ago. It lacks active maintenance, bug fixes, security patches, or support for modern JavaScript features and environments.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use CommonJS `require()` syntax (`const numeric = require('numeric');`) in Node.js. For browser environments, load `numeric.js` via a `<script>` tag. If used in an ESM project, a bundler (e.g., Webpack, Rollup) configured to handle CJS modules is required.","message":"As an older package, 'numeric' is built using CommonJS modules. Attempting to import it directly using ES module syntax (`import ... from 'numeric'`) in modern ESM-only environments will result in runtime errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Be aware of floating-point inaccuracies. For sensitive calculations requiring arbitrary precision, use dedicated decimal arithmetic libraries (e.g., `decimal.js`, `big.js`) instead of standard JavaScript numbers, or explore libraries built on `BigInt` (not supported by 'numeric').","message":"JavaScript's `Number` type uses 64-bit floating-point representation (IEEE 754), which inherently leads to precision issues for certain decimal arithmetic (e.g., `0.1 + 0.2 !== 0.3`). This is critical in numerical analysis where exactness is often required.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For operations with very large integers, JavaScript's native `BigInt` type should be used. However, 'numeric' does not support `BigInt`, requiring developers to manage large integer arithmetic outside the library or use a different numerical package.","message":"The JavaScript `Number` type has limitations for representing large integers reliably (up to `Number.MAX_SAFE_INTEGER`). Calculations exceeding this range can lead to silent data corruption or incorrect results.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Install `@types/numeric` if available, or create custom `.d.ts` files to provide type information for the library's functions and objects. This adds maintenance overhead and potential type mismatches.","message":"The library does not provide official TypeScript type definitions. Integrating 'numeric' into a TypeScript project will either require manually writing declaration files (`.d.ts`) or relying on potentially outdated community-maintained `@types/numeric` packages.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure `const numeric = require('numeric');` is at the top of your Node.js file, or that `<script src=\"numeric.js\"></script>` is loaded before your code in a browser. Verify the file path is correct.","cause":"The 'numeric' object was not correctly imported or is not available in the current scope, or the `numeric.js` script failed to load in the browser.","error":"TypeError: numeric.dot is not a function"},{"fix":"For Node.js, ensure `require('numeric')` is used to import the module. For browser usage, confirm the `<script>` tag pointing to `numeric.js` is correctly placed and loaded, and the `numeric` global object is available. Check for typos in variable names.","cause":"The 'numeric' library was not successfully loaded or imported before being used.","error":"ReferenceError: numeric is not defined"},{"fix":"Replace `import numeric from 'numeric';` with `const numeric = require('numeric');`. If you must use ESM syntax, ensure your project is configured for ES Modules (e.g., `\"type\": \"module\"` in `package.json`) and your bundler can handle CJS interoperability.","cause":"Attempting to use ES Module `import` syntax with the CommonJS-only `numeric` package in an environment not configured for ESM or without a bundler to transpile.","error":"SyntaxError: Cannot use import statement outside a module"}],"ecosystem":"npm"}