Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8318 > unrolled thread

Filling area between curves

Started byElaine Ritter <eyeninei9@gmail.com>
First post2012-02-03 07:14 +0000
Last post2012-02-04 11:29 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Filling area between curves Elaine Ritter <eyeninei9@gmail.com> - 2012-02-03 07:14 +0000
    Re: Filling area between curves "Oleksandr Rasputinov" <oleksandr_rasputinov@ymail.com> - 2012-02-04 11:28 +0000
    Re: Filling area between curves David Reiss <dbreiss@gmail.com> - 2012-02-04 11:29 +0000

#8318 — Filling area between curves

FromElaine Ritter <eyeninei9@gmail.com>
Date2012-02-03 07:14 +0000
SubjectFilling area between curves
Message-ID<jgg1fq$bpm$1@smc.vnet.net>
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?

[toc] | [next] | [standalone]


#8325

From"Oleksandr Rasputinov" <oleksandr_rasputinov@ymail.com>
Date2012-02-04 11:28 +0000
Message-ID<jgj4pk$mt2$1@smc.vnet.net>
In reply to#8318
On Fri, 03 Feb 2012 07:14:02 -0000, Elaine Ritter <eyeninei9@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}}
  }
]

[toc] | [prev] | [next] | [standalone]


#8326

FromDavid Reiss <dbreiss@gmail.com>
Date2012-02-04 11:29 +0000
Message-ID<jgj4qj$mtg$1@smc.vnet.net>
In reply to#8318
Plot[
 { Piecewise[{
    {-1 + 4 x - x^2, x < 1/2 (3 + Sqrt[13]) && x > 1/2 (5 -
Sqrt[13])},
    {0, x > 1/2 (3 + Sqrt[13]) && x < 0},
    {-1 + 4 x - x^2,
     x < 1/2 (3 + Sqrt[13]) && x > 1/2 (5 - Sqrt[13])}}] ,
  Piecewise [{{x - 2, x > 2 && x < 1/2 (3 + Sqrt[13])}, {2 - x ,
     x < 2 && x > 1/2 (5 - Sqrt[13])}}],
  Piecewise [{{x - 2, x > 1/2 (3 + Sqrt[13])}, {2 - x ,
     x < 1/2 (5 - Sqrt[13])}}],
  Piecewise[{{-1 + 4 x - x^2, x > 1/2 (5 - Sqrt[13])}}],
  Piecewise[{{-1 + 4 x - x^2, x < 1/2 (3 + Sqrt[13])}}]
  }, {x, 0, 5},
 Filling -> {1 -> {2}}]


--David




On Feb 3, 2:14 am, Elaine Ritter <eyenin...@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?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web