On January 27, 2021, Google is changing the required permissions for attaching IAM roles to service accounts. If you are using IAM roles for your Google service accounts, please see Changes to User Management.
Computes the sine of an input value for an angle measured in radians. The value can be a Decimal or Integer literal or a reference to a column containing numeric values.
In the above, the sine of angle A is computed as the following:
sin(A) = x/z
The cosecant of angle A is 1/sin(A), or:
csc(A) = 1/sin(A) = z/x
You can convert from degrees to radians. For more information, see RADIANS Function.
Wrangle vs. SQL: This function is part of Wrangle
, a proprietary data transformation language. Wrangle
is not SQL. For more information, see Wrangle Language.
Basic Usage
Numeric literal example:
round(sin(radians(30)),3)
Output: Returns the computation of the sine of a 30-degree angle, which is converted to radians before being passed to the SIN function. The output value is rounded to three decimals: 0.500
.
Column reference example:
sin(X)
Output: Returns the sine of the radians values in X
column.
Syntax and Arguments
sin(numeric_value)
Argument | Required? | Data Type | Description |
---|---|---|---|
numeric_value | Y | string, decimal, or integer | Name of column, Decimal or Integer literal, or function returning those types to apply to the function |
For more information on syntax standards, see Language Documentation Syntax Notes.
numeric_value
Name of the column, Integer or Decimal literal, or function returning that data type to apply to the function.
- Missing input values generate missing results.
- Literal numeric values should not be quoted. Quoted values are treated as strings.
- Multiple columns and wildcards are not supported.
Usage Notes:
Required? | Data Type | Example Value |
---|---|---|
Yes | String (column reference) or Integer or Decimal literal | 0.5 |
Tip: For additional examples, see Common Tasks.Examples
Example - Trigonometry functions
- Sine. See SIN Function.
- Cosine. See COS Function.
- Tangent. See TAN Function.
- Cotangent. Computed as 1/TAN.
- Secant. Computed as 1/COS.
- Cosecant. Computed as 1/SIN.
Source:
In the following sample, input values are in degrees:
X |
---|
-30 |
0 |
30 |
45 |
60 |
90 |
120 |
135 |
180 |
Transformation:
In this example, all values are rounded to three decimals for clarity.
First, the above values in degrees must be converted to radians.
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | round(radians(X), 3) |
Parameter: New column name | 'rX' |
Sine:
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | round(sin(rX), 3) |
Parameter: New column name | 'SINrX' |
Cosine:
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | round(cos(rX), 3) |
Parameter: New column name | 'COSrX' |
Tangent:
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | round(tan(rX), 3) |
Parameter: New column name | 'TANrX' |
Cotangent:
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | round(1 / tan(rX), 3) |
Parameter: New column name | 'COTrX' |
Secant:
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | round(1 / cos(rX), 3) |
Parameter: New column name | 'SECrX' |
Cosecant:
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | round(1 / sin(rX), 3) |
Parameter: New column name | 'CSCrX' |
Results:
X | rX | COTrX | SECrX | CSCrX | TANrX | COSrX | SINrX |
---|---|---|---|---|---|---|---|
-30 | -0.524 | -1.73 | 1.155 | -1.999 | -0.578 | 0.866 | -0.5 |
0 | 0 | null | 1 | null | 0 | 1 | 0 |
30 | 0.524 | 1.73 | 1.155 | 1.999 | 0.578 | 0.866 | 0.5 |
45 | 0.785 | 1.001 | 1.414 | 1.415 | 0.999 | 0.707 | 0.707 |
60 | 1.047 | 0.578 | 1.999 | 1.155 | 1.731 | 0.5 | 0.866 |
90 | 1.571 | 0 | -4909.826 | 1 | -4909.826 | 0 | 1 |
120 | 2.094 | -0.577 | -2.001 | 1.154 | -1.734 | -0.5 | 0.866 |
135 | 2.356 | -1 | -1.414 | 1.414 | -1 | -0.707 | 0.707 |
180 | 3.142 | 2454.913 | -1 | -2454.913 | 0 | -1 | 0 |
This page has no comments.