   (SOLVED) No. of sides of regular polygon given area and side length?
  The area A of a regular convex polygon is defined asA = ((S^2)N)/(4 Tan (PI/N))where S is the side length, and N the number of sides.I have the side length and the proposed area, and need to calculate the number of sides. Unfortunately as N exists both inside and outside the tangent term, I'm finding it hard to solve for only N.Any help at all would be appreciated.[Edited by - Nick of ZA on April 8, 2010 7:01:52 AM]
  So you want to solve N/Tan(PI/N) = 4A/S^2You'll probably not be able to find an explicit solution, so you generally have to do it numerically. Newton-Raphson works beautifully, but in this case there is something easier you can do.The approximation tan(x) = x is very good for small values of x. Using it, your equation looks like N^2/PI = 4A/S^2, and this is trivial to solve:first_guess_for_N = sqrt(4*A*PI)/SIt turns out that this is a great approximation, and simply rounding up to the nearest integer gives you the exact answer.;  alvaro,This absolutely awesome. I didn't expect to get such a simple answer to this (I've never seen these methods you suggested). I tested it and it works fine at 3 sides and seems to grow more accurate as it approaches the asymptote, so that with N=1000 I got an approximate N=999.99. As you say, rounding up does it every time.This is part of numerical analysis, is that correct?Thanks again,Nick   ;  Since 'N' is integer I'd have thought you can solve the problem with something along the lines of:i = 3;while (true){if (abs(poly_area(i, side) - area) < [small number]){return i;}i = i [plus] 1;}Obviously this exact solution isn't ideal since invalid input may cause it to never terminate.Alternatively, have a look for trigonometric identities which might help you:http://en.wikipedia.org/wiki/List_of_trigonometric_identities;Quote:Original post by Nick of ZAThis is part of numerical analysis, is that correct?One way to think about the reason that it works is to think of the approximation of tan(x) = x as using the first term of the Taylor series expansion of the tangent function as the tangent function. If you want the approximation to be even better, use more terms. The next one would give you tan(x) := x + x^3/3   