Average Error: 19.6 → 19.6
Time: 5.0s
Precision: 64
\[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
\[2 \cdot \sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}\]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
2 \cdot \sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}
double f(double x, double y, double z) {
        double r675208 = 2.0;
        double r675209 = x;
        double r675210 = y;
        double r675211 = r675209 * r675210;
        double r675212 = z;
        double r675213 = r675209 * r675212;
        double r675214 = r675211 + r675213;
        double r675215 = r675210 * r675212;
        double r675216 = r675214 + r675215;
        double r675217 = sqrt(r675216);
        double r675218 = r675208 * r675217;
        return r675218;
}

double f(double x, double y, double z) {
        double r675219 = 2.0;
        double r675220 = x;
        double r675221 = y;
        double r675222 = z;
        double r675223 = r675221 + r675222;
        double r675224 = r675221 * r675222;
        double r675225 = fma(r675220, r675223, r675224);
        double r675226 = sqrt(r675225);
        double r675227 = r675219 * r675226;
        return r675227;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original19.6
Target18.6
Herbie19.6
\[\begin{array}{l} \mathbf{if}\;z \lt 7.6369500905736745 \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.6

    \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
  2. Using strategy rm
  3. Applied distribute-lft-out19.6

    \[\leadsto 2 \cdot \sqrt{\color{blue}{x \cdot \left(y + z\right)} + y \cdot z}\]
  4. Applied fma-def19.6

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

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

Reproduce

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