Showing posts with label ALGORITHM. Show all posts
Showing posts with label ALGORITHM. Show all posts

Tuesday, August 2, 2016

ALGORITHM OF TRAPEZOIDAL RULE


ALGORITHM OF TRAPEZOIDAL RULE

1-Enter value of lower limit (a) & upper limit (b)
2-Enter the no. of sub-intervals (n)
3-h = (b-a) / n
4- s = y(a) + y(b)
5- for (j=1 to n-1)
  {
   s = s+2*y(a+i*h)
   }
6-Result = (h/2) * s
7- Print result
8- Exit ( )

ALGORITHM OF SIMPSON 3/8 RULE

ALGORITHM OF SIMPSON 3/8 RULE


1-Enter value of upper limit (a) and lower limit(b)
2-Enter value of sub-interval (n)
3-h = (b-a) / n
4-s = y(a) +y(b)
5-for (j = 1 to n-1)
   if (j % 3 = = 0)
   s = s+2*y(a+j*h)
   else
   s= s +3*y(a+j*h)
6- result = 3*(h/8) * s
7-Print result
8-exit ( )

ALGORITHM OF SIMPSON’S 1/3 RULE


ALGORITHM OF SIMPSON’S 1/3 RULE

1-Enter value of upper limit & lower limit
2-Enter value of sub-interval(n)
3-h=(b-a)/n
4-s=y(a)+y(b)
5-For (j=1 to n-1) dø
   if( j%2==0)
  {
   s= s+2*y(a+j*h)
  else
  s=s+4*y(a+j*h)
  }
6-Result = (h/3)*s
7-Print  “result”
8- exit( )

ALGORITHM FOR REGULA FALSI

ALGORITHM FOR  REGULA FALSI


  1. Input the values of x0,x1,e,n.where e is the error allowed and n  is the maximum number of iteration.


2. Find f(x0)*f(x1) and if [f(x0)*f(x1)]<0
   {
3.    for (i=1 to n)
   }


    4. calculate x2=[x0f(x1)-x1f(x0)]/f(x0)-f(x1)


    5. if |f(x2)|<e and if [f(x0)*f(x2)<0]


        x1=x2


    6. else


       x0=x2

    7. print (“Root is x2”)

ALGORITHM FOR NEWTON RAPHSON METHOD

ALGORITHM FOR NEWTON RAPHSON METHOD


  1.    Start
  2.    Read the values of x0,e,delta,n;
   Where x0 is initial approximation, e is error      
   allowed. delta is the slope and n is
   maximum number of iteration.
 
  1.    for i=1 to n,
  2.    if | f(x0 )|<delta,
   then goto 9
  1.    x1= x0 –[f (x0  )/f (x0 )]
  2.    if |( x0 – x1)/ x0 | <e, then goto 11
  3.    write “Solution does not converge in n
          iteration”.

  1.    Stop
  2.    Write “Slope is too small”.
  3. Stop
  4. Write ”Convergent solution is x”.
  5. Stop

ALGORITHM FOR BISECTION METHOD



ALGORITHM FOR BISECTION METHOD


1- Enter f(x), error, max_iteration.
2- Enter a and b such that f (a).f (b) <0.
3- if f (a).f (b)>0 then
                             goto step 2
4- for (i=0; i<max_iteration; i++)
     {
       x= (a+b)/2
           if f(x).f (a) <0
                  b=x;
           else
                   a=x;
            if [(b-a)/b <=error]
            {
               printf “Root is x”
               Stop
             }
      }
5- printf “Solution does not converge in  
   max_iteration.
6- Stop