summaryrefslogtreecommitdiff
path: root/1332/CH16/EX16.4
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /1332/CH16/EX16.4
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/EX16.4')
-rwxr-xr-x1332/CH16/EX16.4/16_4.pdfbin0 -> 6480 bytes
-rwxr-xr-x1332/CH16/EX16.4/16_4.sce52
2 files changed, 52 insertions, 0 deletions
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