Trigonometric Functions in C#


Trignometric Functions in C# include, ACos, ASin, Sin, Cos, Tan, etc. It comes under the Math type of the System namespace.

The following is an example showing how to implement trigonometric functions in C# −

Example

 Live Demo

using System;

class Program {
   static void Main() {
      Console.WriteLine(Math.Acos(0));
      Console.WriteLine(Math.Cos(2));

      Console.WriteLine(Math.Asin(0.2));
      Console.WriteLine(Math.Sin(2));

      Console.WriteLine(Math.Atan(-5));
      Console.WriteLine(Math.Tan(1));
   }
}

Output

1.5707963267949
-0.416146836547142
0.201357920790331
0.909297426825682
-1.37340076694502
1.5574077246549

Above we saw the Inverse Sine value using Asin −

Math.Asin(0.2)

With that, we also saw the Inverse Cosine value using Acos −

Math.Acos(0)

In the same way, we found out the value of Tan(1), Atab(-5), Sin(2) and Cos(2).

Updated on: 20-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements