# How can I plot two concentric circles with a polygon inscribed in one and circumscribed about the other

So I am new to Mathematica still learning basic codes.. However I need help to become quicker in my research. Can anyone help me with the simplicit code to plot 2 concentric circles and a polygon of sides n (that I can manipulate) inscribed in one circle and circumscribed about the other.

• can you post a sample image - a drawing or from a website. Apr 24, 2016 at 12:08
• Are your polygons always regular (as kirma assumes in his answer)? Not all polygons are circumscribable or inscribable. Apr 24, 2016 at 12:27
• So the polygon does not have to always be regular, as long as I have the circumscribed and inscribed, and my circles fixed May 18, 2016 at 23:33

A simpler and minimal version

Manipulate[
Graphics[{Red, Circle[{0, 0}, Cos[Pi/n]], Blue, Circle[{0, 0}, 1],
Green, Line[{Cos[2 Pi #/n], Sin[2 Pi #/n]} & /@ Range[0, n]]}],
{n, 3, 30, 1}]


Inner circle will adjust itself according to the polygon.

For fixed inner circle

Manipulate[
Graphics[{Red, Circle[{0, 0}, 1], Blue, Circle[{0, 0}, 1/Cos[Pi/n]],
Green, Line[
1/Cos[Pi/n] {Cos[2 Pi #/n], Sin[2 Pi #/n]} & /@ Range[0, n]]},
PlotRange -> 2 {{-1, 1}, {-1, 1}}], {n, 3, 30, 1}]


If you don't use PlotRange, you would not be able to see the difference.

• Alternatively: Manipulate[Graphics[{Blue, Circle[], Red, Circle[{0, 0}, Cos[π/n]], Directive[EdgeForm[Green], FaceForm[]], RegularPolygon[n]}], {n, 3, 30, 1}] Apr 24, 2016 at 13:08
• I am still with M9, @J.M. Apr 24, 2016 at 13:18
• That's fine, I left it just for people who can try it out on later versions. Apr 24, 2016 at 13:20
• If I want the polygon to stay circumscribed about the circle however with the circle inside to stay fixed,, so as n increases the circle inside is fixed but the polygon is still circumscribed about it. May 16, 2016 at 11:10
• Can you help me with that? May 16, 2016 at 11:10

There are numerous ways to do this in Mathematica, and it's hard to say which would be most useful for learning. Here's one; a unit circle is drawn, then a polygon with no filling and black edge on basis of CirclePoints which generates points of a regular polygon lying on the unit circle. Finally, mean of two first points is taken, and distance to the origin is used as the radius of the incircle. Manipulate is then used to control the value of n.

Manipulate[
With[{points = CirclePoints[n]},
Graphics[{Circle[], FaceForm[None], EdgeForm[Black], Polygon[points],
Circle[{0, 0}, Norm[Mean[Take[points, 2]]]]}]], {n, 3, 10, 1}]


• Here is a one-line derivation of the formula for the inradius of a regular $n$-gon, based on kirma's observation: PowerExpand[Simplify[ComplexExpand[Abs[(1 + E^(2 π I/n))/2]]]]. Apr 24, 2016 at 13:12
• @J.M. It was a strange experiment of the "avoid explicit trigonometry" sorts. :) Apr 24, 2016 at 13:53
• Why all the anathema? ;) :P Apr 24, 2016 at 14:03
• @J.M. I guess I wanted to write the solution starting from CirclePoints, and it didn't turn out too awkward to do so. The first sentence in my answer expresses the Weltschmerz involved in expressing the solution only in this manner. :) Apr 24, 2016 at 14:13