Monday 20 December 2010

algorithm to Implement Trapezodial method

Algorithm:

Step 1. Read x1, x2, e { x1 and x2 are the two end points    
              of the internal the allowed error in integral is e}

Step 2. h=x2-x1

Step 3. SI = (f(x1) + f(x2))/2;

Step 4. I = h-si

Step 5. i=1 Repeat

Step 6. x=x1 + h/2

Step 7. for J= 1 to I do

Step 8. SI= SI + f(x)

Step 9. x=x+h
Endfor

Step 10. i=21

Step 11. h=h/2 { Note that the internal has been halved above and the number of points where the function has to be computed is doubled}

Step 12.i0=i1

Step 13. i1 = h.si

Step 14. until / I1-i0 / <=c./i1/

Step 15. Write I1,h,i


Step 16. Stop

Algorithm



No comments:

Post a Comment