Get input float from Math.cos() output value

Viewed 172

I wonder: in Java is there a way to tell what was the original input float value for Math.cos() output?

I basically need something like reverse-engineered Math.cos() where I only know its output value and need to compute the input float it was created from where all I really have is just the output of the Math.cos() function.

The value can be approximate, it does not need to be absolutely exact as it was inputted to the Math.cos() function.

BTW math is not my expertise so the more explanatory (with practical example) you can be the better.

1 Answers

cos is not injective, so you cannot tell (precisely) what the original input was. For example, cos(0) = cos(2π) = 1. You can however use the Math#acos method to identify a possible input.

Related