diff options
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 |