Socket
Socket
Sign inDemoInstall

@rayyamhk/complex

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.11 to 1.0.12

9

lib/core/instance/getArgument.js
"use strict";
/** @module core/instance */
/**
* Calculates the argument of a Complex Number which is restricted to the interval [ 0, 2π ).
* Calculates the argument of a Complex Number which is restricted to the interval [ 0, 2π ).<br><br>
*
* The argument of the Complex Number is the angle between positive real-axis
* and the vector representing the Complex Number on Complex plane.<br><br>
*
* If the given Complex Number is considered as 0, returns undefined.
* @memberof Complex
* @instance

@@ -9,0 +12,0 @@ * @returns {number} The argument of the Complex Number

"use strict";
/** @module core/instance */
/**
* Returns the imaginary part of a Complex Number.
* Gets the imaginary part of a Complex Number.
* @memberof Complex
* @instance

@@ -8,0 +7,0 @@ * @returns {number} The imaginary part of the Complex Number

"use strict";
/** @module core/instance */
/**
* Calculates the modulus of a Complex Number.
* Calculates the modulus of a Complex Number.<br><br>
*
* The modulus of the complex number is the length of the vector
* representing the complex number on complex plane.
* @memberof Complex
* @instance

@@ -8,0 +10,0 @@ * @returns {number} The modulus of the Complex Number

"use strict";
/** @module core/instance */
/**
* Returns the real part of a Complex Number.
* Gets the real part of a Complex Number.
* @memberof Complex
* @instance

@@ -8,0 +7,0 @@ * @returns {number} The real part of the Complex Number

"use strict";
/** @module core/instance */
/**
* Gets the stringified and formatted Complex Number.
* @memberof Complex
* @instance
* @returns {string} The stringified and formatted complex number
* @returns {string} The stringified and formatted Complex Number
*/

@@ -9,0 +9,0 @@ function toString() {

"use strict";
/** @module core/static */
/**
* Calculates the inverse cosine of a Complex Number.
* @static
* @memberof Complex
* @static
* @param {Complex} num - Any Complex Number

@@ -9,0 +8,0 @@ * @returns {Complex} The result of inverse cosine function

"use strict";
/** @module core/static */
/**
* Calculates the inverse cotangent of a Complex Number.
* The domain of this function is C / { i , -i , 0 }.
* @static
* The domain of this function is C / { i , -i , 0 }.<br><br>
*
* If the argument is out of its domain, it returns Complex.NaN.
* @memberof Complex
* @static
* @param {Complex} num - Any Complex Number except i, -i and 0

@@ -10,0 +11,0 @@ * @returns {Complex} The result of inverse cotangent function

"use strict";
/** @module core/static */
/**
* Calculates the inverse cosecant of a Complex Number.
* The domain of this function is C / { 0 }.
* @static
* The domain of this function is C / { 0 }.<br><br>
*
* If the argument is out of its domain, it returns Complex.NaN.
* @memberof Complex
* @static
* @param {Complex} num - Any Complex Number except 0

@@ -10,0 +11,0 @@ * @returns {Complex} The result of inverse cosecant function

"use strict";
/** @module core/static */
/**
* Calculates the sum of two Complex Number.
* @memberof Complex
* @static

@@ -8,0 +7,0 @@ * @param {Complex} num1 - The Complex Number on the left of '+' operator.

"use strict";
/** @module core/static */
/**
* Calculates the inverse secant of a Complex Number.
* The domain of this function is C / { 0 }.
* The domain of this function is C / { 0 }.<br><br>
*
* If the argument is out of its domain, it returns Complex.NaN.
* @memberof Complex
* @static

@@ -9,0 +10,0 @@ * @param {Complex} num - Any Complex Number except 0

"use strict";
/** @module core/static */
/**
* Calculates the inverse sine of a Complex Number.
* @memberof Complex
* @static

@@ -8,0 +7,0 @@ * @param {Complex} num - Any Complex Number

"use strict";
/** @module core/static */
/**
* Calculates the inverse tangent of a Complex Number.
* The domain of this function is C / { i , -i }.
* The domain of this function is C / { i , -i }.<br><br>
*
* If the argument is out of its domain, it returns Complex.NaN.
* @memberof Complex
* @static

@@ -9,0 +10,0 @@ * @param {Complex} num - Any Complex Number except i and -i

"use strict";
/** @module core/static */
/**
* Calculates the complex conjugate of the Complex Number
* Calculates the complex conjugate of the Complex Number.
* @memberof Complex
* @static

@@ -8,0 +7,0 @@ * @param {Complex} num - Complex number

"use strict";
/** @module core/static */
/**
* Calculates the cosine of a Complex Number.
* @memberof Complex
* @static

@@ -8,0 +7,0 @@ * @param {Complex} num - Any Complex Number

"use strict";
/** @module core/static */
/**
* Calculates the cotangent of a Complex Number.
* The domain of this function is C / { kπ/2 : k is any integer }.
* Note that cot(π/2) should gives NaN instead of 0
* because this library does not introduce the concept of Infinity.
* The domain of this function is C / { kπ/2 : k is any integer }.<br><br>
*
* If the argument is out of its domain, it returns Complex.NaN.
* @memberof Complex
* @static

@@ -11,0 +10,0 @@ * @param {Complex} num - Any Complex Number which is not the multiple of π/2

"use strict";
/** @module core/static */
/**
* Calculates the cosecant of a Complex Number.
* The domain of this function is C / { kπ : k is any integer }.
* The domain of this function is C / { kπ : k is any integer }.<br><br>
*
* If the argument is out of its domain, it returns Complex.NaN.
* @memberof Complex
* @static

@@ -9,0 +10,0 @@ * @param {Complex} num - Any Complex Number which is not the multiple of π

"use strict";
/** @module core/static */
/**
* Calculates the quotient of two Complex Number.
* Calculates the quotient of two Complex Number.<br><br>
*
* Note that if the denominator is considered as 0,
* returns NaN instead of Infinity.
* returns Complex.NaN instead of Infinity.
* @memberof Complex
* @static

@@ -10,0 +10,0 @@ * @param {Complex} num1 - The Complex Number on the left of '/' operator.

"use strict";
/** @module core/static */
/**
* Calculates the exponential function with base E
* Calculates the exponential function with base E.
* @memberof Complex
* @static

@@ -8,0 +7,0 @@ * @param {Complex} num - Exponent

"use strict";
/** @module core/static */
/**
* Calculates the inverse of the Complex Number.
* @memberof Complex
* @static

@@ -8,0 +7,0 @@ * @param {Complex} num - Complex Number

"use strict";
/** @module core/static */
/**
* Determines whether two Complex Numbers are considered as identical.
* Determines whether two Complex Numbers are considered as identical.<br><br>
*
* Two Complex Numbers are considered as identical if either
* both are NaN or both real and imaginary parts are extremely closed.
* both are NaN or both real and imaginary parts are extremely closed.<br><br>
*
* 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.
* @memberof Complex
* @static

@@ -10,0 +15,0 @@ * @param {Complex} num1 - Complex Number

"use strict";
/** @module core/static */
/**
* Determines whether the Complex Number is NaN or not.
* @memberof Complex
* @static

@@ -8,0 +7,0 @@ * @param {Complex} num - Any Complex number

"use strict";
/** @module core/static */
/**
* Calculates the natural log of the Complex Number.
* Calculates the natural log of the Complex Number.<br><br>
*
* 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π).
* @memberof Complex
* @static

@@ -11,0 +11,0 @@ * @param {Complex} num - Complex Number

"use strict";
/** @module core/static */
/**
* Calculates the product of two Complex Number.
* @memberof Complex
* @static

@@ -8,0 +7,0 @@ * @param {Complex} num1 - The Complex Number on the left of '*' operator.

"use strict";
/** @module core/static */
/**
* Calculates the power of the Complex Number.
* The exponent can be any real number.
* If you want to calculate the k-th root,
* you should know that it only returns one out of k solutions,
* although there are total k possible solutions for k-th root problem.
* The exponent can be any real number or Complex Number<br><br>
*
* 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.
* @memberof Complex
* @static

@@ -12,0 +11,0 @@ * @param {Complex} num - Base

"use strict";
/** @module core/static */
/**
* Calculates the secant of a Complex Number.
* The domain of this function is C / { (k + 0.5)π : k is any integer }.
* The domain of this function is C / { (k + 0.5)π : k is any integer }.<br><br>
*
* If the argument is out of its domain, it returns Complex.NaN.
* @memberof Complex
* @static

@@ -9,0 +10,0 @@ * @param {Complex} num - Any Complex Number which is not in the form of (k + 0.5)π

"use strict";
/** @module core/static */
/**
* Calculates the sine of a Complex Number.
* @memberof Complex
* @static

@@ -8,0 +7,0 @@ * @param {Complex} num - Any Complex Number

"use strict";
/** @module core/static */
/**
* Calculates the difference of two Complex Number.
* @memberof Complex
* @static

@@ -8,0 +7,0 @@ * @param {Complex} num1 - The Complex Number on the left of '-' operator.

"use strict";
/** @module core/static */
/**
* Calculates the tangent of a Complex Number.
* The domain of this function is C / { (k + 0.5)π : k is any integer }.
* The domain of this function is C / { (k + 0.5)π : k is any integer }.<br><br>
*
* If the argument is out of its domain, it returns Complex.NaN.
* @memberof Complex
* @static

@@ -9,0 +10,0 @@ * @param {Complex} num - Any Complex Number which is not in the form of (k + 0.5)π

@@ -6,3 +6,4 @@ "use strict";

/**
* Creates a new Complex Number
* Creates a new Complex Number.
* @namespace Complex
* @class

@@ -46,2 +47,3 @@ * @param {number} arg1 - The real part of the Complex Number

module.exports = Complex;
Complex.prototype.getReal = require('./core/instance/getReal');

@@ -75,8 +77,31 @@ Complex.prototype.getImaginary = require('./core/instance/getImaginary');

Complex.acot = require('./core/static/acot');
/**
* It represents NaN in this library. It is equivalent to new Complex(NaN).<br><br>
*
* 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
*/
Complex.NaN = new Complex(NaN);
/** @static */
Complex.ONE = new Complex(1);
/** @static */
Complex.ZERO = new Complex(0);
/** @static */
Complex.PI = new Complex(Math.PI);
/** @static */
Complex.E = new Complex(Math.E);
Complex.EPSILON = 1 / (Math.pow(10, 15) * 2);
module.exports = Complex;
/**
* 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.<br><br>
*
* Note that Complex.EPSILON is number instead of instance of Complex.
* @static
*/
Complex.EPSILON = 1 / (Math.pow(10, 15) * 2);
{
"name": "@rayyamhk/complex",
"version": "1.0.11",
"version": "1.0.12",
"author": "Ray Yam",

@@ -18,3 +18,3 @@ "contributors": [

],
"homepage": "https://github.com/rayyamhk/Complex.js",
"homepage": "https://rayyamhk.github.io/Complex.js/",
"bugs": {

@@ -21,0 +21,0 @@ "url": "https://github.com/rayyamhk/Complex.js/issues"

@@ -42,4 +42,6 @@ # Complex.js

## API
[https://rayyamhk.github.io/Complex.js/index.html](https://rayyamhk.github.io/Complex.js/index.html)
You can find the documentation in the following link:
[https://rayyamhk.github.io/Complex.js/Complex.html](https://rayyamhk.github.io/Complex.js/Complex.html)
## Examples

@@ -72,3 +74,2 @@

#### getModulus()
Note that the modulus of the complex number is the length of the vector representing the complex number on complex plane.
```javascript

@@ -80,3 +81,2 @@ new Complex(3, 4).getModulus(); // 5

#### getArgument()
Note that the argument of the complex number is the angle between positive real-axis and the vector representing the complex number on complex plane.
```javascript

@@ -105,5 +105,2 @@ new Complex(3, 3).getArgument(); // π/4

#### isEqual(num1, num2, digit = 15)
The optional argument `digit` limits the number of digits to check after the decimal point.\
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.
```javascript

@@ -120,3 +117,2 @@ const num1 = new Complex(3, 4);

#### 4 basic operations
Note that for `Complex.divide`, if the denominator, i.e. `num2`, is considered as `0`, it returns `Complex.NaN`.
```javascript

@@ -149,4 +145,2 @@ const num1 = new Complex(3, 4);

#### pow(base, exponent)
The `exponent` can be either `number` or instance of `Complex`.\
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.
```javascript

@@ -167,4 +161,2 @@ Complex.pow(z, 2); // z to the power of 2

#### log(num)
It calculates the natural log of the complex number.\
Note that the complex log is a multivalued function, but this function only returns the principal value by restricting the imaginary part to the interval [0, 2π).
```javascript

@@ -176,4 +168,2 @@ Complex.log(Complex.E); // Complex.ONE

#### 6 trigonometric functions
It calculates the value of sin, cos, tan, csc, sec, cot of the complex number.\
Note that if the argument is out of its domain, it returns `Complex.NaN`
```javascript

@@ -197,4 +187,2 @@ Complex.sin(num); // Domain: entire complex plane C

#### 6 inverse of trigonometric functions
It calculates the value of arcsin, arccos, arctan, arccsc, arcsec, arccot of the complex number.\
Note that if the argument is out of its domain, it returns `Complex.NaN`
```javascript

@@ -201,0 +189,0 @@ Complex.asin(num); // Domain: entire complex plane C

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc