Approximate integral using Riemann sum
(f, begin, end, precision_power)
| 101 | |
| 102 | # ---------------------- Math Operations ---------------------- |
| 103 | def do_integral(f, begin, end, precision_power): |
| 104 | """Approximate integral using Riemann sum""" |
| 105 | precision = 10 ** (-precision_power) |
| 106 | x = begin |
| 107 | total = 0.0 |
| 108 | while x < end: |
| 109 | total += f(x) * precision |
| 110 | x += precision |
| 111 | return total |
| 112 | |
| 113 | |
| 114 | def test_math_ops(num_tests, precision_power): |
no outgoing calls