Skip to content

A slick numerics-oriented Mathematical library for Java

License

Notifications You must be signed in to change notification settings

kspalaiologos/Maja

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maja

Maven Package codecov Maven Central DOI wakatime

A slick numerics-oriented Mathematical library for Java. Maja implements around 450 different functions for use in Java programs, including high-performance cached variants of the Math equivalents. Javadoc.

Installation

From Maven Central:

<!-- https://mvnrepository.com/artifact/rocks.palaiologos/maja -->
<dependency>
    <groupId>rocks.palaiologos</groupId>
    <artifactId>maja</artifactId>
    <version>0.2.4</version>
</dependency>

Features

Constants:

  • Apery, Catalan, E, Euler-Mascheroni, Feigenbaum, Glaisher, Golden ratio, Golomb-Dickman, Khinchin, Mills, various standard logarithms and precise values of 1/pi, pi, pi/2, pi/4, 2*pi.

Real Functions:

  • Elementary (abs, add, cbrt, ceil, clamp, compare, copySign, div, eq, exp, expm1, fib, floor, fma, frexp, ge, getExponent, gt, hypot, icbrt, iexp, ilog10, isPerfectSquare, isPowerOfTwo, isqrt, le, log, log10, log1p, log2, lt, max, min, mod, mul, ne, nextAfter, nextDown, nextPowerOfTwo, nextUp, pow, rem, round, scalb, signum, sqrt, sub, ulp)
  • Interpolation (linearInterpolate, linearMap, linearNorm)
  • Random number generation.
  • Sigmoid (logistic) functions (squash, stretch)
  • Batch operations (map, reduce)
  • Trigonometry (acos, acosh, acot, acoth, acsc, acsch, asec, asech, asin, asinh, atan, atan2, atanh, cos, cosh, cot, coth, csc, csch, sec, sech, sin, sinc, sinh, tan, tanh, toDegrees, toRadians)
  • High-performance trigonometry (fastSin, fastCos)
  • Airy Ai function (Ai, Ai', Bi, Bi')
  • Bessel functions (i0, i1, j0, j1, jn, k0, k1, kn, y0, y1, yn, jv, yv)
  • Gamma function family (beta, digamma, factorial, gamma, lower incomplete gamma, logabsgamma, logbeta, loggamma, pochhammer, polygamma, trigamma, upper incomplete gamma, gammaP, gammaQ)
  • Trigonometric integrals (Chi, Ci, Cin, Shi, ShiChi, si, Si)
  • Exponential integral (expint, li)
  • Error function family (Dawson-, Dawson+, erf, erfc, erfi)
  • Polylogarithm family (dilog, polylog, Spence)
  • Fresnel integrals (fresnelC, fresnelS)
  • Zeta family (Hurwitz Zeta, Lerch Transcendent, Riemann Zeta)
  • Lambert W (W0, W-1)
  • Hypergeometric function (2F1, 1F1, 1F2, 3F0).
  • Numerical integration (Simpson, Tanh-Sinh, Gauss-Legendre)
  • Legendre elliptic integrals (F, E, D, Pi)
  • Root finding (Newton-Raphson method).
  • Landau functions.
  • Chi squared and Normal distribution quantiles.
  • Bernoulli numbers bounding.
  • Dual numbers for real automatic differentiation.
  • Struve functions (H0, H1, Hx for double precision x, L0, L1)
  • Arithmetic-geometric mean.
  • Anger and Weber's functions.
  • Polynomial solving via the Aberth method.
  • Lommel functions
  • Legendre polynomials.

Complex functions:

  • Elementary (add, sub, mul, div, conj, abs, sqrt, exp, log, eq, ne, cbrt, root)
  • Trigonometry (sin, cos, tan, cot, sec, csc, asin, acos, atan, acot, asec, acsc, sinh, cosh, tanh, sech, csch, asinh, acosh, atanh, acoth, asech, acsch)
  • Gamma function family (beta, gamma, loggamma, logbeta, pochhammer, polygamma, digamma, trigamma, lower incomplete gamma, upper incomplete gamma)
  • Airy functions (Ai, Bi, Ai', Bi')
  • Error function family (Dawson-, Dawson+, erf, erfc, erfi).
  • Fresnel integrals (fresnelS, fresnelC).
  • Exponential integral family (Ein, E_1, li, E_n)
  • Zeta function family (Riemann Zeta, Hurwitz Zeta, Lerch Transcendent)
  • Trigonometric integral family (Si, si, Ci, Cin, Shi, Chi, ShiChi).
  • Polylogarithm family (dilog, Spence, polylog)
  • Legendre elliptic integrals (F, E, D, Pi)
  • Numerical integration (Simpson, Tanh-Sinh, Gauss-Legendre), contour integration.
  • Lambert W.
  • Abreth method for polynomial equation solving.
  • Anger and Weber's functions.

Linear algebra:

  • Matrix operations: transposition, obtaining rows, columns, generalised dot product, leading/trailing axis reduction, cell mapping, ravelling, robust stringification. Reversing alongside leading and trailing axis, zipping matrices.
  • Real Cholesky, Eigenvalue and Eigenvector, QR, SV, LU and LUP decomposition, trace, determinant, permanent, alternant computation.
  • Specialised code for 1x1...4x4 matrices.
  • Solvers for linear systems using Cholesky, LUP and QR decompositions (least squares).

Dual Numbers:

  • Real automatic differentiation.
  • Supports all trigonometric functions from Maja and a lot of special other functions.

Also, a simple expression evaluator (with operator precedence, grouping, variables, special syntax, etc...).

License

GNU LGPL v3.

Acknowledgements

Literature:

Software:

  • Many lookup tables (e.g. Chebyshev coefficients, Pade approximants) have been generated using Wolfram Mathematica or Dyalog APL one-liners.
  • Some code in Maja uses similar algorithms & the same lookup tables as the ones in the Cephes project (MIT).
  • Error function code was inspired by libcerf (MIT; S. G. Johnson, J. Wuttke: libcerf, numeric library for complex error functions).
  • Some Bessel functions follow the same algorithms as the Jama library (Public Domain).
  • Complex polylogarithm was inspired by mpmath code (MIT).
  • The JAMA library (Public Domain) was used as a reference for some of the real matrix operations.

Citation

Cite as:

Kamila Szewczyk. (2023). Maja - A numerics-oriented Mathematical library for Java (v0.1.9). Zenodo. https://doi.org/10.5281/zenodo.7793154