Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
js-math-complex
Advanced tools
Complex Number for JavaScript
<script src="math-complex.js" charset="UTF-8"></script>
require('./math-complex.js');
var cplx = Math.Complex, // for convenience
j = cplx(0, 1);
j.mul(Math.PI).exp() + ''; // -1+1.2246063538223773e-16i
// ditto
Math.Complex.exp(cplx(0, Math.PI));
This module implements complex number arithmetics. Basic arithmetics + All arithmetic functions in Math
are supported.
Constructor. im === 0 if omitted.
var z = Math.Complex(1,2);
z.re === 1;
z.im === 2;
Constructor in polar form.
In the followin example z is a complex number object. Unless otherwise stated, all methods below return complex number objects.
returns true
if z equals z1, false
otherwise.
The opposite of z.eq( *z1 *)
returns the absolute value in Number
.
returns the argument in Number
.
returns - z
returns the conjugate.
Math.Complex(re, im).con().eq(Math.Complex(re, -im));
returns the norm in Number
.
z + z1. z1 can be either complex number or real number If z1 is a real number (Number
object, that is), it is automatically converted to complex number before the calculation. This applies to all binary methods.
z - z1
z * z1
z / z1
Copmplex version of Math.exp( z ) .
Copmplex version of Math.log( z ) .
Copmplex version of Math.exp( z, z1 ) .
Copmplex version of Math.sin( z ) .
Copmplex version of Math.cos( z ) .
Copmplex version of Math.tan( z ) .
Copmplex version of Math.asin( z ) .
Copmplex version of Math.acos( z ) .
Copmplex version of Math.atan( z ) .
z is approximately equal to z1.
delta abs(z - z1)
------- < EPSILON <=> ----------- < 2*EPSILON
average abs(z + z1)
All methods above can also be accessed in functional form which is handy with with
.
// does not work in strict mode
with(Math.Complex){
console.log(atan2(1,1)) // { re: 0.7853981633974483, im: 0 }
}
FAQs
Complex Number for JavaScript
We found that js-math-complex 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.