title: Objective-c how to implement a "Goal seek" like algorithm, similar to excel?
body: <p>I have a rather complicated equation with a single variable that I would like to vary. T*<em>he goal is to get the equation to equal 0.</em>*</p>
  
  <p>For example:</p>
  
  <pre><code>0 = variable * (complicated equation of constants and exponents)
  </code></pre>
  
  <p>My initial thought was to simply brute force down from some large enough value of variable, but I quickly realized that the number I'm "Goal seeking" may contain a fractional component, so simple integer decrement may not work. </p>
  
  <p>Can someone suggest the correct "Goal seek" algorithm implementation, like excel?</p>
  
  <pre><code>double result = 1;
  double variable = 1000;
  double tempVariable = variable;
  double tolerance = 0.1;
  
  while (abs(result) &gt; tolerance ) {
      variable--;
  
      result = variable * (complicated equation);
  
  };
  </code></pre>
  
  <p>Is there an algorithm I can use to numerically solve the equation that I have?</p>