Average Error: 20.1 → 10.4
Time: 9.7s
Precision: binary64
\[[x, y, z] = \mathsf{sort}([x, y, z]) \\]
\[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -2.3027336494487103 \cdot 10^{+59}:\\ \;\;\;\;2 \cdot e^{0.25 \cdot \left(\log \left({\left(y + z\right)}^{2}\right) - 2 \cdot \log \left(\frac{-1}{x}\right)\right)}\\ \mathbf{elif}\;y \leq 1.5331640059391025 \cdot 10^{+53}:\\ \;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot {\left(e^{0.25}\right)}^{\left(2 \cdot \left(\log \left(y + x\right) + \log z\right)\right)}\\ \end{array} \]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\begin{array}{l}
\mathbf{if}\;y \leq -2.3027336494487103 \cdot 10^{+59}:\\
\;\;\;\;2 \cdot e^{0.25 \cdot \left(\log \left({\left(y + z\right)}^{2}\right) - 2 \cdot \log \left(\frac{-1}{x}\right)\right)}\\

\mathbf{elif}\;y \leq 1.5331640059391025 \cdot 10^{+53}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;2 \cdot {\left(e^{0.25}\right)}^{\left(2 \cdot \left(\log \left(y + x\right) + \log z\right)\right)}\\


\end{array}
(FPCore (x y z)
 :precision binary64
 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
(FPCore (x y z)
 :precision binary64
 (if (<= y -2.3027336494487103e+59)
   (* 2.0 (exp (* 0.25 (- (log (pow (+ y z) 2.0)) (* 2.0 (log (/ -1.0 x)))))))
   (if (<= y 1.5331640059391025e+53)
     (* 2.0 (sqrt (fma y x (* z (+ y x)))))
     (* 2.0 (pow (exp 0.25) (* 2.0 (+ (log (+ y x)) (log z))))))))
double code(double x, double y, double z) {
	return 2.0 * sqrt(((x * y) + (x * z)) + (y * z));
}
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2.3027336494487103e+59) {
		tmp = 2.0 * exp(0.25 * (log(pow((y + z), 2.0)) - (2.0 * log(-1.0 / x))));
	} else if (y <= 1.5331640059391025e+53) {
		tmp = 2.0 * sqrt(fma(y, x, (z * (y + x))));
	} else {
		tmp = 2.0 * pow(exp(0.25), (2.0 * (log(y + x) + log(z))));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original20.1
Target11.8
Herbie10.4
\[\begin{array}{l} \mathbf{if}\;z < 7.636950090573675 \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. Split input into 3 regimes
  2. if y < -2.30273364944871029e59

    1. Initial program 48.0

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

      \[\leadsto \color{blue}{2 \cdot \sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}} \]
    3. Applied add-sqr-sqrt_binary6448.1

      \[\leadsto 2 \cdot \color{blue}{\left(\sqrt{\sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}}\right)} \]
    4. Applied add-cube-cbrt_binary6448.1

      \[\leadsto 2 \cdot \left(\sqrt{\sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}} \cdot \sqrt{\sqrt{\color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(x, y + z, y \cdot z\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, y + z, y \cdot z\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(x, y + z, y \cdot z\right)}}}}\right) \]
    5. Simplified48.1

      \[\leadsto 2 \cdot \left(\sqrt{\sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}} \cdot \sqrt{\sqrt{\color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)}\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, y + z, y \cdot z\right)}}}\right) \]
    6. Simplified48.1

      \[\leadsto 2 \cdot \left(\sqrt{\sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}} \cdot \sqrt{\sqrt{\left(\sqrt[3]{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)}\right) \cdot \color{blue}{\sqrt[3]{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)}}}}\right) \]
    7. Taylor expanded in x around -inf 32.2

      \[\leadsto 2 \cdot \color{blue}{e^{0.25 \cdot \left(\log \left({\left(y + z\right)}^{2}\right) - 2 \cdot \log \left(\frac{-1}{x}\right)\right)}} \]

    if -2.30273364944871029e59 < y < 1.5331640059391025e53

    1. Initial program 4.3

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

      \[\leadsto \color{blue}{2 \cdot \sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}} \]
    3. Taylor expanded in x around 0 4.3

      \[\leadsto 2 \cdot \sqrt{\color{blue}{y \cdot x + \left(y \cdot z + z \cdot x\right)}} \]
    4. Simplified4.3

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

    if 1.5331640059391025e53 < y

    1. Initial program 46.2

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

      \[\leadsto \color{blue}{2 \cdot \sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}} \]
    3. Applied add-sqr-sqrt_binary6446.3

      \[\leadsto 2 \cdot \color{blue}{\left(\sqrt{\sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}}\right)} \]
    4. Applied add-cube-cbrt_binary6446.3

      \[\leadsto 2 \cdot \left(\sqrt{\sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}} \cdot \sqrt{\sqrt{\color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(x, y + z, y \cdot z\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, y + z, y \cdot z\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(x, y + z, y \cdot z\right)}}}}\right) \]
    5. Simplified46.3

      \[\leadsto 2 \cdot \left(\sqrt{\sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}} \cdot \sqrt{\sqrt{\color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)}\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, y + z, y \cdot z\right)}}}\right) \]
    6. Simplified46.3

      \[\leadsto 2 \cdot \left(\sqrt{\sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}} \cdot \sqrt{\sqrt{\left(\sqrt[3]{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)}\right) \cdot \color{blue}{\sqrt[3]{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)}}}}\right) \]
    7. Applied sqrt-unprod_binary6446.3

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

      \[\leadsto 2 \cdot \sqrt{\color{blue}{\sqrt{\mathsf{fma}\left(x, y, z \cdot \left(x + y\right)\right)} \cdot \sqrt{\mathsf{fma}\left(x, z + y, z \cdot y\right)}}} \]
    9. Taylor expanded in z around inf 31.4

      \[\leadsto 2 \cdot \color{blue}{e^{0.25 \cdot \left(\log \left({\left(y + x\right)}^{2}\right) - 2 \cdot \log \left(\frac{1}{z}\right)\right)}} \]
    10. Simplified9.5

      \[\leadsto 2 \cdot \color{blue}{{\left(e^{0.25}\right)}^{\left(2 \cdot \left(\log \left(y + x\right) - \left(-\log z\right)\right)\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.3027336494487103 \cdot 10^{+59}:\\ \;\;\;\;2 \cdot e^{0.25 \cdot \left(\log \left({\left(y + z\right)}^{2}\right) - 2 \cdot \log \left(\frac{-1}{x}\right)\right)}\\ \mathbf{elif}\;y \leq 1.5331640059391025 \cdot 10^{+53}:\\ \;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot {\left(e^{0.25}\right)}^{\left(2 \cdot \left(\log \left(y + x\right) + \log z\right)\right)}\\ \end{array} \]

Reproduce

herbie shell --seed 2022068 
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:descartes from diagrams-contrib-1.3.0.5"
  :precision binary64

  :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)))))