C# .Atan()
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.
Syntax
Math.Atan(x);
- The
Math.Atan()method takes one double as an argument and returns a double. - Using this method requires the
Systemnamespace.
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 angledouble 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.7853981633974483The 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:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve 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