Average Error: 20.3 → 20.3
Time: 39.1s
Precision: 64
\[2.0 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
\[2.0 \cdot \sqrt{\mathsf{fma}\left(y + x, z, x \cdot y\right)}\]
2.0 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
2.0 \cdot \sqrt{\mathsf{fma}\left(y + x, z, x \cdot y\right)}
double f(double x, double y, double z) {
        double r31042955 = 2.0;
        double r31042956 = x;
        double r31042957 = y;
        double r31042958 = r31042956 * r31042957;
        double r31042959 = z;
        double r31042960 = r31042956 * r31042959;
        double r31042961 = r31042958 + r31042960;
        double r31042962 = r31042957 * r31042959;
        double r31042963 = r31042961 + r31042962;
        double r31042964 = sqrt(r31042963);
        double r31042965 = r31042955 * r31042964;
        return r31042965;
}

double f(double x, double y, double z) {
        double r31042966 = 2.0;
        double r31042967 = y;
        double r31042968 = x;
        double r31042969 = r31042967 + r31042968;
        double r31042970 = z;
        double r31042971 = r31042968 * r31042967;
        double r31042972 = fma(r31042969, r31042970, r31042971);
        double r31042973 = sqrt(r31042972);
        double r31042974 = r31042966 * r31042973;
        return r31042974;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original20.3
Target19.3
Herbie20.3
\[\begin{array}{l} \mathbf{if}\;z \lt 7.636950090573675 \cdot 10^{+176}:\\ \;\;\;\;2.0 \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.0\\ \end{array}\]

Derivation

  1. Initial program 20.3

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

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

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

Reproduce

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