summaryrefslogtreecommitdiff
path: root/60/DEPENDENCIES/adamsbash.sce
diff options
context:
space:
mode:
Diffstat (limited to '60/DEPENDENCIES/adamsbash.sce')
-rwxr-xr-x60/DEPENDENCIES/adamsbash.sce27
1 files changed, 27 insertions, 0 deletions
diff --git a/60/DEPENDENCIES/adamsbash.sce b/60/DEPENDENCIES/adamsbash.sce
new file mode 100755
index 000000000..41210017d
--- /dev/null
+++ b/60/DEPENDENCIES/adamsbash.sce
@@ -0,0 +1,27 @@
+
+function [u,t] = adamsbashforth3(u0,t0,tn,h,f)
+
+//adamsbashforth3 3rd order method solving ODE
+// du/dt = f(u,t), with initial
+//conditions u=u0 at t=t0. The
+//solution is obtained for t = [t0:h:tn]
+//and returned in u
+
+umaxAllowed = 1e+100;
+
+t = [t0:h:tn]; u = zeros(t); n = length(u); u(1) = u0;
+for j = 1:n-1
+if j<3 then
+ k1=h*f(t(j),u(j));
+ k2=h*f(t(j)+h,u(j)+k1);
+ u(j+1) = u(j) + (k2+k1)/2;
+end;
+
+if j>=2 then
+ u(j+2) = u(j+1) + (h/12)*(23*f(t(j+1),u(j+1))-16*f(t(j),u(j))+5*f(t(j-1),u(j-1)));
+end;
+end;
+endfunction
+
+
+