Tangent Succession

It is know than the tangent of a given angle \(\theta\) is equivalent to the following mathematical formula involving the sinus and consinus of the same angle:

\(tan \theta = \sqrt{ \frac{1-cos(2\theta)}{1+cos(2\theta)} }\)

Implement the following two Python functions in the module tangent (file tangent.py).


The first function is:

tanf(a)

such that

given a, a float value with the angle in radians, a diferent than 1.5707963267948966 (equivent to 90 degrees).

returns a float with tangent of a calculated using the above formula, rounded to 4 decimals.

For example:


>>> a = math.radians(30)
>>> r1 = tanf(a)
>>> r1
0.5774

>>> r2 = tanf(r1)
>>> r2
0.6515

Note

Python standard modules such as math may be imported and used.

Doctests are available at the tanf-test.txt file.


The second function is:

tanf5(ad)

such that

given ad float value with the angle in degrees

returns the five float values obtained by applying the previous function subsequently. That means that the function tanf is applied to given angle ad (properly converted into radians). Then the result obtained is used as input to tanf yielding the second value and so on.

For example:


>>> tanf5(30)
(0.5774, 0.6515, 0.7626, 0.9554, 1.4145)

Warning

This function implementation must call the previous function as many times as needed.

Doctests for validation are available at the tanf5-test.txt file.