import { describe, expect, it } from '@jest/globals'; import { positiveRootLowerBound_LMQ } from '../../../src/roots/root-bounds/lmq/positive-root-lower-bound-lmq.js'; describe('positiveRootLowerBound_LMQ', function() { it('should correctly find bounds of some polynomial roots', function() { let p1 = [2,-3,6,5,-130]; let p2: number[] = []; let p3 = [3]; // real roots at about -2.397918624065303 and 2.8793785310848383 expect(positiveRootLowerBound_LMQ(p1)).toEqual(1.6883241876925903); // real roots everywhere expect(positiveRootLowerBound_LMQ(p2)).toEqual(Infinity); // real roots nowhere expect(positiveRootLowerBound_LMQ(p3)).toEqual(Infinity); }); it('should handle polynomials with a root at 0', function() { // Regression: reversing the polynomial turned trailing zeros into // leading zeros which were not handled expect(positiveRootLowerBound_LMQ([-1, 5, -3, 0])).toEqual(0.3); // roots 0, 0.697..., 4.30... expect(positiveRootLowerBound_LMQ([1, -3, 0])).toEqual(1.5); // roots 0, 3 expect(positiveRootLowerBound_LMQ([1, -3, 0, 0])).toEqual(1.5); // roots 0, 0, 3 expect(positiveRootLowerBound_LMQ([1, 0])).toEqual(Infinity); // no positive roots }); });