C# Math SinCos() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Math

Definition

In C#, Math.SinCos(x) returns both the sine and the cosine of an angle in one call. It gives you a tuple with two named parts, Sin and Cos. The angle is in radians, like Sin() and Cos().

Think of asking a shop for a pen and a notebook at once instead of making two trips. Many tasks need both values for the same angle: finding a point on a circle, rotating a shape, or building a rotation matrix. SinCos does the work in one go, which is a little faster and keeps your code short. You can unpack the pair with var (s, c) = Math.SinCos(angle);.

This is a static member of the static class System.Math. You call it with the class name, such as Math.SinCos(...). There is no Math object to create. All the work is done by the method you call, and it never changes your variables. Math.SinCos was added in .NET 6. It is not in older versions of .NET.

Syntax

Pass an angle in radians. The answer is a tuple of two double values. Unpack it with a deconstruction.

C#
var (s, c) = Math.SinCos(Math.PI / 2);       // s = 1, c = about 0

(double Sin, double Cos) pair = Math.SinCos(0);
double sine = pair.Sin;     // 0
double cosine = pair.Cos;   // 1
CallWhat it does
Math.SinCos(0)Returns the tuple (0, 1).
var (s, c) = Math.SinCos(x)Unpacks the tuple into two variables, s and c.
Math.SinCos(x).SinReads only the sine from the returned tuple.
Math.SinCos(double.NaN)Both parts are NaN.

The tuple type is (double Sin, double Cos). The results should match separate calls to Math.Sin and Math.Cos, apart from possible differences in the very last digit, so round before comparing. There is also a MathF.SinCos for float. For older .NET versions, call Sin and Cos separately.

Library declarations
C#
public static (double Sin, double Cos) SinCos(double x);

Parameters

ParameterDescription
xRequired. An angle in radians.

Return Value

Return ValueDescription
(double Sin, double Cos)A tuple with the sine of x in Sin and the cosine of x in Cos. Both are NaN if x is NaN or infinity.

C# Examples

Example 1 — Get Sine and Cosine in One Call

Unpack the returned tuple into two variables for two different angles.

C#
using System;
using System.Globalization;

class Program {
    static string R(double value) {
        return Math.Round(value, 4).ToString(CultureInfo.InvariantCulture);
    }

    static void Main() {
        var (s, c) = Math.SinCos(Math.PI / 2);
        Console.WriteLine(R(s));
        Console.WriteLine(R(c));

        var (s0, c0) = Math.SinCos(0);
        Console.WriteLine(R(s0));
        Console.WriteLine(R(c0));
    }
}

How It Works

  1. Tuple deconstruction. var (s, c) = ... splits the returned pair into two variables. The first is the sine and the second is the cosine.
  2. Quarter turn. At pi / 2, the sine is 1 and the cosine is about 0.00000000000000006, which the helper rounds to 0.
  3. Angle 0. The sine is 0 and the cosine is 1. The pair swapped places compared to the quarter turn.
  4. One call, two answers. You did not have to write Math.Sin and Math.Cos separately for the same angle.

Example 2 — Rotate a Point by 90 Degrees

Use the sine and cosine from SinCos to rotate the point (3, 4) around the origin.

C#
using System;
using System.Globalization;

class Program {
    static string R(double value) {
        return Math.Round(value, 4).ToString(CultureInfo.InvariantCulture);
    }

    static string Rotate(double x, double y, double degrees) {
        var (sin, cos) = Math.SinCos(degrees * Math.PI / 180);
        double newX = x * cos - y * sin;
        double newY = x * sin + y * cos;
        return "(" + R(newX) + ", " + R(newY) + ")";
    }

    static void Main() {
        Console.WriteLine(Rotate(3, 4, 0));
        Console.WriteLine(Rotate(3, 4, 90));
        Console.WriteLine(Rotate(3, 4, 180));
    }
}

How It Works

  1. The rotation formulas. To rotate a point, the new x is x * cos - y * sin and the new y is x * sin + y * cos. Both formulas need the same angle's sine and cosine, which is what SinCos gives.
  2. 0 degrees. The sine is 0 and the cosine is 1, so the point does not move: (3, 4).
  3. 90 degrees. A quarter turn counter-clockwise sends (3, 4) to (-4, 3). The tiny noise from the cosine disappears in the rounding.
  4. 180 degrees. A half turn flips both signs: (-3, -4).

Example 3 — Read the Named Parts and Check the Identity

Store the tuple, read Sin and Cos by name, and check that they match separate calls.

C#
using System;
using System.Globalization;

class Program {
    static string R(double value) {
        return Math.Round(value, 4).ToString(CultureInfo.InvariantCulture);
    }

    static void Main() {
        (double Sin, double Cos) pair = Math.SinCos(Math.PI / 6);

        Console.WriteLine(R(pair.Sin));
        Console.WriteLine(R(pair.Cos));
        Console.WriteLine(Math.Round(pair.Sin * pair.Sin + pair.Cos * pair.Cos, 6));
        Console.WriteLine(Math.Round(pair.Sin, 6) == Math.Round(Math.Sin(Math.PI / 6), 6));
    }
}

How It Works

  1. Named tuple. The declared type (double Sin, double Cos) lets you read the parts as pair.Sin and pair.Cos.
  2. 30 degrees. The sine of pi / 6 is 0.5. The cosine is about 0.866 (half the square root of 3).
  3. The identity. Sine squared plus cosine squared always makes 1. After rounding, the printed answer is 1.
  4. Same as separate calls. The sine in the pair matches Math.Sin for the same angle after rounding, so the comparison is True.

Frequently Asked Questions

It returns the sine and cosine of an angle in radians together, as a tuple (Sin, Cos). Use var (s, c) = Math.SinCos(angle); to unpack it.
It was added in .NET 6. Older versions of .NET and .NET Framework do not have it, so call Math.Sin and Math.Cos separately there.
It can be a little faster, because the work for both values is shared. For everyday programs the difference is small. It mainly makes the code shorter and clearer.
Radians. Convert degrees with degrees * Math.PI / 180.
No. Math is a static class, so you call Math.SinCos(...) straight on the class name. You cannot write new Math(), and there is no variable to keep.

Next: Sinh()

Return the hyperbolic sine of a number: (e to the x minus e to the minus x) divided by 2.

Sinh() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful