What is Math.sin() in C#?

C# has a built-in Math class that provides useful mathematical functions and operations. The class has the Sin() function, which is used to compute the sine of a specified angle.

Syntax

public static double Sin (double value);

Parameters

  • value: value is of the Double type and represents the input angle, which is determined by finding Sin(). Its range is all real numbers. value is measured in radians.

Return value

  • Double: Sin() returns the sine of a number and its type is Double. It is true only for all real numbers in value.
  • NaN: Sin() returns NaN type for invalid value, i.e., NaN, infinity, or negative infinity.

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

Example

using System;
class Educative
{
static void Main()
{
double result = Math.Sin(0);
System.Console.WriteLine("Sin(0) = "+ result);
double result1 = Math.Sin(1);
System.Console.WriteLine("Sin(1) = "+ result1);
double result2 = Math.Sin(-1);
System.Console.WriteLine("Sin(-1) = "+ result2);
double result3 = Math.Sin(Double.PositiveInfinity);
System.Console.WriteLine("Sin(∞) = "+ result3);
double result4 = Math.Sin(400);
System.Console.WriteLine("Sin(400) = "+ result4);
}
}

Free Resources