Hi all,
how do we draw an area like below (definite integral)?
and how to make the result function of the area becomes in the same box like label?
This is my code:
using Plots, LaTeXStrings
gr()
function Area(f, a, b, n)
xs = a:(b-a)/n:b
deltas = diff(xs)
cs = xs[1:end-1]
sum(f(cs[i]) * deltas[i] for i in 1:length(deltas))
end
f(x) = x^2
Area(x -> x^2, 0, 1, 50_000)
plot(f,0,1, label=L"y = x^2", legend=:outertop)
annotate!([(0.77,0.95, ("Area = ", 11, :black)),
(0.77,0.85, (Area(x -> x^2, 0, 1, 50_000), 11, :black))])