diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /60/DEPENDENCIES/adamsbash.sce | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '60/DEPENDENCIES/adamsbash.sce')
-rwxr-xr-x | 60/DEPENDENCIES/adamsbash.sce | 27 |
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 + + + |