big-complex.js
big-complex.js
is an arbitrary-precision Complex number type, backed by decimal.js
. It was created for use in CalcBot, a Discord calculator chatbot.
Install
npm install big-complex.js
const Complex = require('big-complex.js');
import Complex from 'big-complex.js';
Examples
Basic arithmetic:
const a = new Complex(4, 7);
const b = new Complex(-1, 5);
console.log(a.add(b));
console.log(b.div(a));
console.log(a.recip());
Exponential and logarithm functions:
const e = new Complex('2.7182818284590452353602874713527');
const iPi = new Complex(0, '3.1415926535897932384626433832795');
console.log(e.pow(iPi));
const negOne = new Complex(-1, 0);
console.log(negOne.ln());
Trigonometric functions:
const r = new Complex(2);
console.log(r.asin());
console.log(r.asech());