Here the red circle circumscribes the outer radius and the green circle the inner one.

Let #r# be the outer radius - that is the radius of the red circle.

Then the vertices of the octagon centred at #(0, 0)# are at:

#(+-r, 0)#, #(0, +-r)#, #(+-r/sqrt(2), +-r/sqrt(2))#

The length of one side is the distance between #(r, 0)# and #(r/sqrt(2), r/sqrt(2))#:

#sqrt((r-r/sqrt(2))^2+(r/sqrt(2))^2)#

#=r sqrt((1-1/sqrt(2))^2 + 1/2)#

#=r sqrt(1-2/sqrt(2) + 1/2 + 1/2)#

#=r sqrt(2-sqrt(2))#

So the total perimeter is:

#color(red)(8r sqrt(2-sqrt(2)))#

So if the outer radius is #20#, then the perimeter is:

#8*20 sqrt(2-sqrt(2)) = 160 sqrt(2-sqrt(2)) ~~ 122.46#

#color(white)()#

The inner radius will be #r_1 = r cos(pi/8) = r/2 (sqrt(2+sqrt(2)))#

So #r = (2r_1)/(sqrt(2+sqrt(2)))#

Then the total perimeter is

#8r sqrt(2-sqrt(2)) = 8(2r_1)/(sqrt(2+sqrt(2)))sqrt(2-sqrt(2))#

#=16r_1 sqrt(2-sqrt(2))/sqrt(2+sqrt(2))#

#=16r_1 (sqrt(2-sqrt(2))sqrt(2+sqrt(2)))/(2+sqrt(2))#

#=16r_1 (sqrt((2-sqrt(2))(2+sqrt(2))))/(2+sqrt(2))#

#=16r_1 sqrt(2)/(2+sqrt(2))#

#=16r_1 (sqrt(2)(2-sqrt(2)))/((2+sqrt(2))(2-sqrt(2)))#

#=8r_1(2sqrt(2)-2)#

#=color(green)(16r_1(sqrt(2)-1))#

So if the inner radius is #20#, then the perimeter is:

#16*20(sqrt(2) - 1) = 320 (sqrt(2) - 1) ~~ 132.55#

#color(white)()#

**How good an approximation for #pi# does this give us?**

While we're here, what approximation for #pi# do we get by averaging the inner and outer radii?

#pi ~~ 2(2(sqrt(2) - 1) + sqrt(2-sqrt(2))) ~~ 3.1876#

...so not great.

To get as good an approximation as #355/113 ~~ 3.1415929#, the Chinese mathematician Zu Chongzhi used a #24576# (#= 2^13 xx 3#) sided polygon and counting rods.

https://en.wikipedia.org/wiki/Zu_Chongzhi