mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-11 02:12:00 +03:00
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:
parent
ccd9cd8b34
commit
a593254eed
1 changed files with 1 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue