Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

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;
§
dichotomy(expression: string, expectedResult: number, x?, options?: dichotomyOptions): number
[src]

§Parameters

§
expression: string
[src]
  • The expression to evaluate.
§
expectedResult: number
[src]
  • The result you want to find
§
x? optional
[src]
§
options?: dichotomyOptions optional
[src]
  • dichotomyOptions

§Return Type

§
number
[src]

the value of x that makes the expression equal to the expected result.