MCPcopy Create free account
hub / github.com/covscript/covscript / do_integral

Function do_integral

tests/benchmark.py:103–111  ·  view source on GitHub ↗

Approximate integral using Riemann sum

(f, begin, end, precision_power)

Source from the content-addressed store, hash-verified

101
102# ---------------------- Math Operations ----------------------
103def 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
114def test_math_ops(num_tests, precision_power):

Callers 1

test_math_opsFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_math_opsFunction · 0.68