?

Average Accuracy: 68.7% → 96.5%
Time: 13.6s
Precision: binary64
Cost: 13572

?

\[ \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 -2 \cdot 10^{-310}:\\ \;\;\;\;2 \cdot \frac{\sqrt{\left(-z\right) - x}}{\sqrt{\frac{-1}{y}}}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\sqrt{z} \cdot \sqrt{y}\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 -2e-310)
   (* 2.0 (/ (sqrt (- (- z) x)) (sqrt (/ -1.0 y))))
   (* 2.0 (* (sqrt z) (sqrt y)))))
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 <= -2e-310) {
		tmp = 2.0 * (sqrt((-z - x)) / sqrt((-1.0 / y)));
	} else {
		tmp = 2.0 * (sqrt(z) * sqrt(y));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = 2.0d0 * sqrt((((x * y) + (x * z)) + (y * z)))
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-2d-310)) then
        tmp = 2.0d0 * (sqrt((-z - x)) / sqrt(((-1.0d0) / y)))
    else
        tmp = 2.0d0 * (sqrt(z) * sqrt(y))
    end if
    code = tmp
end function
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 <= -2e-310) {
		tmp = 2.0 * (Math.sqrt((-z - x)) / Math.sqrt((-1.0 / y)));
	} else {
		tmp = 2.0 * (Math.sqrt(z) * Math.sqrt(y));
	}
	return tmp;
}
def code(x, y, z):
	return 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z)))
def code(x, y, z):
	tmp = 0
	if y <= -2e-310:
		tmp = 2.0 * (math.sqrt((-z - x)) / math.sqrt((-1.0 / y)))
	else:
		tmp = 2.0 * (math.sqrt(z) * math.sqrt(y))
	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 <= -2e-310)
		tmp = Float64(2.0 * Float64(sqrt(Float64(Float64(-z) - x)) / sqrt(Float64(-1.0 / y))));
	else
		tmp = Float64(2.0 * Float64(sqrt(z) * sqrt(y)));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -2e-310)
		tmp = 2.0 * (sqrt((-z - x)) / sqrt((-1.0 / y)));
	else
		tmp = 2.0 * (sqrt(z) * sqrt(y));
	end
	tmp_2 = 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, -2e-310], N[(2.0 * N[(N[Sqrt[N[((-z) - x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[z], $MachinePrecision] * N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-310}:\\
\;\;\;\;2 \cdot \frac{\sqrt{\left(-z\right) - x}}{\sqrt{\frac{-1}{y}}}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original68.7%
Target82.0%
Herbie96.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 2 regimes
  2. if y < -1.999999999999994e-310

    1. Initial program 68.1%

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

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

      [Start]68.1

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

      associate-+l+ [=>]68.1

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

      fma-def [=>]68.1

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

      distribute-rgt-out [=>]68.1

      \[ 2 \cdot \sqrt{\mathsf{fma}\left(x, y, \color{blue}{z \cdot \left(x + y\right)}\right)} \]
    3. Applied egg-rr22.8%

      \[\leadsto 2 \cdot \sqrt{\color{blue}{\frac{\left(y \cdot y\right) \cdot \left(x \cdot x\right) - {\left(z \cdot \left(x + y\right)\right)}^{2}}{x \cdot y - z \cdot \left(x + y\right)}}} \]
    4. Taylor expanded in y around inf 30.7%

      \[\leadsto 2 \cdot \sqrt{\color{blue}{\frac{y \cdot \left({x}^{2} - {z}^{2}\right)}{x - z}}} \]
    5. Simplified36.1%

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

      [Start]30.7

      \[ 2 \cdot \sqrt{\frac{y \cdot \left({x}^{2} - {z}^{2}\right)}{x - z}} \]

      associate-/l* [=>]37.1

      \[ 2 \cdot \sqrt{\color{blue}{\frac{y}{\frac{x - z}{{x}^{2} - {z}^{2}}}}} \]

      associate-/r/ [=>]36.1

      \[ 2 \cdot \sqrt{\color{blue}{\frac{y}{x - z} \cdot \left({x}^{2} - {z}^{2}\right)}} \]

      unpow2 [=>]36.1

      \[ 2 \cdot \sqrt{\frac{y}{x - z} \cdot \left(\color{blue}{x \cdot x} - {z}^{2}\right)} \]

      unpow2 [=>]36.1

      \[ 2 \cdot \sqrt{\frac{y}{x - z} \cdot \left(x \cdot x - \color{blue}{z \cdot z}\right)} \]
    6. Applied egg-rr65.6%

      \[\leadsto 2 \cdot \sqrt{\color{blue}{\frac{x + z}{\frac{1}{y}}}} \]
    7. Applied egg-rr96.3%

      \[\leadsto 2 \cdot \color{blue}{\frac{\sqrt{-\left(x + z\right)}}{\sqrt{\frac{-1}{y}}}} \]
    8. Simplified96.3%

      \[\leadsto 2 \cdot \color{blue}{\frac{\sqrt{\left(-z\right) - x}}{\sqrt{\frac{-1}{y}}}} \]
      Proof

      [Start]96.3

      \[ 2 \cdot \frac{\sqrt{-\left(x + z\right)}}{\sqrt{\frac{-1}{y}}} \]

      distribute-neg-in [=>]96.3

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

      +-commutative [=>]96.3

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

      sub-neg [<=]96.3

      \[ 2 \cdot \frac{\sqrt{\color{blue}{\left(-z\right) - x}}}{\sqrt{\frac{-1}{y}}} \]

    if -1.999999999999994e-310 < y

    1. Initial program 69.3%

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

      \[\leadsto 2 \cdot \sqrt{\color{blue}{\frac{x \cdot \left(y \cdot y - z \cdot z\right)}{y - z}} + y \cdot z} \]
    3. Simplified39.9%

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

      [Start]39.0

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

      associate-/l* [=>]39.9

      \[ 2 \cdot \sqrt{\color{blue}{\frac{x}{\frac{y - z}{y \cdot y - z \cdot z}}} + y \cdot z} \]

      fma-neg [=>]39.9

      \[ 2 \cdot \sqrt{\frac{x}{\frac{y - z}{\color{blue}{\mathsf{fma}\left(y, y, -z \cdot z\right)}}} + y \cdot z} \]
    4. Taylor expanded in x around 0 67.1%

      \[\leadsto 2 \cdot \color{blue}{\sqrt{y \cdot z}} \]
    5. Simplified67.1%

      \[\leadsto 2 \cdot \color{blue}{\sqrt{z \cdot y}} \]
      Proof

      [Start]67.1

      \[ 2 \cdot \sqrt{y \cdot z} \]

      *-commutative [=>]67.1

      \[ 2 \cdot \sqrt{\color{blue}{z \cdot y}} \]
    6. Applied egg-rr96.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-310}:\\ \;\;\;\;2 \cdot \frac{\sqrt{\left(-z\right) - x}}{\sqrt{\frac{-1}{y}}}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\sqrt{z} \cdot \sqrt{y}\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy82.4%
Cost14148
\[\begin{array}{l} \mathbf{if}\;\left(y \cdot x + z \cdot x\right) + y \cdot z \leq 2 \cdot 10^{+306}:\\ \;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(x, y, z \cdot \left(y + x\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{\sqrt{z + x}}{{y}^{-0.5}}\\ \end{array} \]
Alternative 2
Accuracy82.4%
Cost14084
\[\begin{array}{l} \mathbf{if}\;\left(y \cdot x + z \cdot x\right) + y \cdot z \leq 2 \cdot 10^{+306}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot z + x \cdot \left(y + z\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{\sqrt{z + x}}{{y}^{-0.5}}\\ \end{array} \]
Alternative 3
Accuracy82.4%
Cost13892
\[\begin{array}{l} \mathbf{if}\;\left(y \cdot x + z \cdot x\right) + y \cdot z \leq 2 \cdot 10^{+306}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot z + x \cdot \left(y + z\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\sqrt{z} \cdot \sqrt{y}\right)\\ \end{array} \]
Alternative 4
Accuracy68.7%
Cost7104
\[2 \cdot \sqrt{y \cdot z + x \cdot \left(y + z\right)} \]
Alternative 5
Accuracy67.0%
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq -3.4 \cdot 10^{-254}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{z \cdot \left(y + x\right)}\\ \end{array} \]
Alternative 6
Accuracy68.3%
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{-267}:\\ \;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{z \cdot \left(y + x\right)}\\ \end{array} \]
Alternative 7
Accuracy66.1%
Cost6852
\[\begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{-267}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot z}\\ \end{array} \]
Alternative 8
Accuracy33.8%
Cost6720
\[2 \cdot \sqrt{y \cdot x} \]

Error

Reproduce?

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