Average Error: 19.9 → 19.9
Time: 10.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 \left(y + z\right)\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 \left(y + z\right)\right)} \cdot 2
double f(double x, double y, double z) {
        double r579308 = 2.0;
        double r579309 = x;
        double r579310 = y;
        double r579311 = r579309 * r579310;
        double r579312 = z;
        double r579313 = r579309 * r579312;
        double r579314 = r579311 + r579313;
        double r579315 = r579310 * r579312;
        double r579316 = r579314 + r579315;
        double r579317 = sqrt(r579316);
        double r579318 = r579308 * r579317;
        return r579318;
}

double f(double x, double y, double z) {
        double r579319 = y;
        double r579320 = z;
        double r579321 = x;
        double r579322 = r579319 + r579320;
        double r579323 = r579321 * r579322;
        double r579324 = fma(r579319, r579320, r579323);
        double r579325 = sqrt(r579324);
        double r579326 = 2.0;
        double r579327 = r579325 * r579326;
        return r579327;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original19.9
Target19.2
Herbie19.9
\[\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.9

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

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

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

Reproduce

herbie shell --seed 2019351 +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)))))