hbui
2024-07-21 f12ecb67472aa2453d3b1b3fb68e4eb9521aee77
num-int/src/numint/main.py
@@ -1,7 +1,7 @@
import sys
from matplotlib import pyplot as plt
from numint.RiemannSum import numint
from numint.riemann_sum import numint_epsilon
from numint.input_parser import parse_function, parse_value
@@ -10,11 +10,15 @@
    (a, b) = (parse_value(start), parse_value(end))
    eps = parse_value(epsilon)
    (x, y, l, r, n) = numint(f, a, b, eps)
    # print(l, r, n)
    plt.step(x, y, label="x^3")
    plt.step(x, y, where="post", label="x^3")
    plt.plot(x, y, color="gray", alpha=0.3)
    (x, y, l, r, n) = numint_epsilon(f, a, b, eps)
    fig, ax = plt.subplots()
    ax.stairs(y[1:], x, baseline=0, fill=True, alpha=1,label=function_expr)
    ax.stairs(y[0:-1], x, baseline=0, fill=True, color="orange", alpha=0.5, label=function_expr)
    #ax.step(x, y, label=function_expr)
    #ax.step(x, y, where="post", label=function_expr)
    ax.plot(x, y, color="black")
    plt.show()
    pass