?

Average Error: 31.18% → 15.43%
Time: 12.2s
Precision: binary64
Cost: 28233

?

\[ \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} t_0 := \left(x \cdot z + x \cdot y\right) + y \cdot z\\ \mathbf{if}\;t_0 \leq 2 \cdot 10^{-323} \lor \neg \left(t_0 \leq 5 \cdot 10^{+307}\right):\\ \;\;\;\;2 \cdot \left(\sqrt{z} \cdot \sqrt{y} + 0.5 \cdot \left(\frac{x}{\sqrt{y}} \cdot \frac{y + z}{\sqrt{z}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot z + y \cdot \left(x + \frac{x \cdot z}{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
 (let* ((t_0 (+ (+ (* x z) (* x y)) (* y z))))
   (if (or (<= t_0 2e-323) (not (<= t_0 5e+307)))
     (*
      2.0
      (+
       (* (sqrt z) (sqrt y))
       (* 0.5 (* (/ x (sqrt y)) (/ (+ y z) (sqrt z))))))
     (* 2.0 (sqrt (+ (* y z) (* y (+ x (/ (* x z) 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 t_0 = ((x * z) + (x * y)) + (y * z);
	double tmp;
	if ((t_0 <= 2e-323) || !(t_0 <= 5e+307)) {
		tmp = 2.0 * ((sqrt(z) * sqrt(y)) + (0.5 * ((x / sqrt(y)) * ((y + z) / sqrt(z)))));
	} else {
		tmp = 2.0 * sqrt(((y * z) + (y * (x + ((x * z) / 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) :: t_0
    real(8) :: tmp
    t_0 = ((x * z) + (x * y)) + (y * z)
    if ((t_0 <= 2d-323) .or. (.not. (t_0 <= 5d+307))) then
        tmp = 2.0d0 * ((sqrt(z) * sqrt(y)) + (0.5d0 * ((x / sqrt(y)) * ((y + z) / sqrt(z)))))
    else
        tmp = 2.0d0 * sqrt(((y * z) + (y * (x + ((x * z) / 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 t_0 = ((x * z) + (x * y)) + (y * z);
	double tmp;
	if ((t_0 <= 2e-323) || !(t_0 <= 5e+307)) {
		tmp = 2.0 * ((Math.sqrt(z) * Math.sqrt(y)) + (0.5 * ((x / Math.sqrt(y)) * ((y + z) / Math.sqrt(z)))));
	} else {
		tmp = 2.0 * Math.sqrt(((y * z) + (y * (x + ((x * z) / y)))));
	}
	return tmp;
}
def code(x, y, z):
	return 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z)))
def code(x, y, z):
	t_0 = ((x * z) + (x * y)) + (y * z)
	tmp = 0
	if (t_0 <= 2e-323) or not (t_0 <= 5e+307):
		tmp = 2.0 * ((math.sqrt(z) * math.sqrt(y)) + (0.5 * ((x / math.sqrt(y)) * ((y + z) / math.sqrt(z)))))
	else:
		tmp = 2.0 * math.sqrt(((y * z) + (y * (x + ((x * z) / 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)
	t_0 = Float64(Float64(Float64(x * z) + Float64(x * y)) + Float64(y * z))
	tmp = 0.0
	if ((t_0 <= 2e-323) || !(t_0 <= 5e+307))
		tmp = Float64(2.0 * Float64(Float64(sqrt(z) * sqrt(y)) + Float64(0.5 * Float64(Float64(x / sqrt(y)) * Float64(Float64(y + z) / sqrt(z))))));
	else
		tmp = Float64(2.0 * sqrt(Float64(Float64(y * z) + Float64(y * Float64(x + Float64(Float64(x * z) / 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)
	t_0 = ((x * z) + (x * y)) + (y * z);
	tmp = 0.0;
	if ((t_0 <= 2e-323) || ~((t_0 <= 5e+307)))
		tmp = 2.0 * ((sqrt(z) * sqrt(y)) + (0.5 * ((x / sqrt(y)) * ((y + z) / sqrt(z)))));
	else
		tmp = 2.0 * sqrt(((y * z) + (y * (x + ((x * z) / 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_] := Block[{t$95$0 = N[(N[(N[(x * z), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, 2e-323], N[Not[LessEqual[t$95$0, 5e+307]], $MachinePrecision]], N[(2.0 * N[(N[(N[Sqrt[z], $MachinePrecision] * N[Sqrt[y], $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(x / N[Sqrt[y], $MachinePrecision]), $MachinePrecision] * N[(N[(y + z), $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(N[(y * z), $MachinePrecision] + N[(y * N[(x + N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\begin{array}{l}
t_0 := \left(x \cdot z + x \cdot y\right) + y \cdot z\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{-323} \lor \neg \left(t_0 \leq 5 \cdot 10^{+307}\right):\\
\;\;\;\;2 \cdot \left(\sqrt{z} \cdot \sqrt{y} + 0.5 \cdot \left(\frac{x}{\sqrt{y}} \cdot \frac{y + z}{\sqrt{z}}\right)\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original31.18%
Target17.28%
Herbie15.43%
\[\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 (+.f64 (+.f64 (*.f64 x y) (*.f64 x z)) (*.f64 y z)) < 1.97626e-323 or 5e307 < (+.f64 (+.f64 (*.f64 x y) (*.f64 x z)) (*.f64 y z))

    1. Initial program 99.16

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

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

      [Start]99.16

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

      distribute-lft-out [=>]99.16

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

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

      \[\leadsto 2 \cdot \left(\sqrt{y \cdot z} + 0.5 \cdot \color{blue}{\frac{\left(\left(y + z\right) \cdot x\right) \cdot \frac{1}{\sqrt{y}}}{\sqrt{z}}}\right) \]
    5. Simplified99.57

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

      [Start]99.61

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

      *-commutative [<=]99.61

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

      associate-*l/ [=>]99.61

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

      associate-/l/ [=>]99.61

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

      *-lft-identity [=>]99.61

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

      *-commutative [=>]99.61

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

      *-commutative [<=]99.61

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

      times-frac [=>]99.57

      \[ 2 \cdot \left(\sqrt{y \cdot z} + 0.5 \cdot \color{blue}{\left(\frac{x}{\sqrt{y}} \cdot \frac{y + z}{\sqrt{z}}\right)}\right) \]
    6. Applied egg-rr48.55

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

    if 1.97626e-323 < (+.f64 (+.f64 (*.f64 x y) (*.f64 x z)) (*.f64 y z)) < 5e307

    1. Initial program 0.47

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

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

      \[\leadsto 2 \cdot \sqrt{\frac{\color{blue}{{y}^{2} \cdot x}}{y - z} + y \cdot z} \]
    4. Simplified18.11

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

      [Start]18.11

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

      *-commutative [=>]18.11

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

      unpow2 [=>]18.11

      \[ 2 \cdot \sqrt{\frac{x \cdot \color{blue}{\left(y \cdot y\right)}}{y - z} + y \cdot z} \]
    5. Applied egg-rr2.96

      \[\leadsto 2 \cdot \sqrt{\color{blue}{\frac{x}{\frac{y - z}{y}} \cdot y} + y \cdot z} \]
    6. Taylor expanded in y around inf 0.47

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(x \cdot z + x \cdot y\right) + y \cdot z \leq 2 \cdot 10^{-323} \lor \neg \left(\left(x \cdot z + x \cdot y\right) + y \cdot z \leq 5 \cdot 10^{+307}\right):\\ \;\;\;\;2 \cdot \left(\sqrt{z} \cdot \sqrt{y} + 0.5 \cdot \left(\frac{x}{\sqrt{y}} \cdot \frac{y + z}{\sqrt{z}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot z + y \cdot \left(x + \frac{x \cdot z}{y}\right)}\\ \end{array} \]

Alternatives

Alternative 1
Error16.77%
Cost13252
\[\begin{array}{l} \mathbf{if}\;y \leq 8.2 \cdot 10^{-262}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot z + y \cdot \left(x + \frac{x \cdot z}{y}\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\sqrt{z} \cdot \sqrt{y}\right)\\ \end{array} \]
Alternative 2
Error31.18%
Cost7360
\[2 \cdot \sqrt{y \cdot z + y \cdot \left(x + \frac{x \cdot z}{y}\right)} \]
Alternative 3
Error31.23%
Cost7108
\[\begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-305}:\\ \;\;\;\;2 \cdot \sqrt{x \cdot z + x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{z \cdot \left(x + y\right)}\\ \end{array} \]
Alternative 4
Error31.18%
Cost7104
\[2 \cdot \sqrt{y \cdot z + x \cdot \left(y + z\right)} \]
Alternative 5
Error31.18%
Cost7104
\[2 \cdot \sqrt{x \cdot z + y \cdot \left(x + z\right)} \]
Alternative 6
Error32.44%
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{-287}:\\ \;\;\;\;2 \cdot \sqrt{x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{z \cdot \left(x + y\right)}\\ \end{array} \]
Alternative 7
Error31.3%
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{-287}:\\ \;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{z \cdot \left(x + y\right)}\\ \end{array} \]
Alternative 8
Error33.51%
Cost6852
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{-309}:\\ \;\;\;\;2 \cdot \sqrt{x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot z}\\ \end{array} \]
Alternative 9
Error65.4%
Cost6720
\[2 \cdot \sqrt{x \cdot y} \]

Error

Reproduce?

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