JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 118
  • Score
    100M100P100Q58273F
  • License GPL-3.0

Find a zero of a univariate function.

Package Exports

  • fzero

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fzero) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

fzero

Build Status Coverage Status npm version

Falcon Punch

Find a zero of a univariate function. This is a JavaScript port of Jaroslav Hajek's fzero implementation in Octave.

This is essentially the ACM algorithm 748: Enclosing Zeros of Continuous Functions due to Alefeld, Potra and Shi, ACM Transactions on Mathematical Software, Vol. 21, No. 3, September 1995. Although the workflow should be the same, the structure of the algorithm has been transformed non-trivially; instead of the authors' approach of sequentially calling building blocks subprograms we implement here a FSM version using one interior point determination and one bracketing per iteration, thus reducing the number of temporary variables and simplifying the algorithm structure. Further, this approach reduces the need for external functions and error handling. The algorithm has also been slightly modified.

Usage

$ npm install fzero

To use fzero in Node.js, simply require it: javascript var fzero = require("fzero"); A minified, browserified file dist/fzero.min.js is included for use in the browser. Including this file attaches a fzero object to window: html <script src="dist/fzero.min.js" type="text/javascript"></script> fzero is a function that takes 3 arguments: the function to find the zero of, a lower-bound for the zero, and an upper-bound for the zero. Note: since fzero uses decimal.js for arithmetic, the input function should accept a string input (rather than a JS number). javascript var myFunction = function (x) { Math.cos(Number(x)); }; var lowerBound = 0; var upperBound = 3; var zero = fzero(myFunction, lowerBound, upperBound); Tests

Unit tests are included in test/, and can be run using npm:

$ npm test