1
$\begingroup$

I am trying to illustrate this math problem with a graph.

I tried several things, amongst other:

ContourPlot[{4 <= x^2 + y^2 <= 25}, {x, 0, Infinity}, {y, 0, 
  Infinity}]

How should I write it?

Thank you very much.

$\endgroup$
  • $\begingroup$ ContourPlot is used to plot level curves. Is that what you want? Your code indicates that you want to plot a continuous range of level curves. $\endgroup$ – C. E. Jul 5 '18 at 9:26
  • $\begingroup$ RegionPlot is for plotting inequalities. $\endgroup$ – Lotus Jul 5 '18 at 10:00
  • $\begingroup$ @C.E. I don't get the thing with level curves. I have two variables. $\endgroup$ – Dovendyr Jul 5 '18 at 10:30
1
$\begingroup$

Is this what you want ?

RegionPlot[{4 <= x^2 + y^2 <= 25}, {x, -10, 10}, {y, -10, 10}]

enter image description here

$\endgroup$
  • $\begingroup$ Yes @Lotus, this is what I want. I added Axes -> True. How can I make it more beautiful? $\endgroup$ – Dovendyr Jul 5 '18 at 10:29
  • $\begingroup$ RegionPlot has many many options to make it look beautiful. Check it out ! $\endgroup$ – Lotus Jul 5 '18 at 10:31
  • $\begingroup$ Hahaha look, it got out of control really fast! RegionPlot[{4 <= x^2 + y^2 <= 25}, {x, -7, 7}, {y, -7, 7}, Axes -> True, ColorFunction -> "DarkRainbow", PlotLegends -> "Expressions", Mesh -> 30, MeshShading -> {{Red, Yellow}, {Pink, Orange}}] $\endgroup$ – Dovendyr Jul 5 '18 at 10:33
1
$\begingroup$

If you want to use ContourPlot this might be another option:

ContourPlot[Boole[4 <= x^2 + y^2 <= 25], {x, -8, 8}, {y, -8, 8}]

which gives

enter image description here

$\endgroup$
1
$\begingroup$

You can use Annulus:

Region @ Annulus[{2, 5}]

enter image description here

Here, I just use Region to visualize the annulus. If you want the portion of the annulus in the first quadrant:

Region @ Annulus[{0, 0}, {2, 5}, {0, Pi/2}]

enter image description here

The nice thing about this approach is that the annulus is computable. For example, using this representation one can solve the integral in the linked question:

Integrate[x^3 y^2 Log[x^2+y^2], {x,y} ∈ Annulus[{0,0},{2,5},{0,Pi/2}]]

-(4/735) (77997 + 896 Log[2] - 546875 Log[5])

$\endgroup$
0
$\begingroup$

While RegionPlot is the easiest approach, you could also use ContourPlot

ContourPlot[x^2 + y^2, {x, -6, 6}, {y, -6, 6},
 Contours -> {4, 25},
 ContourShading -> {None, LightBlue, None},
 Axes -> True]

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.