Average Error: 45.5 → 6.2
Time: 5.0s
Precision: binary64
\[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
\[\begin{array}{l} \mathbf{if}\;y \leq -1.3477441338726809 \cdot 10^{+135} \lor \neg \left(y \leq 2.8281805749579194 \cdot 10^{-36}\right):\\ \;\;\;\;-1 + \left(\left(\frac{1}{y \cdot x} + \mathsf{fma}\left(\frac{-1}{x}, \frac{1}{y}, z\right)\right) - z\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(\left(\frac{y}{x} + \mathsf{fma}\left(\frac{-1}{x}, y, z\right)\right) - z\right)\\ \end{array}\]
\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)
\begin{array}{l}
\mathbf{if}\;y \leq -1.3477441338726809 \cdot 10^{+135} \lor \neg \left(y \leq 2.8281805749579194 \cdot 10^{-36}\right):\\
\;\;\;\;-1 + \left(\left(\frac{1}{y \cdot x} + \mathsf{fma}\left(\frac{-1}{x}, \frac{1}{y}, z\right)\right) - z\right)\\

\mathbf{else}:\\
\;\;\;\;-1 + \left(\left(\frac{y}{x} + \mathsf{fma}\left(\frac{-1}{x}, y, z\right)\right) - z\right)\\

\end{array}
(FPCore (x y z) :precision binary64 (- (fma x y z) (+ 1.0 (+ (* x y) z))))
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -1.3477441338726809e+135) (not (<= y 2.8281805749579194e-36)))
   (+ -1.0 (- (+ (/ 1.0 (* y x)) (fma (/ -1.0 x) (/ 1.0 y) z)) z))
   (+ -1.0 (- (+ (/ y x) (fma (/ -1.0 x) y z)) z))))
double code(double x, double y, double z) {
	return fma(x, y, z) - (1.0 + ((x * y) + z));
}
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.3477441338726809e+135) || !(y <= 2.8281805749579194e-36)) {
		tmp = -1.0 + (((1.0 / (y * x)) + fma((-1.0 / x), (1.0 / y), z)) - z);
	} else {
		tmp = -1.0 + (((y / x) + fma((-1.0 / x), y, z)) - z);
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original45.5
Target0
Herbie6.2
\[-1\]

Derivation

  1. Split input into 2 regimes
  2. if y < -1.3477441338726809e135 or 2.8281805749579194e-36 < y

    1. Initial program 54.3

      \[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
    2. Taylor expanded around -inf 43.1

      \[\leadsto \color{blue}{\left(\frac{y}{x} + \mathsf{fma}\left(\frac{-1}{x}, y, z\right)\right) - \left(z + 1\right)}\]
    3. Using strategy rm
    4. Applied associate--r+_binary64_137829.0

      \[\leadsto \color{blue}{\left(\left(\frac{y}{x} + \mathsf{fma}\left(\frac{-1}{x}, y, z\right)\right) - z\right) - 1}\]
    5. Taylor expanded around inf 5.3

      \[\leadsto \left(\color{blue}{\left(\mathsf{fma}\left(\frac{-1}{x}, \frac{1}{y}, z\right) + \frac{1}{x \cdot y}\right)} - z\right) - 1\]
    6. Simplified5.3

      \[\leadsto \left(\color{blue}{\left(\frac{1}{y \cdot x} + \mathsf{fma}\left(\frac{-1}{x}, \frac{1}{y}, z\right)\right)} - z\right) - 1\]

    if -1.3477441338726809e135 < y < 2.8281805749579194e-36

    1. Initial program 39.1

      \[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
    2. Taylor expanded around -inf 32.8

      \[\leadsto \color{blue}{\left(\frac{y}{x} + \mathsf{fma}\left(\frac{-1}{x}, y, z\right)\right) - \left(z + 1\right)}\]
    3. Using strategy rm
    4. Applied associate--r+_binary64_13786.9

      \[\leadsto \color{blue}{\left(\left(\frac{y}{x} + \mathsf{fma}\left(\frac{-1}{x}, y, z\right)\right) - z\right) - 1}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification6.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.3477441338726809 \cdot 10^{+135} \lor \neg \left(y \leq 2.8281805749579194 \cdot 10^{-36}\right):\\ \;\;\;\;-1 + \left(\left(\frac{1}{y \cdot x} + \mathsf{fma}\left(\frac{-1}{x}, \frac{1}{y}, z\right)\right) - z\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(\left(\frac{y}{x} + \mathsf{fma}\left(\frac{-1}{x}, y, z\right)\right) - z\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020344 
(FPCore (x y z)
  :name "simple fma test"
  :precision binary64

  :herbie-target
  -1.0

  (- (fma x y z) (+ 1.0 (+ (* x y) z))))