Average Error: 19.3 → 19.6
Time: 11.4s
Precision: 64
\[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
\[\left(\sqrt{\sqrt{\mathsf{fma}\left(x, z, y \cdot \left(z + x\right)\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(x, z, y \cdot \left(z + x\right)\right)}}\right) \cdot 2\]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\left(\sqrt{\sqrt{\mathsf{fma}\left(x, z, y \cdot \left(z + x\right)\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(x, z, y \cdot \left(z + x\right)\right)}}\right) \cdot 2
double f(double x, double y, double z) {
        double r403473 = 2.0;
        double r403474 = x;
        double r403475 = y;
        double r403476 = r403474 * r403475;
        double r403477 = z;
        double r403478 = r403474 * r403477;
        double r403479 = r403476 + r403478;
        double r403480 = r403475 * r403477;
        double r403481 = r403479 + r403480;
        double r403482 = sqrt(r403481);
        double r403483 = r403473 * r403482;
        return r403483;
}

double f(double x, double y, double z) {
        double r403484 = x;
        double r403485 = z;
        double r403486 = y;
        double r403487 = r403485 + r403484;
        double r403488 = r403486 * r403487;
        double r403489 = fma(r403484, r403485, r403488);
        double r403490 = sqrt(r403489);
        double r403491 = sqrt(r403490);
        double r403492 = r403491 * r403491;
        double r403493 = 2.0;
        double r403494 = r403492 * r403493;
        return r403494;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original19.3
Target19.0
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.3

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

    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(y, z, x \cdot \left(y + z\right)\right)} \cdot 2}\]
  3. Taylor expanded around 0 19.3

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

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

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

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

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

Reproduce

herbie shell --seed 2019212 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:descartes from diagrams-contrib-1.3.0.5"
  :precision binary64

  :herbie-target
  (if (< z 7.6369500905736745e176) (* 2 (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))

  (* 2 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))