
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This matlab code implements the bisection method to find the square root of a given number. The user sets the interval bounds and the number of iterations, and the code calculates the square root by repeatedly averaging the interval endpoints and checking which endpoint is the root. The process continues until the function value at the new endpoint is less than zero, indicating that the new endpoint is closer to the root than the previous one.
Typology: Exercises
1 / 1
This page cannot be seen from the preview
Don't miss anything!

%% configuração MATLAB format long clc clear close all %% entrada x = -0.75; %%% menor valor do intervalo [x,X] X = -0.25; %%%maior valor do intervalo l = 1; %%%valor limite %% Conta for k = 1:l Y = (x+X)/2; %%f(a) f = x^5-(10/9)x^3+(5/21)x; %%f(y) h = Y^5-(10/9)Y^3+(5/21)Y if f< X = Y; else x = Y; end k = k+1; end Y