
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
class_complex_number
Advanced tools
This add class for base support complex number in js
npm i class_complex_number
and import class Complex from this package
let Complex = require('class_complex_number');
// Complex(real, imaginary)
let cn1 = new Complex(1, 2);
let cn2 = new Complex(Math.PI, 5);
let res = Complex.add(cn1, cn2);
console.log(res.toString()); // 4.14 + 7.00i
let cn = new Complex(0, Math.PI / 2);
let res = Complex.exp(cn);
console.log(res.toTrigonom()); // 1.00(cos(1.57) + isin(1.57))
console.log(res.toExponen()); // 1.00exp(1.57i)
All methods return object complex class. All arguments should be instance Complex class
static add(cn1, cn2) // +
static sub(cn1, cn2) // -
static mul(cn1, cn2) // *
static div(cn1, cn2) // /
static sqrt(cn) // square root
static exp(cn) // complex exponent
static sin(cn) // complex sin
static cos(cn) // complex cos
static log(cn, [base]) // complex log with real base. If not base return natural log
static log10(cn) // log with base 10
Methods object for convert complex number to string. All number round to tenths (r - modulus, arg - argument)
cn.toString() // {re}+{im}i
cn.toExponen() // {r}(cos({re}) + isin({im}))
cn.toTrigonom() // {r}exp({arg}i)
Getters
cn.mod() // return modulus
cn.arg() // return argument
FAQs
add complex number in js
The npm package class_complex_number receives a total of 0 weekly downloads. As such, class_complex_number popularity was classified as not popular.
We found that class_complex_number demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.