Average Error: 61.8 → 0.3
Time: 2.1s
Precision: 64
\[0.900000000000000022 \le t \le 1.1000000000000001\]
\[\left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)\]
\[\left(t \cdot 3.9999999999999997 \cdot 10^{-32}\right) \cdot t\]
\left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)
\left(t \cdot 3.9999999999999997 \cdot 10^{-32}\right) \cdot t
double code(double t) {
	return (((1.0 + (t * 2e-16)) * (1.0 + (t * 2e-16))) + (-1.0 - (2.0 * (t * 2e-16))));
}
double code(double t) {
	return ((t * 3.9999999999999997e-32) * t);
}

Error

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original61.8
Target50.6
Herbie0.3
\[\mathsf{fma}\left(1 + t \cdot 2 \cdot 10^{-16}, 1 + t \cdot 2 \cdot 10^{-16}, -1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)\]

Derivation

  1. Initial program 61.8

    \[\left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)\]
  2. Simplified57.6

    \[\leadsto \color{blue}{\mathsf{fma}\left(-2 \cdot t, 2 \cdot 10^{-16}, \mathsf{fma}\left(\mathsf{fma}\left(2 \cdot 10^{-16}, t, 1\right), \mathsf{fma}\left(2 \cdot 10^{-16}, t, 1\right), -1\right)\right)}\]
  3. Taylor expanded around 0 0.4

    \[\leadsto \color{blue}{3.9999999999999997 \cdot 10^{-32} \cdot {t}^{2}}\]
  4. Using strategy rm
  5. Applied unpow20.4

    \[\leadsto 3.9999999999999997 \cdot 10^{-32} \cdot \color{blue}{\left(t \cdot t\right)}\]
  6. Applied associate-*r*0.3

    \[\leadsto \color{blue}{\left(3.9999999999999997 \cdot 10^{-32} \cdot t\right) \cdot t}\]
  7. Simplified0.3

    \[\leadsto \color{blue}{\left(t \cdot 3.9999999999999997 \cdot 10^{-32}\right)} \cdot t\]
  8. Final simplification0.3

    \[\leadsto \left(t \cdot 3.9999999999999997 \cdot 10^{-32}\right) \cdot t\]

Reproduce

herbie shell --seed 2020106 +o rules:numerics
(FPCore (t)
  :name "fma_test1"
  :precision binary64
  :pre (<= 0.9 t 1.1)

  :herbie-target
  (fma (+ 1 (* t 2e-16)) (+ 1 (* t 2e-16)) (- -1 (* 2 (* t 2e-16))))

  (+ (* (+ 1 (* t 2e-16)) (+ 1 (* t 2e-16))) (- -1 (* 2 (* t 2e-16)))))