Average Error: 20.0 → 20.0
Time: 19.7s
Precision: 64
\[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
\[2 \cdot \sqrt{\mathsf{fma}\left(y + x, z, x \cdot y\right)}\]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
2 \cdot \sqrt{\mathsf{fma}\left(y + x, z, x \cdot y\right)}
double f(double x, double y, double z) {
        double r27408442 = 2.0;
        double r27408443 = x;
        double r27408444 = y;
        double r27408445 = r27408443 * r27408444;
        double r27408446 = z;
        double r27408447 = r27408443 * r27408446;
        double r27408448 = r27408445 + r27408447;
        double r27408449 = r27408444 * r27408446;
        double r27408450 = r27408448 + r27408449;
        double r27408451 = sqrt(r27408450);
        double r27408452 = r27408442 * r27408451;
        return r27408452;
}

double f(double x, double y, double z) {
        double r27408453 = 2.0;
        double r27408454 = y;
        double r27408455 = x;
        double r27408456 = r27408454 + r27408455;
        double r27408457 = z;
        double r27408458 = r27408455 * r27408454;
        double r27408459 = fma(r27408456, r27408457, r27408458);
        double r27408460 = sqrt(r27408459);
        double r27408461 = r27408453 * r27408460;
        return r27408461;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original20.0
Target19.4
Herbie20.0
\[\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 20.0

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

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

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

Reproduce

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

  :herbie-target
  (if (< z 7.636950090573675e+176) (* 2.0 (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.0))

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