(boundary, steps)
| 10 | from __future__ import print_function |
| 11 | |
| 12 | def method_1(boundary, steps): |
| 13 | # "extended trapezoidal rule" |
| 14 | # int(f) = dx/2 * (f1 + 2f2 + ... + fn) |
| 15 | h = (boundary[1] - boundary[0]) / steps |
| 16 | a = boundary[0] |
| 17 | b = boundary[1] |
| 18 | x_i = makePoints(a,b,h) |
| 19 | y = 0.0 |
| 20 | y += (h/2.0)*f(a) |
| 21 | for i in x_i: |
| 22 | #print(i) |
| 23 | y += h*f(i) |
| 24 | y += (h/2.0)*f(b) |
| 25 | return y |
| 26 | |
| 27 | def makePoints(a,b,h): |
| 28 | x = a + h |
no test coverage detected