Average Error: 19.6 → 19.6
Time: 36.3s
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 r31293397 = 2.0;
        double r31293398 = x;
        double r31293399 = y;
        double r31293400 = r31293398 * r31293399;
        double r31293401 = z;
        double r31293402 = r31293398 * r31293401;
        double r31293403 = r31293400 + r31293402;
        double r31293404 = r31293399 * r31293401;
        double r31293405 = r31293403 + r31293404;
        double r31293406 = sqrt(r31293405);
        double r31293407 = r31293397 * r31293406;
        return r31293407;
}

double f(double x, double y, double z) {
        double r31293408 = 2.0;
        double r31293409 = y;
        double r31293410 = x;
        double r31293411 = r31293409 + r31293410;
        double r31293412 = z;
        double r31293413 = r31293410 * r31293409;
        double r31293414 = fma(r31293411, r31293412, r31293413);
        double r31293415 = sqrt(r31293414);
        double r31293416 = r31293408 * r31293415;
        return r31293416;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original19.6
Target19.0
Herbie19.6
\[\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.6

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

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

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

Reproduce

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