Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-math-complex

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-math-complex

Complex Number for JavaScript

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

Keywords

FAQs

Package last updated on 16 Jan 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc