# How do I insert a circle inside another circle with Piecewise?

I need to create two circles, where one circle is inside the other using the Piecewise function. So far I have

f[x_, y_, z_, a_] := Piecewise[{{1, x^2 + y^2 <= 30}, {0, x^2 + y^2 > 30},}


I know by changing the radius, I can have a circle inside the other, but how do I go about it using Piecewise?

• What is $a$? What is $z$? Why use Piecewise? And do you want a Circle or a Disk? – David G. Stork Feb 10 '17 at 20:05
• @IrisGarza How did you mean to apply Piecewise? – ercegovac Feb 10 '17 at 20:06
• Why not use ParametricPlot, or if you need just two full circles, than simple Graphics directive. – ercegovac Feb 10 '17 at 20:08

PolarPlot[Piecewise[{{1, θ < 2 Pi}, {2, θ > 2 Pi}}], {θ, 0, 4 Pi}]

Module[{i = 1}, % /. x_Line :> {ColorData[i++], x}] Also implicit curves can be given in a list:

ContourPlot[
{x^2 + y^2 == 1, x^2 + y^2 == 2^2},
{x, -E, E}, {y, -E, E},
] It should be noted that constructing "chimeric" curves, given their implicit Cartesian equations, is not too hard, and does not need a piecewise construction. Recall that if $f(x,y)=0$ and $g(x,y)=0$ are two non-identical curves, then the curve $f(x,y)\,g(x,y)=0$ is a curve composed of the two other curves. Thus, using the Wizard's example:

ContourPlot[(x^2 + y^2 - 1) (x^2 + y^2 - 2^2) == 0, {x, -3, 3}, {y, -3, 3}] f[r1_, r2_] := Graphics[
{Circle[{0, 0}, r1],
Circle[{0, 0}, r2]}
]