Average Error: 18.6 → 17.9
Time: 17.9s
Precision: 64
\[2.0 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \le 5.899400734459858 \cdot 10^{+201}:\\ \;\;\;\;{\left(\mathsf{fma}\left(x + y, z, x \cdot y\right)\right)}^{\frac{1}{2}} \cdot 2.0\\ \mathbf{elif}\;y \le 1.4416622308213284 \cdot 10^{+281}:\\ \;\;\;\;\left(\sqrt{y} \cdot \sqrt{x}\right) \cdot 2.0\\ \mathbf{else}:\\ \;\;\;\;{\left(\mathsf{fma}\left(x + y, z, x \cdot y\right)\right)}^{\frac{1}{2}} \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 5.899400734459858 \cdot 10^{+201}:\\
\;\;\;\;{\left(\mathsf{fma}\left(x + y, z, x \cdot y\right)\right)}^{\frac{1}{2}} \cdot 2.0\\

\mathbf{elif}\;y \le 1.4416622308213284 \cdot 10^{+281}:\\
\;\;\;\;\left(\sqrt{y} \cdot \sqrt{x}\right) \cdot 2.0\\

\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{fma}\left(x + y, z, x \cdot y\right)\right)}^{\frac{1}{2}} \cdot 2.0\\

\end{array}
double f(double x, double y, double z) {
        double r31352266 = 2.0;
        double r31352267 = x;
        double r31352268 = y;
        double r31352269 = r31352267 * r31352268;
        double r31352270 = z;
        double r31352271 = r31352267 * r31352270;
        double r31352272 = r31352269 + r31352271;
        double r31352273 = r31352268 * r31352270;
        double r31352274 = r31352272 + r31352273;
        double r31352275 = sqrt(r31352274);
        double r31352276 = r31352266 * r31352275;
        return r31352276;
}

double f(double x, double y, double z) {
        double r31352277 = y;
        double r31352278 = 5.899400734459858e+201;
        bool r31352279 = r31352277 <= r31352278;
        double r31352280 = x;
        double r31352281 = r31352280 + r31352277;
        double r31352282 = z;
        double r31352283 = r31352280 * r31352277;
        double r31352284 = fma(r31352281, r31352282, r31352283);
        double r31352285 = 0.5;
        double r31352286 = pow(r31352284, r31352285);
        double r31352287 = 2.0;
        double r31352288 = r31352286 * r31352287;
        double r31352289 = 1.4416622308213284e+281;
        bool r31352290 = r31352277 <= r31352289;
        double r31352291 = sqrt(r31352277);
        double r31352292 = sqrt(r31352280);
        double r31352293 = r31352291 * r31352292;
        double r31352294 = r31352293 * r31352287;
        double r31352295 = r31352290 ? r31352294 : r31352288;
        double r31352296 = r31352279 ? r31352288 : r31352295;
        return r31352296;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original18.6
Target18.0
Herbie17.9
\[\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 < 5.899400734459858e+201 or 1.4416622308213284e+281 < y

    1. Initial program 17.2

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

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

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

    if 5.899400734459858e+201 < y < 1.4416622308213284e+281

    1. Initial program 39.0

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

      \[\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.0

      \[\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 32.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. Simplified29.4

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

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

Reproduce

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