You just need to use the factor of the apothem (apothem = radius * cos(pi/n)
) in your existing formulas (which I did not check):
# Area of an equal sided polygon with given radius and number of sides
def polygon_area_outer(r, n):
return n * r**2 / 2 * sin(2*pi/n) / cos(pi/n)**2
# Side length of an equal sided polygon with given radius and number of sides
def polygon_side_outer(r, n):
return 2 * r * sin(pi/n) / cos(pi/n)
# Perimeter of an equal sided polygon with given radius and number of sides
def polygon_perimeter_outer(r, n):
return polygon_side_outer(r, n) * n
I changed the order of your functions to base the perimeter
on the side
(not vice versa) to avoid multiplying and then diving by n
when computing the polygon_side length.