Average Error: 0.1 → 0.1
Time: 11.7s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, y \cdot \left(3 \cdot y\right)\right)\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, y \cdot \left(3 \cdot y\right)\right)
double f(double x, double y) {
        double r72079604 = x;
        double r72079605 = r72079604 * r72079604;
        double r72079606 = y;
        double r72079607 = r72079606 * r72079606;
        double r72079608 = r72079605 + r72079607;
        double r72079609 = r72079608 + r72079607;
        double r72079610 = r72079609 + r72079607;
        return r72079610;
}

double f(double x, double y) {
        double r72079611 = x;
        double r72079612 = y;
        double r72079613 = 3.0;
        double r72079614 = r72079613 * r72079612;
        double r72079615 = r72079612 * r72079614;
        double r72079616 = fma(r72079611, r72079611, r72079615);
        return r72079616;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 0.1

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, 3 \cdot \left(y \cdot y\right)\right)}\]
  3. Using strategy rm
  4. Applied associate-*r*0.1

    \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(3 \cdot y\right) \cdot y}\right)\]
  5. Using strategy rm
  6. Applied add-sqr-sqrt0.3

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

    \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{{y}^{2} \cdot {\left(\sqrt{3}\right)}^{2}}\right)\]
  8. Simplified0.1

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

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

Reproduce

herbie shell --seed 2019173 +o rules:numerics
(FPCore (x y)
  :name "Linear.Quaternion:$c/ from linear-1.19.1.3, E"

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

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