summaryrefslogtreecommitdiff
path: root/260/CH13/EX13.4/13_4.sce
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:27:19 +0530
committerprashantsinalkar2017-10-10 12:27:19 +0530
commit7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch)
treedbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /260/CH13/EX13.4/13_4.sce
parentb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (diff)
downloadScilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.gz
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.bz2
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.zip
initial commit / add all books
Diffstat (limited to '260/CH13/EX13.4/13_4.sce')
-rw-r--r--260/CH13/EX13.4/13_4.sce38
1 files changed, 38 insertions, 0 deletions
diff --git a/260/CH13/EX13.4/13_4.sce b/260/CH13/EX13.4/13_4.sce
new file mode 100644
index 000000000..f67c1c3a0
--- /dev/null
+++ b/260/CH13/EX13.4/13_4.sce
@@ -0,0 +1,38 @@
+// about the analytical integration for the analytical solution
+//Eg-13.4
+//pg-529
+
+clear
+clc
+
+
+x(1) = 0;
+yb(1) = 0;
+y(1) = 1; //Initial condition
+h = 0.1;
+deff('out = func(in1,in2)','out = 0.5*(1+in1)*in2^2')
+
+//Taking the exact values using the expression calculated analytically as y = 4/(4-2*x-x^2)
+z(1) = exp(x(1)^3/3);
+
+for(i = 2:11)
+
+ x(i) = 0.1+(i-2)*0.1;
+ z(i+1) = 4/(4-2*x(i)-x(i)^2);
+end
+
+for(i = 1:10)
+ yb(i+1) = y(i) + 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 yPc yExact\n')
+
+for(i = 2:11)
+ printf('%f %f %f\n',x(i),y(i),z(i+1))
+end
+
+printf('\nSolving analytically gives :\n')
+printf('y = 4/(4-2*x-x^2)\n') \ No newline at end of file