dichotomy
import { dichotomy } from "https://raw.githubusercontent.com/JOTSR/Denum/master/mod.ts";It takes an expression, an expected result, a variable name, and some options, and returns the value of the variable that makes the expression equal to the expected result Make sure to prepend variable and constants names with "$"
@example
dichotomy('3 * $x', 8) => 2.666666666666667
dichotomy('- ($x ** 2) + 20', 0, 'x', { min: 0 }) => 4.472135954999579
dichotomy('- ($x ** 2) + 20', 0, 'x', { max: 0 }) => -4.472135954999579
dichotomy('$x ** 2 + $cst', 16, 'x', { min: 0, max: 10, precision: 2, constants: new Map().set('cst', 7) }) => 3
dichotomy('Math.cos(2 * $x) + 5', 5 , 'x', {min: 0, max: Math.PI}) => 2.356194490192345
function dichotomy(
expression: string,
expectedResult: number,
x?,
options?: dichotomyOptions,
): number;