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

Matlab Program For Jacobi Method

This document contains two MATLAB code examples: 1) A MATLAB program that uses Jacobi's iteration method to solve a system of linear equations. It initializes matrices A and B, sets the maximum number of iterations, defines an initial guess vector, and iteratively calculates new values for the solution vector until the norm of the difference between iterations falls below a convergence threshold. 2) A MATLAB function that calculates the nth norm of a vector by raising each element to the nth power, summing the results, and taking the nth root of the sum.

Uploaded by

NASIR HUSSAIN
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)
66 views2 pages

Matlab Program For Jacobi Method

This document contains two MATLAB code examples: 1) A MATLAB program that uses Jacobi's iteration method to solve a system of linear equations. It initializes matrices A and B, sets the maximum number of iterations, defines an initial guess vector, and iteratively calculates new values for the solution vector until the norm of the difference between iterations falls below a convergence threshold. 2) A MATLAB function that calculates the nth norm of a vector by raising each element to the nth power, summing the results, and taking the nth root of the sum.

Uploaded by

NASIR HUSSAIN
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
You are on page 1/ 2

MATLAB PROGRAM FOR JACOBIS

ITERATION METHOD AND NORM OF


ANY ORDER

NASIR HUSSAIN1
KHURRAM SHAHZAD2
1-(MS-FELLOW)PAISTAN INSTITUTE OF ENGINEERING AND APPLIED SCIENCES, NILORE, ISLAMABAD
2-(PHD. STUDENT)PAISTAN INSTITUTE OF ENGINEERING AND APPLIED SCIENCES, NILORE, ISLAMABAD

1)
clc;
A=[10 -1 2 0; -1 11 -1 3; 2 -1 10 -1; 0 3 -1 8]
B=[6; 25; -11; 15]
n=length(B);
x0=[0 ; 0; 0; 0];
x1=[];
s=1000;
conv=1e-10;
for q=1:s
for m=1:n
sum=0;
for k=1:n
if m==k
continue
end
sum=sum+A(m,k)*x0(k);
end
x1(m)=(B(m)-sum)/A(m,m);
x1;
end
if abs(norm(x1)-norm(x0))<=conv
solution=x1;
iter_no=q;
break;
end
for p=1:n
x0(p)=x1(p);
end
end
solution
iter_no

2)
% Any norm of a vector
clc;
nth_val=3;
x=[4 5 6 3];
for k=1:4
y(k)=x(k)^nth_val;
end
sum=0;
for k=1:n
sum=sum+y(k);
end
norm_x=sum^(1/nth_val)

(End of document)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy