This repository has been archived on 2022-10-20. You can view files and clone it, but cannot push or open issues or pull requests.
Math/__tests__/horner.ts

19 lines
611 B
TypeScript

import { Horner } from "../horner";
let h = new Horner([2, 17, -11, -153, 29, 304, 52, -96]);
test('Horner.roots', () => {
expect(Horner.roots(h)[0]).toEqual([-1, -1, 2, 2, -3, -8]);
});
test('Horner.functional_value(1)', () => {
expect(h.functional_value(1)).toEqual([2, 19, 8, -145, -116, 188, 240, 144]);
});
test('Horner.functional_value(-3)', () => {
expect(h.functional_value(-3)).toEqual([2, 11, -44, -21, 92, 28, -32, 0]);
});
test('Horner.candidates', () => {
expect(h.candidates()).toEqual([1, -1, 2, -2, 3, -3, 4, -4, 6, -6, 8, -8, 12, -12, 16, -16, 24, -24, 32, -32, 48, -48, 96, -96]);
});