Average Error: 20.1 → 20.1
Time: 18.0s
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 r565855 = 2.0;
        double r565856 = x;
        double r565857 = y;
        double r565858 = r565856 * r565857;
        double r565859 = z;
        double r565860 = r565856 * r565859;
        double r565861 = r565858 + r565860;
        double r565862 = r565857 * r565859;
        double r565863 = r565861 + r565862;
        double r565864 = sqrt(r565863);
        double r565865 = r565855 * r565864;
        return r565865;
}

double f(double x, double y, double z) {
        double r565866 = y;
        double r565867 = z;
        double r565868 = x;
        double r565869 = r565866 + r565867;
        double r565870 = r565868 * r565869;
        double r565871 = fma(r565866, r565867, r565870);
        double r565872 = sqrt(r565871);
        double r565873 = 2.0;
        double r565874 = r565872 * r565873;
        return r565874;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original20.1
Target19.2
Herbie20.1
\[\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 20.1

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

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

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

Reproduce

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