The Python cmath.acos() function specifies the arc cosine of an angle, in radius.
The arc cosine of an angle is defined as the inverse of a cosine function. Whereas, the domain of the arc cosine function is in the range [-1,1], and this range is obtained in the form of radians.
SyntaxFollowing is the syntax for the Python cmath.acos() function −
cmath.acos(x)Parameters
This function contains a numeric value in the range of -1 to 1. If x is greater than 1 or less than -1, then it will generate an error.
Return valueThis function returns the arccosine of x in radians.
Example 1In the below example, we are finding the arc cosine function for the standard values like '0','-1' and '1' using cmath.acos() function.
import cmath zero = cmath.acos(0) neg_one = cmath.acos(-1) pos_one = cmath.acos(1) print("Arc Cosine value of 0:", cmath.acos(zero)) print("Arc Cosine value of -1:", cmath.acos(neg_one)) print("Arc Cosine value of 1:", cmath.acos(pos_one))Output
When we run above program, it produces following result −
Arc Cosine value of 0: 1.0232274785475506j Arc Cosine value of -1: 1.8115262724608532j Arc Cosine value of 1: (1.5707963267948966+0j)Example 2
Here,we are passing non-standard cosine ratios as arguments, and then arc cosine values for these objects are calculated using cmath.acos() function.
import cmath x=cmath.acos(0.76) y=cmath.acos(-0.23) print(x,y)Output
The result is displayed as follows −
(0.7074832117793429-0j) (1.8028740096576097-0j)Example 3
In this example, input is not a complex number. So, we will get a TypeError.
import cmath cmath.acos("Welcome to TutorialsPoint")Output
The output is produced as follows −
Traceback (most recent call last): File "/home/cg/root/30462/main.py", line 2, in cmath.acos("Welcome to TutorialsPoint") TypeError: must be real number, not str
python_modules.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4