Skip to content

jonathanfishbein1/elm-numbers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Real Numbers, Imaginary Numbers, and Complex Numbers

Summary

A module to define real numbers, imaginary numbers, and complex numbers and basic arithmetic operations on them.

I accidently published this package before checking to see if there already existed an Elm package for complex numbers. This was a rookie mistake I made when getting started developing Elm packages.

However, this package has matured and does contain functionality that differs from the two other Elm complex number packages. Most notably this package makes use of jonathanfishbein1/numeric-typeclasses to define instances of Semigroup, Monoid, Group, Ring, and Field for real numbers and complex numbers. These instances can be valuable if you are trying to define generic functions in your own projects that can operate on both Real.Real and Complex Numbers.

{-| Group for Complex Numbers with addition as the operation
-}
sumGroup : Group.Group (ComplexNumber number)
complexSumGroup =
    { monoid = sumMonoid, inverse = \(ComplexNumber (Real.Real x) (Imaginary y)) -> ComplexNumber (Real.Real -x) (Imaginary -y) }

{-| Group for Complex Numbers with multiplication as the operation
-}
productGroup : Group.Group (ComplexNumber Float)
productGroup =
    { monoid = productMonoid, inverse = \(ComplexNumber (Real.Real x) (Imaginary y)) -> divide one (ComplexNumber (Real.Real x) (Imaginary y)) }

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages