?

Average Accuracy: 68.9% → 82.7%
Time: 11.6s
Precision: binary64
Cost: 13380

?

\[ \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.15 \cdot 10^{-243}:\\ \;\;\;\;2 \cdot \sqrt{\left(y + z\right) \cdot x}\\ \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.15e-243)
   (* 2.0 (sqrt (* (+ y z) x)))
   (* 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.15e-243) {
		tmp = 2.0 * sqrt(((y + z) * x));
	} else {
		tmp = 2.0 * (sqrt((y + x)) * sqrt(z));
	}
	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 <= 1.15d-243) then
        tmp = 2.0d0 * sqrt(((y + z) * x))
    else
        tmp = 2.0d0 * (sqrt((y + x)) * sqrt(z))
    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 <= 1.15e-243) {
		tmp = 2.0 * Math.sqrt(((y + z) * x));
	} else {
		tmp = 2.0 * (Math.sqrt((y + x)) * Math.sqrt(z));
	}
	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 <= 1.15e-243:
		tmp = 2.0 * math.sqrt(((y + z) * x))
	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.15e-243)
		tmp = Float64(2.0 * sqrt(Float64(Float64(y + z) * x)));
	else
		tmp = Float64(2.0 * Float64(sqrt(Float64(y + x)) * sqrt(z)));
	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 <= 1.15e-243)
		tmp = 2.0 * sqrt(((y + z) * x));
	else
		tmp = 2.0 * (sqrt((y + x)) * sqrt(z));
	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, 1.15e-243], N[(2.0 * N[Sqrt[N[(N[(y + z), $MachinePrecision] * x), $MachinePrecision]], $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.15 \cdot 10^{-243}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + z\right) \cdot x}\\

\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

Original68.9%
Target82.2%
Herbie82.7%
\[\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.15e-243

    1. Initial program 69.1%

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

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

      [Start]69.1

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

      distribute-lft-out [=>]69.1

      \[ 2 \cdot \sqrt{\color{blue}{x \cdot \left(y + z\right)} + y \cdot z} \]
    3. Taylor expanded in x around inf 67.3%

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

    if 1.15e-243 < y

    1. Initial program 68.8%

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

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

      [Start]68.8

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

      distribute-lft-out [=>]68.8

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

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

      [Start]68.8

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

      add-cube-cbrt [=>]68.8

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

      pow3 [=>]68.8

      \[ 2 \cdot \sqrt{\color{blue}{{\left(\sqrt[3]{x \cdot \left(y + z\right)}\right)}^{3}} + y \cdot z} \]
    4. Taylor expanded in y around 0 34.7%

      \[\leadsto 2 \cdot \sqrt{{\color{blue}{\left({\left(z \cdot x\right)}^{0.3333333333333333}\right)}}^{3} + y \cdot z} \]
    5. Applied egg-rr68.0%

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

      [Start]34.7

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

      rem-cbrt-cube [<=]34.7

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

      unpow1/3 [<=]34.7

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

      unpow1/3 [=>]34.7

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

      rem-cube-cbrt [=>]34.7

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

      pow1/2 [=>]34.7

      \[ 2 \cdot \color{blue}{{\left({\left({\left(z \cdot x\right)}^{0.3333333333333333}\right)}^{3} + y \cdot z\right)}^{0.5}} \]

      add-cube-cbrt [=>]34.4

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

      pow3 [=>]34.4

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

      pow-pow [=>]34.4

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

      pow-pow [=>]68.0

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

      metadata-eval [=>]68.0

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

      pow1 [<=]68.0

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

      *-commutative [=>]68.0

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

      distribute-lft-out [=>]68.0

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

      metadata-eval [=>]68.0

      \[ 2 \cdot {\left(\sqrt[3]{z \cdot \left(x + y\right)}\right)}^{\color{blue}{1.5}} \]
    6. Applied egg-rr99.4%

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

      [Start]68.0

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

      pow1/3 [=>]63.0

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

      pow-pow [=>]68.7

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

      metadata-eval [=>]68.7

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

      pow1/2 [<=]68.7

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

      *-commutative [=>]68.7

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

      sqrt-prod [=>]99.4

      \[ 2 \cdot \color{blue}{\left(\sqrt{x + y} \cdot \sqrt{z}\right)} \]
    7. Simplified99.4%

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

      [Start]99.4

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

      +-commutative [<=]99.4

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

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

Alternatives

Alternative 1
Accuracy81.4%
Cost13252
\[\begin{array}{l} \mathbf{if}\;y \leq 7.5 \cdot 10^{-243}:\\ \;\;\;\;2 \cdot \sqrt{\left(y + z\right) \cdot x}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\sqrt{z} \cdot \sqrt{y}\right)\\ \end{array} \]
Alternative 2
Accuracy68.9%
Cost7104
\[2 \cdot \sqrt{\left(y + z\right) \cdot x + y \cdot z} \]
Alternative 3
Accuracy67.7%
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-276}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{z \cdot \left(y + x\right)}\\ \end{array} \]
Alternative 4
Accuracy68.7%
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-277}:\\ \;\;\;\;2 \cdot \sqrt{\left(y + z\right) \cdot x}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{z \cdot \left(y + x\right)}\\ \end{array} \]
Alternative 5
Accuracy66.5%
Cost6852
\[\begin{array}{l} \mathbf{if}\;y \leq -4 \cdot 10^{-278}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot z}\\ \end{array} \]
Alternative 6
Accuracy35.1%
Cost6720
\[2 \cdot \sqrt{y \cdot x} \]

Error

Reproduce?

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