summaryrefslogtreecommitdiff
path: root/260/CH3
diff options
context:
space:
mode:
Diffstat (limited to '260/CH3')
-rw-r--r--260/CH3/EX3.1/3_1.sce36
-rw-r--r--260/CH3/EX3.10/3_10.sce54
-rw-r--r--260/CH3/EX3.11/3_11.sce60
-rw-r--r--260/CH3/EX3.12/3_12.sce57
-rw-r--r--260/CH3/EX3.13/3_13.sce54
-rw-r--r--260/CH3/EX3.14/3_14.sce54
-rw-r--r--260/CH3/EX3.15/3_15.sce36
-rw-r--r--260/CH3/EX3.16/3_16.sce34
-rw-r--r--260/CH3/EX3.17/3_17.sce38
-rw-r--r--260/CH3/EX3.18/3_18.sce38
-rw-r--r--260/CH3/EX3.19/3_19.sce90
-rw-r--r--260/CH3/EX3.2/3_2.sce42
-rw-r--r--260/CH3/EX3.3/3_3.sce55
-rw-r--r--260/CH3/EX3.4/3_4.sce45
-rw-r--r--260/CH3/EX3.5/3_5.sce98
-rw-r--r--260/CH3/EX3.6/3_6.sce91
-rw-r--r--260/CH3/EX3.7/3_7.sce93
-rw-r--r--260/CH3/EX3.8/3_8.sce23
-rw-r--r--260/CH3/EX3.9/3_9.sce43
19 files changed, 1041 insertions, 0 deletions
diff --git a/260/CH3/EX3.1/3_1.sce b/260/CH3/EX3.1/3_1.sce
new file mode 100644
index 000000000..f8aa7690e
--- /dev/null
+++ b/260/CH3/EX3.1/3_1.sce
@@ -0,0 +1,36 @@
+//Eg-3.1
+//pg-67
+
+clear
+clc
+
+ // Matrices A and B from set of equations
+for i=1:3
+ if i==1 then
+ a=[1 1 -1;1 2 -0.5;1.5 1 1];
+ b=[5;-1;2];
+ elseif i==2 then
+ a=[-1 2.5 3.5;-1 1 2;.5 1 .5];
+ b=[3;1;1.5];
+ elseif i==3 then
+ a=[1 2 0;1 3 0;2 5 0];
+ b=[3;2.5;1.6];
+end
+//size of A
+ [n,n]=size(a);
+//Augumented matrix
+ auga=[a b];
+//Use of Inbuilt rank function to determine rank of A and AB
+ rank_a=rank(a);
+ rank_auga=rank(auga);
+//Comparing ranks of A,AB,n and determining the type of solution
+ if rank_a==rank_auga&rank_a==n then
+ disp("There exists a Unique Solution")
+ disp(inv(a)*b,"and the solution =")
+ elseif rank_a==rank_auga&rank_a<n then
+ printf('\nInfinite solutions exist for the given set of equations\n\n')
+ elseif rank_a<rank_auga then
+ printf('\nNo solution exists for the given set of equations\n')
+ end
+ end
+ \ No newline at end of file
diff --git a/260/CH3/EX3.10/3_10.sce b/260/CH3/EX3.10/3_10.sce
new file mode 100644
index 000000000..f7677ee53
--- /dev/null
+++ b/260/CH3/EX3.10/3_10.sce
@@ -0,0 +1,54 @@
+//Eg-3.10
+//pg-92
+
+clear
+clc
+
+ //cholesky decomposition
+
+ A=[2 1 0;1 2 1;0 1 2];
+ B=[3.6;6.7;-1.9];
+
+ if A==A' then
+ disp("A is symmetric and we have to check whether it is positive definite or not")
+end
+
+for k=1:3
+ s(k)=det(A(1:k,1:k));
+end
+
+
+j=min(s);
+
+if j>0 then
+ disp("given matrix is positive definite and hence cholesky decomposition can be performed")
+
+[n,n]=size(A);
+summ1=0;
+summ2=0;
+
+for i=1:n
+ summ1=0;
+ for k=1:i-1
+ summ1=summ1+(L(i,k))^2;
+ end
+ L(i,i)=(A(i,i)-summ1)^(1/2);
+ for j=i+1:n
+ summ2=0;
+ for k=1:i-1
+ summ2=summ2+L(i,k)*L(j,k);
+ end
+ L(j,i)=(A(i,j)-summ2)/(L(i,i));
+ end
+end
+
+if L*L'==A then
+ disp("verification was done")
+end
+
+Y=inv(L)*B;
+
+X=inv(L')*Y;
+
+disp(X)
+end \ No newline at end of file
diff --git a/260/CH3/EX3.11/3_11.sce b/260/CH3/EX3.11/3_11.sce
new file mode 100644
index 000000000..7295af7c7
--- /dev/null
+++ b/260/CH3/EX3.11/3_11.sce
@@ -0,0 +1,60 @@
+//Eg-3.11
+//pg-93
+
+clear
+clc
+
+ A=[1 1 -1;1 2 -2;-2 1 1];
+ B=[1;0;1];
+
+
+n=3;
+
+
+matsol=zeros(3,3);//initialising matrix matsol
+Z=A;
+Y=B;
+I=[1 0 0;0 1 0;0 0 1];//creates an identity matrix of size n*n
+X=zeros(3,1);
+inverse=zeros(3,3);
+ABI=zeros(3,7);
+ABI(:,:)=[A(:,:) B(:,:) I(:,:)];//augumented matrix of A,B,I
+ for k=1:n//proceeds from 1st row to the last row
+ u=k;
+ big=abs(ABI(k,k));
+ for t=k+1:n //this loop is for selecting the elementhaving max absolute value in a column
+ dummy=abs(ABI(t,k));
+ if dummy>big then
+ big=dummy;
+ u=t;
+ end
+ end
+ if u~=k then
+ for j=1:2*n+1//interchanging rows to make max absolute element as pivot
+ dummy=ABI(u,j);
+ ABI(u,j)=ABI(k,j);
+ ABI(k,j)=dummy;
+ end
+ end
+ pivot=ABI(k,k);
+
+
+ ABI(k,:)=ABI(k,:)/pivot;
+
+ for i=1:n
+ if i~=k;
+ factor=ABI(i,k);
+ ABI(i,:)=ABI(i,:)-ABI(k,:)*factor;
+ end
+ end
+ X(:,:)=[ABI(:,n+1)];//determining X using augumented matrix
+
+ matsol=inv(Z)*Y;//using matlab inbuilt functions to get X
+
+end
+
+disp("result")
+disp(X)
+
+
+ \ No newline at end of file
diff --git a/260/CH3/EX3.12/3_12.sce b/260/CH3/EX3.12/3_12.sce
new file mode 100644
index 000000000..d5cf922be
--- /dev/null
+++ b/260/CH3/EX3.12/3_12.sce
@@ -0,0 +1,57 @@
+//Eg-3.12
+//pg-100
+
+clear
+clc
+
+ A=[6 15 55 ;15 55 225;55 225 979];
+ B=[74.5;262.3;1078.1];
+
+
+n=3;
+
+
+matsol=zeros(3,3);//initialising matrix matsol
+Z=A;
+Y=B;
+I=[1 0 0;0 1 0;0 0 1];//creates an identity matrix of size n*n
+X=zeros(3,1);
+inverse=zeros(3,3);
+ABI=zeros(3,7);
+ABI(:,:)=[A(:,:) B(:,:) I(:,:)];//augumented matrix of A,B,I
+ for k=1:n//proceeds from 1st row to the last row
+ u=k;
+ big=abs(ABI(k,k));
+ for t=k+1:n //this loop is for selecting the elementhaving max absolute value in a column
+ dummy=abs(ABI(t,k));
+ if dummy>big then
+ big=dummy;
+ u=t;
+ end
+ end
+ if u~=k then
+ for j=1:2*n+1//interchanging rows to make max absolute element as pivot
+ dummy=ABI(u,j);
+ ABI(u,j)=ABI(k,j);
+ ABI(k,j)=dummy;
+ end
+ end
+ pivot=ABI(k,k);
+
+
+ ABI(k,:)=ABI(k,:)/pivot;
+
+ for i=1:n
+ if i~=k;
+ factor=ABI(i,k);
+ ABI(i,:)=ABI(i,:)-ABI(k,:)*factor;
+ end
+ end
+ X(:,:)=[ABI(:,n+1)];//determining X using augumented matrix
+
+ matsol=inv(Z)*Y;//using matlab inbuilt functions to get X
+
+end
+
+disp("Coefficients of parabola")
+disp(X) \ No newline at end of file
diff --git a/260/CH3/EX3.13/3_13.sce b/260/CH3/EX3.13/3_13.sce
new file mode 100644
index 000000000..1f0bc748b
--- /dev/null
+++ b/260/CH3/EX3.13/3_13.sce
@@ -0,0 +1,54 @@
+//Eg-3.13
+//pg-102
+
+clear
+clc
+
+ A=[1 1 -1;1 2 -2;-2 1 1];
+ B=[1;0;1];
+
+n=3;
+
+Z=A;
+Y=B;
+I=[1 0 0;0 1 0;0 0 1];//creates an identity matrix of size n*n
+X=zeros(3,1);
+inverse=zeros(3,3);
+ABI=zeros(3,7);
+ABI(:,:)=[A(:,:) B(:,:) I(:,:)];//augumented matrix of A,B,I
+ for k=1:n//proceeds from 1st row to the last row
+ u=k;
+ big=abs(ABI(k,k));
+ for t=k+1:n //this loop is for selecting the elementhaving max absolute value in a column
+ dummy=abs(ABI(t,k));
+ if dummy>big
+ big=dummy;
+ u=t;
+ end
+ end
+ if u~=k
+ for j=1:2*n+1//interchanging rows to make max absolute element as pivot
+ dummy=ABI(u,j);
+ ABI(u,j)=ABI(k,j);
+ ABI(k,j)=dummy;
+ end
+ end
+ pivot=ABI(k,k);
+
+ ABI(k,:)=ABI(k,:)/pivot;
+
+ for i=1:n
+ if i~=k;
+ factor=ABI(i,k);
+ ABI(i,:)=ABI(i,:)-ABI(k,:)*factor;
+
+ end
+ end
+ X(:,:)=[ABI(:,n+1)];//determining X using augumented matrix
+ inverse(:,:)=[ABI(:,n+2:2*n+1)];//calculating inverse using augmented matrix
+end
+
+
+ disp("result")
+ disp(inverse)
+ \ No newline at end of file
diff --git a/260/CH3/EX3.14/3_14.sce b/260/CH3/EX3.14/3_14.sce
new file mode 100644
index 000000000..54441692d
--- /dev/null
+++ b/260/CH3/EX3.14/3_14.sce
@@ -0,0 +1,54 @@
+//Eg-3.14
+//pg-108
+
+clear
+clc
+
+ A=[1 -1 1;2 -2 3;1 5 -3];
+ B=[4;6;7];
+
+n=3;
+
+Z=A;
+Y=B;
+I=[1 0 0;0 1 0;0 0 1];//creates an identity matrix of size n*n
+X=zeros(3,1);
+inverse=zeros(3,3);
+ABI=zeros(3,7);
+ABI(:,:)=[A(:,:) B(:,:) I(:,:)];//augumented matrix of A,B,I
+ for k=1:n//proceeds from 1st row to the last row
+ u=k;
+ big=abs(ABI(k,k));
+ for t=k+1:n //this loop is for selecting the elementhaving max absolute value in a column
+ dummy=abs(ABI(t,k));
+ if dummy>big
+ big=dummy;
+ u=t;
+ end
+ end
+ if u~=k
+ for j=1:2*n+1//interchanging rows to make max absolute element as pivot
+ dummy=ABI(u,j);
+ ABI(u,j)=ABI(k,j);
+ ABI(k,j)=dummy;
+ end
+ end
+ pivot=ABI(k,k);
+
+ ABI(k,:)=ABI(k,:)/pivot;
+
+ for i=1:n
+ if i~=k;
+ factor=ABI(i,k);
+ ABI(i,:)=ABI(i,:)-ABI(k,:)*factor;
+
+ end
+ end
+ X(:,:)=[ABI(:,n+1)];//determining X using augumented matrix
+ inverse(:,:)=[ABI(:,n+2:2*n+1)];//calculating inverse using augmented matrix
+end
+
+
+ disp("result")
+ disp(inverse)
+ \ No newline at end of file
diff --git a/260/CH3/EX3.15/3_15.sce b/260/CH3/EX3.15/3_15.sce
new file mode 100644
index 000000000..a0c967936
--- /dev/null
+++ b/260/CH3/EX3.15/3_15.sce
@@ -0,0 +1,36 @@
+//Eg-3.15
+//pg-109
+
+clear
+clc
+
+ A=[4 3 0 0;3 3.4 1.7 0;0 1.7 -1.3 0.9;0 0 0.9 2 ];
+ b=[4;3.4;-1.3;2];
+ c=[3;1.7;0.9];
+ a=[3;1.7;0.9];
+ r=[19.7;58.3;33.1;27.6];
+
+ n=4;
+ Beta=zeros(4,1);
+ Gamma=zeros(4,1);
+
+ Beta(1)=b(1);
+ Gamma(1)=r(1)/Beta(1);
+
+ for j=2:4
+ Beta(j)=b(j)-a(j-1)*c(j-1)/Beta(j-1);
+ end
+
+ for j=2:4
+ Gamma(j)=(r(j)-a(j-1)*Gamma(j-1))/Beta(j);
+ end
+
+ X=zeros(4,1);
+
+ X(4)=Gamma(4);
+ X(3)=Gamma(3)-c(3)*X(4)/Beta(3);
+ X(2)=Gamma(2)-c(2)*X(3)/Beta(2);
+ X(1)=Gamma(1)-c(1)*X(2)/Beta(1);
+
+ disp("result")
+ disp(X) \ No newline at end of file
diff --git a/260/CH3/EX3.16/3_16.sce b/260/CH3/EX3.16/3_16.sce
new file mode 100644
index 000000000..5a44f6bb8
--- /dev/null
+++ b/260/CH3/EX3.16/3_16.sce
@@ -0,0 +1,34 @@
+//Eg-3.16
+//pg-113
+
+clear
+clc
+
+ A=[3.6 2.1 0;0.6 7.9 1.6;0 1.3 13.4 ];
+ b=[3.6;7.9;13.4];
+ c=[2.1;1.6];
+ a=[0.6;1.3];
+ r=[-.7;1.1;2.9];
+
+ n=3;
+ Beta=zeros(3,1);
+ Gamma=zeros(3,1);
+ Beta(1)=b(1);
+ Gamma(1)=r(1)/Beta(1);
+
+ for j=2:3
+ Beta(j)=b(j)-a(j-1)*c(j-1)/Beta(j-1);
+ end
+
+ for j=2:3
+ Gamma(j)=(r(j)-a(j-1)*Gamma(j-1))/Beta(j);
+ end
+
+ X=zeros(3,1);
+
+ X(3)=Gamma(3);
+ X(2)=Gamma(2)-c(2)*X(3)/Beta(2);
+ X(1)=Gamma(1)-c(1)*X(2)/Beta(1);
+
+ disp("result")
+ disp(X) \ No newline at end of file
diff --git a/260/CH3/EX3.17/3_17.sce b/260/CH3/EX3.17/3_17.sce
new file mode 100644
index 000000000..6f2dd870b
--- /dev/null
+++ b/260/CH3/EX3.17/3_17.sce
@@ -0,0 +1,38 @@
+//Eg-3.17
+//pg-114
+
+clear
+clc
+
+ A=[-3.5 1 1.5;1 4 -1;-2 -.6 -3.5];
+ B=[2.5;4;-16];
+
+ es=10^-5;
+ imax=10;
+ [r,c] = size(A)
+ n = r;
+ X=[0;0;0];
+
+ iter=1;
+ lambda=1;
+
+ while iter<imax//condition for termination
+ for i=1:n
+ summ=B(i);
+ pivot=A(i,i);
+ if pivot==0
+ error('gsie not applicable');//to avoid a/0 forms
+ end
+ old=X(i);
+ for j=1:n
+ if i~=j
+ summ=summ-A(i,j)*X(j);
+ end
+ end
+ X(i)=(lambda*summ/pivot)+(1-lambda)*old;//relaxation
+ end
+ iter=iter+1;
+end
+
+disp("Solution after 10 iterations")
+disp(X) \ No newline at end of file
diff --git a/260/CH3/EX3.18/3_18.sce b/260/CH3/EX3.18/3_18.sce
new file mode 100644
index 000000000..5b97f3187
--- /dev/null
+++ b/260/CH3/EX3.18/3_18.sce
@@ -0,0 +1,38 @@
+//Eg-3.18
+//pg-119
+
+clear
+clc
+
+ A=[1.11 -.55 0;-.55 2.44 -.66;0 0 1];
+ B=[-93.33;213.34;-25];
+
+ es=10^-5;
+ imax=10;
+
+ X=[0;0;0];
+ [r,c] = size(A)
+ n = r;
+ iter=1;
+ lambda=1;
+
+ while iter<imax//condition for termination
+ for i=1:n
+ summ=B(i);
+ pivot=A(i,i);
+ if pivot==0
+ error('gsie not applicable');//to avoid a/0 forms
+ end
+ old=X(i);
+ for j=1:n
+ if i~=j
+ summ=summ-A(i,j)*X(j);
+ end
+ end
+ X(i)=(lambda*summ/pivot)+(1-lambda)*old;//relaxation
+ end
+ iter=iter+1;
+end
+
+disp("Solution after 10 iterations")
+disp(X) \ No newline at end of file
diff --git a/260/CH3/EX3.19/3_19.sce b/260/CH3/EX3.19/3_19.sce
new file mode 100644
index 000000000..ab41a657c
--- /dev/null
+++ b/260/CH3/EX3.19/3_19.sce
@@ -0,0 +1,90 @@
+//Eg-3.19
+//pg-123
+
+clear
+clc
+
+ A=[4 2 0;0.5 1 .5;0 3 3];
+ B=[2.3;1.1;14];
+
+ es=10^-7;
+ imax=100;
+
+ X=[0;0;0];
+
+ iter=1;
+ lambda=1;
+ [r,c] = size(A)
+ n = r;
+
+ errorcheck=1;
+
+ //Gauss-Seidel Method
+ while errorcheck==1//condition for termination
+ for i=1:n
+ summ=B(i);
+ pivot=A(i,i);
+ if pivot==0
+ error('gsie not applicable');//to avoid a/0 forms
+ end
+ old=X(i);
+ for j=1:n
+ if i~=j
+ summ=summ-A(i,j)*X(j);
+ end
+ end
+ X(i)=(lambda*summ/pivot)+(1-lambda)*old;//relaxation
+ if X(i)~=0 then
+ AbsErr=abs((X(i)-old)/X(i))*100;//absolute error
+ else
+ output=('error cannot be computed')//since xi cant be equal to zero
+ end
+ if AbsErr<es
+ errorcheck=2;
+ end
+ end
+ iter=iter+1;
+end
+
+disp("solution Vector")
+disp(X)
+disp("iterations required for gauss siedel")
+disp(iter)
+
+iter=1;
+lambda=1.5;
+errorcheck=1;
+X=[0;0;0];
+//Gauss Siedel method with SOR
+while errorcheck==1//condition for termination
+ for i=1:n
+ summ=B(i);
+ pivot=A(i,i);
+ if pivot==0
+ error('gsie not applicable');//to avoid a/0 forms
+ end
+ old=X(i);
+ for j=1:n
+ if i~=j
+ summ=summ-A(i,j)*X(j);
+ end
+ end
+ X(i)=(lambda*summ/pivot)+(1-lambda)*old;//relaxation
+ if errorcheck==1&X(i)~=0 then
+ AbsErr=abs((X(i)-old)/X(i))*100;//absolute error
+ else
+ output=('error cannot be computed')//since xi cant be equal to zero
+ end
+ if AbsErr<es
+ errorcheck=2;
+ end
+ end
+ iter=iter+1;
+end
+
+disp("solution Vector")
+disp(X)
+disp("iterations required for gauss siedel with SOR")
+disp(iter)
+
+disp("these results indicate how the convergence is expedited by over-relaxation") \ No newline at end of file
diff --git a/260/CH3/EX3.2/3_2.sce b/260/CH3/EX3.2/3_2.sce
new file mode 100644
index 000000000..f1673aa33
--- /dev/null
+++ b/260/CH3/EX3.2/3_2.sce
@@ -0,0 +1,42 @@
+//Eg-3.2
+//pg-69
+
+clear
+clc
+
+
+ // Matrices A and B (AX=B)
+ a=[1 1 -1;1 2 -2;-2 1 1];
+ [n,n]=size(a);
+ b=[1;0;1];
+
+ //Augumented matrix of A and B
+ auga=[a b];
+
+ //Algorithm of Naive gauss elimination
+ //Forward elimination
+ for k=1:n-1
+ for i=(k+1):n
+ factr=auga(i,k)/auga(k,k);
+ auga(i,:)=auga(i,:)-factr*auga(k,:);
+ end
+ end
+
+ //Initializing X
+ X=zeros(n,1);
+
+ //Backward substitution
+ X(n)=auga(n,n+1)/auga(n,n);
+ for i=(n-1):-1:1
+ summ=auga(i,n+1);
+ for j=(i+1):n
+ summ=summ-auga(i,j)*X(j);
+ end
+ X(i)=summ/auga(i,i);
+ end
+ //Displaying Solution
+ disp(X(1),"x0=")
+ disp(X(2),"x1=")
+ disp(X(3),"x2=")
+
+ \ No newline at end of file
diff --git a/260/CH3/EX3.3/3_3.sce b/260/CH3/EX3.3/3_3.sce
new file mode 100644
index 000000000..68721a5af
--- /dev/null
+++ b/260/CH3/EX3.3/3_3.sce
@@ -0,0 +1,55 @@
+//Eg-3.3
+//pg-71
+
+clear
+clc
+
+// Matrix dimensions for a 3*3 coefficient matrix
+ n=3;
+
+ //First pass
+ k=0;
+
+ //Number of divisions per pass i.e for a particular value of 'k'
+ ndiv=n-k-1;
+
+ //Number of multiplications
+ nmul=(n-k)*(n-k-1);
+
+ //Total number of multiplications and divisions
+ ntot=nmul+ndiv;
+
+ //Displaying result
+disp("total number of divisions and multiplications from formulae derived")
+disp(ntot)
+
+//Verifying result from example 3.2 by taking k=1(first pass)
+// Matrices A and B (AX=B)
+ a=[1 1 -1;1 2 -2;-2 1 1];
+ [n,n]=size(a);
+ b=[1;0;1];
+
+ //Augumented matrix of A and B
+ auga=[a b];
+
+ //initialising nm(no of multiplications),nd(no. of divisions)
+nd=0;
+nm=0;
+
+ //Forward elimination
+ for k=1//only first pass is considered
+ for i=(k+1):n
+ factr=auga(i,k)/auga(k,k);
+ nd=nd+1;
+ auga(i,:)=auga(i,:)-factr*auga(k,:);
+ nm=nm+3;//since each row has 3 elements of A,hence 3 multiplications
+ end
+ end
+
+ //Total number of divisions and multiplications
+ nt=nd+nm;
+
+ //Verifying result
+ disp("total number of divisions and multiplications from code of example 3.2")
+ disp(nt)
+ disp("both are same") \ No newline at end of file
diff --git a/260/CH3/EX3.4/3_4.sce b/260/CH3/EX3.4/3_4.sce
new file mode 100644
index 000000000..dc05f6003
--- /dev/null
+++ b/260/CH3/EX3.4/3_4.sce
@@ -0,0 +1,45 @@
+//Eg-3.4
+//pg-74
+
+clear
+clc
+
+ // Matrices A and B (AX=B)...given by 3 sets of material balance equations
+ a=[.8 .02 .06;.1 .83 .12;.1 .15 .82];
+ [n,n]=size(a);
+ b=[50;30;20];
+
+ //Augumented matrix of A and B
+ auga=[a b];
+
+ //Algorithm of Naive gauss elimination
+ //Forward elimination
+ for k=1:n-1
+ for i=(k+1):n
+ factr=auga(i,k)/auga(k,k);
+ auga(i,:)=auga(i,:)-factr*auga(k,:);
+ end
+ end
+
+ //Initializing X
+ X=zeros(n,1);
+
+ //Backward substitution
+ X(n)=auga(n,n+1)/auga(n,n);
+ for i=(n-1):-1:1
+ summ=auga(i,n+1);
+ for j=(i+1):n
+ summ=summ-auga(i,j)*X(j);
+ end
+ X(i)=summ/auga(i,i);
+ end
+
+//Resuts
+P=X(1);
+Q=X(2);
+R=X(3);
+
+//Displaying results
+disp(P,"P=")
+disp(Q,"Q=")
+disp(R,"R=") \ No newline at end of file
diff --git a/260/CH3/EX3.5/3_5.sce b/260/CH3/EX3.5/3_5.sce
new file mode 100644
index 000000000..1da48aad0
--- /dev/null
+++ b/260/CH3/EX3.5/3_5.sce
@@ -0,0 +1,98 @@
+//Eg-3.5
+//pg-78
+
+clear
+clc
+
+ // Matrices A and B (AX=B)
+ A=[-4 1 0 0 0 1;3 -7 2 0 2 0;0 4 -7 3 0 0;0 0 1 -5 4 0;0 2 0 6 -11 3;3 0 0 0 3 -8];
+ [n,n]=size(A);
+ B=[-130;0;0;0;0;0];
+
+ //Initialising Permutation matrix(which keeps note of column changes in this code) as Identity matrix
+ P=eye(n);
+
+ //Algorithm of gauss elimination with complete pivoting
+
+ //COMPLETE PIVOTING(both rows and columns)
+ //loop from 1 to n-1 pivot elements
+ for k=1:n-1
+ u=k;
+ l=k;
+ big=abs(A(k,k));
+ //Obtaining max absolute element and its position/index in column
+ for t=k+1:n
+ dummy=abs(A(t,k));
+ if dummy>big
+ big=dummy;
+ u=t;
+ end
+ end
+ //Obtaining max absolute element and its position/index in row
+ for t=k+1:n
+ dummy=abs(A(k,t));
+ if dummy>big
+ big=dummy;
+ l=t;
+ end
+end
+//Row and Column interchanges according to index of maximum absolute element obtained
+ if l~=k
+ for j=1:n//column interchanges
+ dummy=A(j,l);
+ A(j,l)=A(j,k);
+ A(j,k)=dummy;
+ temp=P(j,l);//column interchanges are noted with the help of a permutation matrix
+ P(j,l)=P(j,k);
+ P(j,k)=temp;
+ end
+ elseif u~=k
+ for j=1:n//row interchanges
+ dummy=A(u,j);
+ A(u,j)=A(k,j);
+ A(k,j)=dummy;
+ end
+ temp=B(u);//B rows are also interchanged according to A row interchanges
+ B(u)=B(k);
+ B(k)=temp;
+ end
+
+//Forward Elimination
+ for i=(k+1):n
+ facotr=A(i,k)/A(k,k);
+ for j=1:n
+ A(i,j)=A(i,j)-facotr*A(k,j);
+ end
+ B(i)=B(i)-facotr*B(k);
+ end
+ end
+
+ //Backward Substitution
+ X=zeros(n,1);
+ X(n)=B(n)/A(n,n);
+ for i=(n-1):-1:1
+ summ=B(i);
+ for j=(i+1):n
+ summ=summ-A(i,j)*X(j);
+ end
+ X(i)=summ/A(i,i);
+ end
+ //Column interchanges in A correspond to row interchanges in X which can be cancelled out by multiplying with the permutation matrix defined above
+ X=P*X;
+
+ //Result
+ v1=X(1);
+ v2=X(2);
+ v3=X(3);
+ v4=X(4);
+ v5=X(5);
+ v6=X(6);
+
+ //Displaying Results
+ disp(v1,"v1=")
+ disp(v2,"v2=")
+ disp(v3,"v3=")
+ disp(v4,"v4=")
+ disp(v5,"v5=")
+ disp(v6,"v6=")
+ \ No newline at end of file
diff --git a/260/CH3/EX3.6/3_6.sce b/260/CH3/EX3.6/3_6.sce
new file mode 100644
index 000000000..d6597592b
--- /dev/null
+++ b/260/CH3/EX3.6/3_6.sce
@@ -0,0 +1,91 @@
+//Eg-3.6
+//pg-80
+
+clear
+clc
+
+ //Matrices A and B
+ A=[1 1 -1;1 2 -2;-2 1 1];
+ B=[1;0;1];
+[n,n]=size(A);
+
+//Permutation,Lower triangular matrix initialisation
+P=eye(n);
+L=zeros(n,n);
+
+//Algorithm of LU decomposition to find L,U,P and X
+//Partial Pivoting
+ for k=1:n-1
+ u=k;
+ big=abs(A(k,k));
+ for t=k+1:n
+ dummy=abs(A(t,k));
+ if dummy>big//Finidng max absolute element
+ big=dummy;
+ u=t;//Index of max ansolute element
+ end
+ end
+ if u~=k
+ for j=1:n
+ dummy=A(u,j);//Interchanging rows of A
+ A(u,j)=A(k,j);
+ A(k,j)=dummy;
+
+ dummy=L(u,j);//interchanging rows of lowertriangular matrix according to A
+ L(u,j)=L(k,j);
+ L(k,j)=dummy;
+ end
+ dummy=B(u);//interchanging rows of B matrix
+ B(u)=B(k);
+ B(k)=dummy;
+ end
+
+ //forward elimination to get U and sending corresponding factors to L
+ for i=(k+1):n
+ facotr=A(i,k)/A(k,k);
+ for j=1:n
+ A(i,j)=A(i,j)-facotr*A(k,j);
+ U=A;//upper triangular matrix
+ end
+ for j=k
+ L(i,j)=facotr;//factors are transformed to lower triangular matrix
+ end
+
+ end
+ end
+
+ //Lower triangular matrix
+ for s=1:n
+ L(s,s)=1;
+ end
+
+ //Initialisation of D,X
+ D=zeros(n,1);
+ X=zeros(n,1);
+
+ //Forward Substitution Ld=B..we get d here
+ D(1)=B(1)/L(1,1);
+ for i=2:n
+ summ=B(i);
+ for j=1:i-1
+ summ=summ-L(i,j)*D(j);
+ end
+ D(i)=summ/L(i,i);
+ end
+
+ //Backward substitution Ux=B gives X
+ X(n)=D(n)/U(n,n);
+ for i=(n-1):-1:1
+ summ=D(i);
+ for j=(i+1):n
+ summ=summ-U(i,j)*X(j);
+ end
+ X(i)=summ/U(i,i);
+ end
+
+//Displaying results
+disp(X(1),"x0=")
+disp(X(2),"x1=")
+disp(X(3),"x2=")
+
+ \ No newline at end of file
diff --git a/260/CH3/EX3.7/3_7.sce b/260/CH3/EX3.7/3_7.sce
new file mode 100644
index 000000000..2691b2075
--- /dev/null
+++ b/260/CH3/EX3.7/3_7.sce
@@ -0,0 +1,93 @@
+//Eg-3.7
+//pg-86
+
+clear
+clc
+
+ //Matrices A and B
+ A=[-0.41 0.58 1 0 0;0.41 0.58 0 1 0;-.82 -.58 0 0 1;.82 .58 0 0 0;-.82 .58 0 0 0];;
+ B=[0;3;0;6.25;0];
+[n,n]=size(A);
+
+//Permutation,Lower triangular matrix initialisation
+P=eye(n);
+L=zeros(n,n);
+
+//Algorithm of LU decomposition to find L,U,P and X
+//Partial Pivoting
+ for k=1:n-1
+ u=k;
+ big=abs(A(k,k));
+ for t=k+1:n
+ dummy=abs(A(t,k));
+ if dummy>big//Finidng max absolute element
+ big=dummy;
+ u=t;//Index of max ansolute element
+ end
+ end
+ if u~=k
+ for j=1:n
+ dummy=A(u,j);//Interchanging rows of A
+ A(u,j)=A(k,j);
+ A(k,j)=dummy;
+
+ dummy=L(u,j);//interchanging rows of lowertriangular matrix according to A
+ L(u,j)=L(k,j);
+ L(k,j)=dummy;
+ end
+ dummy=B(u);//interchanging rows of B matrix
+ B(u)=B(k);
+ B(k)=dummy;
+ end
+
+ //forward elimination to get U and sending corresponding factors to L
+ for i=(k+1):n
+ facotr=A(i,k)/A(k,k);
+ for j=1:n
+ A(i,j)=A(i,j)-facotr*A(k,j);
+ U=A;//upper triangular matrix
+ end
+ for j=k
+ L(i,j)=facotr;//factors are transformed to lower triangular matrix
+ end
+
+ end
+ end
+
+ //Lower triangular matrix
+ for s=1:n
+ L(s,s)=1;
+ end
+
+ //Initialisation of D,X
+ D=zeros(n,1);
+ X=zeros(n,1);
+
+ //Forward Substitution Ld=B..we get d here
+ D(1)=B(1)/L(1,1);
+ for i=2:n
+ summ=B(i);
+ for j=1:i-1
+ summ=summ-L(i,j)*D(j);
+ end
+ D(i)=summ/L(i,i);
+ end
+
+ //Backward substitution Ux=B gives X
+ X(n)=D(n)/U(n,n);
+ for i=(n-1):-1:1
+ summ=D(i);
+ for j=(i+1):n
+ summ=summ-U(i,j)*X(j);
+ end
+ X(i)=summ/U(i,i);
+ end
+
+//Displaying results
+disp(X(1),"F0=")
+disp(X(2),"F1=")
+disp(X(3),"F2=")
+disp(X(4),"F3=")
+disp(X(5),"F4=")
+
+ \ No newline at end of file
diff --git a/260/CH3/EX3.8/3_8.sce b/260/CH3/EX3.8/3_8.sce
new file mode 100644
index 000000000..fb2abfa35
--- /dev/null
+++ b/260/CH3/EX3.8/3_8.sce
@@ -0,0 +1,23 @@
+//Eg-3.8
+//pg-87
+
+clear
+clc
+
+//checking whether cholesky decomposition can be performed on a matrix
+
+A=[1 0.5 0;.5 1 0.5;0 .5 1];
+if A==A' then
+ printf('The matrix A is symmetric and we have to check whether it is positive definite or not.\n')
+end
+
+for k=1:3
+ s(k)=det(A(1:k,1:k));
+end
+
+
+j=min(s);
+
+if j>0 then
+ printf('\n Given matrix is positive definite and hence cholesky decomposition can be performed\n')
+end \ No newline at end of file
diff --git a/260/CH3/EX3.9/3_9.sce b/260/CH3/EX3.9/3_9.sce
new file mode 100644
index 000000000..3794e2167
--- /dev/null
+++ b/260/CH3/EX3.9/3_9.sce
@@ -0,0 +1,43 @@
+//Eg-3.9
+//pg-88
+
+clear
+clc
+
+ //cholesky decomposition
+
+ A=[1 .5 0;.5 1 .5;0 .5 1];
+ B=[1;2;3];
+
+
+[n,n]=size(A);
+summ1=0;
+summ2=0;
+
+for i=1:n
+ summ1=0;
+ for k=1:i-1
+ summ1=summ1+(L(i,k))^2;
+ end
+ L(i,i)=(A(i,i)-summ1)^(1/2);
+ for j=i+1:n
+ summ2=0;
+ for k=1:i-1
+ summ2=summ2+L(i,k)*L(j,k);
+ end
+ L(j,i)=(A(i,j)-summ2)/(L(i,i));
+ end
+end
+
+if L*L'==A then
+ disp("verification was done")
+end
+
+Y=inv(L)*B;
+
+X=inv(L')*Y;
+
+disp(X)
+
+
+