Average Error: 19.8 → 19.8
Time: 18.6s
Precision: 64
\[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
\[\sqrt{\mathsf{fma}\left(z, x, y \cdot \left(z + x\right)\right)} \cdot 2\]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\sqrt{\mathsf{fma}\left(z, x, y \cdot \left(z + x\right)\right)} \cdot 2
double f(double x, double y, double z) {
        double r490982 = 2.0;
        double r490983 = x;
        double r490984 = y;
        double r490985 = r490983 * r490984;
        double r490986 = z;
        double r490987 = r490983 * r490986;
        double r490988 = r490985 + r490987;
        double r490989 = r490984 * r490986;
        double r490990 = r490988 + r490989;
        double r490991 = sqrt(r490990);
        double r490992 = r490982 * r490991;
        return r490992;
}

double f(double x, double y, double z) {
        double r490993 = z;
        double r490994 = x;
        double r490995 = y;
        double r490996 = r490993 + r490994;
        double r490997 = r490995 * r490996;
        double r490998 = fma(r490993, r490994, r490997);
        double r490999 = sqrt(r490998);
        double r491000 = 2.0;
        double r491001 = r490999 * r491000;
        return r491001;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original19.8
Target19.0
Herbie19.8
\[\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.8

    \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
  2. Using strategy rm
  3. Applied *-un-lft-identity19.8

    \[\leadsto 2 \cdot \sqrt{\color{blue}{1 \cdot \left(\left(x \cdot y + x \cdot z\right) + y \cdot z\right)}}\]
  4. Applied sqrt-prod19.8

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

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

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

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

Reproduce

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