I'm trying to give my user the possibilty to get a value using a mathematical relation.
I need your help in this one.
What it is the value of $A$?
$ S = \frac{{\color{red}A}B^2}{4\tan\frac{\pi}{{\color{red}A}}} $
I'm trying to give my user the possibilty to get a value using a mathematical relation.
I need your help in this one.
What it is the value of $A$?
$ S = \frac{{\color{red}A}B^2}{4\tan\frac{\pi}{{\color{red}A}}} $
As was pointed out in a comment, the equation is of a type that typically does not have a closed form solution. That leaves numerical procedures. But there is more to be said, that might be useful.
Let $x=\frac{\pi}{A}$. Then we can rewrite our equation as $\cot x=kx$, where $k$ is a constant easily obtained from our parameters $B$ and $S$. A sketch of $y=\cot x$ and $y=\cot x$ shows that there are infinitely many solutions, and that large solutions $x$ are near a multiple of $\pi$. (In terms of $A$, small solutions $A$ are close to the reciprocal of an integer.)
This brings us close to a very similar problem that has been much discussed, finding good estimates for large solutions of $\tan x=x$. We can get good general estimates for $\tan x$ when $x$ is close to an odd multiple of $\frac{\pi}{2}$. Essentially identical estimates can be made for $\cot x$ near multiples of $\pi$. So even though one cannot expect a closed form solution of the original equation, one can get good estimates of small solutions $A$ in terms of the parameters.
You may find solutions by :
Iterations by setting $q:=\frac{B^2}{4S}$, reverting $\ \tan\left(\frac{\pi}A\right)=qA\ $ and iterating : $A_{n+1}=\frac{\pi}{\arctan(A_n\cdot q)}$ (starting with $A_0=1$ or better with $A_0=\sqrt{\frac{\pi}q}$ as we will see)
Iterations with Newton-Raphson's method : $A_{n+1}=A_n + \frac {\tan\left(\frac {\pi}A_n\right) - A_n q}{q + \frac {\pi}{A_n^2}\left(\tan\left(\frac{\pi}A_n\right)^2 + 1\right)}$ (it should converge faster but is rather sensible to the initial value here...)
Expanding in series : by series reversion of : $t=x^{\frac 12} \tan(x^{\frac 12})= x + \frac{x^2}3 + \frac{2x^3}{15} + \frac{17 x^4}{315}+ \frac{62x^5}{2835} + \frac{1382x^6}{155925} + \frac{21844x^7}{6081075} + \frac{929569x^8}{638512875} +O(x^9)$ we get : $x= t - \frac {t^2}3 + \frac{4t^3}{45} - \frac{16t^4}{945} + \frac{16t^5}{14175} + \frac{64t^6}{93555} - \frac{69248t^7}{212837625} + \frac{512t^8}{8292375} + \mathrm{O}(t^9)$ Let's apply this to $\ \tan\left(\frac{\pi}A\right) \frac{\pi}A= \frac{\pi B^2}{4S}$ with $x:=\left(\frac{\pi}A\right)^2$ and $t:=\frac{\pi B^2}{4S}=\pi q$ to get : $\left(\frac{\pi}A\right)^2= t - \frac {t^2}3 + \frac{4t^3}{45} - \frac{16t^4}{945}+\cdots$ so that $A= \frac{\pi}{\sqrt{ t - \frac {t^2}3 + \frac{4t^3}{45} - \frac{16t^4}{945}+\cdots}}$ or (with $t:=\frac{\pi B^2}{4S}) : $A=\frac{\pi}{\sqrt{t}} \Bigl(1+\frac t6-\frac {t^2}{360}-\frac{11t^3}{5040}+\frac{1357t^4}{1814400}-\frac{2593t^5}{23950080}-\frac{2345599t^6}{130767436800}+\frac{6861887t^7}{435891456000}-\frac{1114192253t^8}{254062448640000}+\mathrm{O}(t^8) \Bigr)$
This last method is most useful for small values of t (the relative error is $\approx 2\cdot 10^{-5}$ for $t=\frac {\pi}2$). The first and second methods should be better for larger values.
Hoping this helped,