+///
+/// A function that produces a number of type `Float` from an `Int`.
+///
+/// Note: The function is equivalent to the `int.to_float` function in the Gleam stdlib.
+///
+///
+/// Example:
+///
+/// import gleeunit/should
+/// import gleam_community/maths/int as intx
+///
+/// pub fn example() {
+/// intx.to_float(-1)
+/// |> should.equal(-1.0)
+///
+/// intx.to_float(1)
+/// |> should.equal(1.0)
+/// }
+///
+///
+///
+///
+/// The function returns the integral part of a given floating point value.
+/// That is, everything after the decimal point of a given floating point value is discarded and only the integer value before the decimal point is returned.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam/option
+/// import gleam_community/maths/float as floatx
+///
+/// pub fn example() {
+/// floatx.to_int(12.0654)
+/// |> should.equal(12)
+///
+/// // Note: Making the following function call is equivalent
+/// // but instead of returning a value of type 'Int' a value
+/// // of type 'Float' is returned.
+/// floatx.round(12.0654, option.Some(0), option.Some(floatx.RoundToZero))
+/// |> should.equal(Ok(12.0))
+/// }
+///
+///
+///
+///
+/// The inverse cosine function:
+///
+/// \\[
+/// \forall x \in \[-1, 1\], \\; \cos^{-1}{(x)} = y \in \[0, \pi \]
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\[-1, 1\]$$ as input and returns a
+/// numeric value $$y$$ that lies in the range $$\[0, \pi \]$$ (an angle in radians).
+/// If the input value is outside the domain of the function an error is returned.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// elementary.acos(1.0)
+/// |> should.equal(Ok(0.0))
+///
+/// elementary.acos(1.1)
+/// |> should.be_error()
+///
+/// elementary.acos(-1.1)
+/// |> should.be_error()
+/// }
+///
+///
+///
+///
+/// The inverse hyperbolic cosine function:
+///
+/// \\[
+/// \forall x \in [1, +\infty\), \\; \cosh^{-1}{(x)} = y \in \[0, +\infty\)
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\[1, +\infty\)$$ as input and returns
+/// a numeric value $$y$$ that lies in the range $$\[0, +\infty\)$$ (an angle in radians).
+/// If the input value is outside the domain of the function an error is returned.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// floatx.acosh(1.0)
+/// |> should.equal(Ok(0.0))
+///
+/// floatx.acosh(0.0)
+/// |> should.be_error()
+/// }
+///
+///
+///
+///
+/// The inverse sine function:
+///
+/// \\[
+/// \forall x \in \[-1, 1\], \\; \sin^{-1}{(x)} = y \in \(-\infty, +\infty\)
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\[-1, 1\]$$ as input and returns a numeric
+/// value $$y$$ that lies in the range $$\[-\frac{\pi}{2}, \frac{\pi}{2}\]$$ (an angle in radians).
+/// If the input value is outside the domain of the function an error is returned.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// floatx.asin(0.0)
+/// |> should.equal(Ok(0.0))
+///
+/// floatx.asin(1.1)
+/// |> should.be_error()
+///
+/// floatx.asin(-1.1)
+/// |> should.be_error()
+/// }
+///
+///
+///
+///
+/// The inverse hyperbolic sine function:
+///
+/// \\[
+/// \forall x \in \(-\infty, \infty\), \\; \sinh^{-1}{(x)} = y \in \(-\infty, +\infty\)
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\(-\infty, +\infty\)$$ as input and returns
+/// a numeric value $$y$$ that lies in the range $$\(-\infty, +\infty\)$$ (an angle in radians).
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// floatx.asinh(0.0)
+/// |> should.equal(0.0)
+/// }
+///
+///
+///
+///
+/// The inverse tangent function:
+///
+/// \\[
+/// \forall x \in \(-\infty, \infty\), \\; \tan^{-1}{(x)} = y \in \[-\frac{\pi}{2}, \frac{\pi}{2}\]
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\(-\infty, +\infty\)$$ as input and returns
+/// a numeric value $$y$$ that lies in the range $$\[-\frac{\pi}{2}, \frac{\pi}{2}\]$$ (an angle in radians).
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// floatx.atan(0.0)
+/// |> should.equal(0.0)
+/// }
+///
+///
+///
+///
+/// The inverse 2-argument tangent function:
+///
+/// \\[
+/// \text{atan2}(y, x) =
+/// \begin{cases}
+/// \tan^{-1}(\frac y x) &\text{if } x > 0, \\\\
+/// \tan^{-1}(\frac y x) + \pi &\text{if } x < 0 \text{ and } y \ge 0, \\\\
+/// \tan^{-1}(\frac y x) - \pi &\text{if } x < 0 \text{ and } y < 0, \\\\
+/// +\frac{\pi}{2} &\text{if } x = 0 \text{ and } y > 0, \\\\
+/// -\frac{\pi}{2} &\text{if } x = 0 \text{ and } y < 0, \\\\
+/// \text{undefined} &\text{if } x = 0 \text{ and } y = 0.
+/// \end{cases}
+/// \\]
+///
+/// The function returns the angle in radians from the x-axis to the line containing the
+/// origin $$\(0, 0\)$$ and a point given as input with coordinates $$\(x, y\)$$. The numeric value
+/// returned by $$\text{atan2}(y, x)$$ is in the range $$\[-\pi, \pi\]$$.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// floatx.atan2(0.0, 0.0)
+/// |> should.equal(0.0)
+/// }
+///
+///
+///
+///
+/// The inverse hyperbolic tangent function:
+///
+/// \\[
+/// \forall x \in \(-1, 1\), \\; \tanh^{-1}{(x)} = y \in \(-\infty, +\infty\)
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\(-1, 1\)$$ as input and returns
+/// a numeric value $$y$$ that lies in the range $$\(-\infty, \infty\)$$ (an angle in radians).
+/// If the input value is outside the domain of the function an error is returned.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// floatx.atanh(0.0)
+/// |> should.equal(Ok(0.0))
+///
+/// floatx.atanh(1.0)
+/// |> should.be_error()
+///
+/// floatx.atanh(-1.0)
+/// |> should.be_error()
+/// }
+///
+///
+///
+///
+/// The cosine function:
+///
+/// \\[
+/// \forall x \in \(-\infty, +\infty\), \\; \cos{(x)} = y \in \[-1, 1\]
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\(-\infty, \infty\)$$ (an angle in radians)
+/// as input and returns a numeric value $$y$$ that lies in the range $$\[-1, 1\]$$.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// floatx.cos(0.0)
+/// |> should.equal(1.0)
+///
+/// floatx.cos(floatx.pi())
+/// |> should.equal(-1.0)
+/// }
+///
+///
+///
+///
+/// The hyperbolic cosine function:
+///
+/// \\[
+/// \forall x \in \(-\infty, \infty\), \\; \cosh{(x)} = y \in \(-\infty, +\infty\)
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\(-\infty, \infty\)$$ as input (an angle in radians)
+/// and returns a numeric value $$y$$ that lies in the range $$\(-\infty, \infty\)$$.
+/// If the input value is too large an overflow error might occur.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// floatx.cosh(0.0)
+/// |> should.equal(0.0)
+/// }
+///
+///
+///
+///
+/// The sine function:
+///
+/// \\[
+/// \forall x \in \(-\infty, +\infty\), \\; \sin{(x)} = y \in \[-1, 1\]
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\(-\infty, \infty\)$$ (an angle in radians)
+/// as input and returns a numeric value $$y$$ that lies in the range $$\[-1, 1\]$$.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// floatx.sin(0.0)
+/// |> should.equal(0.0)
+///
+/// floatx.sin(0.5 *. floatx.pi())
+/// |> should.equal(1.0)
+/// }
+///
+///
+///
+///
+/// The hyperbolic sine function:
+///
+/// \\[
+/// \forall x \in \(-\infty, +\infty\), \\; \sinh{(x)} = y \in \(-\infty, +\infty\)
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\(-\infty, +\infty\)$$ as input
+/// (an angle in radians) and returns a numeric value $$y$$ that lies in the range
+/// $$\(-\infty, +\infty\)$$. If the input value is too large an overflow error might
+/// occur.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// floatx.sinh(0.0)
+/// |> should.equal(0.0)
+/// }
+///
+///
+///
+///
+/// The tangent function:
+///
+/// \\[
+/// \forall x \in \(-\infty, +\infty\), \\; \tan{(x)} = y \in \(-\infty, +\infty\)
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\(-\infty, +\infty\)$$ as input
+/// (an angle in radians) and returns a numeric value $$y$$ that lies in the range
+/// $$\(-\infty, +\infty\)$$.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// floatx.tan(0.0)
+/// |> should.equal(0.0)
+/// }
+///
+///
+///
+///
+/// The hyperbolic tangent function:
+///
+/// \\[
+/// \forall x \in \(-\infty, \infty\), \\; \tanh{(x)} = y \in \[-1, 1\]
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\(-\infty, \infty\)$$ as input (an angle in radians)
+/// and returns a numeric value $$y$$ that lies in the range $$\[-1, 1\]$$.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example () {
+/// floatx.tanh(0.0)
+/// |> should.equal(0.0)
+///
+/// floatx.tanh(25.0)
+/// |> should.equal(1.0)
+///
+/// floatx.tanh(-25.0)
+/// |> should.equal(-1.0)
+/// }
+///
+///
+///
+///
+/// The natural logarithm function:
+///
+/// \\[
+/// \forall x \in \(0, \infty\), \\; \log_{e}{(x)} = y \in \(-\infty, +\infty\)
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\(0, \infty\)$$ as input and returns
+/// a numeric value $$y$$ that lies in the range $$\(-\infty, \infty\)$$.
+/// If the input value is outside the domain of the function an error is returned.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example () {
+/// floatx.natural_logarithm(1.0)
+/// |> should.equal(Ok(0.0))
+///
+/// floatx.natural_logarithm(floatx.e())
+/// |> should.equal(Ok(1.0))
+///
+/// floatx.natural_logarithm(-1.0)
+/// |> should.be_error()
+/// }
+///
+///
+///
+///
+///
+/// The base $$b$$ logarithm function (computed through the "change of base" formula):
+///
+/// \\[
+/// \forall x \in \(0, \infty\) \textnormal{ and } b > 1, \\; \log_{b}{(x)} = y \in \(-\infty, +\infty\)
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\(0, \infty\)$$ and a base $$b > 1$$ as input and returns
+/// a numeric value $$y$$ that lies in the range $$\(-\infty, \infty\)$$.
+/// If the input value is outside the domain of the function an error is returned.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam/option
+/// import gleam_community/maths/elementary
+///
+/// pub fn example () {
+/// floatx.logarithm(1.0, option.Some(10.0))
+/// |> should.equal(Ok(0.0))
+///
+/// floatx.logarithm(floatx.e(), option.Some(floatx.e()))
+/// |> should.equal(Ok(1.0))
+///
+/// floatx.logarithm(-1.0, option.Some(2.0))
+/// |> should.be_error()
+/// }
+///
+///
+///
+///
+///
+/// The The base-2 logarithm function:
+///
+/// \\[
+/// \forall x \in \(0, \infty), \\; \log_{2}{(x)} = y \in \(-\infty, +\infty\)
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\(0, \infty\)$$ as input and returns
+/// a numeric value $$y$$ that lies in the range $$\(-\infty, \infty\)$$.
+/// If the input value is outside the domain of the function an error is returned.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example () {
+/// floatx.logarithm_2(1.0)
+/// |> should.equal(Ok(0.0))
+///
+/// floatx.logarithm_2(2.0)
+/// |> should.equal(Ok(1.0))
+///
+/// floatx.logarithm_2(-1.0)
+/// |> should.be_error()
+/// }
+///
+///
+///
+///
+/// The base-10 logarithm function:
+///
+/// \\[
+/// \forall x \in \(0, \infty), \\; \log_{10}{(x)} = y \in \(-\infty, +\infty\)
+/// \\]
+///
+/// The function takes a number $$x$$ in its domain $$\(0, \infty\)$$ as input and returns
+/// a numeric value $$y$$ that lies in the range $$\(-\infty, \infty\)$$.
+/// If the input value is outside the domain of the function an error is returned.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example () {
+/// floatx.logarithm_10(1.0)
+/// |> should.equal(Ok(0.0))
+///
+/// floatx.logarithm_10(10.0)
+/// |> should.equal(Ok(1.0))
+///
+/// floatx.logarithm_10(-1.0)
+/// |> should.be_error()
+/// }
+///
+///
+///
+///
+/// The exponentiation function: $$y = x^{a}$$.
+///
+/// Note that the function is not defined if:
+/// 1. The base is negative ($$x < 0$$) and the exponent is fractional
+/// ($$a = \frac{n}{m}$$ is an irrreducible fraction). An error will be returned
+/// as an imaginary number will otherwise have to be returned.
+/// 2. The base is zero ($$x = 0$$) and the exponent is negative ($$a < 0$$) then the
+/// expression is equivalent to the exponent $$y$$ divided by $$0$$ and an
+/// error will have to be returned as the expression is otherwise undefined.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// floatx.power(2., -1.)
+/// |> should.equal(Ok(0.5))
+///
+/// floatx.power(2., 2.)
+/// |> should.equal(Ok(4.0))
+///
+/// floatx.power(-1., 0.5)
+/// |> should.be_error()
+/// }
+///
+///
+///
+///
+pub fn power(x: Float, y: Float) -> Result(Float, String) {
+ let fractional: Bool = do_ceiling(y) -. y >. 0.0
+ // In the following check:
+ // 1. If the base (x) is negative and the exponent (y) is fractional
+ // then return an error as it will otherwise be an imaginary number
+ // 2. If the base (x) is 0 and the exponent (y) is negative then the
+ // expression is equivalent to the exponent (y) divided by 0 and an
+ // error should be returned
+ case x <. 0.0 && fractional || x == 0.0 && y <. 0.0 {
+ True ->
+ "Invalid input argument: x < 0 and y is fractional or x = 0 and y < 0."
+ |> Error
+ False ->
+ do_power(x, y)
+ |> Ok
+ }
+}
+
+@external(erlang, "math", "pow")
+@external(javascript, "../../maths.mjs", "power")
+fn do_power(a: Float, b: Float) -> Float
+
+@external(erlang, "math", "ceil")
+@external(javascript, "../../maths.mjs", "ceiling")
+fn do_ceiling(a: Float) -> Float
+
+///
+///
+/// The square root function: $$y = \sqrt[2]{x} = x^{\frac{1}{2}}$$.
+///
+/// Note that the function is not defined if:
+/// 1. The input is negative ($$x < 0$$). An error will be returned
+/// as an imaginary number will otherwise have to be returned.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// floatx.square_root(1.0)
+/// |> should.equal(Ok(1.0))
+///
+/// floatx.square_root(4.0)
+/// |> should.equal(Ok(2.0))
+///
+/// floatx.square_root(-1.0)
+/// |> should.be_error()
+/// }
+///
+///
+///
+///
+pub fn square_root(x: Float) -> Result(Float, String) {
+ // In the following check:
+ // 1. If x is negative then return an error as it will otherwise be an
+ // imaginary number
+ case x <. 0.0 {
+ True ->
+ "Invalid input argument: x < 0."
+ |> Error
+ False -> {
+ let assert Ok(result) = power(x, 1.0 /. 2.0)
+ result
+ |> Ok
+ }
+ }
+}
+
+///
+///
+/// The cube root function: $$y = \sqrt[3]{x} = x^{\frac{1}{3}}$$.
+///
+/// Note that the function is not defined if:
+/// 1. The input is negative ($$x < 0$$). An error will be returned
+/// as an imaginary number will otherwise have to be returned.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// floatx.cube_root(1.0)
+/// |> should.equal(Ok(1.0))
+///
+/// floatx.cube_root(27.0)
+/// |> should.equal(Ok(3.0))
+///
+/// floatx.cube_root(-1.0)
+/// |> should.be_error()
+/// }
+///
+///
+///
+///
+pub fn cube_root(x: Float) -> Result(Float, String) {
+ // In the following check:
+ // 1. If x is negative then return an error as it will otherwise be an
+ // imaginary number
+ case x <. 0.0 {
+ True ->
+ "Invalid input argument: x < 0."
+ |> Error
+ False -> {
+ let assert Ok(result) = power(x, 1.0 /. 3.0)
+ result
+ |> Ok
+ }
+ }
+}
+
+///
+///
+/// The $$n$$'th root function: $$y = \sqrt[n]{x} = x^{\frac{1}{n}}$$.
+///
+/// Note that the function is not defined if:
+/// 1. The input is negative ($$x < 0$$). An error will be returned
+/// as an imaginary number will otherwise have to be returned.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/elementary
+///
+/// pub fn example() {
+/// floatx.nth_root(1.0, 2)
+/// |> should.equal(Ok(1.0))
+///
+/// floatx.nth_root(27.0, 3)
+/// |> should.equal(Ok(3.0))
+///
+/// floatx.nth_root(256.0, 4)
+/// |> should.equal(Ok(4.0))
+///
+/// floatx.nth_root(-1.0, 2)
+/// |> should.be_error()
+/// }
+///
+///
+///
+///
+pub fn nth_root(x: Float, n: Int) -> Result(Float, String) {
+ // In the following check:
+ // 1. If x is negative then return an error as it will otherwise be an
+ // imaginary number
+ case x <. 0.0 {
+ True ->
+ "Invalid input argument: x < 0. Valid input is x > 0"
+ |> Error
+ False ->
+ case n >= 1 {
+ True -> {
+ let assert Ok(result) = power(x, 1.0 /. int.to_float(n))
+ result
+ |> Ok
+ }
+ False ->
+ "Invalid input argument: n < 1. Valid input is n >= 2."
+ |> Error
+ }
+ }
+}
+
+///
-///
-/// The ceiling function rounds a given input value $$x \in \mathbb{R}$$ to the nearest integer value (at the specified digit) that is larger than or equal to the input $$x$$.
-///
-/// Note: The ceiling function is used as an alias for the rounding function [`round`](#round) with rounding mode `RoundUp`.
-///
-///
-/// Details
-///
-/// For example, $$12.0654$$ is rounded to:
-/// - $$13.0$$ for 0 digits after the decimal point (`digits = 0`)
-/// - $$12.1$$ for 1 digit after the decimal point (`digits = 1`)
-/// - $$12.07$$ for 2 digits after the decimal point (`digits = 2`)
-/// - $$12.066$$ for 3 digits after the decimal point (`digits = 3`)
-///
-/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
-/// For example, $$12.0654$$ is rounded to:
-/// - $$20.0$$ for 1 digit places before the decimal point (`digit = -1`)
-/// - $$100.0$$ for 2 digits before the decimal point (`digits = -2`)
-/// - $$1000.0$$ for 3 digits before the decimal point (`digits = -3`)
-///
-///
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam/option
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.ceiling(12.0654, option.Some(1))
-/// |> should.equal(Ok(12.1))
-///
-/// floatx.ceiling(12.0654, option.Some(2))
-/// |> should.equal(Ok(12.07))
-///
-/// floatx.ceiling(12.0654, option.Some(3))
-/// |> should.equal(Ok(12.066))
-/// }
-///
-///
-///
-///
-/// The floor function rounds input $$x \in \mathbb{R}$$ to the nearest integer value (at the specified digit) that is less than or equal to the input $$x$$.
-///
-/// Note: The floor function is used as an alias for the rounding function [`round`](#round) with rounding mode `RoundDown`.
-///
-///
-/// Details
-///
-/// For example, $$12.0654$$ is rounded to:
-/// - $$12.0$$ for 0 digits after the decimal point (`digits = 0`)
-/// - $$12.0$$ for 1 digits after the decimal point (`digits = 1`)
-/// - $$12.06$$ for 2 digits after the decimal point (`digits = 2`)
-/// - $$12.065$$ for 3 digits after the decimal point (`digits = 3`)
-///
-/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
-/// - $$10.0$$ for 1 digit before the decimal point (`digits = -1`)
-/// - $$0.0$$ for 2 digits before the decimal point (`digits = -2`)
-/// - $$0.0$$ for 3 digits before the decimal point (`digits = -3`)
-///
-///
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam/option
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.floor(12.0654, option.Some(1))
-/// |> should.equal(Ok(12.0))
-///
-/// floatx.floor(12.0654, option.Some(2))
-/// |> should.equal(Ok(12.06))
-///
-/// floatx.floor(12.0654, option.Some(3))
-/// |> should.equal(Ok(12.065))
-/// }
-///
-///
-///
-///
-/// The truncate function rounds a given input $$x \in \mathbb{R}$$ to the nearest integer value (at the specified digit) that is less than or equal to the absolute value of the input $$x$$.
-///
-/// Note: The truncate function is used as an alias for the rounding function [`round`](#round) with rounding mode `RoundToZero`.
-///
-///
-/// Details
-///
-/// For example, $$12.0654$$ is rounded to:
-/// - $$12.0$$ for 0 digits after the decimal point (`digits = 0`)
-/// - $$12.0$$ for 1 digits after the decimal point (`digits = 1`)
-/// - $$12.06$$ for 2 digits after the decimal point (`digits = 2`)
-/// - $$12.065$$ for 3 digits after the decimal point (`digits = 3`)
-///
-/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
-/// - $$10.0$$ for 1 digit before the decimal point (`digits = -1`)
-/// - $$0.0$$ for 2 digits before the decimal point (`digits = -2`)
-/// - $$0.0$$ for 3 digits before the decimal point (`digits = -3`)
-///
-///
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam/option
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.truncate(12.0654, option.Some(1))
-/// |> should.equal(Ok(12.0))
-///
-/// floatx.truncate(12.0654, option.Some(2))
-/// |> should.equal(Ok(12.0))
-///
-/// floatx.truncate(12.0654, option.Some(3))
-/// |> should.equal(Ok(12.0))
-/// }
-///
-///
-///
-///
-/// The function rounds a float to a specific number of digits (after the decimal place or before if negative) using a specified rounding mode.
-///
-/// Valid rounding modes include:
-/// - `RoundNearest` (default): The input $$x$$ is rounded to the nearest integer value (at the specified digit) with ties (fractional values of 0.5) being rounded to the nearest even integer.
-/// - `RoundTiesAway`: The input $$x$$ is rounded to the nearest integer value (at the specified digit) with ties (fractional values of 0.5) being rounded away from zero (C/C++ rounding behavior).
-/// - `RoundTiesUp`: The input $$x$$ is rounded to the nearest integer value (at the specified digit) with ties (fractional values of 0.5) being rounded towards $$+\infty$$ (Java/JavaScript rounding behaviour).
-/// - `RoundToZero`: The input $$x$$ is rounded to the nearest integer value (at the specified digit) that is less than or equal to the absolute value of the input $$x$$. An alias for this rounding mode is [`truncate`](#truncate).
-/// - `RoundDown`: The input $$x$$ is rounded to the nearest integer value (at the specified digit) that is less than or equal to the input $$x$$. An alias for this rounding mode is [`floor`](#floor).
-/// - `RoundUp`: The input $$x$$ is rounded to the nearest integer value (at the specified digit) that is larger than or equal to the input $$x$$. An alias for this rounding mode is [`ceiling`](#ceiling).
-///
-///
-/// Details
-///
-/// The `RoundNearest` rounding mode, rounds $$12.0654$$ to:
-/// - $$12.0$$ for 0 digits after the decimal point (`digits = 0`)
-/// - $$12.1$$ for 1 digit after the decimal point (`digits = 1`)
-/// - $$12.07$$ for 2 digits after the decimal point (`digits = 2`)
-/// - $$12.065$$ for 3 digits after the decimal point (`digits = 3`)
-///
-/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
-/// - $$10.0$$ for 1 digit before the decimal point (`digits = -1`)
-/// - $$0.0$$ for 2 digits before the decimal point (`digits = -2`)
-/// - $$0.0$$ for 3 digits before the decimal point (`digits = -3`)
-///
-/// The `RoundTiesAway` rounding mode, rounds $$12.0654$$ to:
-/// - $$12.0$$ for 0 digits after the decimal point (`digits = 0`)
-/// - $$12.1$$ for 1 digit after the decimal point (`digits = 1`)
-/// - $$12.07$$ for 2 digits after the decimal point (`digits = 2`)
-/// - $$12.065$$ for 3 digits after the decimal point (`digits = 3`)
-///
-/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
-/// - $$10.0$$ for 1 digit before the decimal point (`digits = -1`)
-/// - $$0.0$$ for 2 digits before the decimal point (`digits = -2`)
-/// - $$0.0$$ for 3 digits before the decimal point (`digits = -3`)
-///
-/// The `RoundTiesUp` rounding mode, rounds $$12.0654$$ to:
-/// - $$12.0$$ for 0 digits after the decimal point (`digits = 0`)
-/// - $$12.1$$ for 1 digits after the decimal point (`digits = 1`)
-/// - $$12.07$$ for 2 digits after the decimal point (`digits = 2`)
-/// - $$12.065$$ for 3 digits after the decimal point (`digits = 3`)
-///
-/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
-/// - $$10.0$$ for 1 digit before the decimal point (`digits = -1`)
-/// - $$0.0$$ for 2 digits before the decimal point (`digits = -2`)
-/// - $$0.0$$ for 3 digits before the decimal point (`digits = -3`)
-///
-/// The `RoundToZero` rounding mode, rounds $$12.0654$$ to:
-/// - $$12.0$$ for 0 digits after the decimal point (`digits = 0`)
-/// - $$12.0$$ for 1 digit after the decimal point (`digits = 1`)
-/// - $$12.06$$ for 2 digits after the decimal point (`digits = 2`)
-/// - $$12.065$$ for 3 digits after the decimal point (`digits = 3`)
-///
-/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
-/// - $$10.0$$ for 1 digit before the decimal point (`digits = -1`)
-/// - $$0.0$$ for 2 digits before the decimal point (`digits = -2`)
-/// - $$0.0$$ for 3 digits before the decimal point (`digits = -3`)
-///
-/// The `RoundDown` rounding mode, rounds $$12.0654$$ to:
-/// - $$12.0$$ for 0 digits after the decimal point (`digits = 0`)
-/// - $$12.0$$ for 1 digits after the decimal point (`digits = 1`)
-/// - $$12.06$$ for 2 digits after the decimal point (`digits = 2`)
-/// - $$12.065$$ for 3 digits after the decimal point (`digits = 3`)
-///
-/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
-/// - $$10.0$$ for 1 digit before the decimal point (`digits = -1`)
-/// - $$0.0$$ for 2 digits before the decimal point (`digits = -2`)
-/// - $$0.0$$ for 3 digits before the decimal point (`digits = -3`)
-///
-/// The `RoundUp` rounding mode, rounds $$12.0654$$ to:
-/// - $$13.0$$ for 0 digits after the decimal point (`digits = 0`)
-/// - $$12.1$$ for 1 digit after the decimal point (`digits = 1`)
-/// - $$12.07$$ for 2 digits after the decimal point (`digits = 2`)
-/// - $$12.066$$ for 3 digits after the decimal point (`digits = 3`)
-///
-/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
-/// - $$20.0$$ for 1 digit places before the decimal point (`digit = -1`)
-/// - $$100.0$$ for 2 digits before the decimal point (`digits = -2`)
-/// - $$1000.0$$ for 3 digits before the decimal point (`digits = -3`)
-///
-///
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam/option
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// // The default number of digits is 0 if None is provided
-/// floatx.round(12.0654, option.None, option.Some(floatx.RoundNearest))
-/// |> should.equal(Ok(12.0))
-///
-/// // The default rounding mode is "RoundNearest" if None is provided
-/// floatx.round(12.0654, option.None, option.None)
-/// |> should.equal(Ok(12.0))
-///
-/// // Try different rounding modes
-/// floatx.round(12.0654, option.Some(2), option.Some(floatx.RoundNearest))
-/// |> should.equal(Ok(12.07))
-///
-/// floatx.round(12.0654, option.Some(2), option.Some(floatx.RoundTiesAway))
-/// |> should.equal(Ok(12.07))
-///
-/// floatx.round(12.0654, option.Some(2), option.Some(floatx.RoundTiesUp))
-/// |> should.equal(Ok(12.07))
-///
-/// floatx.round(12.0654, option.Some(2), option.Some(floatx.RoundToZero))
-/// |> should.equal(Ok(12.06))
-///
-/// floatx.round(12.0654, option.Some(2), option.Some(floatx.RoundDown))
-/// |> should.equal(Ok(12.06))
-///
-/// floatx.round(12.0654, option.Some(2), option.Some(floatx.RoundUp))
-/// |> should.equal(Ok(12.07))
-/// }
-///
-///
-///
-///
-/// The function returns the integral part of a given floating point value.
-/// That is, everything after the decimal point of a given floating point value is discarded and only the integer value before the decimal point is returned.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam/option
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.to_int(12.0654)
-/// |> should.equal(12)
-///
-/// // Note: Making the following function call is equivalent
-/// // but instead of returning a value of type 'Int' a value
-/// // of type 'Float' is returned.
-/// floatx.round(12.0654, option.Some(0), option.Some(floatx.RoundToZero))
-/// |> should.equal(Ok(12.0))
-/// }
-///
-///
-///
-///
-/// The inverse cosine function:
-///
-/// \\[
-/// \forall x \in \[-1, 1\], \\; \cos^{-1}{(x)} = y \in \[0, \pi \]
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\[-1, 1\]$$ as input and returns a
-/// numeric value $$y$$ that lies in the range $$\[0, \pi \]$$ (an angle in radians).
-/// If the input value is outside the domain of the function an error is returned.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.acos(1.0)
-/// |> should.equal(Ok(0.0))
-///
-/// floatx.acos(1.1)
-/// |> should.be_error()
-///
-/// floatx.acos(-1.1)
-/// |> should.be_error()
-/// }
-///
-///
-///
-///
-/// The inverse hyperbolic cosine function:
-///
-/// \\[
-/// \forall x \in [1, +\infty\), \\; \cosh^{-1}{(x)} = y \in \[0, +\infty\)
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\[1, +\infty\)$$ as input and returns
-/// a numeric value $$y$$ that lies in the range $$\[0, +\infty\)$$ (an angle in radians).
-/// If the input value is outside the domain of the function an error is returned.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.acosh(1.0)
-/// |> should.equal(Ok(0.0))
-///
-/// floatx.acosh(0.0)
-/// |> should.be_error()
-/// }
-///
-///
-///
-///
-/// The inverse sine function:
-///
-/// \\[
-/// \forall x \in \[-1, 1\], \\; \sin^{-1}{(x)} = y \in \(-\infty, +\infty\)
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\[-1, 1\]$$ as input and returns a numeric
-/// value $$y$$ that lies in the range $$\[-\frac{\pi}{2}, \frac{\pi}{2}\]$$ (an angle in radians).
-/// If the input value is outside the domain of the function an error is returned.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.asin(0.0)
-/// |> should.equal(Ok(0.0))
-///
-/// floatx.asin(1.1)
-/// |> should.be_error()
-///
-/// floatx.asin(-1.1)
-/// |> should.be_error()
-/// }
-///
-///
-///
-///
-/// The inverse hyperbolic sine function:
-///
-/// \\[
-/// \forall x \in \(-\infty, \infty\), \\; \sinh^{-1}{(x)} = y \in \(-\infty, +\infty\)
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\(-\infty, +\infty\)$$ as input and returns
-/// a numeric value $$y$$ that lies in the range $$\(-\infty, +\infty\)$$ (an angle in radians).
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.asinh(0.0)
-/// |> should.equal(0.0)
-/// }
-///
-///
-///
-///
-/// The inverse tangent function:
-///
-/// \\[
-/// \forall x \in \(-\infty, \infty\), \\; \tan^{-1}{(x)} = y \in \[-\frac{\pi}{2}, \frac{\pi}{2}\]
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\(-\infty, +\infty\)$$ as input and returns
-/// a numeric value $$y$$ that lies in the range $$\[-\frac{\pi}{2}, \frac{\pi}{2}\]$$ (an angle in radians).
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.atan(0.0)
-/// |> should.equal(0.0)
-/// }
-///
-///
-///
-///
-/// The inverse 2-argument tangent function:
-///
-/// \\[
-/// \text{atan2}(y, x) =
-/// \begin{cases}
-/// \tan^{-1}(\frac y x) &\text{if } x > 0, \\\\
-/// \tan^{-1}(\frac y x) + \pi &\text{if } x < 0 \text{ and } y \ge 0, \\\\
-/// \tan^{-1}(\frac y x) - \pi &\text{if } x < 0 \text{ and } y < 0, \\\\
-/// +\frac{\pi}{2} &\text{if } x = 0 \text{ and } y > 0, \\\\
-/// -\frac{\pi}{2} &\text{if } x = 0 \text{ and } y < 0, \\\\
-/// \text{undefined} &\text{if } x = 0 \text{ and } y = 0.
-/// \end{cases}
-/// \\]
-///
-/// The function returns the angle in radians from the x-axis to the line containing the
-/// origin $$\(0, 0\)$$ and a point given as input with coordinates $$\(x, y\)$$. The numeric value
-/// returned by $$\text{atan2}(y, x)$$ is in the range $$\[-\pi, \pi\]$$.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.atan2(0.0, 0.0)
-/// |> should.equal(0.0)
-/// }
-///
-///
-///
-///
-/// The inverse hyperbolic tangent function:
-///
-/// \\[
-/// \forall x \in \(-1, 1\), \\; \tanh^{-1}{(x)} = y \in \(-\infty, +\infty\)
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\(-1, 1\)$$ as input and returns
-/// a numeric value $$y$$ that lies in the range $$\(-\infty, \infty\)$$ (an angle in radians).
-/// If the input value is outside the domain of the function an error is returned.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.atanh(0.0)
-/// |> should.equal(Ok(0.0))
-///
-/// floatx.atanh(1.0)
-/// |> should.be_error()
-///
-/// floatx.atanh(-1.0)
-/// |> should.be_error()
-/// }
-///
-///
-///
-///
-/// The cosine function:
-///
-/// \\[
-/// \forall x \in \(-\infty, +\infty\), \\; \cos{(x)} = y \in \[-1, 1\]
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\(-\infty, \infty\)$$ (an angle in radians)
-/// as input and returns a numeric value $$y$$ that lies in the range $$\[-1, 1\]$$.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.cos(0.0)
-/// |> should.equal(1.0)
-///
-/// floatx.cos(floatx.pi())
-/// |> should.equal(-1.0)
-/// }
-///
-///
-///
-///
-/// The hyperbolic cosine function:
-///
-/// \\[
-/// \forall x \in \(-\infty, \infty\), \\; \cosh{(x)} = y \in \(-\infty, +\infty\)
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\(-\infty, \infty\)$$ as input (an angle in radians)
-/// and returns a numeric value $$y$$ that lies in the range $$\(-\infty, \infty\)$$.
-/// If the input value is too large an overflow error might occur.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.cosh(0.0)
-/// |> should.equal(0.0)
-/// }
-///
-///
-///
-///
-/// The base $$b$$ logarithm function (computed through the "change of base" formula):
-///
-/// \\[
-/// \forall x \in \(0, \infty\) \textnormal{ and } b > 1, \\; \log_{b}{(x)} = y \in \(-\infty, +\infty\)
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\(0, \infty\)$$ and a base $$b > 1$$ as input and returns
-/// a numeric value $$y$$ that lies in the range $$\(-\infty, \infty\)$$.
-/// If the input value is outside the domain of the function an error is returned.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam/option
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example () {
-/// floatx.logarithm(1.0, option.Some(10.0))
-/// |> should.equal(Ok(0.0))
-///
-/// floatx.logarithm(floatx.e(), option.Some(floatx.e()))
-/// |> should.equal(Ok(1.0))
-///
-/// floatx.logarithm(-1.0, option.Some(2.0))
-/// |> should.be_error()
-/// }
-///
-///
-///
-///
-///
-/// The natural logarithm function:
-///
-/// \\[
-/// \forall x \in \(0, \infty\), \\; \log_{e}{(x)} = y \in \(-\infty, +\infty\)
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\(0, \infty\)$$ as input and returns
-/// a numeric value $$y$$ that lies in the range $$\(-\infty, \infty\)$$.
-/// If the input value is outside the domain of the function an error is returned.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example () {
-/// floatx.natural_logarithm(1.0)
-/// |> should.equal(Ok(0.0))
-///
-/// floatx.natural_logarithm(floatx.e())
-/// |> should.equal(Ok(1.0))
-///
-/// floatx.natural_logarithm(-1.0)
-/// |> should.be_error()
-/// }
-///
-///
-///
-///
-///
-/// The base-10 logarithm function:
-///
-/// \\[
-/// \forall x \in \(0, \infty), \\; \log_{10}{(x)} = y \in \(-\infty, +\infty\)
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\(0, \infty\)$$ as input and returns
-/// a numeric value $$y$$ that lies in the range $$\(-\infty, \infty\)$$.
-/// If the input value is outside the domain of the function an error is returned.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example () {
-/// floatx.logarithm_10(1.0)
-/// |> should.equal(Ok(0.0))
-///
-/// floatx.logarithm_10(10.0)
-/// |> should.equal(Ok(1.0))
-///
-/// floatx.logarithm_10(-1.0)
-/// |> should.be_error()
-/// }
-///
-///
-///
-///
-/// The The base-2 logarithm function:
-///
-/// \\[
-/// \forall x \in \(0, \infty), \\; \log_{2}{(x)} = y \in \(-\infty, +\infty\)
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\(0, \infty\)$$ as input and returns
-/// a numeric value $$y$$ that lies in the range $$\(-\infty, \infty\)$$.
-/// If the input value is outside the domain of the function an error is returned.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example () {
-/// floatx.logarithm_2(1.0)
-/// |> should.equal(Ok(0.0))
-///
-/// floatx.logarithm_2(2.0)
-/// |> should.equal(Ok(1.0))
-///
-/// floatx.logarithm_2(-1.0)
-/// |> should.be_error()
-/// }
-///
-///
-///
-///
-/// The exponentiation function: $$y = x^{a}$$.
-///
-/// Note that the function is not defined if:
-/// 1. The base is negative ($$x < 0$$) and the exponent is fractional
-/// ($$a = \frac{n}{m}$$ is an irrreducible fraction). An error will be returned
-/// as an imaginary number will otherwise have to be returned.
-/// 2. The base is zero ($$x = 0$$) and the exponent is negative ($$a < 0$$) then the
-/// expression is equivalent to the exponent $$y$$ divided by $$0$$ and an
-/// error will have to be returned as the expression is otherwise undefined.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.power(2., -1.)
-/// |> should.equal(Ok(0.5))
-///
-/// floatx.power(2., 2.)
-/// |> should.equal(Ok(4.0))
-///
-/// floatx.power(-1., 0.5)
-/// |> should.be_error()
-/// }
-///
-///
-///
-///
-pub fn power(x: Float, y: Float) -> Result(Float, String) {
- let fractional: Bool = do_ceiling(y) -. y >. 0.0
- // In the following check:
- // 1. If the base (x) is negative and the exponent (y) is fractional
- // then return an error as it will otherwise be an imaginary number
- // 2. If the base (x) is 0 and the exponent (y) is negative then the
- // expression is equivalent to the exponent (y) divided by 0 and an
- // error should be returned
- case x <. 0.0 && fractional || x == 0.0 && y <. 0.0 {
- True ->
- "Invalid input argument: x < 0 and y is fractional or x = 0 and y < 0."
- |> Error
- False ->
- do_power(x, y)
- |> Ok
- }
-}
-
-if erlang {
- external fn do_power(Float, Float) -> Float =
- "math" "pow"
-}
-
-if javascript {
- external fn do_power(Float, Float) -> Float =
- "../../maths.mjs" "power"
-}
-
-///
-///
-/// The square root function: $$y = \sqrt[2]{x} = x^{\frac{1}{2}}$$.
-///
-/// Note that the function is not defined if:
-/// 1. The input is negative ($$x < 0$$). An error will be returned
-/// as an imaginary number will otherwise have to be returned.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.square_root(1.0)
-/// |> should.equal(Ok(1.0))
-///
-/// floatx.square_root(4.0)
-/// |> should.equal(Ok(2.0))
-///
-/// floatx.square_root(-1.0)
-/// |> should.be_error()
-/// }
-///
-///
-///
-///
-pub fn square_root(x: Float) -> Result(Float, String) {
- // In the following check:
- // 1. If x is negative then return an error as it will otherwise be an
- // imaginary number
- case x <. 0.0 {
- True ->
- "Invalid input argument: x < 0."
- |> Error
- False -> {
- let assert Ok(result) = power(x, 1.0 /. 2.0)
- result
- |> Ok
- }
- }
-}
-
-///
-///
-/// The cube root function: $$y = \sqrt[3]{x} = x^{\frac{1}{3}}$$.
-///
-/// Note that the function is not defined if:
-/// 1. The input is negative ($$x < 0$$). An error will be returned
-/// as an imaginary number will otherwise have to be returned.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.cube_root(1.0)
-/// |> should.equal(Ok(1.0))
-///
-/// floatx.cube_root(27.0)
-/// |> should.equal(Ok(3.0))
-///
-/// floatx.cube_root(-1.0)
-/// |> should.be_error()
-/// }
-///
-///
-///
-///
-pub fn cube_root(x: Float) -> Result(Float, String) {
- // In the following check:
- // 1. If x is negative then return an error as it will otherwise be an
- // imaginary number
- case x <. 0.0 {
- True ->
- "Invalid input argument: x < 0."
- |> Error
- False -> {
- let assert Ok(result) = power(x, 1.0 /. 3.0)
- result
- |> Ok
- }
- }
-}
-
-///
-///
-/// The $$n$$'th root function: $$y = \sqrt[n]{x} = x^{\frac{1}{n}}$$.
-///
-/// Note that the function is not defined if:
-/// 1. The input is negative ($$x < 0$$). An error will be returned
-/// as an imaginary number will otherwise have to be returned.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.nth_root(1.0, 2)
-/// |> should.equal(Ok(1.0))
-///
-/// floatx.nth_root(27.0, 3)
-/// |> should.equal(Ok(3.0))
-///
-/// floatx.nth_root(256.0, 4)
-/// |> should.equal(Ok(4.0))
-///
-/// floatx.nth_root(-1.0, 2)
-/// |> should.be_error()
-/// }
-///
-///
-///
-///
-pub fn nth_root(x: Float, n: Int) -> Result(Float, String) {
- // In the following check:
- // 1. If x is negative then return an error as it will otherwise be an
- // imaginary number
- case x <. 0.0 {
- True ->
- "Invalid input argument: x < 0. Valid input is x > 0"
- |> Error
- False ->
- case n >= 1 {
- True -> {
- let assert Ok(result) = power(x, 1.0 /. int.to_float(n))
- result
- |> Ok
- }
- False ->
- "Invalid input argument: n < 1. Valid input is n >= 2."
- |> Error
- }
- }
-}
-
-///
-///
-/// A function to compute the hypotenuse of a right-angled triangle: $$\sqrt[2]{x^2 + y^2}$$.
-/// The function can also be used to calculate the Euclidean distance in 2 dimensions.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.hypotenuse(0.0, 0.0)
-/// |> should.equal(0.0)
-///
-/// floatx.hypotenuse(1.0, 0.0)
-/// |> should.equal(1.0)
-///
-/// floatx.hypotenuse(0.0, 1.0)
-/// |> should.equal(1.0)
-/// }
-///
-///
-///
-///
-/// The sine function:
-///
-/// \\[
-/// \forall x \in \(-\infty, +\infty\), \\; \sin{(x)} = y \in \[-1, 1\]
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\(-\infty, \infty\)$$ (an angle in radians)
-/// as input and returns a numeric value $$y$$ that lies in the range $$\[-1, 1\]$$.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.sin(0.0)
-/// |> should.equal(0.0)
-///
-/// floatx.sin(0.5 *. floatx.pi())
-/// |> should.equal(1.0)
-/// }
-///
-///
-///
-///
-/// The hyperbolic sine function:
-///
-/// \\[
-/// \forall x \in \(-\infty, +\infty\), \\; \sinh{(x)} = y \in \(-\infty, +\infty\)
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\(-\infty, +\infty\)$$ as input
-/// (an angle in radians) and returns a numeric value $$y$$ that lies in the range
-/// $$\(-\infty, +\infty\)$$. If the input value is too large an overflow error might
-/// occur.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.sinh(0.0)
-/// |> should.equal(0.0)
-/// }
-///
-///
-///
-///
-/// The tangent function:
-///
-/// \\[
-/// \forall x \in \(-\infty, +\infty\), \\; \tan{(x)} = y \in \(-\infty, +\infty\)
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\(-\infty, +\infty\)$$ as input
-/// (an angle in radians) and returns a numeric value $$y$$ that lies in the range
-/// $$\(-\infty, +\infty\)$$.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.tan(0.0)
-/// |> should.equal(0.0)
-/// }
-///
-///
-///
-///
-/// The hyperbolic tangent function:
-///
-/// \\[
-/// \forall x \in \(-\infty, \infty\), \\; \tanh{(x)} = y \in \[-1, 1\]
-/// \\]
-///
-/// The function takes a number $$x$$ in its domain $$\(-\infty, \infty\)$$ as input (an angle in radians)
-/// and returns a numeric value $$y$$ that lies in the range $$\[-1, 1\]$$.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example () {
-/// floatx.tanh(0.0)
-/// |> should.equal(0.0)
-///
-/// floatx.tanh(25.0)
-/// |> should.equal(1.0)
-///
-/// floatx.tanh(-25.0)
-/// |> should.equal(-1.0)
-/// }
-///
-///
-///
-///
-/// The maximum function that takes two arguments $$x, y \in \mathbb{R}$$ and returns the largest of the two.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.maximum(2.0, 1.5)
-/// |> should.equal(1.5)
-///
-/// floatx.maximum(1.5, 2.0)
-/// |> should.equal(1.5)
-/// }
-///
-///
-///
-///
-/// The minmax function that takes two arguments $$x, y \in \mathbb{R}$$ and returns a tuple with the smallest value first and largest second.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.minmax(2.0, 1.5)
-/// |> should.equal(#(1.5, 2.0))
-///
-/// floatx.minmax(1.5, 2.0)
-/// |> should.equal(#(1.5, 2.0))
-/// }
-///
-///
-///
-///
-pub fn copy_sign(x: Float, y: Float) -> Float {
- case sign(x) == sign(y) {
- // x and y have the same sign, just return x
- True -> x
- // x and y have different signs:
- // - x is positive and y is negative, then flip sign of x
- // - x is negative and y is positive, then flip sign of x
- False -> flip_sign(x)
- }
-}
-
-///
-///
-/// The beta function over the real numbers:
-///
-/// \\[
-/// \text{B}(x, y) = \frac{\Gamma(x) \cdot \Gamma(y)}{\Gamma(x + y)}
-/// \\]
-///
-/// The beta function is evaluated through the use of the gamma function.
-///
-///
-///
-/// The gamma function over the real numbers. The function is essentially equal to the
-/// factorial for any positive integer argument: $$\Gamma(n) = (n - 1)!$$
-///
-/// The implemented gamma function is approximated through Lanczos approximation
-/// using the same coefficients used by the GNU Scientific Library.
-///
-///
-///
-/// The lower incomplete gamma function over the real numbers.
-///
-/// The implemented incomplete gamma function is evaluated through a power series
-/// expansion.
-///
-///
-///
-/// The absolute difference:
-///
-/// \\[
-/// \forall x, y \in \mathbb{R}, \\; |x - y| \in \mathbb{R}_{+}.
-/// \\]
-///
-/// The function takes two inputs $$x$$ and $$y$$ and returns a positive float
-/// value which is the the absolute difference of the inputs.
-///
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example() {
-/// floatx.absolute_difference(-10.0, 10.0)
-/// |> should.equal(20.0)
-///
-/// floatx.absolute_difference(0.0, -2.0)
-/// |> should.equal(2.0)
-/// }
-///
-///
-///
-///
-/// Determine if a given value $$a$$ is close to or equivalent to a reference value
-/// $$b$$ based on supplied relative $$r_{tol}$$ and absolute $$a_{tol}$$ tolerance values.
-/// The equivalance of the two given values are then determined based on the equation:
-///
-/// \\[
-/// \|a - b\| \leq (a_{tol} + r_{tol} \cdot \|b\|)
-/// \\]
-///
-/// `True` is returned if statement holds, otherwise `False` is returned.
-///
-/// Example
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-///
-/// pub fn example () {
-/// let val: Float = 99.
-/// let ref_val: Float = 100.
-/// // We set 'atol' and 'rtol' such that the values are equivalent
-/// // if 'val' is within 1 percent of 'ref_val' +/- 0.1
-/// let rtol: Float = 0.01
-/// let atol: Float = 0.10
-/// floatx.is_close(val, ref_val, rtol, atol)
-/// |> should.be_true()
-/// }
-///
-///
-///
-///
-/// Calculcate the $$p$$-norm of a list (representing a vector):
-///
-/// \\[
-/// \left( \sum_{i=1}^n \left|x_i\right|^{p} \right)^{\frac{1}{p}}
-/// \\]
-///
-/// In the formula, $$n$$ is the length of the list and $$x_i$$ is the value in the input list indexed by $$i$$.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-/// import gleam_community/maths/float_list
-///
-/// pub fn example () {
-/// let assert Ok(tol) = floatx.power(-10.0, -6.0)
-///
-/// [1.0, 1.0, 1.0]
-/// |> float_list.norm(1.0)
-/// |> floatx.is_close(3.0, 0.0, tol)
-/// |> should.be_true()
-///
-/// [1.0, 1.0, 1.0]
-/// |> float_list.norm(-1.0)
-/// |> floatx.is_close(0.3333333333333333, 0.0, tol)
-/// |> should.be_true()
-/// }
-///
-///
-///
-///
-/// Generate a linearly spaced list of points over a specified interval. The endpoint of the interval can optionally be included/excluded.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-/// import gleam_community/maths/float_list
-///
-/// pub fn example () {
-/// let assert Ok(tol) = floatx.power(-10.0, -6.0)
-/// let assert Ok(linspace) = float_list.linear_space(10.0, 50.0, 5, True)
-/// let assert Ok(result) =
-/// float_list.all_close(linspace, [10.0, 20.0, 30.0, 40.0, 50.0], 0.0, tol)
-/// result
-/// |> list.all(fn(x) { x == True })
-/// |> should.be_true()
-///
-/// // A negative number of points (-5) does not work
-/// float_list.linear_space(10.0, 50.0, -5, True)
-/// |> should.be_error()
-/// }
-///
-///
-///
-///
-/// Generate a logarithmically spaced list of points over a specified interval. The endpoint of the interval can optionally be included/excluded.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-/// import gleam_community/maths/float_list
-///
-/// pub fn example () {
-/// let assert Ok(tol) = floatx.power(-10.0, -6.0)
-/// let assert Ok(logspace) = float_list.logarithmic_space(1.0, 3.0, 3, True, 10.0)
-/// let assert Ok(result) =
-/// float_list.all_close(logspace, [10.0, 100.0, 1000.0], 0.0, tol)
-/// result
-/// |> list.all(fn(x) { x == True })
-/// |> should.be_true()
-///
-/// // A negative number of points (-3) does not work
-/// float_list.logarithmic_space(1.0, 3.0, -3, False, 10.0)
-/// |> should.be_error()
-/// }
-///
-///
-///
-///
-/// The function returns a list of numbers spaced evenly on a log scale (a geometric progression). Each point in the list is a constant multiple of the previous.
-/// The function is similar to the [`logarithmic_space`](#logarithmic_space) function, but with endpoints specified directly.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float as floatx
-/// import gleam_community/maths/float_list
-///
-/// pub fn example () {
-/// let assert Ok(tol) = floatx.power(-10.0, -6.0)
-/// let assert Ok(logspace) = float_list.geometric_space(10.0, 1000.0, 3, True)
-/// let assert Ok(result) =
-/// float_list.all_close(logspace, [10.0, 100.0, 1000.0], 0.0, tol)
-/// result
-/// |> list.all(fn(x) { x == True })
-/// |> should.be_true()
-///
-/// // Input (start and stop can't be equal to 0.0)
-/// float_list.geometric_space(0.0, 1000.0, 3, False)
-/// |> should.be_error()
-///
-/// float_list.geometric_space(-1000.0, 0.0, 3, False)
-/// |> should.be_error()
-///
-/// // A negative number of points (-3) does not work
-/// float_list.geometric_space(10.0, 1000.0, -3, False)
-/// |> should.be_error()
-/// }
-///
-///
-///
-///
-/// The function returns a list with evenly spaced values within a given interval based on a start, stop value and a given increment (step-length) between consecutive values.
-/// The list returned includes the given start value but excludes the stop value.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float_list
-///
-/// pub fn example () {
-/// float_list.arange(1.0, 5.0, 1.0)
-/// |> should.equal([1.0, 2.0, 3.0, 4.0])
-///
-/// // No points returned since
-/// // start smaller than stop and positive step
-/// float_list.arange(5.0, 1.0, 1.0)
-/// |> should.equal([])
-///
-/// // Points returned since
-/// // start smaller than stop but negative step
-/// float_list.arange(5.0, 1.0, -1.0)
-/// |> should.equal([5.0, 4.0, 3.0, 2.0])
-/// }
-///
-///
-///
-///
-/// Calculcate the sum of the elements in a list:
-///
-/// \\[
-/// \sum_{i=1}^n x_i
-/// \\]
-///
-/// In the formula, $$n$$ is the length of the list and $$x_i$$ is the value in the input list indexed by $$i$$.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float_list
-///
-/// pub fn example () {
-/// // An empty list returns an error
-/// []
-/// |> float_list.sum()
-/// |> should.equal(0.0)
-///
-/// // Valid input returns a result
-/// [1.0, 2.0, 3.0]
-/// |> float_list.sum()
-/// |> should.equal(6.0)
-/// }
-///
-///
-///
-///
-/// Calculcate the product of the elements in a list:
-///
-/// \\[
-/// \prod_{i=1}^n x_i
-/// \\]
-///
-/// In the formula, $$n$$ is the length of the list and $$x_i$$ is the value in the input list indexed by $$i$$.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float_list
-///
-/// pub fn example () {
-/// // An empty list returns 0.0
-/// []
-/// |> float_list.sum()
-/// |> should.equal(0.0)
-///
-/// // Valid input returns a result
-/// [1.0, 2.0, 3.0]
-/// |> float_list.product()
-/// |> should.equal(6.0)
-/// }
-///
-///
-///
-///
-/// Calculcate the cumulative sum of the elements in a list:
-///
-/// \\[
-/// v_j = \sum_{i=1}^j x_i \\;\\; \forall j = 1,\dots, n
-/// \\]
-///
-/// In the formula, $$v_j$$ is the $$j$$'th element in the cumulative sum of $$n$$ elements.
-/// That is, $$n$$ is the length of the list and $$x_i$$ is the value in the input list indexed by $$i$$.
-/// The value $$v_j$$ is thus the sum of the $$1$$ to $$j$$ first elements in the given list.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float_list
-///
-/// pub fn example () {
-/// []
-/// |> float_list.cumulative_sum()
-/// |> should.equal([])
-///
-/// // Valid input returns a result
-/// [1.0, 2.0, 3.0]
-/// |> float_list.cumulative_sum()
-/// |> should.equal([1.0, 3.0, 6.0])
-/// }
-///
-///
-///
-///
-/// Calculcate the cumulative product of the elements in a list:
-///
-/// \\[
-/// v_j = \prod_{i=1}^j x_i \\;\\; \forall j = 1,\dots, n
-/// \\]
-///
-/// In the formula, $$v_j$$ is the $$j$$'th element in the cumulative product of $$n$$ elements.
-/// That is, $$n$$ is the length of the list and $$x_i$$ is the value in the input list indexed by $$i$$.
-/// The value $$v_j$$ is thus the sum of the $$1$$ to $$j$$ first elements in the given list.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/float_list
-///
-/// pub fn example () {
-/// // An empty list returns an error
-/// []
-/// |> float_list.cumulative_product()
-/// |> should.equal([])
-///
-/// // Valid input returns a result
-/// [1.0, 2.0, 3.0]
-/// |> float_list.cumulative_product()
-/// |> should.equal([1.0, 2.0, 6.0])
-/// }
-///
-///
-///
-///
-/// Determine if a list of values are close to or equivalent to a another list of reference values.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam/list
-/// import gleam_community/maths/float_list
-///
-/// pub fn example () {
-/// let val: Float = 99.
-/// let ref_val: Float = 100.
-/// let xarr: List(Float) = list.repeat(val, 42)
-/// let yarr: List(Float) = list.repeat(ref_val, 42)
-/// // We set 'atol' and 'rtol' such that the values are equivalent
-/// // if 'val' is within 1 percent of 'ref_val' +/- 0.1
-/// let rtol: Float = 0.01
-/// let atol: Float = 0.10
-/// float_list.all_close(xarr, yarr, rtol, atol)
-/// |> fn(zarr: Result(List(Bool), String)) -> Result(Bool, Nil) {
-/// case zarr {
-/// Ok(arr) ->
-/// arr
-/// |> list.all(fn(a: Bool) -> Bool { a })
-/// |> Ok
-/// _ -> Nil |> Error
-/// }
-/// }
-/// |> should.equal(Ok(True))
-/// }
-///
-///
-///
-///
-/// The maximum function that takes two arguments $$x, y \in \mathbb{Z}$$ and returns the largest of the two.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/int as intx
-///
-/// pub fn example() {
-/// intx.maximum(2, 1)
-/// |> should.equal(1)
-///
-/// intx.maximum(1, 2)
-/// |> should.equal(1)
-/// }
-///
-///
-///
-///
-/// The minmax function that takes two arguments $$x, y \in \mathbb{Z}$$ and returns a tuple with the smallest value first and largest second.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/int as intx
-///
-/// pub fn example() {
-/// intx.minmax(2, 1)
-/// |> should.equal(#(1, 2))
-///
-/// intx.minmax(1, 2)
-/// |> should.equal(#(1, 2))
-/// }
-///
-///
-///
-///
-pub fn copy_sign(x: Int, y: Int) -> Int {
- case sign(x) == sign(y) {
- // x and y have the same sign, just return x
- True -> x
- // x and y have different signs:
- // - x is positive and y is negative, then flip sign of x
- // - x is negative and y is positive, then flip sign of x
- False -> flip_sign(x)
- }
-}
-
-///
-///
-/// A function that tests whether a given integer value $$x \in \mathbb{Z}$$ is a power of another integer value $$y \in \mathbb{Z}$$.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/int as intx
-///
-/// pub fn example() {
-/// // Check if 4 is a power of 2 (it is)
-/// intx.is_power(4, 2)
-/// |> should.equal(True)
-///
-/// // Check if 5 is a power of 2 (it is not)
-/// intx.is_power(5, 2)
-/// |> should.equal(False)
-/// }
-///
-///
-///
-///
-/// A function that tests whether a given integer value $$n \in \mathbb{Z}$$ is a perfect number. A number is perfect if it is equal to the sum of its proper positive divisors.
-///
-///
-/// Details
-///
-/// For example:
-/// - $$6$$ is a perfect number since the divisors of 6 are $$1 + 2 + 3 = 6$$.
-/// - $$28$$ is a perfect number since the divisors of 28 are $$1 + 2 + 4 + 7 + 14 = 28$$
-///
-///
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/int as intx
-///
-/// pub fn example() {
-/// intx.is_perfect(6)
-/// |> should.equal(True)
-///
-/// intx.is_perfect(28)
-/// |> should.equal(True)
-/// }
-///
-///
-///
-///
-/// The function calculates the greatest common multiple of two integers $$x, y \in \mathbb{Z}$$.
-/// The greatest common multiple is the largest positive integer that is divisible by both $$x$$ and $$y$$.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/int as intx
-///
-/// pub fn example() {
-/// intx.lcm(1, 1)
-/// |> should.equal(1)
-///
-/// intx.lcm(100, 10)
-/// |> should.equal(10)
-///
-/// intx.gcd(-36, -17)
-/// |> should.equal(1)
-/// }
-///
-///
-///
-///
-/// The function calculates the least common multiple of two integers $$x, y \in \mathbb{Z}$$.
-/// The least common multiple is the smallest positive integer that has both $$x$$ and $$y$$ as factors.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/int as intx
-///
-/// pub fn example() {
-/// intx.lcm(1, 1)
-/// |> should.equal(1)
-///
-/// intx.lcm(100, 10)
-/// |> should.equal(100)
-///
-/// intx.lcm(-36, -17)
-/// |> should.equal(612)
-/// }
-///
-///
-///
-///
-/// A function that produces a number of type `Float` from an `Int`.
-///
-/// Note: The function is equivalent to the similar function in the Gleam stdlib.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/int as intx
-///
-/// pub fn example() {
-/// intx.to_float(-1)
-/// |> should.equal(-1.0)
-///
-/// intx.to_float(1)
-/// |> should.equal(1.0)
-/// }
-///
-///
-///
-///
-/// Trim a list to a certain size given min/max indices. The min/max indices are inclusive.
-///
-///
-/// Example:
-///
-/// import gleeunit/should
-/// import gleam_community/maths/list as listx
-///
-/// pub fn example () {
-/// // An empty lists returns an error
-/// []
-/// |> listx.trim(0, 0)
-/// |> should.be_error()
-///
-/// // Trim the list to only the middle part of list
-/// [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
-/// |> listx.trim(1, 4)
-/// |> should.equal(Ok([2.0, 3.0, 4.0, 5.0]))
-/// }
-///
-///
-///
+///
+/// Calculcate the $$p$$-norm of a list (representing a vector):
+///
+/// \\[
+/// \left( \sum_{i=1}^n \left|x_i\right|^{p} \right)^{\frac{1}{p}}
+/// \\]
+///
+/// In the formula, $$n$$ is the length of the list and $$x_i$$ is the value in the input list indexed by $$i$$.
+///
+///
+/// Example:
+///
+/// import gleeunit/should
+/// import gleam_community/maths/float as floatx
+/// import gleam_community/maths/float_list
+///
+/// pub fn example () {
+/// let assert Ok(tol) = floatx.power(-10.0, -6.0)
+///
+/// [1.0, 1.0, 1.0]
+/// |> float_list.norm(1.0)
+/// |> floatx.is_close(3.0, 0.0, tol)
+/// |> should.be_true()
+///
+/// [1.0, 1.0, 1.0]
+/// |> float_list.norm(-1.0)
+/// |> floatx.is_close(0.3333333333333333, 0.0, tol)
+/// |> should.be_true()
+/// }
+///
+///
+///
+///
+/// Calculcate the arithmetic mean of the elements in a list:
+///
+/// \\[
+/// \bar{x} = \frac{1}{n}\sum_{i=1}^n x_i
+/// \\]
+///
+/// In the formula, $$n$$ is the sample size (the length of the list) and
+/// $$x_i$$ is the sample point in the input list indexed by $$i$$.
+///
+///
+/// Example:
+///
+/// import gleeunit/should
+/// import gleam_stats/stats
+///
+/// pub fn example () {
+/// // An empty list returns an error
+/// []
+/// |> stats.mean()
+/// |> should.be_error()
+///
+/// // Valid input returns a result
+/// [1., 2., 3.]
+/// |> stats.mean()
+/// |> should.equal(Ok(2.))
+/// }
+///
+///
+///
+///
+pub fn median(arr: List(Float)) -> Result(Float, String) {
+ case arr {
+ [] ->
+ "Invalid input argument: The list is empty."
+ |> Error
+ _ -> {
+ let count: Int = list.length(arr)
+ let mid: Int = list.length(arr) / 2
+ let sorted: List(Float) = list.sort(arr, float.compare)
+ case tests.is_odd(count) {
+ // If there is an odd number of elements in the list, then the median
+ // is just the middle value
+ True -> {
+ let assert Ok(val0) = list.at(sorted, mid)
+ val0
+ |> Ok
+ }
+ // If there is an even number of elements in the list, then the median
+ // is the mean of the two middle values
+ False -> {
+ let assert Ok(val0) = list.at(sorted, mid - 1)
+ let assert Ok(val1) = list.at(sorted, mid)
+ [val0, val1]
+ |> mean()
+ }
+ }
+ }
+ }
+}
+
+///
+///
+/// Calculcate the sample variance of the elements in a list:
+/// \\[
+/// s^{2} = \frac{1}{n - d} \sum_{i=1}^{n}(x_i - \bar{x})
+/// \\]
+///
+/// In the formula, $$n$$ is the sample size (the length of the list) and
+/// $$x_i$$ is the sample point in the input list indexed by $$i$$.
+/// Furthermore, $$\bar{x}$$ is the sample mean and $$d$$ is the "Delta
+/// Degrees of Freedom", and is by default set to $$d = 0$$, which gives a biased
+/// estimate of the sample variance. Setting $$d = 1$$ gives an unbiased estimate.
+///
+///
+/// Example:
+///
+/// import gleeunit/should
+/// import gleam_stats/stats
+///
+/// pub fn example () {
+/// // Degrees of freedom
+/// let ddof: Int = 1
+///
+/// // An empty list returns an error
+/// []
+/// |> stats.var(ddof)
+/// |> should.be_error()
+///
+/// // Valid input returns a result
+/// [1., 2., 3.]
+/// |> stats.var(ddof)
+/// |> should.equal(Ok(1.))
+/// }
+///
+///
+///
+///
+/// Calculcate the sample standard deviation of the elements in a list:
+/// \\[
+/// s = \left(\frac{1}{n - d} \sum_{i=1}^{n}(x_i - \bar{x}))\right)^{\frac{1}{2}}
+/// \\]
+///
+/// In the formula, $$n$$ is the sample size (the length of the list) and
+/// $$x_i$$ is the sample point in the input list indexed by $$i$$.
+/// Furthermore, $$\bar{x}$$ is the sample mean and $$d$$ is the "Delta
+/// Degrees of Freedom", and is by default set to $$d = 0$$, which gives a biased
+/// estimate of the sample standard deviation. Setting $$d = 1$$ gives an unbiased estimate.
+///
+///
+/// Example:
+///
+/// import gleeunit/should
+/// import gleam_stats/stats
+///
+/// pub fn example () {
+/// // Degrees of freedom
+/// let ddof: Int = 1
+///
+/// // An empty list returns an error
+/// []
+/// |> stats.std(ddof)
+/// |> should.be_error()
+///
+/// // Valid input returns a result
+/// [1., 2., 3.]
+/// |> stats.std(ddof)
+/// |> should.equal(Ok(1.))
+/// }
+///
+///
+///
+///
+/// The ceiling function rounds a given input value $$x \in \mathbb{R}$$ to the nearest integer value (at the specified digit) that is larger than or equal to the input $$x$$.
+///
+/// Note: The ceiling function is used as an alias for the rounding function [`round`](#round) with rounding mode `RoundUp`.
+///
+///
+/// Details
+///
+/// For example, $$12.0654$$ is rounded to:
+/// - $$13.0$$ for 0 digits after the decimal point (`digits = 0`)
+/// - $$12.1$$ for 1 digit after the decimal point (`digits = 1`)
+/// - $$12.07$$ for 2 digits after the decimal point (`digits = 2`)
+/// - $$12.066$$ for 3 digits after the decimal point (`digits = 3`)
+///
+/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
+/// For example, $$12.0654$$ is rounded to:
+/// - $$20.0$$ for 1 digit places before the decimal point (`digit = -1`)
+/// - $$100.0$$ for 2 digits before the decimal point (`digits = -2`)
+/// - $$1000.0$$ for 3 digits before the decimal point (`digits = -3`)
+///
+///
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam/option
+/// import gleam_community/maths/float as floatx
+///
+/// pub fn example() {
+/// floatx.ceiling(12.0654, option.Some(1))
+/// |> should.equal(Ok(12.1))
+///
+/// floatx.ceiling(12.0654, option.Some(2))
+/// |> should.equal(Ok(12.07))
+///
+/// floatx.ceiling(12.0654, option.Some(3))
+/// |> should.equal(Ok(12.066))
+/// }
+///
+///
+///
+///
+/// The floor function rounds input $$x \in \mathbb{R}$$ to the nearest integer value (at the specified digit) that is less than or equal to the input $$x$$.
+///
+/// Note: The floor function is used as an alias for the rounding function [`round`](#round) with rounding mode `RoundDown`.
+///
+///
+/// Details
+///
+/// For example, $$12.0654$$ is rounded to:
+/// - $$12.0$$ for 0 digits after the decimal point (`digits = 0`)
+/// - $$12.0$$ for 1 digits after the decimal point (`digits = 1`)
+/// - $$12.06$$ for 2 digits after the decimal point (`digits = 2`)
+/// - $$12.065$$ for 3 digits after the decimal point (`digits = 3`)
+///
+/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
+/// - $$10.0$$ for 1 digit before the decimal point (`digits = -1`)
+/// - $$0.0$$ for 2 digits before the decimal point (`digits = -2`)
+/// - $$0.0$$ for 3 digits before the decimal point (`digits = -3`)
+///
+///
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam/option
+/// import gleam_community/maths/float as floatx
+///
+/// pub fn example() {
+/// floatx.floor(12.0654, option.Some(1))
+/// |> should.equal(Ok(12.0))
+///
+/// floatx.floor(12.0654, option.Some(2))
+/// |> should.equal(Ok(12.06))
+///
+/// floatx.floor(12.0654, option.Some(3))
+/// |> should.equal(Ok(12.065))
+/// }
+///
+///
+///
+///
+/// The truncate function rounds a given input $$x \in \mathbb{R}$$ to the nearest integer value (at the specified digit) that is less than or equal to the absolute value of the input $$x$$.
+///
+/// Note: The truncate function is used as an alias for the rounding function [`round`](#round) with rounding mode `RoundToZero`.
+///
+///
+/// Details
+///
+/// For example, $$12.0654$$ is rounded to:
+/// - $$12.0$$ for 0 digits after the decimal point (`digits = 0`)
+/// - $$12.0$$ for 1 digits after the decimal point (`digits = 1`)
+/// - $$12.06$$ for 2 digits after the decimal point (`digits = 2`)
+/// - $$12.065$$ for 3 digits after the decimal point (`digits = 3`)
+///
+/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
+/// - $$10.0$$ for 1 digit before the decimal point (`digits = -1`)
+/// - $$0.0$$ for 2 digits before the decimal point (`digits = -2`)
+/// - $$0.0$$ for 3 digits before the decimal point (`digits = -3`)
+///
+///
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam/option
+/// import gleam_community/maths/float as floatx
+///
+/// pub fn example() {
+/// floatx.truncate(12.0654, option.Some(1))
+/// |> should.equal(Ok(12.0))
+///
+/// floatx.truncate(12.0654, option.Some(2))
+/// |> should.equal(Ok(12.0))
+///
+/// floatx.truncate(12.0654, option.Some(3))
+/// |> should.equal(Ok(12.0))
+/// }
+///
+///
+///
+///
+/// The function rounds a float to a specific number of digits (after the decimal place or before if negative) using a specified rounding mode.
+///
+/// Valid rounding modes include:
+/// - `RoundNearest` (default): The input $$x$$ is rounded to the nearest integer value (at the specified digit) with ties (fractional values of 0.5) being rounded to the nearest even integer.
+/// - `RoundTiesAway`: The input $$x$$ is rounded to the nearest integer value (at the specified digit) with ties (fractional values of 0.5) being rounded away from zero (C/C++ rounding behavior).
+/// - `RoundTiesUp`: The input $$x$$ is rounded to the nearest integer value (at the specified digit) with ties (fractional values of 0.5) being rounded towards $$+\infty$$ (Java/JavaScript rounding behaviour).
+/// - `RoundToZero`: The input $$x$$ is rounded to the nearest integer value (at the specified digit) that is less than or equal to the absolute value of the input $$x$$. An alias for this rounding mode is [`truncate`](#truncate).
+/// - `RoundDown`: The input $$x$$ is rounded to the nearest integer value (at the specified digit) that is less than or equal to the input $$x$$. An alias for this rounding mode is [`floor`](#floor).
+/// - `RoundUp`: The input $$x$$ is rounded to the nearest integer value (at the specified digit) that is larger than or equal to the input $$x$$. An alias for this rounding mode is [`ceiling`](#ceiling).
+///
+///
+/// Details
+///
+/// The `RoundNearest` rounding mode, rounds $$12.0654$$ to:
+/// - $$12.0$$ for 0 digits after the decimal point (`digits = 0`)
+/// - $$12.1$$ for 1 digit after the decimal point (`digits = 1`)
+/// - $$12.07$$ for 2 digits after the decimal point (`digits = 2`)
+/// - $$12.065$$ for 3 digits after the decimal point (`digits = 3`)
+///
+/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
+/// - $$10.0$$ for 1 digit before the decimal point (`digits = -1`)
+/// - $$0.0$$ for 2 digits before the decimal point (`digits = -2`)
+/// - $$0.0$$ for 3 digits before the decimal point (`digits = -3`)
+///
+/// The `RoundTiesAway` rounding mode, rounds $$12.0654$$ to:
+/// - $$12.0$$ for 0 digits after the decimal point (`digits = 0`)
+/// - $$12.1$$ for 1 digit after the decimal point (`digits = 1`)
+/// - $$12.07$$ for 2 digits after the decimal point (`digits = 2`)
+/// - $$12.065$$ for 3 digits after the decimal point (`digits = 3`)
+///
+/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
+/// - $$10.0$$ for 1 digit before the decimal point (`digits = -1`)
+/// - $$0.0$$ for 2 digits before the decimal point (`digits = -2`)
+/// - $$0.0$$ for 3 digits before the decimal point (`digits = -3`)
+///
+/// The `RoundTiesUp` rounding mode, rounds $$12.0654$$ to:
+/// - $$12.0$$ for 0 digits after the decimal point (`digits = 0`)
+/// - $$12.1$$ for 1 digits after the decimal point (`digits = 1`)
+/// - $$12.07$$ for 2 digits after the decimal point (`digits = 2`)
+/// - $$12.065$$ for 3 digits after the decimal point (`digits = 3`)
+///
+/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
+/// - $$10.0$$ for 1 digit before the decimal point (`digits = -1`)
+/// - $$0.0$$ for 2 digits before the decimal point (`digits = -2`)
+/// - $$0.0$$ for 3 digits before the decimal point (`digits = -3`)
+///
+/// The `RoundToZero` rounding mode, rounds $$12.0654$$ to:
+/// - $$12.0$$ for 0 digits after the decimal point (`digits = 0`)
+/// - $$12.0$$ for 1 digit after the decimal point (`digits = 1`)
+/// - $$12.06$$ for 2 digits after the decimal point (`digits = 2`)
+/// - $$12.065$$ for 3 digits after the decimal point (`digits = 3`)
+///
+/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
+/// - $$10.0$$ for 1 digit before the decimal point (`digits = -1`)
+/// - $$0.0$$ for 2 digits before the decimal point (`digits = -2`)
+/// - $$0.0$$ for 3 digits before the decimal point (`digits = -3`)
+///
+/// The `RoundDown` rounding mode, rounds $$12.0654$$ to:
+/// - $$12.0$$ for 0 digits after the decimal point (`digits = 0`)
+/// - $$12.0$$ for 1 digits after the decimal point (`digits = 1`)
+/// - $$12.06$$ for 2 digits after the decimal point (`digits = 2`)
+/// - $$12.065$$ for 3 digits after the decimal point (`digits = 3`)
+///
+/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
+/// - $$10.0$$ for 1 digit before the decimal point (`digits = -1`)
+/// - $$0.0$$ for 2 digits before the decimal point (`digits = -2`)
+/// - $$0.0$$ for 3 digits before the decimal point (`digits = -3`)
+///
+/// The `RoundUp` rounding mode, rounds $$12.0654$$ to:
+/// - $$13.0$$ for 0 digits after the decimal point (`digits = 0`)
+/// - $$12.1$$ for 1 digit after the decimal point (`digits = 1`)
+/// - $$12.07$$ for 2 digits after the decimal point (`digits = 2`)
+/// - $$12.066$$ for 3 digits after the decimal point (`digits = 3`)
+///
+/// It is also possible to specify a negative number of digits. In that case, the negative number refers to the digits before the decimal point.
+/// - $$20.0$$ for 1 digit places before the decimal point (`digit = -1`)
+/// - $$100.0$$ for 2 digits before the decimal point (`digits = -2`)
+/// - $$1000.0$$ for 3 digits before the decimal point (`digits = -3`)
+///
+///
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam/option
+/// import gleam_community/maths/float as floatx
+///
+/// pub fn example() {
+/// // The default number of digits is 0 if None is provided
+/// floatx.round(12.0654, option.None, option.Some(floatx.RoundNearest))
+/// |> should.equal(Ok(12.0))
+///
+/// // The default rounding mode is "RoundNearest" if None is provided
+/// floatx.round(12.0654, option.None, option.None)
+/// |> should.equal(Ok(12.0))
+///
+/// // Try different rounding modes
+/// floatx.round(12.0654, option.Some(2), option.Some(floatx.RoundNearest))
+/// |> should.equal(Ok(12.07))
+///
+/// floatx.round(12.0654, option.Some(2), option.Some(floatx.RoundTiesAway))
+/// |> should.equal(Ok(12.07))
+///
+/// floatx.round(12.0654, option.Some(2), option.Some(floatx.RoundTiesUp))
+/// |> should.equal(Ok(12.07))
+///
+/// floatx.round(12.0654, option.Some(2), option.Some(floatx.RoundToZero))
+/// |> should.equal(Ok(12.06))
+///
+/// floatx.round(12.0654, option.Some(2), option.Some(floatx.RoundDown))
+/// |> should.equal(Ok(12.06))
+///
+/// floatx.round(12.0654, option.Some(2), option.Some(floatx.RoundUp))
+/// |> should.equal(Ok(12.07))
+/// }
+///
+///
+///
+///
+/// The absolute difference:
+///
+/// \\[
+/// \forall x, y \in \mathbb{R}, \\; |x - y| \in \mathbb{R}_{+}.
+/// \\]
+///
+/// The function takes two inputs $$x$$ and $$y$$ and returns a positive float
+/// value which is the the absolute difference of the inputs.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/float as floatx
+///
+/// pub fn example() {
+/// floatx.absolute_difference(-10.0, 10.0)
+/// |> should.equal(20.0)
+///
+/// floatx.absolute_difference(0.0, -2.0)
+/// |> should.equal(2.0)
+/// }
+///
+///
+///
+///
+pub fn float_copy_sign(x: Float, y: Float) -> Float {
+ case float_sign(x) == float_sign(y) {
+ // x and y have the same sign, just return x
+ True -> x
+ // x and y have different signs:
+ // - x is positive and y is negative, then flip sign of x
+ // - x is negative and y is positive, then flip sign of x
+ False -> float_flip_sign(x)
+ }
+}
+
+///
+///
+pub fn int_copy_sign(x: Int, y: Int) -> Int {
+ case int_sign(x) == int_sign(y) {
+ // x and y have the same sign, just return x
+ True -> x
+ // x and y have different signs:
+ // - x is positive and y is negative, then flip sign of x
+ // - x is negative and y is positive, then flip sign of x
+ False -> int_flip_sign(x)
+ }
+}
+
+///
+///
+pub fn minimum(x: a, y: a, compare: fn(a, a) -> order.Order) -> a {
+ case compare(x, y) {
+ order.Lt -> x
+ order.Eq -> x
+ order.Gt -> y
+ }
+}
+
+///
+///
+/// The maximum function that takes two arguments $$x, y \in \mathbb{R}$$ and returns the largest of the two.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/float as floatx
+///
+/// pub fn example() {
+/// floatx.maximum(2.0, 1.5)
+/// |> should.equal(1.5)
+///
+/// floatx.maximum(1.5, 2.0)
+/// |> should.equal(1.5)
+/// }
+///
+///
+///
+///
+pub fn maximum(x: a, y: a, compare: fn(a, a) -> order.Order) -> a {
+ case compare(x, y) {
+ order.Lt -> y
+ order.Eq -> y
+ order.Gt -> x
+ }
+}
+
+///
+///
+/// The minmax function that takes two arguments $$x, y \in \mathbb{R}$$ and returns a tuple with the smallest value first and largest second.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/float as floatx
+///
+/// pub fn example() {
+/// floatx.minmax(2.0, 1.5)
+/// |> should.equal(#(1.5, 2.0))
+///
+/// floatx.minmax(1.5, 2.0)
+/// |> should.equal(#(1.5, 2.0))
+/// }
+///
+///
+///
+///
+/// The function returns a list with evenly spaced values within a given interval based on a start, stop value and a given increment (step-length) between consecutive values.
+/// The list returned includes the given start value but excludes the stop value.
+///
+///
+/// Example:
+///
+/// import gleeunit/should
+/// import gleam_community/maths/float_list
+///
+/// pub fn example () {
+/// float_list.arange(1.0, 5.0, 1.0)
+/// |> should.equal([1.0, 2.0, 3.0, 4.0])
+///
+/// // No points returned since
+/// // start smaller than stop and positive step
+/// float_list.arange(5.0, 1.0, 1.0)
+/// |> should.equal([])
+///
+/// // Points returned since
+/// // start smaller than stop but negative step
+/// float_list.arange(5.0, 1.0, -1.0)
+/// |> should.equal([5.0, 4.0, 3.0, 2.0])
+/// }
+///
+///
+///
+///
+/// Generate a linearly spaced list of points over a specified interval. The endpoint of the interval can optionally be included/excluded.
+///
+///
+/// Example:
+///
+/// import gleeunit/should
+/// import gleam_community/maths/float as floatx
+/// import gleam_community/maths/float_list
+///
+/// pub fn example () {
+/// let assert Ok(tol) = floatx.power(-10.0, -6.0)
+/// let assert Ok(linspace) = float_list.linear_space(10.0, 50.0, 5, True)
+/// let assert Ok(result) =
+/// float_list.all_close(linspace, [10.0, 20.0, 30.0, 40.0, 50.0], 0.0, tol)
+/// result
+/// |> list.all(fn(x) { x == True })
+/// |> should.be_true()
+///
+/// // A negative number of points (-5) does not work
+/// float_list.linear_space(10.0, 50.0, -5, True)
+/// |> should.be_error()
+/// }
+///
+///
+///
+///
+/// Generate a logarithmically spaced list of points over a specified interval. The endpoint of the interval can optionally be included/excluded.
+///
+///
+/// Example:
+///
+/// import gleeunit/should
+/// import gleam_community/maths/float as floatx
+/// import gleam_community/maths/float_list
+///
+/// pub fn example () {
+/// let assert Ok(tol) = floatx.power(-10.0, -6.0)
+/// let assert Ok(logspace) = float_list.logarithmic_space(1.0, 3.0, 3, True, 10.0)
+/// let assert Ok(result) =
+/// float_list.all_close(logspace, [10.0, 100.0, 1000.0], 0.0, tol)
+/// result
+/// |> list.all(fn(x) { x == True })
+/// |> should.be_true()
+///
+/// // A negative number of points (-3) does not work
+/// float_list.logarithmic_space(1.0, 3.0, -3, False, 10.0)
+/// |> should.be_error()
+/// }
+///
+///
+///
+///
+/// The function returns a list of numbers spaced evenly on a log scale (a geometric progression). Each point in the list is a constant multiple of the previous.
+/// The function is similar to the [`logarithmic_space`](#logarithmic_space) function, but with endpoints specified directly.
+///
+///
+/// Example:
+///
+/// import gleeunit/should
+/// import gleam_community/maths/float as floatx
+/// import gleam_community/maths/float_list
+///
+/// pub fn example () {
+/// let assert Ok(tol) = floatx.power(-10.0, -6.0)
+/// let assert Ok(logspace) = float_list.geometric_space(10.0, 1000.0, 3, True)
+/// let assert Ok(result) =
+/// float_list.all_close(logspace, [10.0, 100.0, 1000.0], 0.0, tol)
+/// result
+/// |> list.all(fn(x) { x == True })
+/// |> should.be_true()
+///
+/// // Input (start and stop can't be equal to 0.0)
+/// float_list.geometric_space(0.0, 1000.0, 3, False)
+/// |> should.be_error()
+///
+/// float_list.geometric_space(-1000.0, 0.0, 3, False)
+/// |> should.be_error()
+///
+/// // A negative number of points (-3) does not work
+/// float_list.geometric_space(10.0, 1000.0, -3, False)
+/// |> should.be_error()
+/// }
+///
+///
+///
+///
+/// The beta function over the real numbers:
+///
+/// \\[
+/// \text{B}(x, y) = \frac{\Gamma(x) \cdot \Gamma(y)}{\Gamma(x + y)}
+/// \\]
+///
+/// The beta function is evaluated through the use of the gamma function.
+///
+///
+///
+/// The gamma function over the real numbers. The function is essentially equal to the
+/// factorial for any positive integer argument: $$\Gamma(n) = (n - 1)!$$
+///
+/// The implemented gamma function is approximated through Lanczos approximation
+/// using the same coefficients used by the GNU Scientific Library.
+///
+///
+///
+/// The lower incomplete gamma function over the real numbers.
+///
+/// The implemented incomplete gamma function is evaluated through a power series
+/// expansion.
+///
+///
+///
+/// Determine if a given value $$a$$ is close to or equivalent to a reference value
+/// $$b$$ based on supplied relative $$r_{tol}$$ and absolute $$a_{tol}$$ tolerance values.
+/// The equivalance of the two given values are then determined based on the equation:
+///
+/// \\[
+/// \|a - b\| \leq (a_{tol} + r_{tol} \cdot \|b\|)
+/// \\]
+///
+/// `True` is returned if statement holds, otherwise `False` is returned.
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/float as floatx
+///
+/// pub fn example () {
+/// let val: Float = 99.
+/// let ref_val: Float = 100.
+/// // We set 'atol' and 'rtol' such that the values are equivalent
+/// // if 'val' is within 1 percent of 'ref_val' +/- 0.1
+/// let rtol: Float = 0.01
+/// let atol: Float = 0.10
+/// floatx.is_close(val, ref_val, rtol, atol)
+/// |> should.be_true()
+/// }
+///
+///
+///
+///
+/// Determine if a list of values are close to or equivalent to a another list of reference values.
+///
+///
+/// Example:
+///
+/// import gleeunit/should
+/// import gleam/list
+/// import gleam_community/maths/float_list
+///
+/// pub fn example () {
+/// let val: Float = 99.
+/// let ref_val: Float = 100.
+/// let xarr: List(Float) = list.repeat(val, 42)
+/// let yarr: List(Float) = list.repeat(ref_val, 42)
+/// // We set 'atol' and 'rtol' such that the values are equivalent
+/// // if 'val' is within 1 percent of 'ref_val' +/- 0.1
+/// let rtol: Float = 0.01
+/// let atol: Float = 0.10
+/// float_list.all_close(xarr, yarr, rtol, atol)
+/// |> fn(zarr: Result(List(Bool), String)) -> Result(Bool, Nil) {
+/// case zarr {
+/// Ok(arr) ->
+/// arr
+/// |> list.all(fn(a: Bool) -> Bool { a })
+/// |> Ok
+/// _ -> Nil |> Error
+/// }
+/// }
+/// |> should.equal(Ok(True))
+/// }
+///
+///
+///
+///
+/// Determine if a given value $$a$$ is fractional.
+///
+/// `True` is returned if the given value is fractional, otherwise `False` is returned.
+///
+///
+/// Example
+///
+/// import gleeunit/should
+/// import gleam_community/maths/float as floatx
+///
+/// pub fn example () {
+/// }
+///
+///
+///
+///
+/// A function that tests whether a given integer value $$x \in \mathbb{Z}$$ is a power of another integer value $$y \in \mathbb{Z}$$.
+///
+///
+/// Example:
+///
+/// import gleeunit/should
+/// import gleam_community/maths/int as intx
+///
+/// pub fn example() {
+/// // Check if 4 is a power of 2 (it is)
+/// intx.is_power(4, 2)
+/// |> should.equal(True)
+///
+/// // Check if 5 is a power of 2 (it is not)
+/// intx.is_power(5, 2)
+/// |> should.equal(False)
+/// }
+///
+///
+///
+///
+/// A function that tests whether a given integer value $$n \in \mathbb{Z}$$ is a perfect number. A number is perfect if it is equal to the sum of its proper positive divisors.
+///
+///
+/// Details
+///
+/// For example:
+/// - $$6$$ is a perfect number since the divisors of 6 are $$1 + 2 + 3 = 6$$.
+/// - $$28$$ is a perfect number since the divisors of 28 are $$1 + 2 + 4 + 7 + 14 = 28$$
+///
+///
+///
+///
+/// Example:
+///
+/// import gleeunit/should
+/// import gleam_community/maths/int as intx
+///
+/// pub fn example() {
+/// intx.is_perfect(6)
+/// |> should.equal(True)
+///
+/// intx.is_perfect(28)
+/// |> should.equal(True)
+/// }
+///
+///
+///