Numericals - Lab Report 01
Numericals - Lab Report 01
f(x) = x^3 - x - 2
a) Bisection Method
b) False Position Method
c) Fixed Point Iteration Method
d) Newton-Raphson Method
Bisection method
Code:
% Define the function for which you want to find the root
f = @(x) x^3 - x - 2; % Example function f(x) = x^3 - x - 2
fm = f(m);
fn = f(n);
Output:
False Position Method
Code:
% Define the function for which you want to find the root
f = @(x) x^3 - x - 2; % Example function f(x) = x^3 - x - 2
fx = f(X);
fy = f(y);
Output:
Code:
% Initial guess
x0 = input('Enter the initial guess: ');
Output:
Newton-Raphson Method
Code:
% Initial guess
x0 = input('Enter the initial guess: ');
% Newton-Raphson loop
fprintf('Iteration\t x_n\t\t f(x_n)\n'); % Table header
for iter = 1:max_iteration
% Calculate the next approximation using Newton-Raphson formula
x1 = x0 - f(x0) / df(x0);