C MathAsin Examples

In this tutorial, we will learn about the C# Math.Asin() method, and learn how to use this method to find the arc sine of given double value, with the help of examples.

AsinDouble

Math.Asin(d) returns the angle whose sine is the specified number d. The angle returned shall be in radians.

If a value greater than 1 or less than -1 is given as argument, Acos() returns Double.NaN.

Syntax

The syntax of Asin(d) method is

Math.Asin(Double d)

where

Parameter Description
d The double value for which we have to find arc sine.

Return Value

The method returns value of type double.

Example 1 MathAsin05

In this example, we will find the angle for which sine value is 0.5. We shall print the result both in radians and in degrees.

We know that sin(30 degrees) = 0.5. So, we should get the PI/6 radians as return value.

C# Program

using System;

class Example {
    static void Main(string[] args) {
        Double d = 0.5;

        Double angle = Math.Asin(d);
        Console.WriteLine($"Angle in radians : {angle}");
        Console.WriteLine($"Angle in degrees : {(180 / Math.PI) * angle}");
    }
}

Output

Angle in radians : 0.523598775598299
Angle in degrees : 30

Example 2 MathAsin0

In this example, we will find the angle for which sine value is 0.0. We know that sin(0 degrees) = 0. So, we should get the zero radians as return value.

C# Program

using System;

class Example {
    static void Main(string[] args) {
        Double d = 0;

        Double angle = Math.Asin(d);
        Console.WriteLine($"Angle in radians : {angle}");
        Console.WriteLine($"Angle in degrees : {(180 / Math.PI) * angle}");
    }
}

Output

Angle in radians : 0
Angle in degrees : 0

Example 3 Asin10

In this example, we will find the angle for which sine value is 1.0. We know that sin(90 degrees) = 1.0. So, we should get the PI/2 radians as return value.

C# Program

using System;

class Example {
    static void Main(string[] args) {
        Double d = 1.0;

        Double angle = Math.Asin(d);
        Console.WriteLine($"Angle in radians : {angle}");
        Console.WriteLine($"Angle in degrees : {(180 / Math.PI) * angle}");
    }
}

Output

Angle in radians : 1.5707963267949
Angle in degrees : 90

Example 4 Asin5 Invalid Argument

In this example, we will find the angle for which sine value is 5. We know that the range of sin(angle) is [-1.0, 1.0], and since the given argument is out of range, Asin() returns Double.NaN.

C# Program

using System;

class Example {
    static void Main(string[] args) {
        Double d = 5;

        Double angle = Math.Asin(d);
        Console.WriteLine($"Angle in radians : {angle}");
        Console.WriteLine($"Angle in degrees : {(180 / Math.PI) * angle}");
    }
}

Output

Angle in radians : NaN
Angle in degrees : NaN

Conclusion

In this C# Tutorial, we have learnt the syntax of C# Math.Asin() method, and also learnt how to use this method with the help of C# example programs.