Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithm to find the minimum value point of a function

Tags:

algorithm

I would like to find the lowest value of a function with the least number of trials. The function f(x) must have a point with minimum value. Given input x, I can calculate f(x), but not the other direction. I don't have the explicit expression of the function, so it is a blackbox.

I would like to find the input x such that minimizes f(x), with the least number of trials (One trial is when I choose a specific x, and plug it in to get the output). Are there any algorithms to achieve that?

The result doesn't need to be the absolute minimum, since it is derived from a real problem. But it should be less than most of the values.

If the function is constrained to be convex, is there a better way to achieve that?

Thanks!

like image 803
Jarvis Du Avatar asked Jun 10 '15 18:06

Jarvis Du


People also ask

How do you find the minimum value of a function?

If you have the equation in the form of y = ax^2 + bx + c, then you can find the minimum value using the equation min = c - b^2/4a. If you have the equation y = a(x - h)^2 + k and the a term is positive, then the minimum value will be the value of k.

How do you find the minimum and maximum value of a function?

We will set the first derivative of the function to zero and solve for x to get the critical point. If we take the second derivative or f''(x), then we can find out whether this point will be a maximum or minimum. If the second derivative is positive, it will be a minimum value.

How do you find the maximum point of a function?

If you are given the formula y = ax2 + bx + c, then you can find the maximum value using the formula max = c - (b2 / 4a). If you have the equation y = a(x-h)2 + k and the a term is negative, then the maximum value is k.

What is the complexity of finding maximum and minimum value from an array of N values?

Return max and min. Time Complexity is O(n) and Space Complexity is O(1). For each pair, there are a total of three comparisons, first among the elements of the pair and the other two with min and max.


1 Answers

Assuming that the function is convex and the derivative of f(x) exist for all points => there is only one minima. The reason I am stressing the derivative constrain is that in the case when the function looks like two convex functions one next to another at the point of intersection the derivative doesn't exist, but the function is still convex and there are two local minima.

The derivative will have opposite signs to the left and to the right of the minima (the slope changes the directions) You can see a visualization of that here. Having this in mind you can do a simple binary search on your domain to find a point k that satisfies f'(k-e) * f'(k+e) < 0 the smaller you pick e, better the precision of the result. When doing the search let [a,b] be the interval and k=(a+b)/2 you would select left if f'(k)*f'(a) < 0 and right otherwise.

Having f(x), f'(x) = (f(x+e)-f(x))/e, again smaller you pick e, better the precision of the derivative.

like image 141
Alexandru Barbarosie Avatar answered Oct 05 '22 11:10

Alexandru Barbarosie