Dear Community,

According to the* C/C++ Compiler and Library Manual for Blackfin® Processors*, the *acos_fr16*, *acos_fr32*, *acos_fx16* and *acos_fx32* functions are defined for fractional input values between 0 and 0.9. I have verified experimentally that this is indeed the case.

My question is therefore: **how can I compute acos(x) for x=[0.9;1] without resorting to floating-point functions (or a LUT)?**

As far as I know, there is no simple trigonometric identity or symmetry property that allows one to compute this from the available interval.

Thank you for the help!

Oli

Hi Oli,

Pasted below is the reply, and attachment, sent to you via the Private Support channel in answer to your question:

Quoting from Wikipedia (http://en.wikipedia.org/wiki/Inverse_trigonometric_function):

“

Practical considerationsFor angles near 0 and π, arccosine is ill-conditioned and will thus calculate the angle with reduced accuracy in a computer implementation (due to the limited number of digits). Similarly, arcsine is inaccurate for angles near −π/2 and π/2. To achieve full accuracy for all angles, arctangent or atan2 should be used for the implementation.“

The Wikipedia page also contains information on how to use the atan function to compute the desired acos values:

acos(x) = 2 * atan(sqrt(1-x^2) / (1+x)) for -1 < x < 1

= 2 * atan2((1-x^2), (1+x))

Please find attached an example that computes arc cosine ([0.9..1) using the acosf function and the above algorithm using the atan_fr16 function. The use of fixed point arithmetic requires the input argument x to be either zero or a positive number. The program will output the computed results and provide cycle counts for the various options.

Thanks,

Colin.