Average Error: 61.8 → 0.3
Time: 9.1s
Precision: 64
\[0.9 \le t \le 1.1\]
\[\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)\]
\[t \cdot \left(t \cdot 3.9999999999999997 \cdot 10^{-32}\right)\]
\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)
t \cdot \left(t \cdot 3.9999999999999997 \cdot 10^{-32}\right)
double f(double t) {
        double r1105330 = 1.0;
        double r1105331 = t;
        double r1105332 = 2e-16;
        double r1105333 = r1105331 * r1105332;
        double r1105334 = r1105330 + r1105333;
        double r1105335 = r1105334 * r1105334;
        double r1105336 = -1.0;
        double r1105337 = 2.0;
        double r1105338 = r1105337 * r1105333;
        double r1105339 = r1105336 - r1105338;
        double r1105340 = r1105335 + r1105339;
        return r1105340;
}

double f(double t) {
        double r1105341 = t;
        double r1105342 = 3.9999999999999997e-32;
        double r1105343 = r1105341 * r1105342;
        double r1105344 = r1105341 * r1105343;
        return r1105344;
}

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. Simplified61.8

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

    \[\leadsto \color{blue}{3.9999999999999997 \cdot 10^{-32} \cdot {t}^{2}}\]
  4. Simplified0.4

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

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

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

Reproduce

herbie shell --seed 2019153 +o rules:numerics
(FPCore (t)
  :name "fma_test1"
  :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)))))