0
$\begingroup$

This question already has an answer here:

I have two functions:

f[x_] = 2 Cos[x]
g[x_] = -Sqrt[3]

I find the points of intersection.

sol = Solve[f[x] == g[x] && -2 Pi <= x <= 4 Pi, x]
pts = {x, f[x]} /. sol

I plot the two curves, the points, then I want to plot where the graph of f lies below the graph of g. I can fill the area between the curves:

Plot[{f[x], g[x]}, {x, -2 Pi, 4 Pi},
 Filling -> {1 -> {2}},
 Epilog -> {
   Red, PointSize[Medium], Point[pts]
   }]

But how can I fill the area between the curves only where the graph of f lies below the graph of g?

$\endgroup$

marked as duplicate by Sjoerd C. de Vries, Dr. belisarius plotting Oct 8 '15 at 22:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3
$\begingroup$
Plot[{f[x], g[x]}, {x, -2 Pi, 4 Pi}, 
 Filling -> 1 -> {{2}, {LightBlue, White}}, 
 Epilog -> {Red, PointSize[Medium], Point[pts]}]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Is this one of those methods that is still undocumented? $\endgroup$ – David Oct 8 '15 at 22:20
  • $\begingroup$ No, it is in the documentation under the Details section of Filling (last entry in the first table you encounter there). $\endgroup$ – Sjoerd C. de Vries Oct 8 '15 at 22:24
  • $\begingroup$ @SjoercC.deVries Got it. Thanks for the reference. $\endgroup$ – David Oct 9 '15 at 0:16

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