Average Error: 0.1 → 0.1
Time: 4.1s
Precision: binary64
\[\left(0 < m \land 0 < v\right) \land v < 0.25\]
\[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot \left(1 - m\right) \]
\[\begin{array}{l} t_0 := \mathsf{fma}\left(\frac{m}{v}, 1 - m, -1\right)\\ t_0 - m \cdot t_0 \end{array} \]
\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot \left(1 - m\right)
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{m}{v}, 1 - m, -1\right)\\
t_0 - m \cdot t_0
\end{array}
(FPCore (m v) :precision binary64 (* (- (/ (* m (- 1.0 m)) v) 1.0) (- 1.0 m)))
(FPCore (m v)
 :precision binary64
 (let* ((t_0 (fma (/ m v) (- 1.0 m) -1.0))) (- t_0 (* m t_0))))
double code(double m, double v) {
	return (((m * (1.0 - m)) / v) - 1.0) * (1.0 - m);
}
double code(double m, double v) {
	double t_0 = fma((m / v), (1.0 - m), -1.0);
	return t_0 - (m * t_0);
}

Error

Bits error versus m

Bits error versus v

Derivation

  1. Initial program 0.1

    \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot \left(1 - m\right) \]
  2. Taylor expanded in m around 0 0.1

    \[\leadsto \color{blue}{\left(\frac{m}{v} - \left(1 + \frac{{m}^{2}}{v}\right)\right)} \cdot \left(1 - m\right) \]
  3. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{m}{v}, 1 - m, -1\right)} \cdot \left(1 - m\right) \]
  4. Applied *-un-lft-identity_binary640.1

    \[\leadsto \mathsf{fma}\left(\frac{m}{v}, 1 - m, -1\right) \cdot \left(1 - \color{blue}{1 \cdot m}\right) \]
  5. Applied cancel-sign-sub-inv_binary640.1

    \[\leadsto \mathsf{fma}\left(\frac{m}{v}, 1 - m, -1\right) \cdot \color{blue}{\left(1 + \left(-1\right) \cdot m\right)} \]
  6. Applied distribute-rgt-in_binary640.1

    \[\leadsto \color{blue}{1 \cdot \mathsf{fma}\left(\frac{m}{v}, 1 - m, -1\right) + \left(\left(-1\right) \cdot m\right) \cdot \mathsf{fma}\left(\frac{m}{v}, 1 - m, -1\right)} \]
  7. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(\frac{m}{v}, 1 - m, -1\right) - m \cdot \mathsf{fma}\left(\frac{m}{v}, 1 - m, -1\right) \]

Reproduce

herbie shell --seed 2022004 
(FPCore (m v)
  :name "b parameter of renormalized beta distribution"
  :precision binary64
  :pre (and (and (< 0.0 m) (< 0.0 v)) (< v 0.25))
  (* (- (/ (* m (- 1.0 m)) v) 1.0) (- 1.0 m)))