pub trait MixedSqrt {
    fn mixed_sqrt(&self) -> Self;
fn mixed_niirf(&self) -> Self; }

Required methods

The generic square root implementation for the MixedSqrt trait. The implimentation may change with time. To stay on this excact implementation, use the mixed_niirf function.

A fast implementation of the square root using the Nonlinear IIR Filter (NIIRF) method [1].

Only valid for positive values of self. Negative values are forced positive before converison. Accurate to 5*10⁻⁴ with two iterations [2].

The structure of the estimator is illustrated below [1].

Alt version

The method utilizes a lookup-table for the acceleration factor β.

β(x) can be calculated from the following formula, yielding even greater accuracy at a computational cost.

β(x) = 0.763x^2-1.5688x+1.314 

[1] N.Mikami et al., A new DSP-oriented algorithm for calculation of square root using a non-linear digital filter, IEEE Trans. on Signal Processing, July 1992, pp. 1663-1669.

[2] R. G. Lyons, Streamlining Digital Signal Processing, Second Edition, IEEE Press, 2012.

Accuracy and Comparison

The figure below shows error of the NIIRF implementation, compared to the std::f32::sqrt implementation.

Alt version

Another fixed point implementation of the square root can be found in the cordic crate.

Below is the error comparison between the two implementations.

Alt version

Implementations on Foreign Types

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Take the square root of self.

Implementors