Average Error: 0.0 → 0.0
Time: 19.1s
Precision: 64
\[\left(x \cdot x + y\right) + y\]
\[\mathsf{fma}\left(x, x, y\right) + y\]
\left(x \cdot x + y\right) + y
\mathsf{fma}\left(x, x, y\right) + y
double f(double x, double y) {
        double r34706021 = x;
        double r34706022 = r34706021 * r34706021;
        double r34706023 = y;
        double r34706024 = r34706022 + r34706023;
        double r34706025 = r34706024 + r34706023;
        return r34706025;
}

double f(double x, double y) {
        double r34706026 = x;
        double r34706027 = y;
        double r34706028 = fma(r34706026, r34706026, r34706027);
        double r34706029 = r34706028 + r34706027;
        return r34706029;
}

Error

Bits error versus x

Bits error versus y

Target

Original0.0
Target0.0
Herbie0.0
\[\left(y + y\right) + x \cdot x\]

Derivation

  1. Initial program 0.0

    \[\left(x \cdot x + y\right) + y\]
  2. Simplified0.0

    \[\leadsto \color{blue}{y + \mathsf{fma}\left(x, x, y\right)}\]
  3. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(x, x, y\right) + y\]

Reproduce

herbie shell --seed 2019200 +o rules:numerics
(FPCore (x y)
  :name "Data.Random.Distribution.Normal:normalTail from random-fu-0.2.6.2"

  :herbie-target
  (+ (+ y y) (* x x))

  (+ (+ (* x x) y) y))