View Source GoalSeek (GoalSeek v0.1.0)

Basic implementation of Microsoft Excel's GoalSeek macro, inspired by https://github.com/adam-hanna/goal-seek

Link to this section Summary

Functions

Find the specified numeric result by adjusting and returning a correct input value

Link to this section Functions

Link to this function

seek(goal, function, parameters, independent_variable_idx, options \\ [])

View Source
@spec seek(number(), (... -> number()), list(), integer(), keyword()) ::
  {:error, any()} | {:ok, number()}

Find the specified numeric result by adjusting and returning a correct input value

iex> GoalSeek.seek(5, &Kernel.+/2, [3, 0], 1)
{:ok, 2}

iex> GoalSeek.seek(-10, &:math.pow(&1, 3), [0], 0)
{:ok, -2.15}

iex> GoalSeek.seek(-10, &:math.pow(&1, 3), [0], 0, float_precision: 5)
{:ok, -2.15443}