C# .Atan()

NeemaJoju's avatar
Published Mar 25, 2023Updated Nov 9, 2024
Contribute to Docs

Math.Atan() is a static method that calculates the inverse tangent of a given number, in radians.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn Microsoft's popular C# programming language, used to make websites, mobile apps, video games, VR, and more.
    • Beginner Friendly.
      15 hours

Syntax

Math.Atan(x);
  • The Math.Atan() method takes one double as an argument and returns a double.
  • Using this method requires the System namespace.

Example

This example first uses the Math.Atan() method to compute the arctangent of an angle in radians and then converts it to degrees:

using System;
class sample
{
public static void Main()
{
double value = 1.0; // The tangent of an angle
double angleInRadians = Math.Atan(value);
Console.WriteLine("The arctangent of the angle in radians: {0}",angleInRadians);
double angleInDegrees = angleInRadians * (180 / Math.PI);
Console.WriteLine("The arctangent of the angle in degrees: {0}",angleInDegrees);
}
}

The above code creates the following output:

The arctangent of the angle in radians: 0.7853981633974483
The arctangent of the angle in degrees: 45

Codebyte Example

The following example uses Math.Atan() to return the arctangent of a right angled triangle, where the side opposite the angle is equal to 7, and the side adjacent is 5:

Code
Output

All contributors

Contribute to Docs

Learn C# on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn Microsoft's popular C# programming language, used to make websites, mobile apps, video games, VR, and more.
    • Beginner Friendly.
      15 hours