summaryrefslogtreecommitdiff
path: root/1332/CH16
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /1332/CH16
downloadScilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip
initial commit / add all books
Diffstat (limited to '1332/CH16')
-rwxr-xr-x1332/CH16/EX16.1/16_1.pdfbin0 -> 7048 bytes
-rwxr-xr-x1332/CH16/EX16.1/16_1.sce33
-rwxr-xr-x1332/CH16/EX16.2/16_2.pdfbin0 -> 6238 bytes
-rwxr-xr-x1332/CH16/EX16.2/16_2.sce75
-rwxr-xr-x1332/CH16/EX16.3/16_3.pdfbin0 -> 6345 bytes
-rwxr-xr-x1332/CH16/EX16.3/16_3.sce36
-rwxr-xr-x1332/CH16/EX16.4/16_4.pdfbin0 -> 6480 bytes
-rwxr-xr-x1332/CH16/EX16.4/16_4.sce52
-rwxr-xr-x1332/CH16/EX16.5/16_5.pdfbin0 -> 6403 bytes
-rwxr-xr-x1332/CH16/EX16.5/16_5.sce29
-rwxr-xr-x1332/CH16/EX16.6/16_6.pdfbin0 -> 6391 bytes
-rwxr-xr-x1332/CH16/EX16.6/16_6.sce33
12 files changed, 258 insertions, 0 deletions
diff --git a/1332/CH16/EX16.1/16_1.pdf b/1332/CH16/EX16.1/16_1.pdf
new file mode 100755
index 000000000..22caad1e1
--- /dev/null
+++ b/1332/CH16/EX16.1/16_1.pdf
Binary files differ
diff --git a/1332/CH16/EX16.1/16_1.sce b/1332/CH16/EX16.1/16_1.sce
new file mode 100755
index 000000000..a4883eb81
--- /dev/null
+++ b/1332/CH16/EX16.1/16_1.sce
@@ -0,0 +1,33 @@
+//Example 16.1
+//Outline of Linear Shooting Method
+//Page no. 572
+clc;close;clear;
+
+deff('y=f(x)','y=x^2');
+h=0.5;X0=0;Y0=1;Z1=[-1,-1.5,-1.1771];i=1;Y1=Y0;
+for j=1:3
+ Z0=Z1(i);
+ i=i+1
+ Y0=1;
+ for n=1:2
+ printf('\nFor n = %i\n---------------------------\n',n-1)
+ K1(1)=h*Z0;
+ printf('\n K11 = %g',K1(1));
+ K1(2)=h*f(Y0);
+ printf('\n K12 = %g',K1(2));
+ K2=h*f(Y0+K1(2))
+ printf('\n K22 = %g',K2);
+ Z0=Z0+(K1(2)+K2)/2
+ printf('\n Z%i = %g',n,Z0);
+ K2=h*Z0;
+ printf('\n K21 = %g',K2);
+ Y0=Y0+(K1(1)+K2)/2
+ printf('\n Y%i = %g',n,Y0);
+ printf('\n\n\n')
+ if n==1 then
+ Y2=Y0
+ end
+ end
+ printf('\n\n\n')
+end
+printf('Hence the solution is y(%g) = %i, y(%g) = %.4f and y(%g) = %.1f',X0,Y1,X0+h,Y2,X0+2*h,Y0) \ No newline at end of file
diff --git a/1332/CH16/EX16.2/16_2.pdf b/1332/CH16/EX16.2/16_2.pdf
new file mode 100755
index 000000000..07065af81
--- /dev/null
+++ b/1332/CH16/EX16.2/16_2.pdf
Binary files differ
diff --git a/1332/CH16/EX16.2/16_2.sce b/1332/CH16/EX16.2/16_2.sce
new file mode 100755
index 000000000..4bf89280f
--- /dev/null
+++ b/1332/CH16/EX16.2/16_2.sce
@@ -0,0 +1,75 @@
+//Example 16.2
+//Linear Shooting Method
+//Page no. 576
+clc;close;clear;
+
+deff('y=f1(x,y,y1)','y=-x*y1+x^2*y+2*x^3')
+deff('y=F1(x,y,y1)','y=-x*y1+x^2*y+2*x^3')
+deff('y=F2(x,y,y1)','y=-x*y1+x^2*y')
+a=0;b=1;
+y0=1;y1=-1;n=5;
+h=(b-a)/n
+y=y0;y01=0;x=a;
+for i=0:5
+ yi1(1,i+1)=y
+ K1=h*y01;
+ R1=h*F1(x,y,y01);
+ K2=h*(y+R1/2);
+ R2=h*F1(x+h/2,y+K1/2,y01+R1/2)
+ K3=h*(y01+R2/2)
+ R3=h*F1(x+h/2,y+K2/2,y01+R2/2)
+ K4=h*(y+R3)
+ R4=h*F1(x+h,y+K3,y01+R3)
+ y=y+(K1+2*K2+2*K3+K4)/6
+ y01=y01+(R1+2*R2+2*R3+R4)/6
+ x=x+h
+end
+y=0;y01=1;x=a;
+for i=0:5
+ yi2(1,i+1)=y
+ K1=h*y01;
+ R1=h*F2(x,y,y01);
+ K2=h*(y+R1/2);
+ R2=h*F2(x+h/2,y+K1/2,y01+R1/2)
+ K3=h*(y01+R2/2)
+ R3=h*F2(x+h/2,y+K2/2,y01+R2/2)
+ K4=h*(y+R3)
+ R4=h*F2(x+h,y+K3,y01+R3)
+ y=y+(K1+2*K2+2*K3+K4)/6
+ y01=y01+(R1+2*R2+2*R3+R4)/6
+ x=x+h
+end
+for i=1:6
+ yi(i)=yi1(1,i)+((y1-yi1(6))/yi2(6))*yi2(i)
+end
+y=1;x=a;y01=y1
+for i=0:5
+ yir(1,i+1)=y;
+ K1=h*y01;
+ R1=h*f1(x,y,y01);
+ K2=h*(y+R1/2);
+ R2=h*f1(x+h/2,y+K1/2,y01+R1/2)
+ K3=h*(y01+R2/2)
+ R3=h*f1(x+h/2,y+K2/2,y01+R2/2)
+ K4=h*(y+R3)
+ R4=h*f1(x+h,y+K3,y01+R3)
+ y=y+(K1+2*K2+2*K3+K4)/6
+ y01=y01+(R1+2*R2+2*R3+R4)/6
+ x=x+h
+end
+x=a;
+printf('\n ------------------------------------------------------------------------------------------------------\n\tx')
+for i=1:6
+ printf('\t%.1f\t',x)
+ x=x+h
+end
+printf('\n\ty')
+for i=1:6
+ printf('\t%.4f\t',yi(i))
+end
+printf('\n by RK')
+for i=1:6
+ printf('\t%.4f\t',yir(i))
+end
+printf('\n ------------------------------------------------------------------------------------------------------')
+printf('\n\n\nNote: Computation error in calculation of values by RK method performed in book') \ No newline at end of file
diff --git a/1332/CH16/EX16.3/16_3.pdf b/1332/CH16/EX16.3/16_3.pdf
new file mode 100755
index 000000000..5bb88e031
--- /dev/null
+++ b/1332/CH16/EX16.3/16_3.pdf
Binary files differ
diff --git a/1332/CH16/EX16.3/16_3.sce b/1332/CH16/EX16.3/16_3.sce
new file mode 100755
index 000000000..2d907fcd4
--- /dev/null
+++ b/1332/CH16/EX16.3/16_3.sce
@@ -0,0 +1,36 @@
+//Example 16.3
+//Multiple Shooting Method
+//Page no. 577
+clc;close;clear;
+
+h=0.25;x=0;y1=0;
+deff('y=f(x)','y=-(4*h^2)/(1+x)^2')
+deff('y=f1(x)','y=-2*(1+(h^2)/(1+x)^2)')
+
+for i=1:4
+ x=x+h
+ B(i)=f(x);
+ for j=1:4
+ if i==4 & i==j
+ A(i,j)=f1(x)+1/4
+ A(i,j-1)=2
+ elseif j==i then
+ A(i,j)=f1(x)
+ A(i,j+1)=1
+ if j-1~=0 then
+ A(i,j-1)=1
+ end
+ end
+ end
+end
+y=inv(A)*B
+disp(B,"B =",A,'A = ')
+printf('\n\n\n x :')
+for i=1:5
+ printf('\t%.2f',x)
+ x=x+h
+end
+x=0;printf('\n y :\t%.2f',y1);
+for i=1:4
+ printf('\t%.4f',y(i))
+end
diff --git a/1332/CH16/EX16.4/16_4.pdf b/1332/CH16/EX16.4/16_4.pdf
new file mode 100755
index 000000000..1cfe37ab0
--- /dev/null
+++ b/1332/CH16/EX16.4/16_4.pdf
Binary files differ
diff --git a/1332/CH16/EX16.4/16_4.sce b/1332/CH16/EX16.4/16_4.sce
new file mode 100755
index 000000000..d880ae40c
--- /dev/null
+++ b/1332/CH16/EX16.4/16_4.sce
@@ -0,0 +1,52 @@
+//Example 16.4
+//Finite Difference Method
+//Page no. 582
+clc;close;clear;
+
+x=0;h=0.25;q=-1;Y(1)=-2;Y(5)=1;
+printf('\n i\txi\tYi\tpi\tqi\tri\n-----------------------------------------------\n')
+for i=1:5
+ r(i)=-x^2
+ if i>1 & i<5 then
+ printf(' %i\t%g\t%s\t%g\t%i\t%g\n',i-1,x,"?",x,q,r(i))
+ else
+ printf(' %i\t%g\t%g\t%g\t%i\t%g\n',i-1,x,Y(i),x,q,r(i))
+ end
+ x=x+h
+end
+x=0;
+printf('-----------------------------------------------\n')
+for i=1:3
+ x=x+h
+ for j=1:3
+ if i==j then
+ A(i,j)=2+h^2*q
+ elseif i<j & abs(i-j)~=2
+ A(i,j)=-1+h*x/2
+ elseif i>j & abs(i-j)~=2
+ A(i,j)=-1-h*x/2
+ end
+ end
+ if i==3 then
+ B(i)=-h^2*r(i+1)+(-h*x/2+1)*Y(1+2*(i-1))
+ else
+ B(i)=-h^2*r(i+1)+(h*x/2+1)*Y(1+2*(i-1))
+ end
+ B(i)=(-1)^(i+1)*B(i)
+end
+disp(B,"B =",A,'A = ')
+y=inv(A)*B
+for i=1:3
+ Y(i+1)=y(i)
+end
+x=0;
+disp("The Solution is :",B,"B =",A,'A = ')
+printf(' x :')
+for i=1:5
+ printf('\t %.2f',x)
+ x=x+h
+end
+x=0;printf('\n y :');
+for i=1:5
+ printf('\t%.3f',Y(i))
+end \ No newline at end of file
diff --git a/1332/CH16/EX16.5/16_5.pdf b/1332/CH16/EX16.5/16_5.pdf
new file mode 100755
index 000000000..eca8efd81
--- /dev/null
+++ b/1332/CH16/EX16.5/16_5.pdf
Binary files differ
diff --git a/1332/CH16/EX16.5/16_5.sce b/1332/CH16/EX16.5/16_5.sce
new file mode 100755
index 000000000..c3604344a
--- /dev/null
+++ b/1332/CH16/EX16.5/16_5.sce
@@ -0,0 +1,29 @@
+//Example 16.5
+//Non Linear Problem
+//Page no. 584
+clc;close;clear;
+
+deff('y=f(x)','y=2/(1+x)')
+Y=[1,0.75,0.75,0.75,0.5];h=0.25
+A=[-2,1,0;1,-2,1;0,1,-2];A_1=inv(A)
+disp(A_1,"Inverse of A =",A,"A =")
+printf('\nThe Solution of the system is: \n\n Iteration\t Y0\t\t Y1\t\t Y2\t\t Y3\t\t Y4\n----------------------------------------------------------------------------------------')
+for i=0:6
+ printf('\n %i',i)
+ for j=1:5
+ if j<4 & i~=0 then
+ Y(j+1)=y(j)
+ end
+ printf('\t\t%.4f',Y(j))
+ end
+ x=0;
+ for j=1:3
+ x=x+h
+ if j~=2 then
+ B(j)=h^2*f(x)*Y(j+1)^2-Y(1+2*(j-1))
+ else
+ B(j)=h^2*f(x)*Y(j+1)^2
+ end
+ end
+ y=A_1*B
+end \ No newline at end of file
diff --git a/1332/CH16/EX16.6/16_6.pdf b/1332/CH16/EX16.6/16_6.pdf
new file mode 100755
index 000000000..cee0b88fa
--- /dev/null
+++ b/1332/CH16/EX16.6/16_6.pdf
Binary files differ
diff --git a/1332/CH16/EX16.6/16_6.sce b/1332/CH16/EX16.6/16_6.sce
new file mode 100755
index 000000000..72049be59
--- /dev/null
+++ b/1332/CH16/EX16.6/16_6.sce
@@ -0,0 +1,33 @@
+//Example 16.6
+//Collocation Method
+//Page no. 589
+clc;close;clear;
+
+h1=0.000001;h=0.25;x=0;
+Y(1)=0;Y(5)=0;
+deff('y=p(x)','y=1')
+deff('y=q(x)','y=-2/(1+x)^2')
+deff('y=f(x)','y=(2*x-4)/(1+x)^4')
+deff('y=fi(x,j)','y=(1-x)*x^j')
+deff('y=f1(x,y)','y=(-x+y)/h1') //function for differentiation
+for i=1:4
+ x=x+h
+ for j=1:4
+ A(i,j)=p(x)*f1(f1(fi(x,j),fi(x+h1,j)),f1(fi(x+h1,j),fi(x+2*h1,j)))+f1(p(x),p(x+h1))*f1(fi(x,j),fi(x+h1,j))+q(x)*fi(x,j)
+ end
+end
+x=0;
+for i=1:4
+ x=x+h
+ B(i)=f(x)
+end
+disp(B,'B =',A,"A =")
+C=inv(A)*B
+x=0;
+for i=2:4
+ x=x+h;
+ for j=1:4
+ Y(i)=Y(i)+C(j)*fi(x,j)
+ end
+end
+disp(Y,"Solution Matrix Y = ") \ No newline at end of file