To complement the answer by @achrzesz, let us point out two additional approaches to fill exactly the region between the curves y=f(x) and y=g(x) where f(x)≤g(x), with x in a given interval [a,b], that is, the region
{(x,y)∈R2∣a≤x≤b, f(x)≤y≤g(x)}.
First method:
f(x) = sin(2*x+3)
g(x) = 2*cos(2*x+2)
pf = plot(f(x), (x,-3,3), color="red", fill=max_symbolic(f(x),g(x)), fillcolor="lightgreen")
pg = plot(g(x), (x,-3,3), color="blue")
show(pf+pg)
Second method:
var("x,y")
p = plot([f(x),g(x)], (x,-3,3), color=["red","blue"])
r = region_plot([f(x)<y, y<g(x)], (x,-3,3), (y,-2,2), incol="lightgreen", plot_points=[100,100])
show(r+p)
See this SageMath Cell
![]() | 2 | No.2 Revision |
To complement the answer by @achrzesz, let us point out two additional approaches to fill exactly the region between the curves y=f(x) and y=g(x) where f(x)≤g(x), with x in a given interval [a,b], that is, the region
{(x,y)∈R2∣a≤x≤b, f(x)≤y≤g(x)}.
First method:
f(x) = sin(2*x+3)
g(x) = 2*cos(2*x+2)
pf = plot(f(x), (x,-3,3), color="red", fill=max_symbolic(f(x),g(x)), fillcolor="lightgreen")
pg = plot(g(x), (x,-3,3), color="blue")
show(pf+pg)
Second method:
var("x,y")
p = plot([f(x),g(x)], (x,-3,3), color=["red","blue"])
r = region_plot([f(x)<y, y<g(x)], (x,-3,3), (y,-2,2), incol="lightgreen", plot_points=[100,100])
show(r+p)
See this SageMath Cell
![]() | 3 | No.3 Revision |
To complement the answer by @achrzesz, let us point out two additional approaches to fill exactly the region between the curves y=f(x) and y=g(x) where f(x)≤g(x), with x in a given interval [a,b], that is, the region
{(x,y)∈R2∣a≤x≤b, f(x)≤y≤g(x)}.
First method:
f(x) = sin(2*x+3)
g(x) = 2*cos(2*x+2)
pf = plot(f(x), (x,-3,3), color="red", fill=max_symbolic(f(x),g(x)), fillcolor="lightgreen")
pg = plot(g(x), (x,-3,3), color="blue")
show(pf+pg)
Second method:
var("x,y")
p = plot([f(x),g(x)], (x,-3,3), color=["red","blue"])
r = region_plot([f(x)<y, y<g(x)], (x,-3,3), (y,-2,2),
incol="lightgreen", plot_points=[100,100])
show(r+p)
See this SageMath Cell