{"id":10907,"library":"fmin","title":"Unconstrained Function Minimization","description":"fmin is a JavaScript library designed for unconstrained numerical function minimization, offering implementations of several common optimization algorithms. These include the Nelder-Mead method, Gradient Descent, Wolf Line Search, and the Non-Linear Conjugate Gradient method. Currently at version 0.0.4, the package appears to be largely unmaintained; its last known commit was over eight years ago, indicating an abandoned status. While it originally differentiated itself by providing interactive visualizations and an accompanying blog post to explain the algorithms, these are external to the core npm package. Due to its very early development stage (sub-1.0 version) and prolonged inactivity, users should be aware of potential limitations regarding modern JavaScript compatibility, lack of TypeScript type definitions, and unoptimized performance compared to contemporary alternatives. The project has no clear release cadence, and development seems to have ceased.","status":"abandoned","version":"0.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/benfred/fmin","tags":["javascript","fmin","optimization","Nelder-Mead","Conjudate Gradient"],"install":[{"cmd":"npm install fmin","lang":"bash","label":"npm"},{"cmd":"yarn add fmin","lang":"bash","label":"yarn"},{"cmd":"pnpm add fmin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Primarily a CommonJS module from early development. While ESM `import` might work with bundlers, direct Node.js ESM usage without transpilation could be problematic due to its age and module format.","wrong":"import fmin from 'fmin';","symbol":"fmin (module object)","correct":"const fmin = require('fmin');"},{"note":"The `nelderMead` function is a property of the main `fmin` module object, not a named export. It must be accessed via the imported `fmin` object.","wrong":"import { nelderMead } from 'fmin';","symbol":"nelderMead","correct":"const fmin = require('fmin');\nconst solution = fmin.nelderMead(lossFunction, initialPoint);"},{"note":"Similar to `nelderMead`, `conjugateGradient` is a property of the main `fmin` module object. It's not available as a direct named import.","wrong":"import { conjugateGradient } from 'fmin';","symbol":"conjugateGradient","correct":"const fmin = require('fmin');\nconst solution = fmin.conjugateGradient(lossAndGradientFunction, initialPoint);"}],"quickstart":{"code":"function loss(X) {\n    var x = X[0], y = X[1];\n    return Math.sin(y) * x  + Math.sin(x) * y  +  x * x +  y * y;\n}\n\n// Assuming a CommonJS environment or bundled application\nconst fmin = require('fmin');\n\nconst initialGuess = [-3.5, 3.5];\nconst solution = fmin.nelderMead(loss, initialGuess);\n\nconsole.log(\"Minimum found at:\", solution.x);\nconsole.log(\"Value at minimum:\", solution.fx);\nconsole.log(\"Iterations:\", solution.iterations);","lang":"javascript","description":"Demonstrates how to use the Nelder-Mead algorithm to find the minimum of a simple 2D function, logging the solution and iterations."},"warnings":[{"fix":"Consider more actively maintained numerical optimization libraries for production systems. If used, thoroughly review the code and be prepared to fork or fix issues yourself.","message":"The `fmin` package is largely unmaintained, with its last commit over eight years ago (as of 2026) and remaining at version 0.0.4. This indicates a lack of ongoing support and potential for unaddressed bugs or security vulnerabilities.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Manual type declarations (`.d.ts` files) would need to be created, or explicit `any` types used, compromising type safety.","message":"The package lacks official TypeScript type definitions, which can lead to poorer developer experience and potential type-related errors when integrating into TypeScript projects.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"For performance-critical applications, evaluate contemporary optimization libraries that leverage modern JS features and optimization techniques.","message":"Performance of algorithms may not be optimized for modern JavaScript engines or large-scale optimization problems compared to newer, actively developed libraries. Benchmarking against current alternatives is advisable.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Ensure proper module bundling (e.g., Webpack, Rollup) or use Node.js's CommonJS `require` syntax. For browser environments, ensure your code is bundled to resolve `require` calls.","message":"The library primarily uses CommonJS module syntax, and direct ESM `import` statements might not work as expected in all environments without a bundler or specific Node.js configuration due to its age and early development stage.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure you have `const fmin = require('fmin');` at the top of your CommonJS file, or that your bundler correctly handles the import in an ESM context.","cause":"Attempting to use `fmin` without properly importing or requiring it, or if the module failed to load.","error":"ReferenceError: fmin is not defined"},{"fix":"Verify that `const fmin = require('fmin');` correctly assigns the module's export to the `fmin` variable, and that the `nelderMead` function is indeed available as a property on it. Avoid named imports like `import { nelderMead } from 'fmin';` as it's not a named export.","cause":"The `fmin` object was imported incorrectly, or `nelderMead` property does not exist on the imported object (e.g., due to a failed or partial import).","error":"TypeError: fmin.nelderMead is not a function"},{"fix":"If in a pure ESM environment, you may need a bundler to process `require` statements or investigate dynamic `import()` if feasible. For browser usage, ensure your code is bundled to resolve `require` calls.","cause":"Trying to use CommonJS `require` syntax in an environment that is pure ESM (e.g., a Node.js ESM module without `createRequire` or a browser environment without a bundler).","error":"ReferenceError: require is not defined"}],"ecosystem":"npm"}