First let me explain the problem I'm trying to solve. I'm integrating my code with 3rd party library which does quite complicated financial predictions. For the purposes of this question let's just say I have a blackbox which returns y when I pass in x. Now, what I need to do is find input (x) for a given output (y). Since I know lowest and highest possible input values I wrote the following algorithm:
- define starting input range (minimum input value to maximum input value)
- divide the range into two equal parts and find output for a middle value
- find which half output falls into
- repeat steps 2 and 3 until range is too small to divide any further
This algorithm does the job nicely, I don't see any problems with it. However, is there a faster way to solve this problem?
xandyare strongly correlated (i.e. asxincreases, so doesy), as otherwise your divide and conquer algorithm wouldn't work. Can you confirm this is the case?