47 lines
927 B
Matlab
47 lines
927 B
Matlab
%
|
|
% Keeping epsilon fixed, test the iteration needed for different lambda
|
|
% values.
|
|
%
|
|
|
|
|
|
% Clear workspace and load the functions and region
|
|
clear
|
|
|
|
funGivenEnv;
|
|
|
|
% * epsilon: e = 0.001
|
|
% * lambda: l > 2e = 0.001
|
|
% * dl: A small step away from 2e
|
|
% dl = 0.0001
|
|
% * lambda_max: 0.1
|
|
% * size: 25 points
|
|
|
|
size = 25;
|
|
epsilon = 0.001;
|
|
dl = 0.0001;
|
|
lambda_max= 0.1;
|
|
lambda = linspace(2*epsilon + dl, lambda_max, size);
|
|
k = zeros(1,size);
|
|
|
|
|
|
%
|
|
% * Call the bisection method for each lambda value for each function and
|
|
% keep the number of iterations needed.
|
|
% * Plot the iterations k(lambda) for each function
|
|
%
|
|
i = 0;
|
|
for f = funs
|
|
i = i + 1;
|
|
j = 0;
|
|
for l = lambda
|
|
j = j + 1;
|
|
[a, b, k(j)] = bisection(f, a_0, b_0, epsilon, l);
|
|
end
|
|
subplot(1, 3, i)
|
|
plot(lambda, k, '-b', 'LineWidth', 1.0)
|
|
title(titles(i), 'Interpreter', 'latex')
|
|
xlabel('lambda')
|
|
ylabel('Iterations')
|
|
end
|
|
|
|
|