Average Error: 20.3 → 20.2
Time: 14.7s
Precision: 64
\[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
\[\sqrt{\sqrt{\mathsf{fma}\left(x, z + y, y \cdot z\right)} \cdot \sqrt{\mathsf{fma}\left(x, z + y, y \cdot z\right)}} \cdot 2\]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\sqrt{\sqrt{\mathsf{fma}\left(x, z + y, y \cdot z\right)} \cdot \sqrt{\mathsf{fma}\left(x, z + y, y \cdot z\right)}} \cdot 2
double f(double x, double y, double z) {
        double r638747 = 2.0;
        double r638748 = x;
        double r638749 = y;
        double r638750 = r638748 * r638749;
        double r638751 = z;
        double r638752 = r638748 * r638751;
        double r638753 = r638750 + r638752;
        double r638754 = r638749 * r638751;
        double r638755 = r638753 + r638754;
        double r638756 = sqrt(r638755);
        double r638757 = r638747 * r638756;
        return r638757;
}

double f(double x, double y, double z) {
        double r638758 = x;
        double r638759 = z;
        double r638760 = y;
        double r638761 = r638759 + r638760;
        double r638762 = r638760 * r638759;
        double r638763 = fma(r638758, r638761, r638762);
        double r638764 = sqrt(r638763);
        double r638765 = r638764 * r638764;
        double r638766 = sqrt(r638765);
        double r638767 = 2.0;
        double r638768 = r638766 * r638767;
        return r638768;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original20.3
Target19.3
Herbie20.2
\[\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. Using strategy rm
  3. Applied distribute-lft-out20.3

    \[\leadsto 2 \cdot \sqrt{\color{blue}{x \cdot \left(y + z\right)} + y \cdot z}\]
  4. Using strategy rm
  5. Applied add-sqr-sqrt20.3

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

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

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

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

Reproduce

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