Given a square of side length ‘a’, the task is to find the side length of the biggest octagon that can be inscribed within it.
Input: a = 4 Output: 1.65685 Input: a = 5 Output: 2.07107
=> From the figure, it can be seen that, side length of the Octagon = b
=> Also since the polygons are regular, therefore 2*x + b = a
=> From the right angled triangle, x^2 + x^2 = b^2
=> Hence, x = b/√2,
=> So, √2b + b = a
=> Therefore, b = a/(√2 +1)
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Program to calculate area of an Circle inscribed in a Square
- Find the Side of the smallest Square that can contain given 4 Big Squares
- Largest square that can be inscribed within a hexagon which is inscribed within an equilateral triangle
- Area of a square inscribed in a circle which is inscribed in an equilateral triangle
- Biggest Reuleaux Triangle inscribed within a square which is inscribed within an ellipse
- Biggest Reuleaux Triangle inscribed within a square which is inscribed within a hexagon
- Area of a square inscribed in a circle which is inscribed in a hexagon
- Find the side of the squares which are lined in a row, and distance between the centers of first and last square is given
- Find side of Square which makes minimal area to fit two identical rectangles inside it
- Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle
- Program to calculate Area Of Octagon
- Program to find third side of triangle using law of cosines
- Program to find Area of Triangle inscribed in N-sided Regular Polygon
- Largest hexagon that can be inscribed within a square
- Largest square that can be inscribed in a semicircle
- Largest Square that can be inscribed within a hexagon
- Biggest Square that can be inscribed within an Equilateral triangle
- Area of the Largest square that can be inscribed in an ellipse
- Area of a Square | Using Side, Diagonal and Perimeter
- Biggest Reuleaux Triangle within a Square which is inscribed within a Circle
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.