Average Error: 18.7 → 16.0
Time: 18.6s
Precision: 64
\[2.0 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;\left(x \cdot y + z \cdot x\right) + z \cdot y \le 5.789025125631018 \cdot 10^{+307}:\\ \;\;\;\;2.0 \cdot \sqrt{\left(x \cdot y + z \cdot x\right) + z \cdot y}\\ \mathbf{else}:\\ \;\;\;\;2.0 \cdot \left(\sqrt{y} \cdot \sqrt{x}\right)\\ \end{array}\]
2.0 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\begin{array}{l}
\mathbf{if}\;\left(x \cdot y + z \cdot x\right) + z \cdot y \le 5.789025125631018 \cdot 10^{+307}:\\
\;\;\;\;2.0 \cdot \sqrt{\left(x \cdot y + z \cdot x\right) + z \cdot y}\\

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

\end{array}
double f(double x, double y, double z) {
        double r30009143 = 2.0;
        double r30009144 = x;
        double r30009145 = y;
        double r30009146 = r30009144 * r30009145;
        double r30009147 = z;
        double r30009148 = r30009144 * r30009147;
        double r30009149 = r30009146 + r30009148;
        double r30009150 = r30009145 * r30009147;
        double r30009151 = r30009149 + r30009150;
        double r30009152 = sqrt(r30009151);
        double r30009153 = r30009143 * r30009152;
        return r30009153;
}

double f(double x, double y, double z) {
        double r30009154 = x;
        double r30009155 = y;
        double r30009156 = r30009154 * r30009155;
        double r30009157 = z;
        double r30009158 = r30009157 * r30009154;
        double r30009159 = r30009156 + r30009158;
        double r30009160 = r30009157 * r30009155;
        double r30009161 = r30009159 + r30009160;
        double r30009162 = 5.789025125631018e+307;
        bool r30009163 = r30009161 <= r30009162;
        double r30009164 = 2.0;
        double r30009165 = sqrt(r30009161);
        double r30009166 = r30009164 * r30009165;
        double r30009167 = sqrt(r30009155);
        double r30009168 = sqrt(r30009154);
        double r30009169 = r30009167 * r30009168;
        double r30009170 = r30009164 * r30009169;
        double r30009171 = r30009163 ? r30009166 : r30009170;
        return r30009171;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original18.7
Target18.1
Herbie16.0
\[\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 (+ (+ (* x y) (* x z)) (* y z)) < 5.789025125631018e+307

    1. Initial program 2.6

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

    if 5.789025125631018e+307 < (+ (+ (* x y) (* x z)) (* y z))

    1. Initial program 60.1

      \[2.0 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
    2. Simplified60.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/260.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 51.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(x \cdot y + z \cdot x\right) + z \cdot y \le 5.789025125631018 \cdot 10^{+307}:\\ \;\;\;\;2.0 \cdot \sqrt{\left(x \cdot y + z \cdot x\right) + z \cdot y}\\ \mathbf{else}:\\ \;\;\;\;2.0 \cdot \left(\sqrt{y} \cdot \sqrt{x}\right)\\ \end{array}\]

Reproduce

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