How to Plot Trapezoidal and Simpson's rule plot with given curve or function?

Instead of plotting the interval boxes:

for X in intervals
    Y = f(X)
    plot!(IntervalBox(X, Interval(0, Y.hi)), c=:blue, label="", alpha=0.1)
end

try plotting polygon trapezoidal shapes:

for X in intervals
    x = [X.lo, X.hi, X.hi, X.lo]
    y = [0, 0, f(X.hi), f(X.lo)]
    plot!(Shape(x, y), c=:blue, label="", alpha=0.1)
end
1 Like