Average Error: 19.7 → 1.5
Time: 12.9s
Precision: binary64
Cost: 26828
\[ \begin{array}{c}[x, y, z] = \mathsf{sort}([x, y, z])\\ \end{array} \]
\[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -1.12 \cdot 10^{+67}:\\ \;\;\;\;2 \cdot {\left(\sqrt[3]{y} \cdot \sqrt[3]{x}\right)}^{1.5}\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-225}:\\ \;\;\;\;2 \cdot \sqrt{x \cdot z + y \cdot \left(x + z\right)}\\ \mathbf{elif}\;y \leq 0:\\ \;\;\;\;2 \cdot {\left(e^{0.25 \cdot \left(\log \left(\left(-y\right) - z\right) - \log \left(\frac{-1}{x}\right)\right)}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\sqrt{y + x} \cdot \sqrt{z}\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 -1.12e+67)
   (* 2.0 (pow (* (cbrt y) (cbrt x)) 1.5))
   (if (<= y -1e-225)
     (* 2.0 (sqrt (+ (* x z) (* y (+ x z)))))
     (if (<= y 0.0)
       (* 2.0 (pow (exp (* 0.25 (- (log (- (- y) z)) (log (/ -1.0 x))))) 2.0))
       (* 2.0 (* (sqrt (+ y x)) (sqrt 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 <= -1.12e+67) {
		tmp = 2.0 * pow((cbrt(y) * cbrt(x)), 1.5);
	} else if (y <= -1e-225) {
		tmp = 2.0 * sqrt(((x * z) + (y * (x + z))));
	} else if (y <= 0.0) {
		tmp = 2.0 * pow(exp((0.25 * (log((-y - z)) - log((-1.0 / x))))), 2.0);
	} else {
		tmp = 2.0 * (sqrt((y + x)) * sqrt(z));
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	return 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
}
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.12e+67) {
		tmp = 2.0 * Math.pow((Math.cbrt(y) * Math.cbrt(x)), 1.5);
	} else if (y <= -1e-225) {
		tmp = 2.0 * Math.sqrt(((x * z) + (y * (x + z))));
	} else if (y <= 0.0) {
		tmp = 2.0 * Math.pow(Math.exp((0.25 * (Math.log((-y - z)) - Math.log((-1.0 / x))))), 2.0);
	} else {
		tmp = 2.0 * (Math.sqrt((y + x)) * Math.sqrt(z));
	}
	return tmp;
}
function code(x, y, z)
	return Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z))))
end
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.12e+67)
		tmp = Float64(2.0 * (Float64(cbrt(y) * cbrt(x)) ^ 1.5));
	elseif (y <= -1e-225)
		tmp = Float64(2.0 * sqrt(Float64(Float64(x * z) + Float64(y * Float64(x + z)))));
	elseif (y <= 0.0)
		tmp = Float64(2.0 * (exp(Float64(0.25 * Float64(log(Float64(Float64(-y) - z)) - log(Float64(-1.0 / x))))) ^ 2.0));
	else
		tmp = Float64(2.0 * Float64(sqrt(Float64(y + x)) * sqrt(z)));
	end
	return tmp
end
code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(N[(N[(x * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[y, -1.12e+67], N[(2.0 * N[Power[N[(N[Power[y, 1/3], $MachinePrecision] * N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1e-225], N[(2.0 * N[Sqrt[N[(N[(x * z), $MachinePrecision] + N[(y * N[(x + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.0], N[(2.0 * N[Power[N[Exp[N[(0.25 * N[(N[Log[N[((-y) - z), $MachinePrecision]], $MachinePrecision] - N[Log[N[(-1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[N[(y + x), $MachinePrecision]], $MachinePrecision] * N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\begin{array}{l}
\mathbf{if}\;y \leq -1.12 \cdot 10^{+67}:\\
\;\;\;\;2 \cdot {\left(\sqrt[3]{y} \cdot \sqrt[3]{x}\right)}^{1.5}\\

\mathbf{elif}\;y \leq -1 \cdot 10^{-225}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot z + y \cdot \left(x + z\right)}\\

\mathbf{elif}\;y \leq 0:\\
\;\;\;\;2 \cdot {\left(e^{0.25 \cdot \left(\log \left(\left(-y\right) - z\right) - \log \left(\frac{-1}{x}\right)\right)}\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\sqrt{y + x} \cdot \sqrt{z}\right)\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.7
Target11.2
Herbie1.5
\[\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 4 regimes
  2. if y < -1.12e67

    1. Initial program 49.1

      \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
    2. Taylor expanded in y around 0 49.1

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

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

      \[\leadsto 2 \cdot {\left(\sqrt[3]{\color{blue}{y \cdot x}}\right)}^{1.5} \]
    5. Applied egg-rr2.1

      \[\leadsto 2 \cdot {\color{blue}{\left(\sqrt[3]{y} \cdot \sqrt[3]{x}\right)}}^{1.5} \]

    if -1.12e67 < y < -9.9999999999999996e-226

    1. Initial program 2.8

      \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
    2. Taylor expanded in y around 0 2.8

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

    if -9.9999999999999996e-226 < y < 0.0

    1. Initial program 20.1

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

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

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

    if 0.0 < y

    1. Initial program 20.0

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

      \[\leadsto \color{blue}{2 \cdot \sqrt{\mathsf{fma}\left(x, y, z \cdot \left(x + y\right)\right)}} \]
      Proof
      (*.f64 2 (sqrt.f64 (fma.f64 x y (*.f64 z (+.f64 x y))))): 0 points increase in error, 0 points decrease in error
      (*.f64 2 (sqrt.f64 (fma.f64 x y (Rewrite<= distribute-rgt-out_binary64 (+.f64 (*.f64 x z) (*.f64 y z)))))): 1 points increase in error, 1 points decrease in error
      (*.f64 2 (sqrt.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x y) (+.f64 (*.f64 x z) (*.f64 y z)))))): 1 points increase in error, 1 points decrease in error
      (*.f64 2 (sqrt.f64 (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (*.f64 x y) (*.f64 x z)) (*.f64 y z))))): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in z around inf 20.0

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

      \[\leadsto 2 \cdot \color{blue}{\left(\sqrt{y + x} \cdot \sqrt{z}\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification1.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.12 \cdot 10^{+67}:\\ \;\;\;\;2 \cdot {\left(\sqrt[3]{y} \cdot \sqrt[3]{x}\right)}^{1.5}\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-225}:\\ \;\;\;\;2 \cdot \sqrt{x \cdot z + y \cdot \left(x + z\right)}\\ \mathbf{elif}\;y \leq 0:\\ \;\;\;\;2 \cdot {\left(e^{0.25 \cdot \left(\log \left(\left(-y\right) - z\right) - \log \left(\frac{-1}{x}\right)\right)}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\sqrt{y + x} \cdot \sqrt{z}\right)\\ \end{array} \]

Alternatives

Alternative 1
Error1.6
Cost19980
\[\begin{array}{l} t_0 := 2 \cdot {\left(\sqrt[3]{y} \cdot \sqrt[3]{x}\right)}^{1.5}\\ \mathbf{if}\;y \leq -1.12 \cdot 10^{+67}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -8 \cdot 10^{-224}:\\ \;\;\;\;2 \cdot \sqrt{x \cdot z + y \cdot \left(x + z\right)}\\ \mathbf{elif}\;y \leq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\sqrt{y + x} \cdot \sqrt{z}\right)\\ \end{array} \]
Alternative 2
Error10.0
Cost13380
\[\begin{array}{l} \mathbf{if}\;y \leq 9.6 \cdot 10^{-267}:\\ \;\;\;\;2 \cdot \sqrt{x \cdot z + y \cdot \left(x + z\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\sqrt{y + x} \cdot \sqrt{z}\right)\\ \end{array} \]
Alternative 3
Error10.9
Cost13252
\[\begin{array}{l} \mathbf{if}\;y \leq 10^{-266}:\\ \;\;\;\;2 \cdot \sqrt{x \cdot z + y \cdot \left(x + z\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\sqrt{z} \cdot \sqrt{y}\right)\\ \end{array} \]
Alternative 4
Error19.7
Cost7104
\[2 \cdot \sqrt{x \cdot z + y \cdot \left(x + z\right)} \]
Alternative 5
Error20.5
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-289}:\\ \;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot z}\\ \end{array} \]
Alternative 6
Error19.7
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq 0:\\ \;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{z \cdot \left(y + x\right)}\\ \end{array} \]
Alternative 7
Error21.3
Cost6916
\[\begin{array}{l} \mathbf{if}\;y \leq -1.62 \cdot 10^{-289}:\\ \;\;\;\;2 \cdot {\left(y \cdot x\right)}^{0.5}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot z}\\ \end{array} \]
Alternative 8
Error21.3
Cost6852
\[\begin{array}{l} \mathbf{if}\;y \leq -1.62 \cdot 10^{-289}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot z}\\ \end{array} \]
Alternative 9
Error62.8
Cost6720
\[y \cdot \sqrt{\frac{z}{x}} \]
Alternative 10
Error41.9
Cost6720
\[2 \cdot \sqrt{y \cdot z} \]

Error

Reproduce

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