Average Error: 20.1 → 20.1
Time: 37.0s
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 r31548370 = 2.0;
        double r31548371 = x;
        double r31548372 = y;
        double r31548373 = r31548371 * r31548372;
        double r31548374 = z;
        double r31548375 = r31548371 * r31548374;
        double r31548376 = r31548373 + r31548375;
        double r31548377 = r31548372 * r31548374;
        double r31548378 = r31548376 + r31548377;
        double r31548379 = sqrt(r31548378);
        double r31548380 = r31548370 * r31548379;
        return r31548380;
}

double f(double x, double y, double z) {
        double r31548381 = 2.0;
        double r31548382 = y;
        double r31548383 = x;
        double r31548384 = z;
        double r31548385 = r31548383 + r31548384;
        double r31548386 = r31548383 * r31548384;
        double r31548387 = fma(r31548382, r31548385, r31548386);
        double r31548388 = sqrt(r31548387);
        double r31548389 = r31548381 * r31548388;
        return r31548389;
}

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)))))