refactor: extract helper functions from evalGoalSeek

Extracts `solveLinear`, `findBisectionBounds`, and `solveBisection`
helper functions to improve the readability and maintainability
of `evalGoalSeek` within `src/engine/evaluator.ts`. Fixed a CI build failure by removing the unused `fhi` variable in `solveBisection`.

Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
google-labs-jules[bot] 2026-08-26 14:08:53 +00:00
parent ccd9cd8b34
commit a593254eed

View file

@ -539,7 +539,7 @@ function findBisectionBounds(safeEval: SafeEvalFn): Bounds {
}
function solveBisection(safeEval: SafeEvalFn, initialBounds: Bounds): Decimal {
let { lo, hi, flo, fhi } = initialBounds;
let { lo, hi, flo } = initialBounds;
for (let i = 0; i < 100; i++) {
const mid = lo.plus(hi).div(2);
if (hi.minus(lo).abs().lt(new Decimal("1e-10"))) return mid;
@ -550,7 +550,6 @@ function solveBisection(safeEval: SafeEvalFn, initialBounds: Bounds): Decimal {
}
if (flo!.mul(fm).lte(0)) {
hi = mid;
fhi = fm;
} else {
lo = mid;
flo = fm;