hbui
2024-07-25 11beed44c78847c91b25d8b4c9d8b3c7ada8de35
num-int/src/numint/riemann_sum.py
@@ -17,7 +17,16 @@
    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)]
@@ -36,7 +45,15 @@
    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)]