Average Error: 20.0 → 5.1
Time: 9.1s
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.361197447632789 \cdot 10^{+24}:\\ \;\;\;\;2 \cdot {\left(\sqrt{e^{0.3333333333333333 \cdot \left(\log \left(-\left(y + z\right)\right) - \log \left(\frac{-1}{x}\right)\right)}}\right)}^{3}\\ \mathbf{elif}\;y \leq 1.8541994331994472 \cdot 10^{+49}:\\ \;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(x, y, z \cdot x\right) + y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot {\left(\sqrt{{\left(e^{0.3333333333333333}\right)}^{\left(\log \left(y + x\right) + \log z\right)}}\right)}^{3}\\ \end{array} \]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\begin{array}{l}
\mathbf{if}\;y \leq -2.361197447632789 \cdot 10^{+24}:\\
\;\;\;\;2 \cdot {\left(\sqrt{e^{0.3333333333333333 \cdot \left(\log \left(-\left(y + z\right)\right) - \log \left(\frac{-1}{x}\right)\right)}}\right)}^{3}\\

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

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


\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.361197447632789e+24)
   (*
    2.0
    (pow
     (sqrt (exp (* 0.3333333333333333 (- (log (- (+ y z))) (log (/ -1.0 x))))))
     3.0))
   (if (<= y 1.8541994331994472e+49)
     (* 2.0 (sqrt (+ (fma x y (* z x)) (* y z))))
     (*
      2.0
      (pow
       (sqrt (pow (exp 0.3333333333333333) (+ (log (+ y x)) (log z))))
       3.0)))))
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.361197447632789e+24) {
		tmp = 2.0 * pow(sqrt(exp(0.3333333333333333 * (log(-(y + z)) - log(-1.0 / x)))), 3.0);
	} else if (y <= 1.8541994331994472e+49) {
		tmp = 2.0 * sqrt(fma(x, y, (z * x)) + (y * z));
	} else {
		tmp = 2.0 * pow(sqrt(pow(exp(0.3333333333333333), (log(y + x) + log(z)))), 3.0);
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original20.0
Target11.5
Herbie5.1
\[\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.3611974476327889e24

    1. Initial program 40.1

      \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
    2. Applied add-cube-cbrt_binary6440.4

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot {\left(\sqrt{\color{blue}{e^{0.3333333333333333 \cdot \left(\log \left(-\left(y + z\right)\right) - \log \left(\frac{-1}{x}\right)\right)}}}\right)}^{3} \]
    10. Simplified7.0

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

    if -2.3611974476327889e24 < y < 1.85419943319944716e49

    1. Initial program 3.9

      \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
    2. Applied fma-def_binary643.9

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

    if 1.85419943319944716e49 < y

    1. Initial program 45.2

      \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
    2. Applied add-cube-cbrt_binary6445.4

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot {\left(\sqrt{\color{blue}{e^{0.3333333333333333 \cdot \left(\log \left(y + x\right) - \log \left(\frac{1}{z}\right)\right)}}}\right)}^{3} \]
    10. Simplified6.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.361197447632789 \cdot 10^{+24}:\\ \;\;\;\;2 \cdot {\left(\sqrt{e^{0.3333333333333333 \cdot \left(\log \left(-\left(y + z\right)\right) - \log \left(\frac{-1}{x}\right)\right)}}\right)}^{3}\\ \mathbf{elif}\;y \leq 1.8541994331994472 \cdot 10^{+49}:\\ \;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(x, y, z \cdot x\right) + y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot {\left(\sqrt{{\left(e^{0.3333333333333333}\right)}^{\left(\log \left(y + x\right) + \log z\right)}}\right)}^{3}\\ \end{array} \]

Reproduce

herbie shell --seed 2022019 
(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)))))