The short answer is , where w is the side-to-side width and x is the length of a segment.
We have a nifty little search utility you can use here:
(A simplified version is on the home page of our site)
If you search on "octagon", you will see my response to Martin, which is titled Making a wooden octagon. On that page, you will see how I've come up with this formula.
Stephen La Rocque.