diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /1670/CH7 | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '1670/CH7')
-rwxr-xr-x | 1670/CH7/EX7.1/7_1.sce | 12 | ||||
-rwxr-xr-x | 1670/CH7/EX7.10/7_10.sce | 9 | ||||
-rwxr-xr-x | 1670/CH7/EX7.11/7_11.sce | 57 | ||||
-rwxr-xr-x | 1670/CH7/EX7.12/7_12.sce | 31 | ||||
-rwxr-xr-x | 1670/CH7/EX7.13/7_13.sce | 42 | ||||
-rwxr-xr-x | 1670/CH7/EX7.14/7_14.sce | 13 | ||||
-rwxr-xr-x | 1670/CH7/EX7.2/7_2.sce | 22 | ||||
-rwxr-xr-x | 1670/CH7/EX7.3/7_3.sce | 18 | ||||
-rwxr-xr-x | 1670/CH7/EX7.4/7_4.sce | 13 | ||||
-rwxr-xr-x | 1670/CH7/EX7.5/7_5.sce | 36 | ||||
-rwxr-xr-x | 1670/CH7/EX7.6/7_6.sce | 39 | ||||
-rwxr-xr-x | 1670/CH7/EX7.7/7_7.sce | 47 | ||||
-rwxr-xr-x | 1670/CH7/EX7.8/7_8.sce | 43 | ||||
-rwxr-xr-x | 1670/CH7/EX7.9/7_9.sce | 38 |
14 files changed, 420 insertions, 0 deletions
diff --git a/1670/CH7/EX7.1/7_1.sce b/1670/CH7/EX7.1/7_1.sce new file mode 100755 index 000000000..45238c2cc --- /dev/null +++ b/1670/CH7/EX7.1/7_1.sce @@ -0,0 +1,12 @@ +//Example 7.1
+//Differentiation
+//Page no. 230
+clc;close;clear;
+deff('y=f(x)','y=sin(x)')
+deff('y=f1(x,h)','y=(f(x+h)-f(x-h))/(2*h)')
+deff('y=f2(x,h)','y=(-f(x+2*h)+8*f(x+h)-8*f(x-h)+f(x-2*h))/(12*h)')
+h=0.01;x=0.5
+d=f1(x,h)
+d1=f2(x,h)
+printf('Centred Formula of Order O(h2) = %g\n',d)
+printf('\n Centred Formula of Order O(h4) = %g',d1)
\ No newline at end of file diff --git a/1670/CH7/EX7.10/7_10.sce b/1670/CH7/EX7.10/7_10.sce new file mode 100755 index 000000000..4a512749d --- /dev/null +++ b/1670/CH7/EX7.10/7_10.sce @@ -0,0 +1,9 @@ +//Example 7.10
+//Lagrange's Differentiation
+//Page no. 246
+clc;close;clear;
+
+z=[0,0.989992;0.1,0.999135;0.2,0.998295;0.3,0.987480];
+h=0.1;
+deff('y=f(x)','y=(-3*z(x,2)+4*z(x+1,2)-z(x+2,2))/(2*h)')
+printf('\n f`(0) = %g\n\n f`(0.1) = %g',f(1),f(2))
\ No newline at end of file diff --git a/1670/CH7/EX7.11/7_11.sce b/1670/CH7/EX7.11/7_11.sce new file mode 100755 index 000000000..bd997839a --- /dev/null +++ b/1670/CH7/EX7.11/7_11.sce @@ -0,0 +1,57 @@ +//Example 7.11
+//Newton's Divided Difference Interpolation
+//Page no. 247
+clc;close;clear;
+
+x=[-1,1,2,3]
+y=[-21,15,12,3];
+y1=y;h=0.0000001
+deff('yi=P(a,b,d,e)','yi=(b(d+1)-b(d))/(a(d+e)-a(d))') //function for finding polynomials
+for i=1:3
+ for j=1:4-i
+ z(j,i)=P(x,y,j,i)
+ y(j)=z(j,i)
+ end
+end
+z(6,1)=0;
+printf('x y f(x0,x1) f(x0,x1,x3) f(x0,x1,x2,x3)\n')
+printf('---------------------------------------------------------\n')
+ for j=1:4
+ printf(' %i %i \t%i\t\t%i\t\t%i\n',x(1,j),y1(1,j),z(j,1),z(j,2),z(j,3))
+ end
+x1=poly(0,'x');
+p=1;f=y1(1);
+for i=1:3
+ for j=1:i
+ p=p*(x1-x(j))
+ end
+ p=p*z(1,i)
+ f=f+p
+ p=1;
+end
+disp(f,"f(x) = ")
+f1=y1(1)
+x2=poly(h,'x');
+for i=1:3
+ for j=1:i
+ p=p*(x2-x(j))
+ end
+ p=p*z(1,i)
+ f1=f1+p
+ p=1;
+end
+f1=(f1-f)/h
+disp(f1,"f`(x) = ")
+r=roots(f1)
+disp(r,"Roots = ")
+x1=r(2)
+p=1;f=y1(1);
+for i=1:3
+ for j=1:i
+ p=p*(x1-x(j))
+ end
+ p=p*z(1,i)
+ f=f+p
+ p=1;
+end
+disp(f,"Maximum Value = ")
\ No newline at end of file diff --git a/1670/CH7/EX7.12/7_12.sce b/1670/CH7/EX7.12/7_12.sce new file mode 100755 index 000000000..f66bf046f --- /dev/null +++ b/1670/CH7/EX7.12/7_12.sce @@ -0,0 +1,31 @@ +//Example 7.12
+//Stirlings Central Difference Derivatives
+//Page no. 248
+clc;close;clear;
+printf(' x\t y\t d\t d2\t d3\t d4\n')
+printf('------------------------------------------------')
+function [x]=f(x1)
+ x=0;
+ for i=3:6
+ x=x+(-1)^(i-1)*(z(x1,i))/((i-2)*h)
+ end
+endfunction
+h=1;
+z=[-3,-33;-2,-12;-1,-3;0,0;1,3;2,12;3,33];
+for i=3:6
+ for j=1:9-i
+ z(j,i)=z(j+1,i-1)-z(j,i-1)
+ end
+end
+printf('\n')
+for i=1:7
+ for j=1:6
+ if j==1
+ printf(' %g\t ',z(i,j))
+ else
+ printf('%i\t ',z(i,j))
+ end
+ end
+ printf('\n')
+end
+printf("\n\nf`(-3) = %g\n\nf`(0) = %g",f(1),f(4))
\ No newline at end of file diff --git a/1670/CH7/EX7.13/7_13.sce b/1670/CH7/EX7.13/7_13.sce new file mode 100755 index 000000000..4a8b12a74 --- /dev/null +++ b/1670/CH7/EX7.13/7_13.sce @@ -0,0 +1,42 @@ +//Example 7.13
+//Newtons Backward Formula
+//Page no. 248
+clc;close;clear;
+printf(' x\t y\t d\t d2\t d3\t d4\t d5\n')
+printf('--------------------------------------------------------')
+h=0.5;
+deff('y=f2(x)','y=(z(x,4)-z(x,5)+z(x,6))/h^2')
+z=[1.5,3.375;2,7;2.5,13.625;3,24;3.5,38.875;4,59];
+for i=1:6
+ for j=3:7
+ z(i,j)=-1
+ end
+end
+for i=3:7
+ for j=1:8-i
+ z(j,i)=z(j+1,i-1)-z(j,i-1)
+ end
+end
+printf('\n')
+for i=1:6
+ for j=1:7
+ if z(i,j)==-1 then
+ printf(' \t')
+ elseif j==1
+ printf(' %.1f\t',z(i,j))
+ else
+ printf('%.3f\t',z(i,j))
+ end
+ end
+ printf('\n')
+end
+
+j=1;y1=0;
+for i=3:6
+ y1=y1+(-1)^(i-1)*z(j,i)/(i-2)
+end
+y1=y1/h;
+y2(7)=f2(1);
+printf('\n\n f`(1.5)= %g',y1)
+printf('\n\n f``(1.5) = %g',y2(7))
+
diff --git a/1670/CH7/EX7.14/7_14.sce b/1670/CH7/EX7.14/7_14.sce new file mode 100755 index 000000000..c8dd35868 --- /dev/null +++ b/1670/CH7/EX7.14/7_14.sce @@ -0,0 +1,13 @@ +//Example 7.14
+//Newtons Divided Difference
+//Page no. 249
+clc;close;clear;
+
+x=[3,5,11,27,34]
+y=[-13,23,899,17315,35606]
+deff('y=f(x1)','y=a1+a2*((x1-x(2))+(x1-x(3)))')
+a1=(y(3)-y(2))/(x(3)-x(2))
+a2=((y(4)-y(3))/(x(4)-x(3))-(y(3)-y(2))/(x(3)-x(2)))/(x(4)-x(2))
+disp(y,"y:",x,"x:")
+printf('\n\n a1 = %g\t\ta2 = %g\n\n',a1,a2)
+disp(f(10),"f`(10) = ")
\ No newline at end of file diff --git a/1670/CH7/EX7.2/7_2.sce b/1670/CH7/EX7.2/7_2.sce new file mode 100755 index 000000000..041900836 --- /dev/null +++ b/1670/CH7/EX7.2/7_2.sce @@ -0,0 +1,22 @@ +//Example 7.2
+//Differentiation
+//Page no. 232
+clc;close;clear;
+
+t=[1,1.1,1.2,1.3,1.4]
+I=[8.2277,7.2428,5.9908,4.5260,2.9122]
+L=0.05;R=2;h=0.1;
+deff('y=f(x)','y=L*i1(x)+R*I(x)')
+deff('y=f1(x,h1)','y=(I(x+h1)-I(x-h1))/(2*h)')
+deff('y=f2(x,h1)','y=(-I(x+2*h1)+8*I(x+h1)-8*I(x-h1)+I(x-2*h1))/(12*h)')
+x=3;h1=1;
+i1(x)=f1(x,h1)
+E=f(x)
+printf('Using Centred Tendency of Order O(h2)\n')
+printf('I`(1.2) = %g\n',i1(x))
+printf('\n E(1.2) = %g',E)
+i1(x)=f2(x,h1)
+E=f(x)
+printf('\n\n\nUsing Centred Tendency of Order O(h4)\n')
+printf('I`(1.2) = %g\n',i1(x))
+printf('\n E(1.2) = %g',E)
\ No newline at end of file diff --git a/1670/CH7/EX7.3/7_3.sce b/1670/CH7/EX7.3/7_3.sce new file mode 100755 index 000000000..ac94dd29e --- /dev/null +++ b/1670/CH7/EX7.3/7_3.sce @@ -0,0 +1,18 @@ +//Example 7.3
+//Richardson Extrapolation
+//Page no. 233
+clc;close;clear;
+
+t=[1,1.1,1.2,1.3,1.4]
+I=[8.2277,7.2428,5.9908,4.5260,2.9122]
+h=0.1;
+deff('y=f1(x,h1)','y=(I(x+h1)-I(x-h1))/(2*h)')
+deff('y=f2(x,h1)','y=(I(x+2*h1)-I(x-2*h1))/(4*h)')
+deff('y=f3(x,h1)','y=(I(x+h1)-I(x-h1))/(2*h)')
+x=3;h1=1;
+D0h=f1(x,h1)
+printf('\nD0(h) = %g\n',D0h)
+D02h=f2(x,h1)
+printf('\nD0(2h) = %g\n',D02h)
+I1=(4*D0h-D02h)/x
+printf('\nI` (1.2) = %g',I1)
\ No newline at end of file diff --git a/1670/CH7/EX7.4/7_4.sce b/1670/CH7/EX7.4/7_4.sce new file mode 100755 index 000000000..e1afbb4e7 --- /dev/null +++ b/1670/CH7/EX7.4/7_4.sce @@ -0,0 +1,13 @@ +//Example 7.4
+//Differentiation
+//Page no. 233
+clc;close;clear;
+
+t=[1.2,1.3,1.4,1.5,1.6]
+I=[1.5095,1.6984,1.9043,2.1293,2.3756]
+h=0.1;
+deff('y=f2(x,h1)','y=(-I(x+2*h1)+8*I(x+h1)-8*I(x-h1)+I(x-2*h1))/(12*h)')
+x=3;h1=1;
+i1(x)=f2(x,h1)
+printf('\nUsing Centred Tendency of Order O(h4)\n')
+printf('f`(1.4) = %g\n',i1(x))
\ No newline at end of file diff --git a/1670/CH7/EX7.5/7_5.sce b/1670/CH7/EX7.5/7_5.sce new file mode 100755 index 000000000..e879350d9 --- /dev/null +++ b/1670/CH7/EX7.5/7_5.sce @@ -0,0 +1,36 @@ +//Example 7.5
+//Stirlings Central Difference Derivatives
+//Page no. 238
+clc;close;clear;
+printf(' x\t\t y\t\t d\t\t d2\t\t d3\t\t d4\n')
+printf('-----------------------------------------------------------------------------------------')
+h=0.1;s=1;
+e=[1,6,30]
+deff('y=f1(x,s)','y=((z(x,3)+z(x-1,3))/2+s*z(x-1,4)+(z(x-1,5)+z(x-2,5))*(3*s^2-1)/12)/h')
+deff('y=f2(x,s)','y=(z(x-1,4))/h^2')
+deff('y=f3(x,s)','y=(z(x-1,5)+z(x-2,5))/(2*h^3)')
+z=[0.7,0.644218;0.8,0.717356;0.9,0.783327;1,0.841471;1.1,0.891207;1.2,0.932039;1.3,0.963558];
+for i=3:6
+ for j=1:9-i
+ z(j,i)=z(j+1,i-1)-z(j,i-1)
+ end
+end
+printf('\n')
+for i=1:7
+ for j=1:6
+ if z(i,j)==0 then
+ printf(' \t')
+ elseif j==1
+ printf(' %.1f\t\t',z(i,j))
+ else
+ printf('%.6f\t',z(i,j))
+ end
+ end
+ printf('\n')
+end
+fp=0;i=5;
+for j=2:2:6
+ fp=fp+((-1)^(j/2+1))*(z(i,j)-z(i-2,j))/(2*h*e(j/2))
+ i=i-1;
+end
+printf('\n\nf`p (sin`(x))= %g',fp)
\ No newline at end of file diff --git a/1670/CH7/EX7.6/7_6.sce b/1670/CH7/EX7.6/7_6.sce new file mode 100755 index 000000000..e10954e41 --- /dev/null +++ b/1670/CH7/EX7.6/7_6.sce @@ -0,0 +1,39 @@ +//Example 7.6
+//Stirlings Central Difference Derivatives
+//Page no. 239
+clc;close;clear;
+printf(' x\t\t y\t\t d\t\t d2\t\t d3\t\t d4\t\t d5\n')
+printf('----------------------------------------------------------------------------------------------------------')
+h=0.2;s=1;
+deff('y=f1()','y=(z(4,3)+(3*p^2-1)*z(4,4)/factorial(3)-(3*p^2-6*p+2)*z(3,4)/factorial(3))/h')
+z=[0.2,2.10022;0.4,1.98730;0.6,1.90940;0.8,1.86672;1,1.85937;1.2,1.88737;1.4,1.95063];
+x0=0.8;p=poly(0,'p');
+for i=3:7
+ for j=1:9-i
+ z(j,i)=z(j+1,i-1)-z(j,i-1)
+ end
+end
+printf('\n')
+for i=1:7
+ for j=1:7
+ if z(i,j)==0 then
+ printf(' \t')
+ elseif j==1
+ printf(' %.1f\t\t',z(i,j))
+ else
+ printf('%.6f\t',z(i,j))
+ end
+ end
+ printf('\n')
+end
+f1p=f1()
+disp(f1p)
+r=roots(f1p);
+for i=1:2
+ if abs(r(i))==r(i) then
+ r1=r(i)
+ disp(r(i),"p = ")
+ end
+end
+x=x0+r1*h;
+disp(x,"x = ")
\ No newline at end of file diff --git a/1670/CH7/EX7.7/7_7.sce b/1670/CH7/EX7.7/7_7.sce new file mode 100755 index 000000000..5da90a4fc --- /dev/null +++ b/1670/CH7/EX7.7/7_7.sce @@ -0,0 +1,47 @@ +//Example 7.7
+//Stirlings Central Difference Derivatives
+//Page no. 240
+clc;close;clear;
+printf(' x\t\t y\t\t d\t\t d2\t\t d3\t\t d4\n')
+printf('------------------------------------------------------------------------------------------')
+h=0.2;s=1;
+a=poly(0,'a');
+b=poly(0,'b');
+deff('y=f3(x)','y=z(x,1)*y2(x)+(z(x,1)-b)*z(x,2)')
+deff('y=f4(x)','y=y1(x)*a')
+deff('y=f1(x)','y=(z(x+1,2)-z(x-1,2)-(z(x,4)-z(x-2,4))/factorial(3)+4*(z(x-1,6)-z(x-3,6))/factorial(5))/(2*h)')
+deff('y=f2(x)','y=(z(x-1,4)-2*(z(x-2,6))/factorial(4))/h^2')
+z=[0.8,1.73036;1,1.95532;1.2,2.19756;1.4,2.45693;1.6,2.73309;1.8,3.02549;2,3.33334;2.2,3.65563];
+x0=0.8;
+for i=3:6
+ for j=1:10-i
+ z(j,i)=z(j+1,i-1)-z(j,i-1)
+ end
+end
+printf('\n')
+for i=1:8
+ for j=1:6
+ if z(i,j)==0 then
+ printf(' \t')
+ elseif j==1
+ printf(' %.1f\t\t',z(i,j))
+ else
+ printf('%.6f\t',z(i,j))
+ end
+ end
+ printf('\n')
+end
+y1(4)=f1(4);
+y2(4)=f2(4);
+y1(5)=f1(5);
+y2(5)=f2(5);
+g=f3(4)
+printf('\n\ny`(1.4) = %g\n\ny``(1.4) = %g\n\ny`(1.6) = %g\n\ny``(1.6) = %g\n\n',y1(4),y2(4),y1(5),y2(5))
+disp(f3(4),f4(4))
+printf('\n\n')
+A=[y1(4),z(4,2);y1(5),z(5,2)];
+B=[z(4,1)*(y2(4)+z(4,2));z(5,1)*(y2(5)+z(5,2))];
+disp(f3(5),f4(5))
+
+C=inv(A)*B;
+printf('\n\n a = %g\n\n b = %g',C(1),C(2))
\ No newline at end of file diff --git a/1670/CH7/EX7.8/7_8.sce b/1670/CH7/EX7.8/7_8.sce new file mode 100755 index 000000000..1ca7401ab --- /dev/null +++ b/1670/CH7/EX7.8/7_8.sce @@ -0,0 +1,43 @@ +//Example 7.8
+//Stirlings Central Difference Derivatives
+//Page no. 242
+clc;close;clear;
+printf(' x\t\t y\t\t d\t\t d2\t\t d3\t\t d4\n')
+printf('------------------------------------------------------------------------------------------')
+h=0.01;
+a=poly(0,'n');
+deff('y=f3(x)','y=z(x,1)^2*y2(x)+z(x,1)*y1(x)+(z(x,1)^2-a^2)*z(x,2)')
+deff('y=f1(x)','y=(z(x+1,2)-z(x-1,2)-(z(x,4)-z(x-2,4))/factorial(3))/(2*h)')
+deff('y=f2(x)','y=(z(x-1,4)-2*(z(x-2,6))/factorial(4))/h^2')
+z=[85,0.0353878892;85.01,0.0346198696;85.02,0.0338490002;85.03,0.0330753467;85.04,0.032298975];
+for i=3:6
+ for j=1:7-i
+ z(j,i)=z(j+1,i-1)-z(j,i-1)
+ end
+end
+printf('\n')
+for i=1:5
+ for j=1:6
+ if z(i,j)==0 then
+ printf(' \t')
+ elseif j==1
+ printf(' %.2f\t',z(i,j))
+ else
+ printf('%.10f\t',z(i,j))
+ end
+ end
+ printf('\n')
+end
+y1(3)=f1(3);
+y2(3)=f2(3);
+
+printf('\n\ny`(85.02) = %g\n\ny``(85.02) = %.7g\n\n',y1(3),y2(3))
+n=f3(3)
+disp(n,"0 =")
+n=roots(n)
+for i=1:2
+ if abs(n(i))==n(i) then
+ n1=n(i)
+ end
+end
+printf('\n\nn = %.2g',n1)
\ No newline at end of file diff --git a/1670/CH7/EX7.9/7_9.sce b/1670/CH7/EX7.9/7_9.sce new file mode 100755 index 000000000..08d554a09 --- /dev/null +++ b/1670/CH7/EX7.9/7_9.sce @@ -0,0 +1,38 @@ +//Example 7.9
+//Newtons Backward Formula
+//Page no. 243
+clc;close;clear;
+printf(' x\t y\t d\t d2\t d3\t d4\t d5\t d6\n')
+printf('---------------------------------------------------------------')
+h=0.1;
+deff('y=f2(x)','y=(z(x-2,4)+z(x-3,5)+z(x-4,6))/h^2')
+z=[1,7.989;1.1,8.403;1.2,8.781;1.3,9.129;1.4,9.451;1.5,9.750;1.6,10.031];
+for i=3:8
+ for j=1:9-i
+ z(j,i)=z(j+1,i-1)-z(j,i-1)
+ end
+end
+printf('\n')
+for i=1:7
+ for j=1:8
+ if z(i,j)==0 then
+ printf(' \t')
+ elseif j==1
+ printf(' %.1f\t',z(i,j))
+ else
+ printf('%.3f\t',z(i,j))
+ end
+ end
+ printf('\n')
+end
+
+j=6;y1=0;
+for i=3:6
+ y1=y1+z(j,i)/(i-2)
+j=j-1
+end
+y1=y1/h;
+y2(7)=f2(7);
+printf('\n\n dy\n -- = %.10g\n dx',y1)
+printf('\n\n\n d2y\n --- = %.5g\n dx2',y2(7))
+
|