Thursday, 2024-12-12, 5:29 AM

Main Sign Up Login
Welcome, Guest · RSS
Site menu
Search
Site friends
  • acmgmat
  • nano-unt
  • fc-unt
  • accf
  • Statistics

    Total online: 2
    Guests: 2
    Users: 0
     Publisher
    Main » Articles » E-Learn » Numerical Methods

    Secant Method - Wolfram Mathematica v10.

    ROOTFINDING

     

     Secant  Method

    www.jesus-avalos.ucoz.com

     

    ALGORITHM CODE:

     SecantMethod[x0_,x1_,max_]:=Module[{},k=1;p0=N[x0];p1=N[x1];

      Print["p0=",PaddedForm[p0,{16,16}]", f[p0]=",NumberForm[f[p0],16]];

      Print["p1=", PaddedForm[p1,{16,16}],", f[p1]=", NumberForm[f[p1],16]];

      p2=p1;

      p1=p0;

      While[k<max, p0=p1;p1=p2; p2=p1-(f[p1](p1-p0))/(f[p1]-f[p0]);

       k=k+1;

       Print["p "k, "=", PaddedForm[p2,{16,16}],", f[","p"k,"]=",NumberForm[f[p2],16]];];

      Print["p =",NumberForm[p2,16]];

      Print[" Δp=±"Abs[p2-p1]];

      Print["f[p]=",NumberForm[f[p2],16]];]

     EXAMPLE:

     f[x_]=x^3+x-1

     -1+x+x3

     SecantMethod[0,1,9]

     p0= , f[p0]=  0.0000000000000000 -1.

     p1=  1.0000000000000000 , f[p1]= 1.

     2  p =  0.5000000000000000 , f[ 2 p ]= -0.375

     3  p =  0.6363636363636363 , f[ 3 p ]= -0.1059353869271225

     4  p =  0.6900523560209423 , f[ 4 p ]= 0.01863614179998446

     5  p =  0.6820204196481856 , f[ 5 p ]= -0.000736518493373528

     6  p =  0.6823257814098928 , f[ 6 p ]= -4.847148849740357*10-6

     7  p =  0.6823278043590257 , f[ 7 p ]= 1.272670357987948*10-9

     8  p =  0.6823278038280184 , f[ 8 p ]= -2.275957200481571*10-15

     9  p =  0.6823278038280193 , f[ 9 p ]= 1.665334536937735*10-16

      p= 0.6823278038280193

     9.99201*10-16  Δp=±

     f[p]= 1.665334536937735*10-16

     Plot[-1+x+x3,{x,0,1}]

    Category: Numerical Methods | Added by: JARMASTER (2015-08-05)
    Views: 1161 | Tags: método de la secante, secant method - wolfram mathematica
    SOFT JAR © 2024
    Create a free website with uCoz