I am trying to solve the equation f(x) = x^3 + x – 1 , by using Bisection method within the interval [ 0 , 1] , i have succeeded to generate a code to solve this equation but by using " while " function for looping , i need some one to help me to solve it by using " for " function , could any one help me to do that ? the code is :
% Numerical Program to find the roots of % the equation f(x) = x^3 + x – 1 % By using Bisection Method within x = [ 0 , 1 ] , 1st method clear ; clc ; close all a = 0 ; b = 1 ; error = 1e-16 ; while ( b – a )/2 > error % by using " while " function c = ( a + b )/2 fc = c^3 + c – 1 ; if fc < 0 a = c ; else b = c ; end end
Thanks in advance Razi
Best Answer