Average Error: 19.5 → 19.5
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(z, x, y \cdot \left(z + x\right)\right)}\]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
2 \cdot \sqrt{\mathsf{fma}\left(z, x, y \cdot \left(z + x\right)\right)}
double f(double x, double y, double z) {
        double r393012 = 2.0;
        double r393013 = x;
        double r393014 = y;
        double r393015 = r393013 * r393014;
        double r393016 = z;
        double r393017 = r393013 * r393016;
        double r393018 = r393015 + r393017;
        double r393019 = r393014 * r393016;
        double r393020 = r393018 + r393019;
        double r393021 = sqrt(r393020);
        double r393022 = r393012 * r393021;
        return r393022;
}

double f(double x, double y, double z) {
        double r393023 = 2.0;
        double r393024 = z;
        double r393025 = x;
        double r393026 = y;
        double r393027 = r393024 + r393025;
        double r393028 = r393026 * r393027;
        double r393029 = fma(r393024, r393025, r393028);
        double r393030 = sqrt(r393029);
        double r393031 = r393023 * r393030;
        return r393031;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original19.5
Target18.8
Herbie19.5
\[\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.5

    \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
  2. Taylor expanded around 0 19.5

    \[\leadsto 2 \cdot \sqrt{\color{blue}{x \cdot z + \left(z \cdot y + x \cdot y\right)}}\]
  3. Simplified19.5

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

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

Reproduce

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