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 /964/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 '964/CH7')
-rwxr-xr-x | 964/CH7/EX7.1/7_1.sce | 21 | ||||
-rwxr-xr-x | 964/CH7/EX7.2/7_2.sce | 36 | ||||
-rwxr-xr-x | 964/CH7/EX7.3/7_3.sce | 49 | ||||
-rwxr-xr-x | 964/CH7/EX7.4/7_4.sce | 19 | ||||
-rwxr-xr-x | 964/CH7/EX7.5/7_5.sce | 16 | ||||
-rwxr-xr-x | 964/CH7/EX7.6/7_6.sce | 6 | ||||
-rwxr-xr-x | 964/CH7/EX7.7/7_7.sce | 6 | ||||
-rwxr-xr-x | 964/CH7/EX7.8/7_8.sce | 19 |
8 files changed, 172 insertions, 0 deletions
diff --git a/964/CH7/EX7.1/7_1.sce b/964/CH7/EX7.1/7_1.sce new file mode 100755 index 000000000..b9062a072 --- /dev/null +++ b/964/CH7/EX7.1/7_1.sce @@ -0,0 +1,21 @@ +clc;
+clear;
+function y=f(x)
+ y=(x-4)*(x+6)
+endfunction
+n=2;
+a(1)=-24;
+a(2)=2;
+a(3)=1;
+t=4;
+r=a(3);
+a(3)=0;
+for i=(n):-1:1
+ s=a(i);
+ a(i)=r;
+ r=s+r*t;
+end
+disp("The quptient is a(1)+a(2)*x where :")
+disp(a(1),"a(1)=")
+disp(a(2),"a(2)=")
+disp(r,"remainder=")
\ No newline at end of file diff --git a/964/CH7/EX7.2/7_2.sce b/964/CH7/EX7.2/7_2.sce new file mode 100755 index 000000000..ac713b96e --- /dev/null +++ b/964/CH7/EX7.2/7_2.sce @@ -0,0 +1,36 @@ +clc;
+clear;
+function y=f(x)
+ y=x^3 - 13*x - 12
+endfunction
+
+x1t=-3;
+x2t=-1;
+x3t=4;
+x0=4.5;
+x1=5.5;
+x2=5;
+disp(0,"iteration:")
+disp(x2,"xr:")
+disp("---------------------------------------------")
+for i=1:4
+
+h0=x1-x0;
+h1=x2-x1;
+d0=(f(x1)-f(x0))/(x1-x0);
+d1=(f(x2)-f(x1))/(x2-x1);
+a=(d1-d0)/(h1+h0);
+b=a*h1+d1;
+c=f(x2);
+d=(b^2 - 4*a*c)^0.5;
+if abs(b+d)>abs(b-d) then x3=x2+((-2*c)/(b+d));
+else x3=x2+((-2*c)/(b-d)); end
+ea=abs(x3-x2)*100/x3;
+x0=x1;
+x1=x2;
+x2=x3;
+disp(i,"iteration:")
+disp(x2,"xr:")
+disp(ea,"ea(%):")
+disp("---------------------------------------------")
+end
diff --git a/964/CH7/EX7.3/7_3.sce b/964/CH7/EX7.3/7_3.sce new file mode 100755 index 000000000..037a09ed0 --- /dev/null +++ b/964/CH7/EX7.3/7_3.sce @@ -0,0 +1,49 @@ +clc;
+clear;
+function y=f(x)
+ y=x^5-3.5*x^4+2.75*x^3+2.125*x^2-3.875*x+1.25
+endfunction
+r=-1;
+s=-1;
+es=1;//%
+n=6;
+count=1;
+ear=100;
+eas=100;
+a=[1.25 -3.875 2.125 2.75 -3.5 1];
+while (ear>es) and (eas>es)
+
+ b(n)=a(n);
+ b(n-1)=a(n-1)+r*b(n);
+ for i=n-2:-1:1
+ b(i)=a(i)+r*b(i+1)+s*b(i+2);
+ end
+ c(n)=b(n);
+ c(n-1)=b(n-1)+r*c(n);
+ for i=(n-2):-1:2
+ c(i)=b(i)+r*c(i+1)+s*c(i+2);
+ end
+ //c(3)*dr+c(4)*ds=-b(2)
+ //c(2)*dr+c(3)*ds=-b(1)
+ ds=((-b(1))+(b(2)*c(2)/c(3)))/(c(3)-(c(4)*c(2 )/c(3)));
+ dr=(-b(2)-c(4)*ds)/c(3);
+ r=r+dr;
+ s=s+ds;
+ ear=abs(dr/r)*100;
+ eas=abs(ds/s)*100;
+ disp(count,"Iteration:")
+ disp(dr,"delata r:")
+ disp(ds,"delata s:")
+ disp(r,"r:")
+ disp(s,"s:")
+ disp(ear,"Error in r:")
+ disp(eas,"Error in s:")
+ disp("-----------------------------------------------------")
+ count=count+1;
+end
+x1=(r+(r^2 + 4*s)^0.5)/2;
+x2=(r-(r^2 + 4*s)^0.5)/2;
+bracket=[x1 x2];
+disp(bracket,"The roots are:")
+disp("x^3 - 4*x^2 + 5.25*x - 2.5","The quotient is:")
+disp("-----------------------------------------------------")
diff --git a/964/CH7/EX7.4/7_4.sce b/964/CH7/EX7.4/7_4.sce new file mode 100755 index 000000000..e716b64bc --- /dev/null +++ b/964/CH7/EX7.4/7_4.sce @@ -0,0 +1,19 @@ +clc;
+clear;
+function y=f(x)
+ y=x-cos(x)
+endfunction
+x1=0;
+if f(x1)<0 then
+ x2=x1+0.001;
+ while f(x2)<0
+ x2=x2+0.001;
+ end
+elseif x2=x1+0.001;
+ while f(x2)>0
+ x2=x2+0.001;
+ end
+else disp(x1,"The root is=")
+end
+x=x2-(x2-x1)*f(x2)/(f(x2)-f(x1));
+disp(x,"The root is=")
\ No newline at end of file diff --git a/964/CH7/EX7.5/7_5.sce b/964/CH7/EX7.5/7_5.sce new file mode 100755 index 000000000..6f2e774a2 --- /dev/null +++ b/964/CH7/EX7.5/7_5.sce @@ -0,0 +1,16 @@ +clc;
+clear;
+function z=u(x,y)
+ z=x^2+x*y-10
+endfunction
+function z=v(x,y)
+ z=y+3*x*y^2-57
+endfunction
+x=1;
+y=3.5;
+while u(x,y)~=v(x,y)
+ x=x+1;
+ y=y-0.5;
+end
+disp(x,"x=")
+disp(y,"y=")
diff --git a/964/CH7/EX7.6/7_6.sce b/964/CH7/EX7.6/7_6.sce new file mode 100755 index 000000000..08e8a35da --- /dev/null +++ b/964/CH7/EX7.6/7_6.sce @@ -0,0 +1,6 @@ +clc;
+clear;
+x=poly(0,'s');
+p=x^10 -1;
+disp("The roots of the polynomial are:")
+disp(roots(p))
\ No newline at end of file diff --git a/964/CH7/EX7.7/7_7.sce b/964/CH7/EX7.7/7_7.sce new file mode 100755 index 000000000..28d482850 --- /dev/null +++ b/964/CH7/EX7.7/7_7.sce @@ -0,0 +1,6 @@ +clc;
+clear;
+x=poly(0,'s');
+p=x^5 - 3.5*x^4 +2.75*x^3 +2.125*x^2 - 3.875*x + 1.25;
+disp("The roots of the polynomial are:")
+disp(roots(p))
\ No newline at end of file diff --git a/964/CH7/EX7.8/7_8.sce b/964/CH7/EX7.8/7_8.sce new file mode 100755 index 000000000..e0b7523ea --- /dev/null +++ b/964/CH7/EX7.8/7_8.sce @@ -0,0 +1,19 @@ +clc;
+clear;
+function y=f(x)
+ y=x-cos(x)
+endfunction
+x1=0;
+if f(x1)<0 then
+ x2=x1+0.00001;
+ while f(x2)<0
+ x2=x2+0.00001;
+ end
+elseif x2=x1+0.00001;
+ while f(x2)>0
+ x2=x2+0.00001;
+ end
+else disp(x1,"The root is=")
+end
+x=x2-(x2-x1)*f(x2)/(f(x2)-f(x1));
+disp(x,"The root is=")
\ No newline at end of file |