Re: Filling area between curves

*To*: mathgroup at smc.vnet.net*Subject*: [mg124748] Re: Filling area between curves*From*: "Oleksandr Rasputinov" <oleksandr_rasputinov at ymail.com>*Date*: Sat, 4 Feb 2012 06:27:28 -0500 (EST)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*References*: <jgg1fq$bpm$1@smc.vnet.net>

On Fri, 03 Feb 2012 07:14:02 -0000, Elaine Ritter <eyeninei9 at gmail.com> wrote: > I have 3 curves, and I want to fill one of the areas that they bound. > The equations are > F[x] = -1 + 4 x - x^2 > G[x] := x - 2 > H[x] := 2 - x > and I want to fill the region that I shaded in this picture: > http://i.imgur.com/X2urH.png > > I've been trying to figure this out on my own, but to no avail. How do > I do this? > Please, try to copy the code in your post from Mathematica rather than re-typing it. There are errors in all three of the definitions above. Filling regions can be defined between a pair of curves, but not bounded by several curves, so you might try ending the line segments at the horizontal axis and filling the pieces separately as follows: F[x_] := -1 + 4 x - x^2; G[x_] := Piecewise[{{x - 2, x >= 2}, {Indeterminate, True}}]; H[x_] := Piecewise[{{2 - x, x <= 2}, {Indeterminate, True}}]; Plot[ {F[x], G[x], H[x]}, {x, 0, 5}, PlotRange -> {0, 3}, Filling -> { 1 -> {{2}, {None, Red}}, 1 -> {{3}, {None, Red}} } ] Or, you can close the region another way: F[x_] := -1 + 4 x - x^2; G[x_] := x - 2; H[x_] := 2 - x; m[x_] := Max[G[x], H[x]]; Plot[ {F[x], G[x], H[x], m[x]}, {x, 0, 5}, PlotStyle -> {Automatic, Automatic, Automatic, None}, PlotRange -> {0, 3}, Filling -> { 1 -> {{4}, {None, Automatic}} } ]