Average Error: 20.1 → 20.1
Time: 26.4s
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 z\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 z\right)}
double f(double x, double y, double z) {
        double r31699997 = 2.0;
        double r31699998 = x;
        double r31699999 = y;
        double r31700000 = r31699998 * r31699999;
        double r31700001 = z;
        double r31700002 = r31699998 * r31700001;
        double r31700003 = r31700000 + r31700002;
        double r31700004 = r31699999 * r31700001;
        double r31700005 = r31700003 + r31700004;
        double r31700006 = sqrt(r31700005);
        double r31700007 = r31699997 * r31700006;
        return r31700007;
}

double f(double x, double y, double z) {
        double r31700008 = 2.0;
        double r31700009 = y;
        double r31700010 = x;
        double r31700011 = z;
        double r31700012 = r31700010 + r31700011;
        double r31700013 = r31700010 * r31700011;
        double r31700014 = fma(r31700009, r31700012, r31700013);
        double r31700015 = sqrt(r31700014);
        double r31700016 = r31700008 * r31700015;
        return r31700016;
}

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, z \cdot x\right)} \cdot 2}\]
  3. Final simplification20.1

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

Reproduce

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