Diagrams.TwoD.Apollonian:descartes from diagrams-contrib-1.3.0.5

Percentage Accurate: 70.6% → 99.4%
Time: 15.6s
Alternatives: 13
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
double code(double x, double y, double z) {
	return 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
}
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
public static double code(double x, double y, double z) {
	return 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
}
def code(x, y, z):
	return 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z)))
function code(x, y, z)
	return Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z))))
end
function tmp = code(x, y, z)
	tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
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]
\begin{array}{l}

\\
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 13 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 70.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
double code(double x, double y, double z) {
	return 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
}
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
public static double code(double x, double y, double z) {
	return 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
}
def code(x, y, z):
	return 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z)))
function code(x, y, z)
	return Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z))))
end
function tmp = code(x, y, z)
	tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
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]
\begin{array}{l}

\\
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\end{array}

Alternative 1: 99.4% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1.1 \cdot 10^{-299}:\\ \;\;\;\;{\left(\frac{-1}{x}\right)}^{-0.5} \cdot \left({\left(\left(0 - z\right) - y\right)}^{0.5} \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{\sqrt{z}}{{\left(x + y\right)}^{-0.5}}\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.1e-299)
   (* (pow (/ -1.0 x) -0.5) (* (pow (- (- 0.0 z) y) 0.5) 2.0))
   (* 2.0 (/ (sqrt z) (pow (+ x y) -0.5)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.1e-299) {
		tmp = pow((-1.0 / x), -0.5) * (pow(((0.0 - z) - y), 0.5) * 2.0);
	} else {
		tmp = 2.0 * (sqrt(z) / pow((x + y), -0.5));
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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.1d-299)) then
        tmp = (((-1.0d0) / x) ** (-0.5d0)) * ((((0.0d0 - z) - y) ** 0.5d0) * 2.0d0)
    else
        tmp = 2.0d0 * (sqrt(z) / ((x + y) ** (-0.5d0)))
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.1e-299) {
		tmp = Math.pow((-1.0 / x), -0.5) * (Math.pow(((0.0 - z) - y), 0.5) * 2.0);
	} else {
		tmp = 2.0 * (Math.sqrt(z) / Math.pow((x + y), -0.5));
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if y <= -1.1e-299:
		tmp = math.pow((-1.0 / x), -0.5) * (math.pow(((0.0 - z) - y), 0.5) * 2.0)
	else:
		tmp = 2.0 * (math.sqrt(z) / math.pow((x + y), -0.5))
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.1e-299)
		tmp = Float64((Float64(-1.0 / x) ^ -0.5) * Float64((Float64(Float64(0.0 - z) - y) ^ 0.5) * 2.0));
	else
		tmp = Float64(2.0 * Float64(sqrt(z) / (Float64(x + y) ^ -0.5)));
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.1e-299)
		tmp = ((-1.0 / x) ^ -0.5) * ((((0.0 - z) - y) ^ 0.5) * 2.0);
	else
		tmp = 2.0 * (sqrt(z) / ((x + y) ^ -0.5));
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[y, -1.1e-299], N[(N[Power[N[(-1.0 / x), $MachinePrecision], -0.5], $MachinePrecision] * N[(N[Power[N[(N[(0.0 - z), $MachinePrecision] - y), $MachinePrecision], 0.5], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[z], $MachinePrecision] / N[Power[N[(x + y), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{-299}:\\
\;\;\;\;{\left(\frac{-1}{x}\right)}^{-0.5} \cdot \left({\left(\left(0 - z\right) - y\right)}^{0.5} \cdot 2\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.1e-299

    1. Initial program 69.1%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Applied egg-rr0

      \[\leadsto expr\]
    5. Taylor expanded in x around -inf 0

      \[\leadsto expr\]
    6. Simplified0

      \[\leadsto expr\]
    7. Applied egg-rr0

      \[\leadsto expr\]

    if -1.1e-299 < y

    1. Initial program 66.7%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in z around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
    7. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 85.2% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -6.1 \cdot 10^{-304}:\\ \;\;\;\;2 \cdot \sqrt{x \cdot \left(z + \left(\frac{z}{x} + 1\right) \cdot y\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{\sqrt{z}}{{\left(x + y\right)}^{-0.5}}\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= y -6.1e-304)
   (* 2.0 (sqrt (* x (+ z (* (+ (/ z x) 1.0) y)))))
   (* 2.0 (/ (sqrt z) (pow (+ x y) -0.5)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= -6.1e-304) {
		tmp = 2.0 * sqrt((x * (z + (((z / x) + 1.0) * y))));
	} else {
		tmp = 2.0 * (sqrt(z) / pow((x + y), -0.5));
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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 <= (-6.1d-304)) then
        tmp = 2.0d0 * sqrt((x * (z + (((z / x) + 1.0d0) * y))))
    else
        tmp = 2.0d0 * (sqrt(z) / ((x + y) ** (-0.5d0)))
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -6.1e-304) {
		tmp = 2.0 * Math.sqrt((x * (z + (((z / x) + 1.0) * y))));
	} else {
		tmp = 2.0 * (Math.sqrt(z) / Math.pow((x + y), -0.5));
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if y <= -6.1e-304:
		tmp = 2.0 * math.sqrt((x * (z + (((z / x) + 1.0) * y))))
	else:
		tmp = 2.0 * (math.sqrt(z) / math.pow((x + y), -0.5))
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= -6.1e-304)
		tmp = Float64(2.0 * sqrt(Float64(x * Float64(z + Float64(Float64(Float64(z / x) + 1.0) * y)))));
	else
		tmp = Float64(2.0 * Float64(sqrt(z) / (Float64(x + y) ^ -0.5)));
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -6.1e-304)
		tmp = 2.0 * sqrt((x * (z + (((z / x) + 1.0) * y))));
	else
		tmp = 2.0 * (sqrt(z) / ((x + y) ^ -0.5));
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[y, -6.1e-304], N[(2.0 * N[Sqrt[N[(x * N[(z + N[(N[(N[(z / x), $MachinePrecision] + 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[z], $MachinePrecision] / N[Power[N[(x + y), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.1 \cdot 10^{-304}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(z + \left(\frac{z}{x} + 1\right) \cdot y\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.1000000000000004e-304

    1. Initial program 69.1%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]

    if -6.1000000000000004e-304 < y

    1. Initial program 66.7%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in z around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
    7. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 85.2% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -2.32 \cdot 10^{-290}:\\ \;\;\;\;2 \cdot \sqrt{x \cdot \left(z + \left(\frac{z}{x} + 1\right) \cdot y\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \sqrt{z}\right) \cdot \sqrt{x + y}\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= y -2.32e-290)
   (* 2.0 (sqrt (* x (+ z (* (+ (/ z x) 1.0) y)))))
   (* (* 2.0 (sqrt z)) (sqrt (+ x y)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2.32e-290) {
		tmp = 2.0 * sqrt((x * (z + (((z / x) + 1.0) * y))));
	} else {
		tmp = (2.0 * sqrt(z)) * sqrt((x + y));
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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 <= (-2.32d-290)) then
        tmp = 2.0d0 * sqrt((x * (z + (((z / x) + 1.0d0) * y))))
    else
        tmp = (2.0d0 * sqrt(z)) * sqrt((x + y))
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -2.32e-290) {
		tmp = 2.0 * Math.sqrt((x * (z + (((z / x) + 1.0) * y))));
	} else {
		tmp = (2.0 * Math.sqrt(z)) * Math.sqrt((x + y));
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if y <= -2.32e-290:
		tmp = 2.0 * math.sqrt((x * (z + (((z / x) + 1.0) * y))))
	else:
		tmp = (2.0 * math.sqrt(z)) * math.sqrt((x + y))
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= -2.32e-290)
		tmp = Float64(2.0 * sqrt(Float64(x * Float64(z + Float64(Float64(Float64(z / x) + 1.0) * y)))));
	else
		tmp = Float64(Float64(2.0 * sqrt(z)) * sqrt(Float64(x + y)));
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -2.32e-290)
		tmp = 2.0 * sqrt((x * (z + (((z / x) + 1.0) * y))));
	else
		tmp = (2.0 * sqrt(z)) * sqrt((x + y));
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[y, -2.32e-290], N[(2.0 * N[Sqrt[N[(x * N[(z + N[(N[(N[(z / x), $MachinePrecision] + 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Sqrt[z], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(x + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.32 \cdot 10^{-290}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(z + \left(\frac{z}{x} + 1\right) \cdot y\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.32000000000000001e-290

    1. Initial program 68.6%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]

    if -2.32000000000000001e-290 < y

    1. Initial program 67.2%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in z around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 83.4% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 7.2 \cdot 10^{+22}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot \left(z + x\right) + x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{\sqrt{z}}{\sqrt{\frac{1}{y}}}\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= y 7.2e+22)
   (* 2.0 (sqrt (+ (* y (+ z x)) (* x z))))
   (* 2.0 (/ (sqrt z) (sqrt (/ 1.0 y))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= 7.2e+22) {
		tmp = 2.0 * sqrt(((y * (z + x)) + (x * z)));
	} else {
		tmp = 2.0 * (sqrt(z) / sqrt((1.0 / y)));
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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 <= 7.2d+22) then
        tmp = 2.0d0 * sqrt(((y * (z + x)) + (x * z)))
    else
        tmp = 2.0d0 * (sqrt(z) / sqrt((1.0d0 / y)))
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 7.2e+22) {
		tmp = 2.0 * Math.sqrt(((y * (z + x)) + (x * z)));
	} else {
		tmp = 2.0 * (Math.sqrt(z) / Math.sqrt((1.0 / y)));
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if y <= 7.2e+22:
		tmp = 2.0 * math.sqrt(((y * (z + x)) + (x * z)))
	else:
		tmp = 2.0 * (math.sqrt(z) / math.sqrt((1.0 / y)))
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= 7.2e+22)
		tmp = Float64(2.0 * sqrt(Float64(Float64(y * Float64(z + x)) + Float64(x * z))));
	else
		tmp = Float64(2.0 * Float64(sqrt(z) / sqrt(Float64(1.0 / y))));
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 7.2e+22)
		tmp = 2.0 * sqrt(((y * (z + x)) + (x * z)));
	else
		tmp = 2.0 * (sqrt(z) / sqrt((1.0 / y)));
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[y, 7.2e+22], N[(2.0 * N[Sqrt[N[(N[(y * N[(z + x), $MachinePrecision]), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[z], $MachinePrecision] / N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.2 \cdot 10^{+22}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot \left(z + x\right) + x \cdot z}\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \frac{\sqrt{z}}{\sqrt{\frac{1}{y}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 7.2e22

    1. Initial program 74.6%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Applied egg-rr0

      \[\leadsto expr\]

    if 7.2e22 < y

    1. Initial program 46.3%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in z around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
    7. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    8. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 82.9% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 1.35 \cdot 10^{-160}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot \left(z + x\right) + x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{y}}{{z}^{-0.5}} \cdot 2\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= y 1.35e-160)
   (* 2.0 (sqrt (+ (* y (+ z x)) (* x z))))
   (* (/ (sqrt y) (pow z -0.5)) 2.0)))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= 1.35e-160) {
		tmp = 2.0 * sqrt(((y * (z + x)) + (x * z)));
	} else {
		tmp = (sqrt(y) / pow(z, -0.5)) * 2.0;
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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.35d-160) then
        tmp = 2.0d0 * sqrt(((y * (z + x)) + (x * z)))
    else
        tmp = (sqrt(y) / (z ** (-0.5d0))) * 2.0d0
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 1.35e-160) {
		tmp = 2.0 * Math.sqrt(((y * (z + x)) + (x * z)));
	} else {
		tmp = (Math.sqrt(y) / Math.pow(z, -0.5)) * 2.0;
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if y <= 1.35e-160:
		tmp = 2.0 * math.sqrt(((y * (z + x)) + (x * z)))
	else:
		tmp = (math.sqrt(y) / math.pow(z, -0.5)) * 2.0
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= 1.35e-160)
		tmp = Float64(2.0 * sqrt(Float64(Float64(y * Float64(z + x)) + Float64(x * z))));
	else
		tmp = Float64(Float64(sqrt(y) / (z ^ -0.5)) * 2.0);
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 1.35e-160)
		tmp = 2.0 * sqrt(((y * (z + x)) + (x * z)));
	else
		tmp = (sqrt(y) / (z ^ -0.5)) * 2.0;
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[y, 1.35e-160], N[(2.0 * N[Sqrt[N[(N[(y * N[(z + x), $MachinePrecision]), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[y], $MachinePrecision] / N[Power[z, -0.5], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{-160}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot \left(z + x\right) + x \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{y}}{{z}^{-0.5}} \cdot 2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.35000000000000005e-160

    1. Initial program 73.2%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Applied egg-rr0

      \[\leadsto expr\]

    if 1.35000000000000005e-160 < y

    1. Initial program 59.1%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Applied egg-rr0

      \[\leadsto expr\]
    5. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    6. Simplified0

      \[\leadsto expr\]
    7. Applied egg-rr0

      \[\leadsto expr\]
    8. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 83.1% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 9 \cdot 10^{+50}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot \left(z + x\right) + x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\sqrt{z} \cdot \sqrt{y}\right)\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= y 9e+50)
   (* 2.0 (sqrt (+ (* y (+ z x)) (* x z))))
   (* 2.0 (* (sqrt z) (sqrt y)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= 9e+50) {
		tmp = 2.0 * sqrt(((y * (z + x)) + (x * z)));
	} else {
		tmp = 2.0 * (sqrt(z) * sqrt(y));
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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 <= 9d+50) then
        tmp = 2.0d0 * sqrt(((y * (z + x)) + (x * z)))
    else
        tmp = 2.0d0 * (sqrt(z) * sqrt(y))
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 9e+50) {
		tmp = 2.0 * Math.sqrt(((y * (z + x)) + (x * z)));
	} else {
		tmp = 2.0 * (Math.sqrt(z) * Math.sqrt(y));
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if y <= 9e+50:
		tmp = 2.0 * math.sqrt(((y * (z + x)) + (x * z)))
	else:
		tmp = 2.0 * (math.sqrt(z) * math.sqrt(y))
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= 9e+50)
		tmp = Float64(2.0 * sqrt(Float64(Float64(y * Float64(z + x)) + Float64(x * z))));
	else
		tmp = Float64(2.0 * Float64(sqrt(z) * sqrt(y)));
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 9e+50)
		tmp = 2.0 * sqrt(((y * (z + x)) + (x * z)));
	else
		tmp = 2.0 * (sqrt(z) * sqrt(y));
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[y, 9e+50], N[(2.0 * N[Sqrt[N[(N[(y * N[(z + x), $MachinePrecision]), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[z], $MachinePrecision] * N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{+50}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot \left(z + x\right) + x \cdot z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 9.00000000000000027e50

    1. Initial program 75.3%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Applied egg-rr0

      \[\leadsto expr\]

    if 9.00000000000000027e50 < y

    1. Initial program 40.4%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Applied egg-rr0

      \[\leadsto expr\]
    5. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    6. Simplified0

      \[\leadsto expr\]
    7. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 71.4% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{-307}:\\ \;\;\;\;2 \cdot {\left(\frac{\frac{1}{z + y}}{x}\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{z \cdot \left(y + x\right)}\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= y -1e-307)
   (* 2.0 (pow (/ (/ 1.0 (+ z y)) x) -0.5))
   (* 2.0 (sqrt (* z (+ y x))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1e-307) {
		tmp = 2.0 * pow(((1.0 / (z + y)) / x), -0.5);
	} else {
		tmp = 2.0 * sqrt((z * (y + x)));
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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 <= (-1d-307)) then
        tmp = 2.0d0 * (((1.0d0 / (z + y)) / x) ** (-0.5d0))
    else
        tmp = 2.0d0 * sqrt((z * (y + x)))
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1e-307) {
		tmp = 2.0 * Math.pow(((1.0 / (z + y)) / x), -0.5);
	} else {
		tmp = 2.0 * Math.sqrt((z * (y + x)));
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if y <= -1e-307:
		tmp = 2.0 * math.pow(((1.0 / (z + y)) / x), -0.5)
	else:
		tmp = 2.0 * math.sqrt((z * (y + x)))
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= -1e-307)
		tmp = Float64(2.0 * (Float64(Float64(1.0 / Float64(z + y)) / x) ^ -0.5));
	else
		tmp = Float64(2.0 * sqrt(Float64(z * Float64(y + x))));
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1e-307)
		tmp = 2.0 * (((1.0 / (z + y)) / x) ^ -0.5);
	else
		tmp = 2.0 * sqrt((z * (y + x)));
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[y, -1e-307], N[(2.0 * N[Power[N[(N[(1.0 / N[(z + y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{-307}:\\
\;\;\;\;2 \cdot {\left(\frac{\frac{1}{z + y}}{x}\right)}^{-0.5}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -9.99999999999999909e-308

    1. Initial program 69.4%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Applied egg-rr0

      \[\leadsto expr\]
    5. Taylor expanded in x around -inf 0

      \[\leadsto expr\]
    6. Simplified0

      \[\leadsto expr\]
    7. Applied egg-rr0

      \[\leadsto expr\]

    if -9.99999999999999909e-308 < y

    1. Initial program 66.4%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in z around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 70.8% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -4 \cdot 10^{-293}:\\ \;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{z \cdot \left(y + x\right)}\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= y -4e-293) (* 2.0 (sqrt (* x (+ y z)))) (* 2.0 (sqrt (* z (+ y x))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= -4e-293) {
		tmp = 2.0 * sqrt((x * (y + z)));
	} else {
		tmp = 2.0 * sqrt((z * (y + x)));
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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 <= (-4d-293)) then
        tmp = 2.0d0 * sqrt((x * (y + z)))
    else
        tmp = 2.0d0 * sqrt((z * (y + x)))
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -4e-293) {
		tmp = 2.0 * Math.sqrt((x * (y + z)));
	} else {
		tmp = 2.0 * Math.sqrt((z * (y + x)));
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if y <= -4e-293:
		tmp = 2.0 * math.sqrt((x * (y + z)))
	else:
		tmp = 2.0 * math.sqrt((z * (y + x)))
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= -4e-293)
		tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z))));
	else
		tmp = Float64(2.0 * sqrt(Float64(z * Float64(y + x))));
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -4e-293)
		tmp = 2.0 * sqrt((x * (y + z)));
	else
		tmp = 2.0 * sqrt((z * (y + x)));
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[y, -4e-293], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{-293}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.0000000000000002e-293

    1. Initial program 68.6%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]

    if -4.0000000000000002e-293 < y

    1. Initial program 67.2%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in z around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 69.7% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 2.15 \cdot 10^{-285}:\\ \;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{y \cdot z} \cdot 2\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= y 2.15e-285) (* 2.0 (sqrt (* x (+ y z)))) (* (sqrt (* y z)) 2.0)))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= 2.15e-285) {
		tmp = 2.0 * sqrt((x * (y + z)));
	} else {
		tmp = sqrt((y * z)) * 2.0;
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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 <= 2.15d-285) then
        tmp = 2.0d0 * sqrt((x * (y + z)))
    else
        tmp = sqrt((y * z)) * 2.0d0
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 2.15e-285) {
		tmp = 2.0 * Math.sqrt((x * (y + z)));
	} else {
		tmp = Math.sqrt((y * z)) * 2.0;
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if y <= 2.15e-285:
		tmp = 2.0 * math.sqrt((x * (y + z)))
	else:
		tmp = math.sqrt((y * z)) * 2.0
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= 2.15e-285)
		tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z))));
	else
		tmp = Float64(sqrt(Float64(y * z)) * 2.0);
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 2.15e-285)
		tmp = 2.0 * sqrt((x * (y + z)));
	else
		tmp = sqrt((y * z)) * 2.0;
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[y, 2.15e-285], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(y * z), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.15 \cdot 10^{-285}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{y \cdot z} \cdot 2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 2.15000000000000006e-285

    1. Initial program 69.9%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]

    if 2.15000000000000006e-285 < y

    1. Initial program 65.7%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 68.5% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-310}:\\ \;\;\;\;2 \cdot {\left(x \cdot y\right)}^{0.5}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{y \cdot z} \cdot 2\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= y -2e-310) (* 2.0 (pow (* x y) 0.5)) (* (sqrt (* y z)) 2.0)))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2e-310) {
		tmp = 2.0 * pow((x * y), 0.5);
	} else {
		tmp = sqrt((y * z)) * 2.0;
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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 * ((x * y) ** 0.5d0)
    else
        tmp = sqrt((y * z)) * 2.0d0
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -2e-310) {
		tmp = 2.0 * Math.pow((x * y), 0.5);
	} else {
		tmp = Math.sqrt((y * z)) * 2.0;
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if y <= -2e-310:
		tmp = 2.0 * math.pow((x * y), 0.5)
	else:
		tmp = math.sqrt((y * z)) * 2.0
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= -2e-310)
		tmp = Float64(2.0 * (Float64(x * y) ^ 0.5));
	else
		tmp = Float64(sqrt(Float64(y * z)) * 2.0);
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -2e-310)
		tmp = 2.0 * ((x * y) ^ 0.5);
	else
		tmp = sqrt((y * z)) * 2.0;
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[y, -2e-310], N[(2.0 * N[Power[N[(x * y), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(y * z), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-310}:\\
\;\;\;\;2 \cdot {\left(x \cdot y\right)}^{0.5}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{y \cdot z} \cdot 2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.999999999999994e-310

    1. Initial program 69.4%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in z around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]

    if -1.999999999999994e-310 < y

    1. Initial program 66.4%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 70.7% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ 2 \cdot \sqrt{x \cdot y + z \cdot \left(x + y\right)} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z) :precision binary64 (* 2.0 (sqrt (+ (* x y) (* z (+ x y))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	return 2.0 * sqrt(((x * y) + (z * (x + y))));
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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) + (z * (x + y))))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	return 2.0 * Math.sqrt(((x * y) + (z * (x + y))));
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	return 2.0 * math.sqrt(((x * y) + (z * (x + y))))
x, y, z = sort([x, y, z])
function code(x, y, z)
	return Float64(2.0 * sqrt(Float64(Float64(x * y) + Float64(z * Float64(x + y)))))
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
	tmp = 2.0 * sqrt(((x * y) + (z * (x + y))));
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(N[(x * y), $MachinePrecision] + N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
2 \cdot \sqrt{x \cdot y + z \cdot \left(x + y\right)}
\end{array}
Derivation
  1. Initial program 67.9%

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Add Preprocessing

Alternative 12: 68.5% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-310}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{y \cdot z} \cdot 2\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= y -2e-310) (* 2.0 (sqrt (* y x))) (* (sqrt (* y z)) 2.0)))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2e-310) {
		tmp = 2.0 * sqrt((y * x));
	} else {
		tmp = sqrt((y * z)) * 2.0;
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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((y * x))
    else
        tmp = sqrt((y * z)) * 2.0d0
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -2e-310) {
		tmp = 2.0 * Math.sqrt((y * x));
	} else {
		tmp = Math.sqrt((y * z)) * 2.0;
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if y <= -2e-310:
		tmp = 2.0 * math.sqrt((y * x))
	else:
		tmp = math.sqrt((y * z)) * 2.0
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= -2e-310)
		tmp = Float64(2.0 * sqrt(Float64(y * x)));
	else
		tmp = Float64(sqrt(Float64(y * z)) * 2.0);
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -2e-310)
		tmp = 2.0 * sqrt((y * x));
	else
		tmp = sqrt((y * z)) * 2.0;
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[y, -2e-310], N[(2.0 * N[Sqrt[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(y * z), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-310}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot x}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{y \cdot z} \cdot 2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.999999999999994e-310

    1. Initial program 69.4%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in z around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]

    if -1.999999999999994e-310 < y

    1. Initial program 66.4%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 13: 36.4% accurate, 1.1× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ 2 \cdot \sqrt{y \cdot x} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z) :precision binary64 (* 2.0 (sqrt (* y x))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	return 2.0 * sqrt((y * x));
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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((y * x))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	return 2.0 * Math.sqrt((y * x));
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	return 2.0 * math.sqrt((y * x))
x, y, z = sort([x, y, z])
function code(x, y, z)
	return Float64(2.0 * sqrt(Float64(y * x)))
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
	tmp = 2.0 * sqrt((y * x));
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
2 \cdot \sqrt{y \cdot x}
\end{array}
Derivation
  1. Initial program 67.9%

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Taylor expanded in z around 0 0

    \[\leadsto expr\]
  5. Simplified0

    \[\leadsto expr\]
  6. Add Preprocessing

Developer target: 82.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 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}\\ \mathbf{if}\;z < 7.636950090573675 \cdot 10^{+176}:\\ \;\;\;\;2 \cdot \sqrt{\left(x + y\right) \cdot z + x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\left(t\_0 \cdot t\_0\right) \cdot 2\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0
         (+
          (* 0.25 (* (* (pow y -0.75) (* (pow z -0.75) x)) (+ y z)))
          (* (pow z 0.25) (pow y 0.25)))))
   (if (< z 7.636950090573675e+176)
     (* 2.0 (sqrt (+ (* (+ x y) z) (* x y))))
     (* (* t_0 t_0) 2.0))))
double code(double x, double y, double z) {
	double t_0 = (0.25 * ((pow(y, -0.75) * (pow(z, -0.75) * x)) * (y + z))) + (pow(z, 0.25) * pow(y, 0.25));
	double tmp;
	if (z < 7.636950090573675e+176) {
		tmp = 2.0 * sqrt((((x + y) * z) + (x * y)));
	} else {
		tmp = (t_0 * t_0) * 2.0;
	}
	return tmp;
}
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 = (0.25d0 * (((y ** (-0.75d0)) * ((z ** (-0.75d0)) * x)) * (y + z))) + ((z ** 0.25d0) * (y ** 0.25d0))
    if (z < 7.636950090573675d+176) then
        tmp = 2.0d0 * sqrt((((x + y) * z) + (x * y)))
    else
        tmp = (t_0 * t_0) * 2.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (0.25 * ((Math.pow(y, -0.75) * (Math.pow(z, -0.75) * x)) * (y + z))) + (Math.pow(z, 0.25) * Math.pow(y, 0.25));
	double tmp;
	if (z < 7.636950090573675e+176) {
		tmp = 2.0 * Math.sqrt((((x + y) * z) + (x * y)));
	} else {
		tmp = (t_0 * t_0) * 2.0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (0.25 * ((math.pow(y, -0.75) * (math.pow(z, -0.75) * x)) * (y + z))) + (math.pow(z, 0.25) * math.pow(y, 0.25))
	tmp = 0
	if z < 7.636950090573675e+176:
		tmp = 2.0 * math.sqrt((((x + y) * z) + (x * y)))
	else:
		tmp = (t_0 * t_0) * 2.0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(0.25 * Float64(Float64((y ^ -0.75) * Float64((z ^ -0.75) * x)) * Float64(y + z))) + Float64((z ^ 0.25) * (y ^ 0.25)))
	tmp = 0.0
	if (z < 7.636950090573675e+176)
		tmp = Float64(2.0 * sqrt(Float64(Float64(Float64(x + y) * z) + Float64(x * y))));
	else
		tmp = Float64(Float64(t_0 * t_0) * 2.0);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (0.25 * (((y ^ -0.75) * ((z ^ -0.75) * x)) * (y + z))) + ((z ^ 0.25) * (y ^ 0.25));
	tmp = 0.0;
	if (z < 7.636950090573675e+176)
		tmp = 2.0 * sqrt((((x + y) * z) + (x * y)));
	else
		tmp = (t_0 * t_0) * 2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(0.25 * N[(N[(N[Power[y, -0.75], $MachinePrecision] * N[(N[Power[z, -0.75], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[z, 0.25], $MachinePrecision] * N[Power[y, 0.25], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[z, 7.636950090573675e+176], N[(2.0 * N[Sqrt[N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 2.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 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}\\
\mathbf{if}\;z < 7.636950090573675 \cdot 10^{+176}:\\
\;\;\;\;2 \cdot \sqrt{\left(x + y\right) \cdot z + x \cdot y}\\

\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot t\_0\right) \cdot 2\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024110 
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:descartes from diagrams-contrib-1.3.0.5"
  :precision binary64

  :alt
  (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)))))