Oracle ASIN, ACOS, ATAN, ATAN2, and COSH FunctionsIn this article, I’ll explain how to use the Oracle ASIN, ACOS, ATAN, ATAN2, and COSH functions with some examples.

I’ve grouped all of these functions into a single article because they are quite similar and are related functions.

Purpose of the Oracle ASIN, ACOS, ATAN, ATAN2, and COSH Functions

The purpose of these functions is to:

  • ASIN – return the arc sine of a number
  • ACOS – return the arc cosine of a number
  • ATAN – return the arc tangent of a number
  • ATAN2 – returns the arc tangent of two numbers.
  • COSH – returns the hyperbolinc cosine of a number.

Now, if you need to use these functions, then you probably know what these terms (like arc sine) mean. I don’t remember what they mean (it’s been a while since I did high school maths), but you can find the definitions of them here: (LINK)

 

Syntax

The syntax of these three functions is similar.

The ASIN function syntax is:

ASIN ( number)

The ACOS function syntax is:

ACOS ( number )

The ATAN function syntax is:

ATAN ( number )

The COSH function syntax is:

COSH ( number )

However, the ATAN2 syntax is slightly different:

ATAN2 ( number1 [/|,] number2 )

For the ATAN2 function, it can be written as either number1,number2 or number1/number2. Both formats produce the same results.

 

Parameters

The parameters of four of functions are all the same:

  • number (mandatory): The number to convert to either an ASIN, ACOS, ATAN, or COSH value.

 

For ATAN2, the parameters are:

  • number1 (mandatory): The first number to use in the arc tangent calculation.
  • number2 (mandatory): The second number to use in the arc tangent calculation.

 

There are some things to note about these parameters:

  • For ASIN, ACOS, and ATAN, the function returns the same data type as the input data type (unless the input is a BINARY_FLOAT, then the function returns a BINARY_DOUBLE).
  • For ATAN2, the function returns NUMBER (unless either of the inputs is a BINARY_FLOAT, then the function returns a BINARY_DOUBLE).
  • For COSH, the function returns a DECIMAL value.
  • For ASIN and ACOS, the number must be in the range of -1 to 1.

 

Examples of the ASIN, ACOS, ATAN, ATAN2, and COSH Functions

Here are some examples of these functions. I find that examples are the best way for me to learn about code, even with the explanation above.

Example 1 – ASIN

This is an example of the ASIN function.

SELECT ASIN(-0.4) AS asin_value
FROM dual;

Result:

ASIN_VALUE
-0.4115168461

 

Example 2 – ACOS

This is an example of the ACOS function.

SELECT ACOS(0.31) AS acos_value
FROM dual;

Result:

ACOS_VALUE
1.255603294

 

Example 3 – ATAN

This is an example of the ATAN function.

SELECT ATAN(1.1) AS atan_value
FROM dual;

Result:

ATAN_VALUE
0.8329812667

 

Example 4 – ATAN2

This is an example of the ATAN2 function.

SELECT ATAN2(3, 1.6) AS atan2_value
FROM dual;

Result:

ATAN2_VALUE
1.080839001

 

Example 5 – COSH

This is an example of the COSH function.

SELECT COSH(5) AS cosh_value
FROM dual;

Result:

COSH_VALUE
74.20994852

 

Similar Functions

 Other than each of the functions mentioned in this article, some functions which are similar to these functions are:

  • SIN – Returns the sine of a number.
  • COS – Returns the cosine of a number.
  • TAN – Returns the tangent of a number.

You can find a full list of Oracle SQL functions here.

Lastly, if you enjoy the information and career advice I’ve been providing, sign up to my newsletter below to stay up-to-date on my articles. You’ll also receive a fantastic bonus. Thanks!

Want To Improve Your Oracle SQL?

Improve your Oracle SQL queries by signing up to my free 10-day Oracle Tips email course.

BONUS: Oracle SQL functions PDF cheat sheet

We won't send you spam. Unsubscribe at any time. Powered by ConvertKit