summaryrefslogtreecommitdiff
path: root/50/CH6/EX6.21/ex_6_21.sce
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /50/CH6/EX6.21/ex_6_21.sce
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 '50/CH6/EX6.21/ex_6_21.sce')
-rwxr-xr-x50/CH6/EX6.21/ex_6_21.sce27
1 files changed, 27 insertions, 0 deletions
diff --git a/50/CH6/EX6.21/ex_6_21.sce b/50/CH6/EX6.21/ex_6_21.sce
new file mode 100755
index 000000000..32b9e0d95
--- /dev/null
+++ b/50/CH6/EX6.21/ex_6_21.sce
@@ -0,0 +1,27 @@
+// example no. 6.21,
+// caption: solving the IVP by implicit RK2 method
+
+// u'=f(t,u)
+// u'=-2tu^2
+//u(0)=1,h=0.2;
+t0=0;h=0.2;tn=.4;u0=1;
+deff('[z]=f(t,u)','z=-2*t*u^2');
+umaxAllowed = 1e+100;
+
+t = [t0:h:tn]; u = zeros(t); n = length(u); u(1) = u0;
+
+for j = 1:n-1
+ // k1=h*f(t(j)+h/2,u(j)+k1/2);
+ // conidering the IVP we can infer that the above expression in non linear in k1,
+// hence we use newton rapson method to solve for k1;
+deff('[w]=F(u2)','w=k1+h*(2*t(j)+h)*(u(j)+k1/2)^2') // u2=u(2)
+deff('[x]=Fp(u2)','x=1+h*(2*t(j)+h)*(u(j)+k1/2)')
+
+k1=h*f(t(j),u(j));
+
+newton(k1,F,Fp);
+ u(j+1) = u(j) +k1
+ disp(u(j+1))
+
+end;
+