Hi all,
I have a function : x^{3} - 5x^{2} + 2x + 8
and I have this code:
using Plots, LaTeXStrings, ValidatedNumerics
gr()
f(x) = x^3 - 5x^2 + 2x + 8
#plot(f, 0, 2, aspect_ratio=:equal, fill=(0, :green), alpha=0.2, label="")
function make_intervals(N=6)
xs = range(0, stop=5, length=N+1)
return [xs[i]..xs[i+1] for i in 1:length(xs)-1]
end
# Plot Riemann Sums
intervals = make_intervals(6)
p = plot(aspect_ratio=:equal)
for X in intervals
Y = f(X)
plot!(IntervalBox(X, Interval(0, Y.lo)), c=:blue, label="", alpha=0.1)
plot!(IntervalBox(X, Interval(Y.lo, Y.hi)), c=:red, label="", alpha=0.1)
end
plot!(f, 0, 5, xlims=(0, 5), ylims=(-1,18), label=L"x^{3} - 5x^{2} + 2x + 8")
but the plot is far from the image I want to achieve. Which lines should I modify?