4
$\begingroup$

enter image description here

Hi. I want to filling the are between the curves x^2, x and -x+1 from x=0 to x=a:=-1/2 + sqrt(5)/2. How can do this? Thanks.

$\endgroup$
1
  • $\begingroup$ Please post the code in text form. $\endgroup$
    – cvgmt
    Apr 25, 2023 at 23:29

3 Answers 3

4
$\begingroup$
Plot[{x^2, x, -x + 1, Min[x, 1 - x]}, {x, 0, 1}, 
 PlotStyle -> {Automatic, Automatic, Automatic, None}, 
 Filling -> {4 -> {{1}, {None, Automatic}}}]

enter image description here

$\endgroup$
3
$\begingroup$
Plot[{x^2, x, -x + 1}, {x, 0, 1}, Filling -> {1 -> {{3}, {Automatic, None}}}]

enter image description here

You can replace Automatic with whatever directive you want.

Update

Missed that the desire was to highlight the area between all three. Here's one approach:

Plot[{x^2, x, -x + 1}, {x, 0, 1}, 
  Filling -> {1 -> {{3}, {Automatic, None}}, 2 -> {{3}, {White, None}}}]

enter image description here

It's a bit hacky, in that it assumes the background to be white, but it avoids introducing extra functions.

$\endgroup$
3
  • $\begingroup$ But I don't want the top to be painted. I only want the part enclosed by the three curves. $\endgroup$
    – eraldcoil
    Apr 25, 2023 at 19:50
  • $\begingroup$ Oh, sorry, I didn't see the little x. I read it as between the curves x^2 and -x+1. Others have already posted answers. $\endgroup$
    – lericr
    Apr 25, 2023 at 20:15
  • $\begingroup$ I posted a slightly different way to solve it. $\endgroup$
    – lericr
    Apr 25, 2023 at 20:19
2
$\begingroup$
Clear["Global`*"]

An alternative to using Filling

Show[
 RegionPlot[
  Tooltip[y < x && y < 1 - x && y > x^2 && 0 < x < 1],
  {x, 0, 1}, {y, 0, 1},
  PlotPoints -> 25,
  MaxRecursion -> 5,
  FrameLabel -> (Style[#, 14] & /@ {"x", "y"})],
 Plot[Evaluate[
   Tooltip /@ {x^2, x, -x + 1}], {x, 0, 1},
  PlotLegends -> Placed["Expressions", {.5, .8}]]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.