Average Error: 19.4 → 19.4
Time: 12.8s
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 r887039 = 2.0;
        double r887040 = x;
        double r887041 = y;
        double r887042 = r887040 * r887041;
        double r887043 = z;
        double r887044 = r887040 * r887043;
        double r887045 = r887042 + r887044;
        double r887046 = r887041 * r887043;
        double r887047 = r887045 + r887046;
        double r887048 = sqrt(r887047);
        double r887049 = r887039 * r887048;
        return r887049;
}

double f(double x, double y, double z) {
        double r887050 = y;
        double r887051 = z;
        double r887052 = x;
        double r887053 = r887050 + r887051;
        double r887054 = r887052 * r887053;
        double r887055 = fma(r887050, r887051, r887054);
        double r887056 = sqrt(r887055);
        double r887057 = 2.0;
        double r887058 = r887056 * r887057;
        return r887058;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

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

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

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

Reproduce

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