Add fixed epsilon and lambda variations for bisection method
This commit is contained in:
parent
364b9c998d
commit
59c61e5824
47
Work 1/scripts/bisection_epsilonFixed.m
Normal file
47
Work 1/scripts/bisection_epsilonFixed.m
Normal file
@ -0,0 +1,47 @@
|
||||
%
|
||||
% 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
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
%
|
||||
% Keeping l (accuracy) fix, test the iteration needed for different e
|
||||
% values.
|
||||
% Keeping l (accuracy) fixed, test the iteration needed for different
|
||||
% epsilon values.
|
||||
%
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ k = zeros(1,size);
|
||||
%
|
||||
% * Call the bisection method for each epsilon value for each function and
|
||||
% keep the number of iterations needed.
|
||||
% * Plot the (epsilon, iterations) for each function
|
||||
% * Plot the iterations k(epsilon) for each function
|
||||
%
|
||||
i = 0;
|
||||
for f = funs
|
Loading…
x
Reference in New Issue
Block a user