summaryrefslogtreecommitdiff
path: root/260/CH13/EX13.2/13_2.sce
diff options
context:
space:
mode:
Diffstat (limited to '260/CH13/EX13.2/13_2.sce')
-rw-r--r--260/CH13/EX13.2/13_2.sce26
1 files changed, 26 insertions, 0 deletions
diff --git a/260/CH13/EX13.2/13_2.sce b/260/CH13/EX13.2/13_2.sce
new file mode 100644
index 000000000..06af7e065
--- /dev/null
+++ b/260/CH13/EX13.2/13_2.sce
@@ -0,0 +1,26 @@
+//Eg-13.2
+//pg-523
+
+clc
+clear
+
+
+//F = x^2*y = dy/dx
+
+deff('[out] = func(in1,in2)','out = in1^2*in2')
+
+y(1) = 1; //Initial condition
+x(1) = 0;
+z(1) = exp(x(1)^3/3);
+
+h = 0.1;
+
+printf('x yEuler yexact\n')
+for(i = 1:10)
+ x(i) = 0.1*i;
+ y(i+1) = y(i) + h*func(x(i),y(i));
+ z(i+1) = exp(x(i)^3/3);
+ printf('%f %f %f\n',x(i),y(i),z(i+1))
+end
+
+printf('\nNote that the exact solution is calculated from the analytical solution y = exp(x^3/3)\n') \ No newline at end of file