new Complex(arg1, arg2)
Creates a new Complex Number.
Parameters:
Name | Type | Description |
---|---|---|
arg1 |
number | The real part of the Complex Number |
arg2 |
number | The imaginary part of the Complex Number |
Members
(static) NaN
It represents NaN in this library. It is equivalent to new Complex(NaN).
It is important to know that this library does not introduce the concept of Complex Infinity, all Infinity in this library are represented by Complex.NaN.
It is important to know that this library does not introduce the concept of Complex Infinity, all Infinity in this library are represented by Complex.NaN.
(static) ONE
(static) ZERO
(static) PI
(static) E
(static) EPSILON
It represents the value of 5e-16, which is the smallest number considered as non-zero in this library.
In the other words, any number less than Complex.EPSILON is considered as 0.
Note that Complex.EPSILON is number instead of instance of Complex.
Note that Complex.EPSILON is number instead of instance of Complex.
Methods
getArgument() → {number}
- Source:
Calculates the argument of a Complex Number which is restricted to the interval [ 0, 2π ).
The argument of the Complex Number is the angle between positive real-axis and the vector representing the Complex Number on Complex plane.
If the given Complex Number is considered as 0, returns undefined.
The argument of the Complex Number is the angle between positive real-axis and the vector representing the Complex Number on Complex plane.
If the given Complex Number is considered as 0, returns undefined.
Returns:
The argument of the Complex Number
- Type
- number
getImaginary() → {number}
- Source:
Gets the imaginary part of a Complex Number.
Returns:
The imaginary part of the Complex Number
- Type
- number
getModulus() → {number}
- Source:
Calculates the modulus of a Complex Number.
The modulus of the complex number is the length of the vector representing the complex number on complex plane.
The modulus of the complex number is the length of the vector representing the complex number on complex plane.
Returns:
The modulus of the Complex Number
- Type
- number
getReal() → {number}
- Source:
Gets the real part of a Complex Number.
Returns:
The real part of the Complex Number
- Type
- number
toString() → {string}
- Source:
Gets the stringified and formatted Complex Number.
Returns:
The stringified and formatted Complex Number
- Type
- string
(static) acos(num) → {Complex}
- Source:
Calculates the inverse cosine of a Complex Number.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Any Complex Number |
Returns:
The result of inverse cosine function
- Type
- Complex
(static) acot(num) → {Complex}
- Source:
Calculates the inverse cotangent of a Complex Number.
The domain of this function is C / { i , -i , 0 }.
If the argument is out of its domain, it returns Complex.NaN.
If the argument is out of its domain, it returns Complex.NaN.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Any Complex Number except i, -i and 0 |
Returns:
The result of inverse cotangent function
- Type
- Complex
(static) acsc(num) → {Complex}
- Source:
Calculates the inverse cosecant of a Complex Number.
The domain of this function is C / { 0 }.
If the argument is out of its domain, it returns Complex.NaN.
If the argument is out of its domain, it returns Complex.NaN.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Any Complex Number except 0 |
Returns:
The result of inverse cosecant function
- Type
- Complex
(static) add(num1, num2) → {Complex}
- Source:
Calculates the sum of two Complex Number.
Parameters:
Name | Type | Description |
---|---|---|
num1 |
Complex | The Complex Number on the left of '+' operator. |
num2 |
Complex | The Complex Number on the right of '+' operator. |
Returns:
The sum of two Complex Numbers
- Type
- Complex
(static) asec(num) → {Complex}
- Source:
Calculates the inverse secant of a Complex Number.
The domain of this function is C / { 0 }.
If the argument is out of its domain, it returns Complex.NaN.
If the argument is out of its domain, it returns Complex.NaN.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Any Complex Number except 0 |
Returns:
The result of inverse secant function
- Type
- Complex
(static) asin(num) → {Complex}
- Source:
Calculates the inverse sine of a Complex Number.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Any Complex Number |
Returns:
The result of inverse sine function
- Type
- Complex
(static) atan(num) → {Complex}
- Source:
Calculates the inverse tangent of a Complex Number.
The domain of this function is C / { i , -i }.
If the argument is out of its domain, it returns Complex.NaN.
If the argument is out of its domain, it returns Complex.NaN.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Any Complex Number except i and -i |
Returns:
The result of inverse tangent function
- Type
- Complex
(static) conjugate(num) → {Complex}
- Source:
Calculates the complex conjugate of the Complex Number.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Complex number |
Returns:
The complex conjugate of the Complex Number
- Type
- Complex
(static) cos(num) → {Complex}
- Source:
Calculates the cosine of a Complex Number.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Any Complex Number |
Returns:
The result of cosine function
- Type
- Complex
(static) cot(num) → {Complex}
- Source:
Calculates the cotangent of a Complex Number.
The domain of this function is C / { kπ/2 : k is any integer }.
If the argument is out of its domain, it returns Complex.NaN.
If the argument is out of its domain, it returns Complex.NaN.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Any Complex Number which is not the multiple of π/2 |
Returns:
The result of cotangent function
- Type
- Complex
(static) csc(num) → {Complex}
- Source:
Calculates the cosecant of a Complex Number.
The domain of this function is C / { kπ : k is any integer }.
If the argument is out of its domain, it returns Complex.NaN.
If the argument is out of its domain, it returns Complex.NaN.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Any Complex Number which is not the multiple of π |
Returns:
The result of cosecant function
- Type
- Complex
(static) divide(num1, num2) → {Complex}
- Source:
Calculates the quotient of two Complex Number.
Note that if the denominator is considered as 0, returns Complex.NaN instead of Infinity.
Note that if the denominator is considered as 0, returns Complex.NaN instead of Infinity.
Parameters:
Name | Type | Description |
---|---|---|
num1 |
Complex | The Complex Number on the left of '/' operator. |
num2 |
Complex | The Complex Number on the right of '/' operator. |
Returns:
The quotient of two Complex Numbers
- Type
- Complex
(static) exp(num) → {Complex}
- Source:
Calculates the exponential function with base E.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Exponent |
Returns:
The value of E to the power of num
- Type
- Complex
(static) inverse(num) → {number}
- Source:
Calculates the inverse of the Complex Number.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Complex Number |
Returns:
Inverse of the Complex Number
- Type
- number
(static) isEqual(num1, num2, digitopt) → {boolean}
- Source:
Determines whether two Complex Numbers are considered as identical.
Two Complex Numbers are considered as identical if either both are NaN or both real and imaginary parts are extremely closed.
The test criterion is Math.abs(x - y) < 1 / (10 ** digit * 2). For default value 15, it should be 5e-16. That means if the difference of two numbers is less than 5e-16, they are considered as same value.
Two Complex Numbers are considered as identical if either both are NaN or both real and imaginary parts are extremely closed.
The test criterion is Math.abs(x - y) < 1 / (10 ** digit * 2). For default value 15, it should be 5e-16. That means if the difference of two numbers is less than 5e-16, they are considered as same value.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
num1 |
Complex | Complex Number | ||
num2 |
Complex | Complex Number | ||
digit |
number |
<optional> |
15
|
Number of significant digits |
Returns:
Returns true if two Complex Numbers are considered as identical
- Type
- boolean
(static) isNaN(num) → {boolean}
- Source:
Determines whether the Complex Number is NaN or not.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Any Complex number |
Returns:
Returns true if one of real and imaginary part are NaN
- Type
- boolean
(static) log(num) → {number}
- Source:
Calculates the natural log of the Complex Number.
Note that complex log is a multivalued function, and this function only provides the principal value by restricting the imaginary part to the interval [0, 2π).
Note that complex log is a multivalued function, and this function only provides the principal value by restricting the imaginary part to the interval [0, 2π).
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Complex Number |
Returns:
Natural log of the Complex Number
- Type
- number
(static) multiply(num1, num2) → {Complex}
- Source:
Calculates the product of two Complex Number.
Parameters:
Name | Type | Description |
---|---|---|
num1 |
Complex | The Complex Number on the left of '*' operator. |
num2 |
Complex | The Complex Number on the right of '*' operator. |
Returns:
The product of two Complex Numbers
- Type
- Complex
(static) pow(num, n) → {Complex}
- Source:
Calculates the power of the Complex Number.
The exponent can be any real number or Complex Number
You can find the k-th root of complex number by setting the exponent to 1 / k. But you should know that it only returns one out of k possible solutions.
You can find the k-th root of complex number by setting the exponent to 1 / k. But you should know that it only returns one out of k possible solutions.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Base |
n |
Complex | number | Exponent |
Returns:
The result of the exponentiation
- Type
- Complex
(static) sec(num) → {Complex}
- Source:
Calculates the secant of a Complex Number.
The domain of this function is C / { (k + 0.5)π : k is any integer }.
If the argument is out of its domain, it returns Complex.NaN.
If the argument is out of its domain, it returns Complex.NaN.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Any Complex Number which is not in the form of (k + 0.5)π |
Returns:
The result of secant function
- Type
- Complex
(static) sin(num) → {Complex}
- Source:
Calculates the sine of a Complex Number.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Any Complex Number |
Returns:
The result of sine function
- Type
- Complex
(static) subtract(num1, num2) → {Complex}
- Source:
Calculates the difference of two Complex Number.
Parameters:
Name | Type | Description |
---|---|---|
num1 |
Complex | The Complex Number on the left of '-' operator. |
num2 |
Complex | The Complex Number on the right of '-' operator. |
Returns:
The difference of two Complex Numbers
- Type
- Complex
(static) tan(num) → {Complex}
- Source:
Calculates the tangent of a Complex Number.
The domain of this function is C / { (k + 0.5)π : k is any integer }.
If the argument is out of its domain, it returns Complex.NaN.
If the argument is out of its domain, it returns Complex.NaN.
Parameters:
Name | Type | Description |
---|---|---|
num |
Complex | Any Complex Number which is not in the form of (k + 0.5)π |
Returns:
The result of tangent function
- Type
- Complex