Number.Cos
NumberReturns the cosine of an angle specified in radians.
Syntax
Number.Cos(number as nullable number) as nullable numberParameters
| Name | Type | Required | Description |
|---|---|---|---|
number | number | Yes | The angle in radians. |
Return Value
number — The cosine of the angle in radians, in the range [-1, 1].
Remarks
Number.Cos returns the trigonometric cosine of an angle measured in radians. The result is always in the range [-1, 1]. This is a fundamental point of confusion: Power Query M (like most programming environments) uses radians, not degrees. To convert a degree value to radians before computing the cosine, multiply by Number.PI / 180.
The cosine function is even (cos(-x) = cos(x)) and periodic with period 2π. Key reference values: Number.Cos(0) = 1, Number.Cos(Number.PI / 2) ≈ 0 (not exactly 0 due to floating-point), Number.Cos(Number.PI) = -1. Due to floating-point representation, values like Number.Cos(60 * Number.PI / 180) may not be exactly 0.5 — expect results like 0.5000000000000001. Use Number.Round if you need a clean value for display.
Common uses in data transformation include rotating 2D coordinates, computing angular similarity between unit vectors, and implementing physics or geometry calculations in Power Query.
Examples
Example 3: Convert degrees to radians then compute cosine
Number.Cos(60 * Number.PI / 180)Result | |
|---|---|
| 1 | 0.50 |