w3resource

PostgreSQL Trigonometric Functions

Trigonometric Functions

The PostgreSQL trigonometric functions accept the input values as radians and returns the corresponding values against this function.

List of Trigonometric Functions

Functions Syntax Description
acos ( ) acos(a) Returns inverse cosine or arc cosine.
asin( ) asin(a) Returns inverse sine or arc sine.
atan( ) atan(a) Returns inverse tangent or arc tangent.
atan2( ) atan2(b,a) Returns inverse tangent of b/a.
cos( ) cos(a) Returns cosine.
cot( ) cot(a) Returns cotangent.
sin( ) sin(a) Returns sine.
tan( ) tan(a) Returns tangent.

PostgreSQL acos() function

The PostgreSQL acos() returns the inverse cosine of a given argument.

SQL

Code:

SELECT ACOS(0) AS "Acos (0)",ACOS(1) AS "Acos (1)",ACOS(-1) AS "Acos (-1)";

Output:

PostgreSQL acos() function

PostgreSQL asin() function

The PostgreSQL asin() returns the inverse sine of a given argument.

SQL

Code:

SELECT ASIN(0) AS "Asin (0)",ASIN(1) AS "Asin (1)",ASIN(-1) AS "Asin (-1)";

Output:

PostgreSQL asin() function

PostgreSQL atan() function

The PostgreSQL atan() returns the inverse tangent of a given argument.

SQL

Code:

SELECT ATAN(0) AS "Atan (0)",ATAN(1) AS "Atan (1)",ATAN(2) AS "Atan (2)";

Output:

PostgreSQL atan() function

PostgreSQL atan2() function

The PostgreSQL atan2() returns the inverse tangent of a division given in the argument.

SQL

Code:

SELECT ATAN2(0,1) AS "Atan2 (0,1)", ATAN2(1,0) AS "Atan2 (1,0)", ATAN2(1,-1) AS "Atan2 (1,-1)", ATAN2(-3,2) AS "Atan2 (-3,2)";

Output:

PostgreSQL atan2() function

PostgreSQL cos() function

The PostgreSQL cos() returns the cosine of a given argument.

SQL

Code:

SELECT COS(0) AS "Cos (0)",COS(1) AS "Cos (1)",COS(-1) AS "Cos (-1)";

Output:

PostgreSQL cos() function

PostgreSQL cot() function

The PostgreSQL cot() returns the cotangent of a given argument.

SQL

Code:

SELECT COT(0) AS "Cot (0)",COT(1) AS "Cot (1)",COT(-1) AS "Cot (-1)";

Output:

PostgreSQL cot() function

PostgreSQL sin() function

The PostgreSQL sin() returns the sine of a given argument.

SQL

Code:

SELECT SIN(0) AS "Sin (0)",SIN(1) AS "Sin (1)",SIN(-1) AS "Sin (-1)";

Output:

PostgreSQL sin() function

PostgreSQL tan() function

The PostgreSQL tan() returns the tangent of a given argument.

SQL

Code:

SELECT TAN(0) AS "Tan (0)",TAN(1) AS "Tan (1)",TAN(-1) AS "Tan (-1)";

Output:

PostgreSQL tan() function

Previous:Pattern Matching
Next: Data Type Formatting Functions



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/PostgreSQL/postgresql-trigonometric-functions.php