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 /75/DEPENDENCIES/muller.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 '75/DEPENDENCIES/muller.sce')
-rwxr-xr-x | 75/DEPENDENCIES/muller.sce | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/75/DEPENDENCIES/muller.sce b/75/DEPENDENCIES/muller.sce new file mode 100755 index 000000000..4faba6b75 --- /dev/null +++ b/75/DEPENDENCIES/muller.sce @@ -0,0 +1,32 @@ +function x=muller(x0,x1,x2,f) + R=3; + PE=10^-8; + maxval=10^4; + for n=1:1:R + + La=(x2-x1)/(x1-x0); + Da=1+La; + ga=La^2*f(x0)-Da^2*f(x1)+(La+Da)*f(x2); + Ca=La*(La*f(x0)-Da*f(x1)+f(x2)); + + q=ga^2-4*Da*Ca*f(x2); + if q<0 then q=0; + end + p= sqrt(q); + if ga<0 then p=-p; + end + La=-2*Da*f(x2)/(ga+p); + x=x2+(x2-x1)*La; + if abs(f(x))<=PE then break + end + if (abs(f(x))>maxval) then error('Solution diverges'); + abort; + break + else + x0=x1; + x1=x2; + x2=x; + end + end + disp(n," no. of iterations =") +endfunction
\ No newline at end of file |