Codes
Codes
a = 0;
b = 1;
tolerance = 1e-3;
iteration = 1;
maxiterations = 100;
c = (a + b) / 2;
fc = f(c);
if fc == 0
break;
b = c;
else
a = c;
end
iteration = iteration + 1;
end
root = (a + b) / 2;
a = 0;
b = 1;
tolerance = 1e-3;
iteration = 1;
maxiterations = 100;
c = (a + b) / 2;
fa = f(a);
fb = f(b);
fc = f(c);
if fc == 0
break;
b = c;
else
a = c;
end
iteration = iteration + 1;
end
root = c;
x0 = 1;
y0 = 1.2;
h = 0. 01
N = 5;
x_values(1) = x0;
y_values(1) = y0;
for i = 1:N
x = x_values(i);
y = y_values(i);
x_values(i + 1) = x + h;
end
xlabel(‘x’);
ylabel(‘y’);