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 🙏

© 2024 – Pkg Stats / Ryan Hefner

js-math-complex

v0.3.0

Published

Complex Number for JavaScript

Downloads

2

Readme

build status

math-complex.js

Complex Number for JavaScript

USAGE

In Browser

<script src="math-complex.js" charset="UTF-8"></script>

node.js

require('./math-complex.js');

SYNOPSIS

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));

DESCRIPTION

This module implements complex number arithmetics. Basic arithmetics + All arithmetic functions in Math are supported.

Constructors

Math.Complex( re [, im] )

Constructor. im === 0 if omitted.

var z = Math.Complex(1,2);
z.re === 1;
z.im === 2;

Math.Complex.polar( abs, arg )

Constructor in polar form.

Methods

In the followin example z is a complex number object. Unless otherwise stated, all methods below return complex number objects.

z.eq( z1 )

returns true if z equals z1, false otherwise.

z.ne( z1 )

The opposite of z.eq( *z1 *)

z.abs()

returns the absolute value in Number.

z.arg()

returns the argument in Number.

z.neg()

returns - z

z.con()

returns the conjugate.

Math.Complex(re, im).con().eq(Math.Complex(re, -im));

z.norm()

returns the norm in Number.

z.add( z1 )

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.sub( z1 )

z - z1

z.mul( z1 )

z * z1

z.div( z1 )

z / z1

z.exp()

Copmplex version of Math.exp( z ) .

z.log()

Copmplex version of Math.log( z ) .

z.pow( z1 )

Copmplex version of Math.exp( z, z1 ) .

z.sin()

Copmplex version of Math.sin( z ) .

z.cos()

Copmplex version of Math.cos( z ) .

z.tan()

Copmplex version of Math.tan( z ) .

z.asin()

Copmplex version of Math.asin( z ) .

z.acos()

Copmplex version of Math.acos( z ) .

z.atan()

Copmplex version of Math.atan( z ) .

z.approx(z1)

z is approximately equal to z1.

 delta                abs(z - z1)
------- < EPSILON <=> ----------- < 2*EPSILON
average               abs(z + z1)

Functional Form

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 }
}