1
$\begingroup$

Let's say we have a list of functions:

y = 4/Sqrt[4 - x^2],
y = 4, 
y = 6/(x + 5), 
y = Abs[x],
x >= -2

The simple plot of these functions:

Plot[{4/Sqrt[4 - x^2], 4, 6/(x + 5), Abs[x]}, {x, -2, 5}, 
 PlotLegends -> "Expressions"]

enter image description here

And here is my best attempt to get the region derived by intersections:

Plot[{4/Sqrt[4 - x^2], 4, 6/(x + 5), Abs[x]}, {x, -5, 5}, PlotLegends -> "Expressions",
RegionFunction -> Function[{x, y},Reduce[x >= -2 && y <= 4 && y >= 6/(x + 5) &&y >= Abs[x]]],Filling -> Axis]

enter image description here

Here is the desired figure:

enter image description here

  1. Is there any way to plot functions and inequalities on the same chart?
  2. Is there any way to plot and calculate the squares of figures obtained by intersections of functions?
$\endgroup$
  • 1
    $\begingroup$ How are you picking the intersections and regions? $\endgroup$ – Feyre Nov 10 '16 at 18:43
  • $\begingroup$ The only one possible region that could be constructed by intersections of all the functions: res.cloudinary.com/invimind/image/upload/q_100/v1478804588/… $\endgroup$ – Elias Nov 10 '16 at 19:06
  • $\begingroup$ I think you are after RegionPlot; see RegionPlot[ Reduce[x >= -2 && y <= 4 && y >= 6/(x + 5) && y >= Abs[x]], {x, -2, 4}, {y, 0, 4}]. Note, however, that FunctionDomain[4/Sqrt[4 - x^2], x] yields -2 < x < 2, so RegionPlot[Reduce[x >= -2 && y <= 4 && y >= 6/(x + 5) && y >= Abs[x] && y <= 4/Sqrt[4 - x^2]], {x, -2, 4}, {y, 0, 4}] will fail. $\endgroup$ – corey979 Nov 10 '16 at 21:36
  • $\begingroup$ So how can I overcome that? I don't quite understand, why even such expression as RegionPlot[Reduce[y <= 4/Sqrt[4 - x^2]], {x, -1, 1}, {y, 0, 4}] yields an error $\endgroup$ – Elias Nov 11 '16 at 6:38
  • $\begingroup$ Reduce in not needed here; see RegionPlot[ x >= -2 && y <= 4 && y >= 6/(x + 5) && y >= Abs[x] && y <= 4/Sqrt[4 - x^2], {x, -2, 4}, {y, 0, 4}]. The region $x\in(2,4)$ is empty because, via &&, the conditions are a logical conjuction; in that interval 4/Sqrt[4 - x^2] doesn't exist, so the whole condition is False, so RegionPlot won't plot anything there. You'd have to separately add what you want to achieve in that region, e.g. RegionPlot[ 2 <= x <= 4 && y <= 4 && y >= Abs[x], {x, -2, 4}, {y, 0, 4}]. $\endgroup$ – corey979 Nov 11 '16 at 11:01
4
$\begingroup$

I think you are after a RegionPlot in this case.

RegionPlot[
 x >= -2 && y <= 4 && y >= 6/(x + 5) && y >= Abs[x] && 
  y <= 4/Sqrt[4 - x^2] && 2 <= x <= 4 && y <= 4 && 
  y >= Abs[x], {x, -2, 4}, {y, 0, 4}]

gives an empty plot; this is because

FunctionDomain[4/Sqrt[4 - x^2], x]

-2 < x < 2

so the function does not exist (in reals) in the region $x\in (2,4)$. 4/Sqrt[4 - x^2] /. x -> 3 gives -((4 I)/Sqrt[5]), and there is no order among the complex numbers so you can't choose values smaller than this. The region specification is a logical conjunction, so the condition y <= 4/Sqrt[4 - x^2] yields False in $x\in (2,4)$, hence the whole conjunction is False and so RegionPlot won't plot anything there. Therefore (note the "or": ||)

RegionPlot[(-2 <= x <= 2 && y <= 4 && y >= 6/(x + 5) && y >= Abs[x] &&
     y <= 4/Sqrt[4 - x^2]) || (2 <= x <= 4 && y <= 4 && 
    y >= Abs[x]), {x, -2, 4}, {y, 0, 4}]

enter image description here

gives the desired output.


Additionally, as a display of the line of reasoning, consider the disjoint regions separately:

plot1 = RegionPlot[
  x >= -2 && y <= 4 && y >= 6/(x + 5) && y >= Abs[x] && 
   y <= 4/Sqrt[4 - x^2], {x, -2, 4}, {y, 0, 4}]

plot2 = RegionPlot[
  2 <= x <= 4 && y <= 4 && y >= Abs[x], {x, -2, 4}, {y, 0, 4}]

GraphicsRow[{plot1, plot2}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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