complex-number
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -45,2 +45,6 @@ function multiplyImaginaryParts(x,y){ | ||
getConjugate(){ | ||
return new ComplexNumber(this.realPart, this.imaginaryPart*-1); | ||
} | ||
getAdditiveInverse(){ | ||
@@ -69,3 +73,3 @@ let realSquared = this.realPart * -1; | ||
toString(){ | ||
return `${this.realPart} +${this.imaginaryPart}i`; | ||
return `${this.realPart} + ${this.imaginaryPart}i`; | ||
} | ||
@@ -72,0 +76,0 @@ |
{ | ||
"name": "complex-number", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A simple complex number package that can add, multiply, get the additive and mulitplicative inverses and compare Complex Numbers.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# complex-number | ||
A simple complex number package that can add, multiply, get the additive and mulitplicative inverses and compare Complex Numbers. | ||
ComplexNumber has realPart and imaginaryPart. | ||
A complex number package that can add, multiply, get the additive and mulitplicative inverses, get the conjugate, and compare Complex Numbers. | ||
ComplexNumber has an add, multiply, and equals functions which take another complex number implementation. | ||
## Getting Started | ||
ComplexNumber has getAdditiveInverse and getMultiplicativeInverse which return Complex Numbers. | ||
There is an NPM package: complex-number. | ||
``` | ||
npm i complex-number | ||
``` | ||
### Example | ||
``` | ||
const ComplexNumber = require ('complex-number') | ||
let x = new ComplexNumber(1,2); | ||
let conjugate = x.getConjugate(); | ||
let additiveInverse = x.getAdditiveInverse(); | ||
let multiplicativeInverse = x.getMultiplicativeInverse(); | ||
// prints out false | ||
console.log(x.equals(conjugate).toString()); | ||
// prints out 0 + 0i | ||
console.log(x.add(additiveInverse).toString()); | ||
// prints out 1 + 0i | ||
console.log(x.multiply(multiplicativeInverse).toString()); | ||
``` |
5181
96
35