[][src]Crate nikisas

An implementation of common mathematical functions with focus on speed and simplicity of implementation at the cost of precision, with support for no_std environments.

The implementations contain explanations of the algorithms and Sollya programs for finding the coefficients of polynomials reside in sollya directory.

If you want a reasonable implementation of mathematical functions with small memory footprint and performance cost, you should use micromath crate.

Usage

use nikisas::{ln, consts::E};
assert_eq!(ln(E), 1.0);

What's included

Not much. This is (at least for now) for educational purposes. Here is the list:

  • exponentiation - exp(x), pow(x, p), pow2(p), pow10(p)
  • logarithms - ln(x), log2(x), log10(x)
  • trigonometric functions - sin(x), cos(x), tan(x), cot(x)

Note that implementation of trigonometric functions give poor results for some inputs (and therefore they fail our current tests).

Errors

The implementations are thoroughly tested and the error is bound to be 0.1% or 4 decimal places. The testing involves random sampling from valid interval. The ground truth for error computation are the implementations of the corresponding functions in the Rust's standard library.

The table of real errors is here:

functionmaximum relativeroot mean square (overall quality)
cosN/AN/A
cotN/AN/A
exp4.15e-61.39e-6
ln9.60e-84.05e-8
log21.29e-74.08e-8
log102.02e-76.24e-8
pow21.19e-73.53e-8
pow104.47e-61.49e-6
sinN/AN/A
tanN/AN/A

Name

So this is the story. If we read "libm" (widely-used abbreviation for mathematical library) as "lib em" and do not make the pause in the middle, we get the word "libem". While employing little imagination, we could hear "líbem" /'liːbɛm/, a colloquial form of czech word "líbáme" /'liːbaːmɛ/, meaning "we kiss". Now wekiss is not that cool name for a library, so it needs to go through english-esperanto translation first and here we are: nikisas. Naming is hard, but at least you can experience love while using this small piece of software.

License

nikisas is licensed under MIT. Feel free to use it, contribute or spread the word.

Modules

consts

A collection of mathematical constants.

Functions

cos

Computes the cosine of a number in radians.

cot

Computes the cotangent of a number in radians.

exp

Computes exponentiation function of a number.

ln

Computes natural logarithm of a number.

log2

Computes binary logarithm of a number.

log10

Computes decimal logarithm of a number.

pow

Computes a number raised to a power.

pow2

Computes 2 raised to a power.

pow10

Computes 10 raised to a power.

sin

Computes the sine of a number in radians.

tan

Computes tangent of a number.