I need to obtain an inverse cosine and inverse sine from the result of a series of other calculations. If my input value is outside the range -1 to 1 then acosf
or asinf
return nan
, which is expected given the definition of the function.
How should I adjust the value so that it falls within the acceptable range, but still gives the correct answer? In the spreadsheet I am using to check my calculations this normalisation is happening behind the scenes so nan is not returned.
I think I have to do something like, for acosf, add cos(pi) until the value falls into the range, but I'd like some confirmation or advice please.