Take angle out of tan()

117 Views Asked by At

I have the following formulas:

$$S = 4 \times \tan\left(\frac{180^\circ-a}{2}\right) - \frac{π}{90^\circ} \times (180^\circ-a)$$

where:

$$S \gt 0$$

$$0^\circ \lt a \lt 180^\circ$$

and I want to solve them by α but I don't know how to take α out of the tan().
I tried to use some functions with arctan() but with no luck.

Could someone help me out with it?

3

There are 3 best solutions below

2
On

You also have, in the relation of degree and radian units, $\pi=180^∘$, $90^∘=\frac\pi2$ etc. so that the equation reduces to $$ \frac{S}4=\tan(x)-x $$ where $x=\frac{180^∘−α}2$.

Now apply Newton's method or apply a fixed-point method. For the Newton method consider $f(x)=\arctan(x+\frac S4)-x$. For small $S$, $x$ dominates the sum with $S/4$,see below. Thus $f(x)\sim x^3$. To remove this multiple root, divide by $x^2$ which gives a Newton iteration $N(x)=x-\frac{xf(x)}{xf'(x)-2f(x)}$ which converges very rapidly

A suitable fixed-point equation that works without trying too many alternative formulations is $x=g(x)=\arctan(x+\frac S4)$. It converges reliably, however slowly.

plot of the fixed-point iteration Iteration $x_{k+1}=g(x_k)$, $x_0=0$, over $S$

Finally, convert back $α=180^∘-360^∘\frac{x}\pi$.


For small values of $S$ and thus small $x$ this gives approximately $$ \frac S4\approx \frac{x^3}3\implies x\approx\sqrt[3]{\frac34S}. $$ For larger $S$ you can use the approximation $\frac{x}{1-4x^2/\pi^2}$ of the tangent function, so that an approximation is obtained as the smaller solution of a quadratic equation. $$ 0=\left(\frac{2x}\pi\right)^2+2\frac{2x}{\pi}\frac{\pi}{S}-1 =\left(\frac{2x}\pi+\frac{\pi}{S}\right)^2-1-\frac{\pi^2}{S^2} \\ \implies x=\frac\pi2\left(\sqrt{1+\frac{\pi^2}{S^2}}-\frac{\pi}{S}\right) =\frac{\pi S}{2(\sqrt{S^2+\pi^2}+\pi)} $$

4
On

Rewrite your expression, angle in radians

$${S\over4} + {\pi \over 2} =\cot{a\over2} +{a\over2}$$ $$a_{i+1} = 2\cot^{-1}({S \over 4} + {\pi-a_i \over 2})$$

Example, with $S=10, a_0=0$, using Aitkens Extrapolation

$$Aitken(a_i) = a_{i} - {(a_{i}-a_{i-1})^2 \over a_{i} - 2a_{i-1}+a_{i-2}}$$

$\begin{matrix} i & a_i & Aitken(a_i) \cr 1 & 0.4817648629 \cr 2 & 0.5108008969 \cr 3 & 0.5126606739 & 0.5127879457\cr 4 & 0.5127884300 \cr 5 & 0.5127884612 & 0.5127884633 \cr 6 & 0.5127884633 \end{matrix}$


We can give a better guess for above iterations.
$$S = 4 \cot{a\over2} - 2(\pi-a) = {8 \over a} - 2\pi + {4a \over 3} - {a^3 \over 90}+ O(a^5)$$

Let $b = \large \frac{3}{8}\normalsize (S+2\pi)$ $$b = {3\over a} + {a \over 2} - {a^3 \over 240} + O(a^5)$$ Drop $O(a^3)$, and solve the quadratic:

$$a ≈ \frac{6}{b + \sqrt{b^2-6}}$$

For $S=10,\quad a ≈ 0.51284 02951,\quad error ≈ 0.010\%$

We can improve the guess by re-using above formula, with a new $b$.
$$b ← b + {1\over240}\left( \frac{6}{b + \sqrt{b^2-6}} \right)^3$$

For $S=10,\quad a ≈ 0.51278 87723,\quad error ≈ 0.000060\%$

Note: the guess goes complex if $S < 8\sqrt{2\over3} - 2\pi ≈ 0.24879$

For small S, I use @Lutz setup, but with $\tan(x)$ continued fraction representation.

$${S \over 4} ≈ \large{x \over 1- {x^2 \over 3- {x^2\over5}}}-x = \large {5x^3 \over 15-6x^2}$$ $$x^3 ≈ S({3\over4}-{3\over10}x^2)$$ Since small S also meant small x, we let $t={3\over4}S$, and keep approximating ...

1st approximation: $x ≈ \sqrt[3]{t(1-\require{cancel} \cancel{{2\over5}x^2)}} ≈ \sqrt[3]{t}$
2nd approximation: $x ≈ \sqrt[3]{t(1-{2\over5}(\sqrt[3]t)^2}$
3rd approximation: $x ≈ \sqrt[3]{t} - {2 \over 15}t \require{cancel} \cancel{-{4\over225}t^{5/3} +\;...}$
$$a = \pi-2x ≈ \pi - \sqrt[3]{6S} + {S \over 5}$$


By trial and error, I found a formula that is even better than solving the cubic exactly!
For small $S$, let $b = \sqrt[3]{6S}$

$$a ≈ \pi - {30b \over 30 + b^2}$$

0
On

Starting from LutzL's answer, we need to find "good" approximation of $x$ such that $$k=\tan(x)-x \qquad \text{where} \qquad k=\frac S 4$$ For the range $ 0 \leq x \leq \frac \pi 4$, a quite good approximation of the rhs is $$\tan(x)-x\sim\frac{5 x^3}{15-6 x^2}$$ corresponding to the $[3,2]$ Padé approximant built at $x=0$. As a result, this gives a cubic equation in $x$ $$x^3+\frac{6 k }{5}x^2-3 k=0$$ the only real solution of which being given by $$\color{blue}{x=\frac{2}{5} k \left(2 \cosh \left(\frac{1}{3} \cosh ^{-1}\left(\frac{375}{16 k^2}-1\right)\right)-1\right)}$$ Below are given some results for comparison $$\left( \begin{array}{ccc} k & \text{approximation} & \text{exact} \\ 0.00 & 0.000000 & 0.000000 \\ 0.01 & 0.306774 & 0.306773 \\ 0.02 & 0.383648 & 0.383643 \\ 0.03 & 0.436456 & 0.436446 \\ 0.04 & 0.477750 & 0.477734 \\ 0.05 & 0.512063 & 0.512040 \\ 0.06 & 0.541613 & 0.541582 \\ 0.07 & 0.567670 & 0.567630 \\ 0.08 & 0.591038 & 0.590989 \\ 0.09 & 0.612261 & 0.612203 \\ 0.10 & 0.631728 & 0.631659 \\ 0.11 & 0.649725 & 0.649646 \\ 0.12 & 0.666472 & 0.666382 \\ 0.13 & 0.682141 & 0.682039 \\ 0.14 & 0.696867 & 0.696753 \\ 0.15 & 0.710763 & 0.710637 \\ 0.16 & 0.723922 & 0.723783 \\ 0.17 & 0.736418 & 0.736266 \\ 0.18 & 0.748319 & 0.748154 \\ 0.19 & 0.759678 & 0.759500 \\ 0.20 & 0.770545 & 0.770352 \\ 0.21 & 0.780960 & 0.780753 \end{array} \right)$$

For the case where $ \frac \pi 4 \leq x \leq \frac \pi 2$, let $t= \frac \pi 2-x$ which makes the equation to be $$k'=k+\frac \pi 2=t+\cot(t)$$ and using again Padé approximant built at $t=0$ $$t+\cot(t)\sim \frac{1+\frac{7 }{10}t^2}{t+\frac{1}{30}t^3}$$ This again gives a cubic equation in $t$ $$\frac{k' }{30}t^3-\frac{7}{10} t^2+k' t-1=0$$