Average Error: 19.6 → 19.6
Time: 14.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 r26494196 = 2.0;
        double r26494197 = x;
        double r26494198 = y;
        double r26494199 = r26494197 * r26494198;
        double r26494200 = z;
        double r26494201 = r26494197 * r26494200;
        double r26494202 = r26494199 + r26494201;
        double r26494203 = r26494198 * r26494200;
        double r26494204 = r26494202 + r26494203;
        double r26494205 = sqrt(r26494204);
        double r26494206 = r26494196 * r26494205;
        return r26494206;
}

double f(double x, double y, double z) {
        double r26494207 = 2.0;
        double r26494208 = y;
        double r26494209 = x;
        double r26494210 = r26494208 + r26494209;
        double r26494211 = z;
        double r26494212 = r26494209 * r26494208;
        double r26494213 = fma(r26494210, r26494211, r26494212);
        double r26494214 = sqrt(r26494213);
        double r26494215 = r26494207 * r26494214;
        return r26494215;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original19.6
Target18.7
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 2019179 +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)))))