Hi all, I want to plot partitions of Riemann Sums from this blog:
https://julialang.org/blog/2017/03/piday/
The problem is since it is from 2017 article, it is using linspace, I read around and see it is replaced by range. I try to convert it and it has problem still.
LoadError: UndefVarError: … not defined
[1] (::var"#23#24"{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}})(i::Int64)
** @ Main ./twiceprecision.jl:0**
…
This is the code
using Plots, LaTeXStrings
gr()
f(x) = √(4 - x^2)
#plot(f, 0, 2, aspect_ratio=:equal, fill=(0, :green), alpha=0.2, label="")
function make_intervals(N=10)
xs = range(0, stop=2, length=11)
return [xs[i]..xs[i+1] for i in 1:length(xs)-1]
end
intervals = make_intervals(30)
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, 2)
p