Average Error: 19.6 → 19.6
Time: 12.6s
Precision: 64
\[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
\[2 \cdot \sqrt{\sqrt{\mathsf{fma}\left(z, x + y, y \cdot x\right)} \cdot \sqrt{\mathsf{fma}\left(z, x + y, y \cdot x\right)}}\]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
2 \cdot \sqrt{\sqrt{\mathsf{fma}\left(z, x + y, y \cdot x\right)} \cdot \sqrt{\mathsf{fma}\left(z, x + y, y \cdot x\right)}}
double f(double x, double y, double z) {
        double r614115 = 2.0;
        double r614116 = x;
        double r614117 = y;
        double r614118 = r614116 * r614117;
        double r614119 = z;
        double r614120 = r614116 * r614119;
        double r614121 = r614118 + r614120;
        double r614122 = r614117 * r614119;
        double r614123 = r614121 + r614122;
        double r614124 = sqrt(r614123);
        double r614125 = r614115 * r614124;
        return r614125;
}

double f(double x, double y, double z) {
        double r614126 = 2.0;
        double r614127 = z;
        double r614128 = x;
        double r614129 = y;
        double r614130 = r614128 + r614129;
        double r614131 = r614129 * r614128;
        double r614132 = fma(r614127, r614130, r614131);
        double r614133 = sqrt(r614132);
        double r614134 = r614133 * r614133;
        double r614135 = sqrt(r614134);
        double r614136 = r614126 * r614135;
        return r614136;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original19.6
Target19.1
Herbie19.6
\[\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 19.6

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

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

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

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

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

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

Reproduce

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