Average Error: 19.8 → 19.8
Time: 18.5s
Precision: 64
\[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
\[\sqrt{\mathsf{fma}\left(y, z, x \cdot y + x \cdot z\right)} \cdot 2\]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\sqrt{\mathsf{fma}\left(y, z, x \cdot y + x \cdot z\right)} \cdot 2
double f(double x, double y, double z) {
        double r463596 = 2.0;
        double r463597 = x;
        double r463598 = y;
        double r463599 = r463597 * r463598;
        double r463600 = z;
        double r463601 = r463597 * r463600;
        double r463602 = r463599 + r463601;
        double r463603 = r463598 * r463600;
        double r463604 = r463602 + r463603;
        double r463605 = sqrt(r463604);
        double r463606 = r463596 * r463605;
        return r463606;
}

double f(double x, double y, double z) {
        double r463607 = y;
        double r463608 = z;
        double r463609 = x;
        double r463610 = r463609 * r463607;
        double r463611 = r463609 * r463608;
        double r463612 = r463610 + r463611;
        double r463613 = fma(r463607, r463608, r463612);
        double r463614 = sqrt(r463613);
        double r463615 = 2.0;
        double r463616 = r463614 * r463615;
        return r463616;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original19.8
Target19.2
Herbie19.8
\[\begin{array}{l} \mathbf{if}\;z \lt 7.636950090573674520215292914121377944071 \cdot 10^{176}:\\ \;\;\;\;2 \cdot \sqrt{\left(x + y\right) \cdot z + x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(0.25 \cdot \left(\left({y}^{-0.75} \cdot \left({z}^{-0.75} \cdot x\right)\right) \cdot \left(y + z\right)\right) + {z}^{0.25} \cdot {y}^{0.25}\right) \cdot \left(0.25 \cdot \left(\left({y}^{-0.75} \cdot \left({z}^{-0.75} \cdot x\right)\right) \cdot \left(y + z\right)\right) + {z}^{0.25} \cdot {y}^{0.25}\right)\right) \cdot 2\\ \end{array}\]

Derivation

  1. Initial program 19.8

    \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
  2. Simplified19.8

    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(y, z, x \cdot \left(y + z\right)\right)} \cdot 2}\]
  3. Using strategy rm
  4. Applied distribute-lft-in19.8

    \[\leadsto \sqrt{\mathsf{fma}\left(y, z, \color{blue}{x \cdot y + x \cdot z}\right)} \cdot 2\]
  5. Final simplification19.8

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

Reproduce

herbie shell --seed 2019323 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:descartes from diagrams-contrib-1.3.0.5"
  :precision binary64

  :herbie-target
  (if (< z 7.636950090573675e+176) (* 2 (sqrt (+ (* (+ x y) z) (* x y)))) (* (* (+ (* 0.25 (* (* (pow y -0.75) (* (pow z -0.75) x)) (+ y z))) (* (pow z 0.25) (pow y 0.25))) (+ (* 0.25 (* (* (pow y -0.75) (* (pow z -0.75) x)) (+ y z))) (* (pow z 0.25) (pow y 0.25)))) 2))

  (* 2 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))