Average Error: 20.3 → 20.3
Time: 19.1s
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 y\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 y\right)}
double f(double x, double y, double z) {
        double r34210317 = 2.0;
        double r34210318 = x;
        double r34210319 = y;
        double r34210320 = r34210318 * r34210319;
        double r34210321 = z;
        double r34210322 = r34210318 * r34210321;
        double r34210323 = r34210320 + r34210322;
        double r34210324 = r34210319 * r34210321;
        double r34210325 = r34210323 + r34210324;
        double r34210326 = sqrt(r34210325);
        double r34210327 = r34210317 * r34210326;
        return r34210327;
}

double f(double x, double y, double z) {
        double r34210328 = 2.0;
        double r34210329 = y;
        double r34210330 = x;
        double r34210331 = r34210329 + r34210330;
        double r34210332 = z;
        double r34210333 = r34210330 * r34210329;
        double r34210334 = fma(r34210331, r34210332, r34210333);
        double r34210335 = sqrt(r34210334);
        double r34210336 = r34210328 * r34210335;
        return r34210336;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original20.3
Target19.3
Herbie20.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 20.3

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

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

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

Reproduce

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