Average Error: 18.3 → 17.7
Time: 17.6s
Precision: 64
\[2.0 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \le 8.73433001687622 \cdot 10^{+216}:\\ \;\;\;\;{\left(\mathsf{fma}\left(x + y, z, x \cdot y\right)\right)}^{\frac{1}{2}} \cdot 2.0\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{y} \cdot \sqrt{x}\right) \cdot 2.0\\ \end{array}\]
2.0 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\begin{array}{l}
\mathbf{if}\;y \le 8.73433001687622 \cdot 10^{+216}:\\
\;\;\;\;{\left(\mathsf{fma}\left(x + y, z, x \cdot y\right)\right)}^{\frac{1}{2}} \cdot 2.0\\

\mathbf{else}:\\
\;\;\;\;\left(\sqrt{y} \cdot \sqrt{x}\right) \cdot 2.0\\

\end{array}
double f(double x, double y, double z) {
        double r30551255 = 2.0;
        double r30551256 = x;
        double r30551257 = y;
        double r30551258 = r30551256 * r30551257;
        double r30551259 = z;
        double r30551260 = r30551256 * r30551259;
        double r30551261 = r30551258 + r30551260;
        double r30551262 = r30551257 * r30551259;
        double r30551263 = r30551261 + r30551262;
        double r30551264 = sqrt(r30551263);
        double r30551265 = r30551255 * r30551264;
        return r30551265;
}

double f(double x, double y, double z) {
        double r30551266 = y;
        double r30551267 = 8.73433001687622e+216;
        bool r30551268 = r30551266 <= r30551267;
        double r30551269 = x;
        double r30551270 = r30551269 + r30551266;
        double r30551271 = z;
        double r30551272 = r30551269 * r30551266;
        double r30551273 = fma(r30551270, r30551271, r30551272);
        double r30551274 = 0.5;
        double r30551275 = pow(r30551273, r30551274);
        double r30551276 = 2.0;
        double r30551277 = r30551275 * r30551276;
        double r30551278 = sqrt(r30551266);
        double r30551279 = sqrt(r30551269);
        double r30551280 = r30551278 * r30551279;
        double r30551281 = r30551280 * r30551276;
        double r30551282 = r30551268 ? r30551277 : r30551281;
        return r30551282;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original18.3
Target17.5
Herbie17.7
\[\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(\frac{1}{4} \cdot \left(\left({y}^{\frac{-3}{4}} \cdot \left({z}^{\frac{-3}{4}} \cdot x\right)\right) \cdot \left(y + z\right)\right) + {z}^{\frac{1}{4}} \cdot {y}^{\frac{1}{4}}\right) \cdot \left(\frac{1}{4} \cdot \left(\left({y}^{\frac{-3}{4}} \cdot \left({z}^{\frac{-3}{4}} \cdot x\right)\right) \cdot \left(y + z\right)\right) + {z}^{\frac{1}{4}} \cdot {y}^{\frac{1}{4}}\right)\right) \cdot 2.0\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < 8.73433001687622e+216

    1. Initial program 16.6

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

      \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x + y, z, y \cdot x\right)} \cdot 2.0}\]
    3. Using strategy rm
    4. Applied pow1/216.6

      \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(x + y, z, y \cdot x\right)\right)}^{\frac{1}{2}}} \cdot 2.0\]

    if 8.73433001687622e+216 < y

    1. Initial program 39.1

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

      \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x + y, z, y \cdot x\right)} \cdot 2.0}\]
    3. Using strategy rm
    4. Applied pow1/239.1

      \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(x + y, z, y \cdot x\right)\right)}^{\frac{1}{2}}} \cdot 2.0\]
    5. Taylor expanded around inf 34.6

      \[\leadsto \color{blue}{e^{\frac{-1}{2} \cdot \left(\log \left(\frac{1}{x}\right) + \log \left(\frac{1}{y}\right)\right)}} \cdot 2.0\]
    6. Simplified31.6

      \[\leadsto \color{blue}{\left(\sqrt{x} \cdot \sqrt{y}\right)} \cdot 2.0\]
  3. Recombined 2 regimes into one program.
  4. Final simplification17.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le 8.73433001687622 \cdot 10^{+216}:\\ \;\;\;\;{\left(\mathsf{fma}\left(x + y, z, x \cdot y\right)\right)}^{\frac{1}{2}} \cdot 2.0\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{y} \cdot \sqrt{x}\right) \cdot 2.0\\ \end{array}\]

Reproduce

herbie shell --seed 2019164 +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)))) (* (* (+ (* 1/4 (* (* (pow y -3/4) (* (pow z -3/4) x)) (+ y z))) (* (pow z 1/4) (pow y 1/4))) (+ (* 1/4 (* (* (pow y -3/4) (* (pow z -3/4) x)) (+ y z))) (* (pow z 1/4) (pow y 1/4)))) 2.0))

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