This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
An elm module for working with complex numbers.
version 1.0.1
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.1
Committed At 2017-11-06 22:47:30 UTC
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1



Build Status


A complex number library for Elm. Someone needed to write one.


I've found that testing numeric computations in elm can be a little bit annoying. Just testing a few critical values is not good enough so you need to randomly generate values and you need to compute the correct values from those values. This could be done with native, but that is rather annoying. Instead, I decided to have python to calculate a bunch of correct values from some randomly generated complex numbers and then write the test code from that. How I do this can be seen in, which is not yet documented.

Update to elm 0.18.0

Minor changes to Complex.elm for elm ver 0.18.0

Major changes to tests to use elm-community/elm-test ver 0.18.9

Tests have been split into separate files to avoid stack overflow. creates a suite of 15 test files, each containing 200 randomly generated tests for a specific function of the library.

Tests now use relative tolerance. See Guide to Floating Point Comarison for the rationale. All tests pass within a relative tolerance of 0.0000000000001.

You must install elm-test to use the new tests. To install, do:

$ npm install -g elm-test

To run tests, do:

$ cd tests && make

This will generate the test files if necessary and then run them in sequence. Each testfile contains 200 random tests for a primary library function. A given testfile uses additional functions from the library to test a primary function thereby providing good test coverage.

You can optionally run a single testfile. Example:

$ elm-test tests/Abs.elm

You can generate a new set of testfiles thus:

$ cd tests && make clean && make

Testfiles created are:

Abs.elm Acos.elm Arg.elm Asin.elm Atan.elm Cos.elm Div.elm Exp.elm Ln.elm Mult.elm Pow.elm Sign.elm Sin.elm Sqrt.elm Tan.elm



complex, i, one, zero, fromReal

Basic Unary Operations

real, imaginary, abs, conjugate, negation, sgn, arg, sqrt

Basic Binary Operations

add, sub, mult, div


sin, cos, tan, asin, acos, atan, euler

Exponents and Logarithms

ln, exp, pow


Teodoro Fields Collin email original author

Kevin Butler email port to elm 0.17.0

Ryman github port to elm 0.17.0

Teo email github current maintainer

Stu Heiss email github port to elm 0.18.0