I need general purpose code in vb.net that finds the variable input to a black box function that returns a goal value within a search tolerance in the fewest steps possible.
For the given inputs:
goal_y = 0.876543210
search_tolerance = 0.00000001
minimum_x = 0
maximum_x = 1
x = some value between minimum_x and maximum_x
Find the value of x that makes:
return_y within search_tolerance of goal_y
return_y = black_box_function(x)
Function black_box_function(ByVal x)
Dim y As Double = Sin(x)
In my planned use, the function is not Sin(x). The actual function that will be used takes a long time to compute so it is important to solve it in the fewest steps possible.
The actual function that will be used does not have any local minimums.
If the solution is outside of the range minimum_x to maximum_x, return an error message.