Average Error: 19.3 → 19.3
Time: 17.4s
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 r431808 = 2.0;
        double r431809 = x;
        double r431810 = y;
        double r431811 = r431809 * r431810;
        double r431812 = z;
        double r431813 = r431809 * r431812;
        double r431814 = r431811 + r431813;
        double r431815 = r431810 * r431812;
        double r431816 = r431814 + r431815;
        double r431817 = sqrt(r431816);
        double r431818 = r431808 * r431817;
        return r431818;
}

double f(double x, double y, double z) {
        double r431819 = y;
        double r431820 = z;
        double r431821 = x;
        double r431822 = r431819 + r431820;
        double r431823 = r431821 * r431822;
        double r431824 = fma(r431819, r431820, r431823);
        double r431825 = sqrt(r431824);
        double r431826 = 2.0;
        double r431827 = r431825 * r431826;
        return r431827;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original19.3
Target18.6
Herbie19.3
\[\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.3

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

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

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

Reproduce

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