# Equations of the sides of a regular octagon inscribed in x² + y² = 2 with four vertices on the axes

**URL:** <https://community.wolfram.com/t/equations-of-the-sides-of-a-regular-octagon-inscribed-in-x-y-2-with-four-vertices-on-the-axes/25918>\
**Category:** Questions\
**Tags:** geometry\
**Created:** [August 25, 2025, 2:11pm UTC](https://community.wolfram.com/t/equations-of-the-sides-of-a-regular-octagon-inscribed-in-x-y-2-with-four-vertices-on-the-axes/25918 "2025-08-25T14:11:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![studymma168](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@studymma168](https://community.wolfram.com/u/studymma168)\
**Post date:** [August 25, 2025, 2:11pm UTC](https://community.wolfram.com/t/equations-of-the-sides-of-a-regular-octagon-inscribed-in-x-y-2-with-four-vertices-on-the-axes/25918/1 "2025-08-25T14:11:14Z")

</div>

> 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?

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [August 25, 2025, 7:21pm UTC](https://community.wolfram.com/t/equations-of-the-sides-of-a-regular-octagon-inscribed-in-x-y-2-with-four-vertices-on-the-axes/25918/2 "2025-08-25T19:21:23Z")

</div>

You could use`CirclePoints[{Sqrt[2], 0}, 8]` to generate the vertices:

```
vertices = CirclePoints[{Sqrt[2], 0}, 8];
sides = Partition[vertices, 2, 1, 1];
equations = couples /. {p1_List, p2_} :>
   ({x, y} - p1) . RotationMatrix[Pi/2] . (p2 - p1) == 0
ContourPlot[equations, {x, -2, 2}, {y, -2, 2},
 Epilog -> Circle[{0, 0}, Sqrt[2]]]

```

---

<div class="post-metadata">

**Author:** ![mroge02](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mroge02/32/28775_2.png) [@mroge02](https://community.wolfram.com/u/mroge02)\
**Post date:** [August 26, 2025, 12:12am UTC](https://community.wolfram.com/t/equations-of-the-sides-of-a-regular-octagon-inscribed-in-x-y-2-with-four-vertices-on-the-axes/25918/3 "2025-08-26T00:12:19Z")

</div>

More alternatives for the steps:

Maybe this:

```
RegularPolygon[{1, Pi/4}, 8] //
    CanonicalizePolygon //
   Apply@Part //
  Partition[#, 2, 1, 1] & //
 Map[y == InterpolatingPolynomial[#, x] &]

```

Or this if have one with vertical and horizontal sides:

```
RegularPolygon[8] //
    CanonicalizePolygon //
   Apply@Part //
  Partition[#, 2, 1, 1] & //
 Map[
  Quiet[Check[
     y == InterpolatingPolynomial[#, x],
     x == InterpolatingPolynomial[Reverse /@ #, y],
     InterpolatingPolynomial::ipdup],
    InterpolatingPolynomial::ipdup] &
  ](*//
 ToRadicals//
 FullSimplify*)

```

---

<div class="post-metadata">

**Author:** ![studymma168](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@studymma168](https://community.wolfram.com/u/studymma168)\
**Post date:** [August 26, 2025, 4:48am UTC](https://community.wolfram.com/t/equations-of-the-sides-of-a-regular-octagon-inscribed-in-x-y-2-with-four-vertices-on-the-axes/25918/4 "2025-08-26T04:48:22Z")

</div>

Leveraging built-in functions to extract vertex coordinates is indeed the most efficient approach. Excellent method—thanks!

---

<div class="post-metadata">

**Author:** ![studymma168](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@studymma168](https://community.wolfram.com/u/studymma168)\
**Post date:** [August 26, 2025, 4:51am UTC](https://community.wolfram.com/t/equations-of-the-sides-of-a-regular-octagon-inscribed-in-x-y-2-with-four-vertices-on-the-axes/25918/5 "2025-08-26T04:51:12Z")

</div>

This approach works perfectly for addressing this issue—thank you!
