| | |
| | | pass |
| | | |
| | | |
| | | def numint_epsilon(f:Callable[[float], float], a: float, b: float, epsilon: float = 1e-3): |
| | | def numint_epsilon(f: Callable[[float], float], a: float, b: float, epsilon: float = 1e-3): |
| | | """ |
| | | a not very stupid implementation of Riemann sum for a function, |
| | | left sum and right sum are calculated as long as their difference less than the given epsilon. |
| | | :param f: |
| | | :param a: |
| | | :param b: |
| | | :param epsilon: |
| | | :return: |
| | | """ |
| | | dx = b - a |
| | | x = [a, b] # debug only |
| | | y = [f(a), f(b)] |
| | |
| | | return x, y, s_left, s_right, n |
| | | |
| | | |
| | | def numint_section(f:Callable[[float], float], a: float, b: float, section_count: int = 8): |
| | | def numint_section(f: Callable[[float], float], a: float, b: float, section_count: int = 8): |
| | | """ |
| | | a stupid implementation of Riemann sum for a function with a fixed number of sections in interval [a, b] |
| | | :param f: |
| | | :param a: |
| | | :param b: |
| | | :param section_count: |
| | | :return: |
| | | """ |
| | | dx = b - a |
| | | x = [a, b] |
| | | y = [f(a), f(b)] |