summaryrefslogtreecommitdiff
path: root/964/CH26
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /964/CH26
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 '964/CH26')
-rwxr-xr-x964/CH26/EX26.1/26_1.sce40
-rwxr-xr-x964/CH26/EX26.1/26_1_1.jpegbin0 -> 34007 bytes
-rwxr-xr-x964/CH26/EX26.1/26_1_2.jpegbin0 -> 24619 bytes
-rwxr-xr-x964/CH26/EX26.2/26_2.sce18
-rwxr-xr-x964/CH26/EX26.3/26_3.sce17
-rwxr-xr-x964/CH26/EX26.4/26_4.sce26
-rwxr-xr-x964/CH26/EX26.5/26_5.sce17
-rwxr-xr-x964/CH26/EX26.6/26_6.sce19
-rwxr-xr-x964/CH26/EX26.7/26_7.sce25
9 files changed, 162 insertions, 0 deletions
diff --git a/964/CH26/EX26.1/26_1.sce b/964/CH26/EX26.1/26_1.sce
new file mode 100755
index 000000000..0af6c6d95
--- /dev/null
+++ b/964/CH26/EX26.1/26_1.sce
@@ -0,0 +1,40 @@
+clc;
+clear;
+function yp=f(t,y)
+ yp=-1000*y+3000-2000*exp(-t)
+endfunction
+y0=0;
+//explicit euler
+h1=0.0005;
+y1(1)=y0;
+count=2;
+t=0:0.0001:0.006
+for i=0:0.0001:0.0059
+ y1(count)=y1(count-1)+f(i,y1(count-1))*h1
+ count=count+1;
+end
+plot(t,y1)
+h2=0.0015;
+y2(1)=y0;
+count=2;
+t=0:0.0001:0.006
+for i=0:0.0001:0.0059
+ y2(count)=y2(count-1)+f(i,y2(count-1))*h2
+ count=count+1;
+end
+plot(t,y2,'.-')
+xtitle("y vs t","t","y")
+h=legend(["h-0.0005","h=0.0015"])
+clf();
+//implicit order
+h3=0.05;
+y3(1)=y0;
+count=2;
+t=0:0.01:0.4
+for j=0:0.01:0.39
+ y3(count)=(y3(count-1)+3000*h3-2000*h3*exp(-(j+0.01)))/(1+1000*h3)
+ count=count+1;
+end
+
+plot(t,y3)
+xtitle("y vs t","t","y")
diff --git a/964/CH26/EX26.1/26_1_1.jpeg b/964/CH26/EX26.1/26_1_1.jpeg
new file mode 100755
index 000000000..29a2401f8
--- /dev/null
+++ b/964/CH26/EX26.1/26_1_1.jpeg
Binary files differ
diff --git a/964/CH26/EX26.1/26_1_2.jpeg b/964/CH26/EX26.1/26_1_2.jpeg
new file mode 100755
index 000000000..33d1479ac
--- /dev/null
+++ b/964/CH26/EX26.1/26_1_2.jpeg
Binary files differ
diff --git a/964/CH26/EX26.2/26_2.sce b/964/CH26/EX26.2/26_2.sce
new file mode 100755
index 000000000..dd56f99ff
--- /dev/null
+++ b/964/CH26/EX26.2/26_2.sce
@@ -0,0 +1,18 @@
+//clc()
+disp("f(x,y) = 4*exp(0.8*x) - 0.5*y")
+//f'(x,y) = 4*exp(0.8*x) - 0.5*y
+h = 1;
+x=0:h:4;
+y(1) = 2;
+x1 = -1;
+y1 = -0.3929953;
+y10 = y1 + (4*exp(0.8*x(1)) - 0.5*y(1))*2;
+y11 = y(1) + (4*exp(0.8*x(1)) - 0.5*y(1) + 4*exp(0.8*x(2)) - 0.5*y10)*h/2;
+y12 = y(1) + (3 + 4*exp(0.8*x(2)) - 0.5*y11)*h/2;
+t = 6.360865;
+y20 = y(1) + (4*exp(0.8*x(2)) - 0.5*t) *2;
+y21 = t + (4*exp(0.8*x(2)) - 0.5*t + 4*exp(0.8*x(3)) - 0.5*y20)*h/2;
+disp(y21,"the first corrector yields y = ")
+t = 14.84392
+e = (t - y21)*100/t;
+disp("%",e,"error = ")
diff --git a/964/CH26/EX26.3/26_3.sce b/964/CH26/EX26.3/26_3.sce
new file mode 100755
index 000000000..b72953d08
--- /dev/null
+++ b/964/CH26/EX26.3/26_3.sce
@@ -0,0 +1,17 @@
+//clc()
+x1 = 1;
+x2 = 2;
+y1 = 6.194631;
+y2 = 14.84392;
+y10 = 5.607005;
+y11 = 6.360865;
+y20 = 13.44346;
+y21 = 15.30224;
+Ec1 = -(y11 - y10)/5;
+disp(Ec1,"Ec (x = 1) = ")
+e1 = y1 - y11;
+disp(e1,"true error (x = 1) = ")
+Ec2 = -(y21 - y20)/5;
+disp(Ec2,"Ec (x = 2) = ")
+e2 = y2 - y21;
+disp(e2,"true error (x = 2) = ")
diff --git a/964/CH26/EX26.4/26_4.sce b/964/CH26/EX26.4/26_4.sce
new file mode 100755
index 000000000..f4ef8ffa2
--- /dev/null
+++ b/964/CH26/EX26.4/26_4.sce
@@ -0,0 +1,26 @@
+//clc()
+//clc()
+x0 = 0;
+x1 = 1;
+x2 = 2;
+y1 = 6.194631;
+y2 = 14.84392;
+y10 = 5.607005;
+y11 = 6.360865;
+y1m = y11 - (y11 - y10)/5;
+e = (y1 - y1m)*100/y1;
+disp(y1m,"ym")
+disp("%",e,"error = ")
+y20 =2+(4*exp(0.8*x1) - 0.5*y1m)*2;
+e2 = (y2 - y20)*100/y2;
+disp(y20,"y20 = ")
+disp("%",e2,"error = ")
+y2o = y20 + 4* (y11 - y10)/5;
+e2 = (y2 - y2o)*100/y2;
+disp(y2o,"y20 = ")
+disp("%",e2,"error = ")
+y21 = 15.21178;
+y23 = y21 - (y21 - y20)/5;
+disp(y23,"y2 = ")
+e3 = (y2 - y23)*100/y2;
+disp("%",e3,"error = ")
diff --git a/964/CH26/EX26.5/26_5.sce b/964/CH26/EX26.5/26_5.sce
new file mode 100755
index 000000000..2c4614273
--- /dev/null
+++ b/964/CH26/EX26.5/26_5.sce
@@ -0,0 +1,17 @@
+//clc()
+disp("f(x,y) = 4*exp(0.8*x) - 0.5*y")
+//f'(x,y) = 4*exp(0.8*x) - 0.5*y
+h = 1;
+x = -3:h:4;
+y(1) = -4.547302;
+y(2) = -2.306160;
+y(3) = -0.3929953;
+y(4) = 2;
+y1(4) = 2;
+for i = 4:7;
+ y(i+1) = y(i-3) + 4*h*(2*(4*exp(0.8*x(i)) - 0.5*y(i)) - 4*exp(0.8*x(i-1)) + 0.5*y(i-1) + 2*(4*exp(0.8*x(i-2)) - 0.5*y(i-2)))/3;
+ y1(i+1) = y(i-1) + h*(4*exp(0.8*x(i-1)) - 0.5*y(i-1) +4 * (4*exp(0.8*x(i)) - 0.5*y(i)) + 4*exp(0.8*x(i+1)) - 0.5*y(i+1))/3;
+end
+disp(x(4:8),"x = ")
+disp(y(4:8),"y0 = ")
+disp(y1(4:8),"corrected y1 = ")
diff --git a/964/CH26/EX26.6/26_6.sce b/964/CH26/EX26.6/26_6.sce
new file mode 100755
index 000000000..b09fcb8ec
--- /dev/null
+++ b/964/CH26/EX26.6/26_6.sce
@@ -0,0 +1,19 @@
+//clc()
+disp("f(x,y) = 4*exp(0.8*x) - 0.5*y")
+//f'(x,y) = 4*exp(0.8*x) - 0.5*y
+h = 1;
+x = -3:h:4;
+y(1) = -4.547302;
+y(2) = -2.306160;
+y(3) = -0.3929953;
+y(4) = 2;
+m(4) = y(4);
+for i =4:7
+ y(i+1) = y(i) + h *(55* (4*exp(0.8*x(i)) - 0.5*y(i)) / 24 - 59 * (4*exp(0.8*x(i-1)) - 0.5*y(i-1)) / 24 + 37*(4*exp(0.8*x(i-2)) - 0.5*y(i-2))/24 - 9*(4*exp(0.8*x(i-3)) - 0.5*y(i-3))/24);
+ m(i+1) = y(i+1)
+ y(i+1) = y(i) + h*(9*(4*exp(0.8*x(i+1)) - 0.5*y(i+1))/24 +19*(4*exp(0.8*x(i)) - 0.5*y(i))/24 - 5*(4*exp(0.8*x(i-1)) - 0.5*y(i-1))/24 + (4*exp(0.8*x(i-2)) - 0.5*y(i-2))/24);
+end
+disp(x(4:8),"x = ")
+disp(m(4:8),"y0 = ")
+disp(y(4:8),"y1 = ")
+
diff --git a/964/CH26/EX26.7/26_7.sce b/964/CH26/EX26.7/26_7.sce
new file mode 100755
index 000000000..96fb04aed
--- /dev/null
+++ b/964/CH26/EX26.7/26_7.sce
@@ -0,0 +1,25 @@
+//clc()
+//dy/dx = -y
+//y = exp(-x)
+h = 0.5;
+x = -1.5:h:10;
+y(1) = exp(-x(1));
+y(2) = exp(-x(2));
+y(3) = exp(-x(3));
+y(4) = 1;
+m(4) = y(4);
+for i = 4:23;
+ y(i+1) = y(i-3) + 4*h*(2*(-y(i)) + y(i-1) + 2*(-y(i-2)))/3;
+ m(i+1) = y(i+1);
+ y(i+1) = y(i-1) + h*(-y(i-1) +4 * (-y(i)) + (-y(i+1)))/3;
+end
+disp(x(4:24),"x = ")
+disp(m(4:24),"y0(milnes method) = ")
+disp(y(4:24),"corrected y1(milnes method) = ")
+for i =4:23
+ y(i+1) = y(i) + h *(55* (-y(i)) / 24 - 59 * (-y(i-1)) / 24 + 37*(-y(i-2))/24 - 9*(-y(i-3))/24);
+ m(i+1) = y(i+1)
+ y(i+1) = y(i) + h*(9*(-y(i+1))/24 +19*(-y(i))/24 - 5*(-y(i-1))/24 + (-y(i-2))/24);
+end
+disp(m(4:23),"y0(fourth order adams method) = ")
+disp(y(4:23),"y1(fourth order adams method) = ")