npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

complex_operation

v0.0.4

Published

some basic operations for complex

Readme

Complex_Operation

Do some basic calculations with Complex numbers #####functions:

  • add
  • substact
  • multiplication
  • divide
  • exponential
  • logarithm
  • negate
  • conjugate
  • angle
  • magnitude
  • equals

Node

You can get this package with NPM:

npm install Complex
var Complex = require('Complex');
console.log(new Complex(3,4).add(Complex(1,1)));    //4+5i

brower

test complex_operation in your brower

require("complex_operation");
var Complex = require("Complex");
var a = new Complex(1,1);
var b = new Complex(2,3);
console.log(a.add(b));

the result is:

Complex 
im:4
real:3

Testing

Testing is done with Complex_test.js

var Complex = require("./Complex");
var c = console;
var c1 = new Complex(1,3), c2= new Complex(2,5);
c.log("c1=%s", c1);
c.log("c2=%s", c2);
c.log("c1 + c2=%s", c1.add(c2));
c.log("c1 - c2=%s", c1.sub(c2));
c.log("c1 * c2=%s", c1.mul(c2));
c.log("c1 / c2=%s", c1.div(c2));
c.log("exp(c1)=%s", c1.exp());
c.log("ln(c1)=%s", c1.ln());
c.log("neg(c1)=%s",c1.neg());
c.log("conj(c1)=%s",c1.conj());
c.log("ang(c1)=%s",c1.ang());
c.log("mag(c1)=%s",c1.mag());
c.log("c1 equ c2 ? ",c1.equ(c2));

API Documentation

Complex Constructor:

var c = new Complex(r,i);
Arguments:

1.r(number) :the real part of the number 2.i(number) :the imaginary part of the number

Method:add

Adds a real or complex number

MyComplex.add(c);
Arguments:

1.c(number,complex)the number to add(MyComplex + c)

Method:sub

Subtracts a real or complex number

MyComplex.sub(c);
Arguments:

1.c(number,complex)the number to subtract(MyComplex - c)

Method:mul

Multiplies the number with a real or complex number

MyComplex.mul(c);
Arguments:

1.c(number,complex)the number to multiply with(MyComplex * c)

Method:div

Divides the number by a real or complex number

MyComplex.div(c);
Arguments:

1.c(number,complex)the number to divide by(MyComplex/c)

Method:exp

Calculates the e^z where the base is E and the exponential the complex number

MyComplex.exp();

Method:ln

Return the natural logarithm(base E)

MyComplex.ln();

Method:neg

Negates the number(multiplies both the real and imaginary part with -1)

MyComplex.neg(c);

####Method:conj Calculates the conjugate of the complex number(multiplies the imaginary part with -1)

MyComplex.conj(c)

####Method:ang Calculates the angle with respect to the real axis,in radians

MyComplex.ang();

####Method:mag Calculates the magnitude of the complex number

MyComplex.mag();

####Method:equ Checks if the real and imaginary components are equal to the passed in complex components

MyComplex.equ(c);
Arguments:

1.c(number,complex)the complex number to compare with

Method:toString

Return a string representation of the complex number

MyComplex.toString();
Examples:
new Complex(2,2).toString();  //2+2i
new Complex(0,7).toString();  //7i
new Complex(7,0).toString();  //7
new Complex(1,5).toString();  //1+5i
'my Complex Number is : ' + (new Complex(3,4));  //'my Complex Number is : 3+4i