0% found this document useful (0 votes)
9 views2 pages

Linear Systems and Newton-Raphson Methods

The document contains two sections of MATLAB code demonstrating numerical methods for solving linear systems and finding roots of functions. The first section implements the Jacobi iteration method for a linear system, while the second section uses the Newton-Raphson method to find a root of a cubic function. Both sections include initialization, decomposition, and iterative processes to arrive at solutions.

Uploaded by

doutvanny06
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Linear Systems and Newton-Raphson Methods

The document contains two sections of MATLAB code demonstrating numerical methods for solving linear systems and finding roots of functions. The first section implements the Jacobi iteration method for a linear system, while the second section uses the Newton-Raphson method to find a root of a cubic function. Both sections include initialization, decomposition, and iterative processes to arrive at solutions.

Uploaded by

doutvanny06
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ដូត វណ្ណី(០៥)

លំ ហាត់ទ១
ី ប្រព័ន្ធសមកា
ី រលីនន្អ រ៊ែ 3 នេរ

#Mathblab code
clear all;
clc;
% Iterative method for linear system Ax = b
% Jacobi iteration : A = D - (E + F)
% Input A and b
A = [4 -1 0;
-1 4 -1;
0 -1 4];
b = [3 2 3]';
n = length(b);
% Decomposition
D = [4 0 0;
0 4 0;
0 0 4];
E = [0 0 0;
-1 0 0;
0 -1 0];
F = [0 -1 0;
0 0 -1;
0 0 0];
% Jacobi matrices
B = inv(D)*b;
MJ = inv(D)*(E + F);
% Initial estimation
x = [0 0 0]';
% Iteration
N = 10;
for k = 1:N
x = B + MJ*x;
end
x
លំ ហាត់ទ២

�#Mathblab code

clear all;
clc;
% Newton-Raphson method

f = @(x) x^3 + 2*x + 1;


df = @(x) 3*x^2 + 2;

% Initial guess in [-1,0]


x = -0.5;

% Iteration
N = 5;
for k = 1:N
x = x - f(x)/df(x);
end

x
#Answer

You might also like