Average Error: 45.0 → 0.9
Time: 4.3s
Precision: binary64
\[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
\[\begin{array}{l} \mathbf{if}\;x \leq -0.5750703147639804 \lor \neg \left(x \leq 1.7079677124514205\right):\\ \;\;\;\;\left(\mathsf{fma}\left(0, 0, 0\right) - 1\right) \cdot \langle \left( \langle \left( \left(1 - \frac{1}{x}\right) \right)_{binary64} \rangle_{posit16} \right)_{posit16} \rangle_{binary64}\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(0, 0, 0\right) - 1\right) \cdot \left(x + 1\right)\\ \end{array}\]
\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)
\begin{array}{l}
\mathbf{if}\;x \leq -0.5750703147639804 \lor \neg \left(x \leq 1.7079677124514205\right):\\
\;\;\;\;\left(\mathsf{fma}\left(0, 0, 0\right) - 1\right) \cdot \langle \left( \langle \left( \left(1 - \frac{1}{x}\right) \right)_{binary64} \rangle_{posit16} \right)_{posit16} \rangle_{binary64}\\

\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(0, 0, 0\right) - 1\right) \cdot \left(x + 1\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 (<= x -0.5750703147639804) (not (<= x 1.7079677124514205)))
   (*
    (- (fma 0.0 0.0 0.0) 1.0)
    (cast
     (! :precision posit16 (cast (! :precision binary64 (- 1.0 (/ 1.0 x)))))))
   (* (- (fma 0.0 0.0 0.0) 1.0) (+ x 1.0))))

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original45.0
Target0
Herbie0.9
\[-1\]

Derivation

  1. Split input into 2 regimes
  2. if x < -0.5750703147639804 or 1.707967712451421 < x

    1. Initial program 53.4

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

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(0, 0, 0\right) - 1\right) \cdot \left(1 - \frac{1}{x}\right)}\]
    3. Using strategy rm
    4. Applied insert-posit160.6

      \[\leadsto \left(\mathsf{fma}\left(0, 0, 0\right) - 1\right) \cdot \color{blue}{\langle \color{blue}{\left( \color{blue}{\langle \color{blue}{\left( \color{blue}{\left(1 - \frac{1}{x}\right)} \right)_{binary64}} \rangle_{posit16}} \right)_{posit16}} \rangle_{binary64}}\]

    if -0.5750703147639804 < x < 1.707967712451421

    1. Initial program 36.7

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

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(0, 0, 0\right) - 1\right) \cdot \left(1 + x\right)}\]
    3. Simplified1.3

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(0, 0, 0\right) - 1\right) \cdot \left(x + 1\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.5750703147639804 \lor \neg \left(x \leq 1.7079677124514205\right):\\ \;\;\;\;\left(\mathsf{fma}\left(0, 0, 0\right) - 1\right) \cdot \langle \left( \langle \left( \left(1 - \frac{1}{x}\right) \right)_{binary64} \rangle_{posit16} \right)_{posit16} \rangle_{binary64}\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(0, 0, 0\right) - 1\right) \cdot \left(x + 1\right)\\ \end{array}\]

Reproduce

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

  :herbie-target
  -1.0

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