Thursday, 2024-04-18, 11:22 PM

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

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

    Bisection Method - Wolfram Mathematica v10.

     

    ROOTFINDING

     

     Bisection Method

    www.jesus-avalos.ucoz.com

     

    ALGORITHM CODE:

     Bisection[a0_,b0_,m_]:=Module[{},a=N[a0];b=N[b0]; c=(a+b)/2; k=0;

      output={{k,a,c,b,f[c]}};

      While[k<m,

       If[Sign[f[b]]==Sign[f[c]],

        b=c,  a=c;];

       c=(a+b)/2;

       k=k+1;

       output=Append[output,{k,a,c,b,f[c]}];];

      Print[NumberForm[TableForm[output,

         TableHeadings->{None,{"k","a_k","c_k", "b_k","f[c_k]"}}],16]];

      Print["  c=",NumberForm[c,16]];

      Print[" Δc=±",(b-a)/2];

      Print["f[c]=", NumberForm[f[c],16]];]

     EXAMPLE:

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

     -1+x+x3

     Bisection[0,1,10]

     {

     {k, a_k, c_k, b_k, f[c_k]},

     {0, 0., 0.5, 1., -0.375},

     {1, 0.5, 0.75, 1., 0.171875},

     {2, 0.5, 0.625, 0.75, -0.130859375},

     {3, 0.625, 0.6875, 0.75, 0.012451171875},

     {4, 0.625, 0.65625, 0.6875, -0.061126708984375},

     {5, 0.65625, 0.671875, 0.6875, -0.02482986450195312},

     {6, 0.671875, 0.6796875, 0.6875, -0.006313800811767578},

     {7, 0.6796875, 0.68359375, 0.6875, 0.003037393093109131},

     {8, 0.6796875, 0.681640625, 0.68359375, -0.001646004617214203},

     {9, 0.681640625, 0.6826171875, 0.68359375, 0.0006937412545084953},

     {10, 0.681640625, 0.68212890625, 0.6826171875, -0.0004766195779666305}

    }

       c= 0.68212890625

      Δc=± 0.000488281

     f[c]= -0.0004766195779666305

     

    Plot[{x^3 + x - 1, (1 - x)^(1/3), x}, {x, 0, 1}]

     

    Category: Numerical Methods | Added by: JARMASTER (2015-08-05)
    Views: 1646 | Tags: Wolfram Mathematica, Bisection method, método de bisección
    SOFT JAR © 2024
    Create a free website with uCoz