Average Error: 0.0 → 0.0
Time: 6.3s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, \mathsf{fma}\left(x \cdot y, 2, y \cdot y\right)\right)\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, \mathsf{fma}\left(x \cdot y, 2, y \cdot y\right)\right)
double f(double x, double y) {
        double r26238520 = x;
        double r26238521 = r26238520 * r26238520;
        double r26238522 = 2.0;
        double r26238523 = r26238520 * r26238522;
        double r26238524 = y;
        double r26238525 = r26238523 * r26238524;
        double r26238526 = r26238521 + r26238525;
        double r26238527 = r26238524 * r26238524;
        double r26238528 = r26238526 + r26238527;
        return r26238528;
}

double f(double x, double y) {
        double r26238529 = x;
        double r26238530 = y;
        double r26238531 = r26238529 * r26238530;
        double r26238532 = 2.0;
        double r26238533 = r26238530 * r26238530;
        double r26238534 = fma(r26238531, r26238532, r26238533);
        double r26238535 = fma(r26238529, r26238529, r26238534);
        return r26238535;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 0.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, \mathsf{fma}\left(2, x, y\right), x \cdot x\right)}\]
  3. Using strategy rm
  4. Applied add-cbrt-cube37.1

    \[\leadsto \color{blue}{\sqrt[3]{\left(\mathsf{fma}\left(y, \mathsf{fma}\left(2, x, y\right), x \cdot x\right) \cdot \mathsf{fma}\left(y, \mathsf{fma}\left(2, x, y\right), x \cdot x\right)\right) \cdot \mathsf{fma}\left(y, \mathsf{fma}\left(2, x, y\right), x \cdot x\right)}}\]
  5. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{{y}^{2} + \left({x}^{2} + 2 \cdot \left(x \cdot y\right)\right)}\]
  6. Simplified0.0

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

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

Reproduce

herbie shell --seed 2019179 +o rules:numerics
(FPCore (x y)
  :name "Examples.Basics.ProofTests:f4 from sbv-4.4"

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

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