A regular octagon is inscribed in the circle x² + y² = 2, with four of its vertices lying on the coordinate axes. What are the equations of the lines containing the eight sides of the octagon?
r = Sqrt[2];
angles = Table[\[Theta], {\[Theta], 0, 2 \[Pi] - \[Pi]/4, \[Pi]/4}];
vertices =
Table[{r Cos[\[Theta]], r Sin[\[Theta]]}, {\[Theta], angles}];
lines = Table[
With[{p1 = vertices[[i]],
p2 = vertices[[Mod[i, 8] +
1]]}, (y - p1[[2]]) (p2[[1]] - p1[[1]]) == (x -
p1[[1]]) (p2[[2]] - p1[[2]]) // Expand // Simplify], {i, 1,
8}]
The code above is one way to solve the problem using parametric equations in polar coordinates. What other methods could be used?