0% found this document useful (0 votes)
21 views3 pages

Function: 'La Respuesta Ess'

The document contains definitions for several functions related to solving systems of linear equations: 1) regresiva performs backward substitution on a matrix A and vector b to solve for the variables x. 2) infsup computes the lower and upper triangular matrices (L and U) of A during Gaussian elimination. 3) progresiva performs forward substitution on the matrices L and b to solve for intermediate values, which are then passed to regresiva to solve for x. 4) gauss performs Gaussian elimination on A and b to reduce to upper triangular form. 5) cholezky computes the Cholesky decomposition of A into L such that L*L'=A, then uses pro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views3 pages

Function: 'La Respuesta Ess'

The document contains definitions for several functions related to solving systems of linear equations: 1) regresiva performs backward substitution on a matrix A and vector b to solve for the variables x. 2) infsup computes the lower and upper triangular matrices (L and U) of A during Gaussian elimination. 3) progresiva performs forward substitution on the matrices L and b to solve for intermediate values, which are then passed to regresiva to solve for x. 4) gauss performs Gaussian elimination on A and b to reduce to upper triangular form. 5) cholezky computes the Cholesky decomposition of A into L such that L*L'=A, then uses pro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

function y=regresiva(A,b)

[n,g]=size(A);
c=[A,b];
for k=n:-1:1
s=0;
for p=k+1:n
s=s+c(k,p)*x(p);
end
x(k)=(c(k,n+1)-s)/c(k,k);
y=x';
end
disp ('la respuesta ess')

function x=infsup(A,b)
[n,m]=size(A);
l=zeros(n,n);
u=zeros(n,n);
fori=1:n
l(i,i)=1;
end
fori=1:n
u(1,i)=A(1,i);
end
for k=1:n
for j=k+1:n
m(j,k)=A(j,k)/A(k,k);
l(j,k)=m(j,k);
for r=k+1:n
A(j,r)=A(j,r)-m(j,k)*A(k,r);
end
end
end
for j=2:n
for k=j:n
u(j,k)=A(j,k);
end
end
%no quiero llevar en verano!!!!!!
y=progresiva(l,b);
x=regresiva(u,y);

function y=progresiva(A,b)
[n m]=size(A);
c=[A,b];
for k=1:n
s=0;
for p=1:k-1
s=s+c(k,p)*x(p);
end
x(k)=(c(k,n+1)-s)/c(k,k);
y=x';
end
%disp('la respuesta es');
disp(y);

function x=gauss(A,b)
[n m]=size(A);
c=[A,b];
for r=1:n
fori=r+1:n
t(i,r)=c(i,r)/c(r,r)
for k=r:n+1
c(i,k)=c(i,k)-t(i,r)*c(r,k);
end
end
end
A1=[c(1:n,1:n)]
b1=[c(1:n,n+1)]
regresiva(A1,b1)

function x=cholezky(A,b)
[n m]=size(A);
L=zeros(n,n);
% LT=zeros(n,n);
L(1,1)=(A(1,1)).^(0.5);
fori=2:n
L(i,1)=A(1,i)/L(1,1);
end
for j=2:n
s=0;
for k=1:j-1
s=s+((L(j,k)).^(2));
end
L(j,j)=(A(j,j)-s).^(0.5);
end
%for j=2:+1:k-1
fori=3:n
for j=2:i-1
s=0;
for k=1:j-1

s=s+(L(i,k)*L(j,k));
end
L(i,j)=(A(i,j)-s)/L(j,j);
end
end
T=L';
y=progresiva(L,b);
x=regresiva(T,y);

function y=jacobi(A,b,x)
[n m]=size(A);
fori=1:n
s=0;
for j=1:n
s=s+A(i,j)*x(j);
end
s=s-A(i,i)*x(i);
y(i)=(b(i)-s)/A(i,i);
end

You might also like