Matlab Script To Find Root Using Fixed Point Iteration Method
Matlab Script To Find Root Using Fixed Point Iteration Method
% Initialize variables
validFunction = false;
while ~validFunction
% Step 0: Input the function
user_func = input('Enter the function in terms of x: ', 's');
syms x; % Define symbolic variable
try
func_sym = str2sym(user_func); % Convert string to symbolic expression
func = matlabFunction(func_sym); % Convert symbolic expression to function handle
root = xi;
end
1. Use the MATLAB implementation of fixed-point method to find a root of the function 𝑓(𝑥) = cos(𝑥) − 𝑥 when the initial
guess x0 = 0 and 𝑔(𝑥) = cos(𝑥). Perform the computations until percentage approximate relative error (a(%)) is less than
εs=5%. You are required to fill the following table.
2. Find a root of the function 𝑓(𝑥) = cos(𝑥) − 𝑥 when the initial guess x0 = 0 and . You need to modify the
MATLAB code of gfunc and dgfunc accordingly. Perform the computations until percentage approximate relative error is
less than εs=1%. You are required to fill the following table.