This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... snip: a bunch of passing inputs | |
[ 13, 10, 38, 33, 19 ] | |
[ 10, 38, 33, 19 ] | |
[ 6, 10, 38, 33, 19 ] | |
[ 9, 10, 38, 33, 19 ] | |
[ 10, 10, 38, 33, 19 ] | |
[ 10, 38, 33, 19 ] | |
[ 5, 10, 38, 33, 19 ] | |
[ 7, 10, 38, 33, 19 ] | |
[ 8, 10, 38, 33, 19 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const boundedInt = jsc.integer(-MAX_COEFFICIENT, MAX_COEFFICIENT); | |
const polynomialArbitrary = jsc.nearray(boundedInt).smap( | |
Polynomial.create, | |
Polynomial.getCoefficents | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('newton\'s method', () => { | |
it('solves polynomial functions from a guess within 0.5', () => { | |
const solverTest = (polynomial, x) => { | |
if (polynomial.degree <= 0) { | |
return true; // no fun solving constant functions | |
}; | |
// polynomial(x) = y, so we make a new polynomial | |
// polynomialWithZero such that polynomialWithZero(x) = 0 | |
const y = polynomial.evaluate(x); |
OlderNewer