Math extension to work on complex numbers.
For example to perform:
write:
const z1 = [1,2];
const z2 = [3,4];
const s = Math.cn.add(z1,z2);
// [4,6]
A complex number is expected to be an array of form
[re,im]
.
mod(z)
- returns the modulus of a numberarg(z)
- returns the argument of a numberconjugate(z)
- returns the conjugate of a numberadd(z1,z2)
- performs addition of numberssub(z1,z2)
- performs subtraction of numbersmul(z1,z2)
- performs multiplication of numbersdiv(z1,z2)
- performs division of numberspow(z,n)
- returns the n-th power of a numberroots(z,n)
- returns the n-th roots of a numbercis(r,phi)
- returns a complex number[re,im]
defined by modulus (r
) and argument (phi
)