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
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
adfloatvalue with the angle in degreesreturns the five
floatvalues obtained by applying the previous function subsequently. That means that the functiontanfis applied to given anglead(properly converted into radians). Then the result obtained is used as input totanfyielding 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.