|
- function [a, b, k, n] = fmin_bisection(fun, alpha, beta, epsilon, lambda)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if alpha > beta || 2*epsilon >= lambda || lambda <= 0
- error ('Input criteria not met')
- end
-
-
- a = alpha;
- b = beta;
- n = 0;
-
- k=1;
- while b(k) - a(k) > lambda
-
- mid = (a(k) + b(k)) / 2;
- x_1 = mid - epsilon;
- x_2 = mid + epsilon;
-
-
- k = k + 1;
- if fun(x_1) < fun(x_2)
- a(k) = a(k-1);
- b(k) = x_2;
- else
- a(k) = x_1;
- b(k) = b(k-1);
- end
- end
-
- end
|