I'm trying to make a PHP code that uses the inverse sine function (sin^-1), but I can't seem to find a function in PHP that is equivalent to the inverse sine trigonometric function of a calculator. I found a PHP function called asin (arcsine) but it does not seem to provide the same answers as the inverse sine function of a calculator. I compared the PHP asin() function to the calculator sin^-1 function in degree mode, and these were the results:
PHP: asin(-1) = -1.5707963267949
Calculator: sin^-1(-1) = -90
So, clearly, these two functions are not the same. I also tried using 1/sin() but that did not produce the correct result either. I am stuck. Can anybody help me out with a PHP function or formula that is equivalent to the inverse sine trigonometric function? I would be eternally grateful.
Oh, nevermind, I figured it out.
The thing that was wrong was that my calculator was in degree mode, and I guess PHP is in radian mode by default. So, after a lot of experimenting, I figured out that I just had to use the rad2deg() PHP function.
So, I compared the results and got the same answers! Yay!:
PHP: rad2deg(asin(0.68)) = 42.843643043596
Calculator: sin^-1(0.68) = 42.843643043596
So, hopefully this can help anyone else who has my same question! 8D
PHP: asin(-1) = -1.5707963267949
Calculator: sin^-1(-1) = -90
So, clearly, these two functions are not the same. I also tried using 1/sin() but that did not produce the correct result either. I am stuck. Can anybody help me out with a PHP function or formula that is equivalent to the inverse sine trigonometric function? I would be eternally grateful.
Oh, nevermind, I figured it out.
The thing that was wrong was that my calculator was in degree mode, and I guess PHP is in radian mode by default. So, after a lot of experimenting, I figured out that I just had to use the rad2deg() PHP function.
So, I compared the results and got the same answers! Yay!:
PHP: rad2deg(asin(0.68)) = 42.843643043596
Calculator: sin^-1(0.68) = 42.843643043596
So, hopefully this can help anyone else who has my same question! 8D