{"_id":"compute-polynomial","_rev":"7-89bc22b91da282e3f89908d9cf4ba656","name":"compute-polynomial","description":"Evaluates a polynomial.","dist-tags":{"latest":"1.1.0"},"versions":{"0.0.0":{"name":"compute-polynomial","version":"0.0.0","description":"Evaluates a polynomial.","author":{"name":"Athan Reines","email":"kgryte@gmail.com"},"contributors":[{"name":"Athan Reines","email":"kgryte@gmail.com"}],"scripts":{"test":"mocha","test-cov":"istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coverage -- -R spec","coveralls":"istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coveralls/coverage --report lcovonly -- -R spec && cat ./reports/coveralls/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./reports/coveralls"},"main":"./lib","repository":{"type":"git","url":"git://github.com/compute-io/polynomial.git"},"keywords":["compute.io","compute","computation","polynomial","evaluate","horner","polyval","math"],"bugs":{"url":"https://github.com/compute-io/polynomial/issues"},"dependencies":{},"devDependencies":{"chai":"1.x.x","mocha":"1.x.x","coveralls":"^2.11.1","istanbul":"^0.3.0"},"licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/MIT"}],"gitHead":"1c161c4a776fc126d543b1262e43302ba30f4ff2","homepage":"https://github.com/compute-io/polynomial","_id":"compute-polynomial@0.0.0","_shasum":"1cef6dc402a8864a54aff368654909be93b2dda2","_from":".","_npmVersion":"1.5.0-alpha-1","_npmUser":{"name":"kgryte","email":"kgryte@gmail.com"},"maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"}],"dist":{"shasum":"1cef6dc402a8864a54aff368654909be93b2dda2","tarball":"https://registry.npmjs.org/compute-polynomial/-/compute-polynomial-0.0.0.tgz","integrity":"sha512-flZM23oL4M0R+k7k6GVTiApCeQ8YrjL8oofMKZzVpKBXpDX7jRw64ng7YfPZXlGBw/9mTrEz1e3v6tUcEgB3yA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGLIOlwNDGTgsAILWbxOli8A1suCxnUYrmD+HUV5GyulAiBBkwWGPdbN7ptE9YmTQFExM1oHxdwsGhutuHlbxzXHog=="}]}},"1.0.0":{"name":"compute-polynomial","version":"1.0.0","description":"Evaluates a polynomial.","author":{"name":"Athan Reines","email":"kgryte@gmail.com"},"contributors":[{"name":"Athan Reines","email":"kgryte@gmail.com"}],"scripts":{"test":"mocha","test-cov":"istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coverage -- -R spec","coveralls":"istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coveralls/coverage --report lcovonly -- -R spec && cat ./reports/coveralls/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./reports/coveralls"},"main":"./lib","repository":{"type":"git","url":"git://github.com/compute-io/polynomial.git"},"keywords":["compute.io","compute","computation","polynomial","evaluate","horner","polyval","math"],"bugs":{"url":"https://github.com/compute-io/polynomial/issues"},"dependencies":{},"devDependencies":{"chai":"1.x.x","mocha":"1.x.x","coveralls":"^2.11.1","istanbul":"^0.3.0"},"licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/MIT"}],"gitHead":"81eb8ca8a1db414c40fe0837bb3a08f2775e6a1f","homepage":"https://github.com/compute-io/polynomial","_id":"compute-polynomial@1.0.0","_shasum":"73c72d5ed2dca4afbdd66796e5f4e04986885aad","_from":".","_npmVersion":"1.5.0-alpha-1","_npmUser":{"name":"kgryte","email":"kgryte@gmail.com"},"maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"}],"dist":{"shasum":"73c72d5ed2dca4afbdd66796e5f4e04986885aad","tarball":"https://registry.npmjs.org/compute-polynomial/-/compute-polynomial-1.0.0.tgz","integrity":"sha512-A92RTzLWHiLSRIa4py+UyFFo4TiotncquYu8figl0F4vFHTTwjPBK7OzzrZNqvhs6WNVXPh3qOnBP8FPv9ax6w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAz4QBycyXWLJD5Lq+obeEKRSDdr2lRnkN3hr2ERllJLAiBGGVlGmi8YZiFWqV2Xmd0CUZYbsyes5/R+PRwgZixmNQ=="}]}},"1.1.0":{"name":"compute-polynomial","version":"1.1.0","description":"Evaluates a polynomial.","author":{"name":"Athan Reines","email":"kgryte@gmail.com"},"contributors":[{"name":"Athan Reines","email":"kgryte@gmail.com"}],"scripts":{"test":"mocha","test-cov":"istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coverage -- -R spec","coveralls":"istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coveralls/coverage --report lcovonly -- -R spec && cat ./reports/coveralls/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./reports/coveralls"},"main":"./lib","repository":{"type":"git","url":"git://github.com/compute-io/polynomial.git"},"keywords":["compute.io","compute","computation","polynomial","evaluate","horner","horner's rule","polyval","math","mathematics"],"bugs":{"url":"https://github.com/compute-io/polynomial/issues"},"dependencies":{"validate.io-array":"^1.0.3","validate.io-boolean-primitive":"^1.0.0","validate.io-function":"^1.0.2","validate.io-number-primitive":"^1.0.0","validate.io-number-primitive-array":"^1.0.0","validate.io-object":"^1.0.3"},"devDependencies":{"chai":"2.x.x","coveralls":"^2.11.1","istanbul":"^0.3.0","jshint":"2.x.x","jshint-stylish":"^1.0.0","mocha":"2.x.x"},"licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/MIT"}],"gitHead":"f1bc09f215b5713de32be4ea9e1387c484ef0b14","homepage":"https://github.com/compute-io/polynomial#readme","_id":"compute-polynomial@1.1.0","_shasum":"580782e6ca5dcf3c59baecc7fef3f7a23520275e","_from":".","_npmVersion":"2.8.3","_nodeVersion":"0.10.29","_npmUser":{"name":"kgryte","email":"kgryte@gmail.com"},"dist":{"shasum":"580782e6ca5dcf3c59baecc7fef3f7a23520275e","tarball":"https://registry.npmjs.org/compute-polynomial/-/compute-polynomial-1.1.0.tgz","integrity":"sha512-6qSP2fxb+BIVep1CtpjrZUyLgd6vaZXz6Qj4M5yDuwX6VUHh1WHDWYX7LwPuQmQfhTkNWldzZJJe6IHQldNxpA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCE6UXQe5Td/PHV5/KIsnm63P71LtyrmkQuvK4DGBLJzwIgWaeFC2S0zhrgyUhYfec4zRepaA3OaBE6mePqEt+CvxY="}]},"maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"}]}},"readme":"polynomial\n===\n[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependencies][dependencies-image]][dependencies-url]\n\n> Evaluates a polynomial.\n\n\n## Installation\n\n``` bash\n$ npm install compute-polynomial\n```\n\nFor use in the browser, use [browserify](https://github.com/substack/node-browserify).\n\n\n## Usage\n\n``` javascript\nvar polyval = require( 'compute-polynomial' );\n```\n\n\n#### polyval( coef, x[, options] )\n\nEvaluates a polynomial whose coefficients are defined by `coef`. `x` may be either a single `numeric` value or an `array` of values at which to evaluate to the polynomial.\n\nThe coefficients should be ordered in __descending__ degree. For example, for a polynomial\n\n```\na_nx^n + a_(n-1)x^(n-1) + ... + a_1x^1 + a_0x^0\n```\n\nthe coefficients would be\n\n```\n[a_n, a_(n-1),..., a_1, a_0]\n```\n\nConsider the polynomial `4x^3 + 2x^2 + 6x - 17`. To evaluate the polynomial at a single value,\n\n``` javascript\nvar val = polyval( [ 4, 2, 6, -17 ], 10 );\n// returns 4243\n```\n\nTo evaluate the polynomial at multiple values,\n\n``` javascript\nvar vals = polyval( [ 4, 2, 6, -17 ], [ 10, -3 ] );\n// returns [ 4243, -125 ]\n```\n\nWhen provided an input `array`, the function accepts the following `options`:\n\n*\t__copy__: `boolean` indicating whether to return a new `array`. Default: `true`.\n*\t__accessor__: accessor `function` for accessing numeric values in object `arrays`.\n\nTo mutate the input `array` (e.g., when input values can be discarded or when optimizing memory usage), set the `copy` option to `false`.\n\n``` javascript\nvar coefs = [ 4, 2, 6, -17 ],\n\tx = [ 10, -3 ];\n\nvar vals = polyval( coefs, x, {\n\t'copy': false\n});\n// returns [ 4243, -125 ]\n\nconsole.log( x === vals );\n// returns true\n```\n\nFor object `arrays`, provide an accessor `function` for accessing `array` values.\n\n``` javascript\nvar coefs = [ 4, 2, 6, -17 ];\n\nvar data = [\n\t['beep', 10],\n\t['boop', -3]\n];\n\nfunction getValue( d, i ) {\n\treturn d[ 1 ];\n}\n\nvar vals = polyval( coefs, data, {\n\t'accessor': getValue\n});\n// returns [ 4243, -125 ]\n```\n\n\n\n## Examples\n\n``` javascript\nvar polyval = require( 'compute-polynomial' );\n\nvar coef = new Array( 25 ),\n\tsign;\n\nfor ( var i = 0; i < coef.length; i++ ) {\n\tsign = 1;\n\tif ( Math.random()-0.5 < 0 ) {\n\t\tsign = -1;\n\t}\n\tcoef[ i ] = sign * Math.round( Math.random()*i );\n}\n\n// Evaluate the polynomial at a single value:\nconsole.log( polyval( coef, 10 ) );\n\n// Evaluate the polynomial at multiple values:\nconsole.log( polyval( coef, [ 10, -10 ] ) );\n```\n\nTo run the example code from the top-level application directory,\n\n``` bash\n$ node ./examples/index.js\n```\n\n\n## Notes\n\nThis method implements [Horner's rule](http://en.wikipedia.org/wiki/Horner's_method) to achieve efficient computation.\n\n\n## Tests\n\n### Unit\n\nUnit tests use the [Mocha](http://mochajs.org) test framework with [Chai](http://chaijs.com) assertions. To run the tests, execute the following command in the top-level application directory:\n\n``` bash\n$ make test\n```\n\nAll new feature development should have corresponding unit tests to validate correct functionality.\n\n\n### Test Coverage\n\nThis repository uses [Istanbul](https://github.com/gotwarlost/istanbul) as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:\n\n``` bash\n$ make test-cov\n```\n\nIstanbul creates a `./reports/coverage` directory. To access an HTML version of the report,\n\n``` bash\n$ make view-cov\n```\n\n\n---\n## License\n\n[MIT license](http://opensource.org/licenses/MIT). \n\n\n## Copyright\n\nCopyright &copy; 2014-2015. Athan Reines.\n\n\n[npm-image]: http://img.shields.io/npm/v/compute-polynomial.svg\n[npm-url]: https://npmjs.org/package/compute-polynomial\n\n[travis-image]: http://img.shields.io/travis/compute-io/polynomial/master.svg\n[travis-url]: https://travis-ci.org/compute-io/polynomial\n\n[coveralls-image]: https://img.shields.io/coveralls/compute-io/polynomial/master.svg\n[coveralls-url]: https://coveralls.io/r/compute-io/polynomial?branch=master\n\n[dependencies-image]: http://img.shields.io/david/compute-io/polynomial.svg\n[dependencies-url]: https://david-dm.org/compute-io/polynomial\n\n[dev-dependencies-image]: http://img.shields.io/david/dev/compute-io/polynomial.svg\n[dev-dependencies-url]: https://david-dm.org/dev/compute-io/polynomial\n\n[github-issues-image]: http://img.shields.io/github/issues/compute-io/polynomial.svg\n[github-issues-url]: https://github.com/compute-io/polynomial/issues\n","maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"}],"time":{"modified":"2022-06-13T20:31:42.761Z","created":"2014-09-20T02:44:00.233Z","0.0.0":"2014-09-20T02:44:00.233Z","1.0.0":"2014-09-20T02:44:20.222Z","1.1.0":"2015-05-06T03:02:25.653Z"},"homepage":"https://github.com/compute-io/polynomial#readme","keywords":["compute.io","compute","computation","polynomial","evaluate","horner","horner's rule","polyval","math","mathematics"],"repository":{"type":"git","url":"git://github.com/compute-io/polynomial.git"},"contributors":[{"name":"Athan Reines","email":"kgryte@gmail.com"}],"author":{"name":"Athan Reines","email":"kgryte@gmail.com"},"bugs":{"url":"https://github.com/compute-io/polynomial/issues"},"readmeFilename":"README.md"}