Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
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
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
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.