C# Program to Calculate the Cosine(X) Without Using a Predefined Method Last Updated : 23 Dec, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 : 1Code: C# // C# program to calculate the Cosine(X) // Without using a predefined method using System; class GFG{ // Function to calculate the Cosine(X) static double Cos(double theta) { double R; double S; double ans; R = Math.Pow(theta, 2); S = Math.Pow(R, 2); // Substituting p,q in the below formula ans = 1.0 - R / 2 + S / 24 - R * S / 720 + S * S / 40320 - R * S * S / 3628800; return ans; } // Driver code static void Main(string[] args) { Console.WriteLine("Cos(0):" + Cos(0)); Console.WriteLine("Cos(3):" + Cos(1)); Console.WriteLine("Cos(8):" + Cos(2)); } } Output: Cos(0):1 Cos(3):0.540302303791887 Cos(8):-0.41615520282187 Comment More infoAdvertise with us Next Article C# Program to Calculate the Cosine(X) Without Using a Predefined Method P pulamolusaimohan Follow Improve Article Tags : C# C# Programs CSharp-Math Similar Reads C# Program to Find the Value of Sin(x) Sin(x) is also known as Sine. It is a trigonometric function of an angle. In a right-angled triangle, the ratio of the length of the perpendicular to the length of the hypotenuse is known as the sine of an angle. sin θ = perpendicular / hypotenuseThe values of sine of some of the common angles are g 6 min read How to evaluate trigonometric functions without a calculator? Trigonometry is known as the branch of mathematics that deals with certain measurements of triangular regions. A common application of trigonometry is the measurement of the sides and angles of a triangle. For this, we use some trigonometric functions of acute angles. These functions are defined as 6 min read How to convert a Sine Function Into a Cosine To convert a sine function into a cosine function, shift the sine function by 90° (or Ï/2 radians) to the left. Mathematically:sinâ¡(x) = cosâ¡(x â Ï/2)Let's discuss this in detail in this article.Sine and Cosine FunctionsBefore diving into the conversion process It is essential to understanding the b 2 min read How to Use GNU bc (Basic Calculator) in Linux The Basic calculator (bc) is an arbitrary-precision calculator that you can use as a simple scientific or financial calculator on the command-line interface of your Linux system. The syntax is similar to the C programming language. You just have to type the following command to see whether bc is alr 3 min read MathF.Cos() Method in C# with Examples MathF.Cos(Single) is an inbuilt MathF class method which returns the cosine of a given float value argument(specified angle). Syntax: public static float Cos (float x); Here, x is the angle(measured in radian) whose cosine is to be returned and the type of this parameter is System.Single. Return Val 2 min read Like