diff options
Diffstat (limited to '260/CH13/EX13.14/13_14.sce')
-rw-r--r-- | 260/CH13/EX13.14/13_14.sce | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/260/CH13/EX13.14/13_14.sce b/260/CH13/EX13.14/13_14.sce new file mode 100644 index 000000000..7c857b4a6 --- /dev/null +++ b/260/CH13/EX13.14/13_14.sce @@ -0,0 +1,40 @@ +//Eg-13.14
+//pg-556
+
+clear
+clc
+
+deff('out = func(in1,in2)','out = -0.3*(in2-50)^1.25')
+
+h = 0.1;
+x(1) = 0;
+y(1) = 100;
+y(2) = 96.20249; //from the question
+x(2) = x(1) + h;
+
+n = 10/h;
+
+for(i = 1:n)
+
+ x(i+1) = x(i) + h ;
+
+end
+
+
+
+
+for(i = 2:n)
+
+ yb(i+1) = y(i-1) + 2*h*func(x(i),y(i));
+ y(i+1) = y(i) + h/2*(func(x(i),y(i)) + func(x(i+1),yb(i+1)));
+
+end
+
+printf(' x y\n')
+for(i = 1:10)
+
+ printf('%f %f\n',x(i*10+1),y(i*10+1))
+
+end
+
+printf('\n\nThe value of T at t = 10 agrees with that of the analytical solution:\nT = 50 + (0.075t + 0.37604)^-4\n')
\ No newline at end of file |