Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c#

What is Math.Acos() in C#?

Arslan Bajwa

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

C# has a built-in Math class that provides useful mathematical functions and operations. The Math class has the Acos() function, which is used to compute the angle whose cosine comes out to be a specified number. This is also known as the inverse cosine of a specified number.

Syntax

public static double Acos (double value);

Parameters

  • value: value is of the Double type and represents the input value, which is determined by finding Acos(). Its range must be:

    • -1 <= value <= 1

Return value

  • Double: Acos() returns an angle Θ measured in radians, and of type Double, whose cosine is value.

    • 0 <= Θ <= π (radians)

    It is true only for a valid range of value.

  • NaN: Acos() returns NaN for an invalid range of value.

Radians can be converted into degrees by multiplying radians by 180/Math.PI.

Example

using System;
class Educative
{
static void Main()
{
Double result = Math.Acos(0);
System.Console.WriteLine("Acos(0) = "+ result + " radians");
Double result1 = Math.Acos(1);
System.Console.WriteLine("Acos(1) = "+ result1 + " radians");
Double result2 = Math.Acos(-1);
System.Console.WriteLine("Acos(-1) = "+ result2 + " radians");
Double result3 = Math.Acos(2);
System.Console.WriteLine("Acos(2) = "+ result3);
}
}

RELATED TAGS

c#

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring