![]() |
VOOZH | about |
Cosine(x) is also known as Cos(x). It is a trigonometric function of an angle. The ratio of the length of the base to the length of the hypotenuse is known as the cosine of an angle in the right-angle triangle. In this article, we will learn to calculate the Cosine(X) without using a predefined method. So to do this task we use the following formula:
cos(x) = 1.0 - p /2 + q /24 - p * q /720 + q * q /40320 - p * q * q /3628800
Example:
Input : cos(45) Output : 0.7071 Input : cos(0) Output : 1
Code:
Output:
Cos(0):1 Cos(3):0.540302303791887 Cos(8):-0.41615520282187