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

Percentage Accurate: 69.7% → 94.9%
Time: 5.3s
Alternatives: 12
Speedup: 1.1×

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)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z)
use fmin_fmax_functions
    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}

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 12 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: 69.7% 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)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z)
use fmin_fmax_functions
    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: 94.9% accurate, 0.4× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 2.55 \cdot 10^{-300}:\\ \;\;\;\;2 \cdot e^{\left(\log \left(\mathsf{fma}\left(-1, y, -1 \cdot z\right)\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z\\ \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.55e-300)
   (*
    2.0
    (exp (* (+ (log (fma -1.0 y (* -1.0 z))) (* -1.0 (log (/ -1.0 x)))) 0.5)))
   (* (* 2.0 (/ (sqrt (+ x y)) (sqrt z))) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= 2.55e-300) {
		tmp = 2.0 * exp(((log(fma(-1.0, y, (-1.0 * z))) + (-1.0 * log((-1.0 / x)))) * 0.5));
	} else {
		tmp = (2.0 * (sqrt((x + y)) / sqrt(z))) * z;
	}
	return tmp;
}
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= 2.55e-300)
		tmp = Float64(2.0 * exp(Float64(Float64(log(fma(-1.0, y, Float64(-1.0 * z))) + Float64(-1.0 * log(Float64(-1.0 / x)))) * 0.5)));
	else
		tmp = Float64(Float64(2.0 * Float64(sqrt(Float64(x + y)) / sqrt(z))) * z);
	end
	return 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.55e-300], N[(2.0 * N[Exp[N[(N[(N[Log[N[(-1.0 * y + N[(-1.0 * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-1.0 * N[Log[N[(-1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[(N[Sqrt[N[(x + y), $MachinePrecision]], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.55 \cdot 10^{-300}:\\
\;\;\;\;2 \cdot e^{\left(\log \left(\mathsf{fma}\left(-1, y, -1 \cdot z\right)\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \cdot 0.5}\\

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


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

    1. Initial program 68.4%

      \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
    2. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto 2 \cdot \color{blue}{\sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}} \]
      2. lift-*.f64N/A

        \[\leadsto 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + \color{blue}{y \cdot z}} \]
      3. lift-+.f64N/A

        \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right) + y \cdot z}} \]
      4. lift-*.f64N/A

        \[\leadsto 2 \cdot \sqrt{\left(\color{blue}{x \cdot y} + x \cdot z\right) + y \cdot z} \]
      5. lift-*.f64N/A

        \[\leadsto 2 \cdot \sqrt{\left(x \cdot y + \color{blue}{x \cdot z}\right) + y \cdot z} \]
      6. lift-+.f64N/A

        \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right)} + y \cdot z} \]
      7. pow1/2N/A

        \[\leadsto 2 \cdot \color{blue}{{\left(\left(x \cdot y + x \cdot z\right) + y \cdot z\right)}^{\frac{1}{2}}} \]
      8. pow-to-expN/A

        \[\leadsto 2 \cdot \color{blue}{e^{\log \left(\left(x \cdot y + x \cdot z\right) + y \cdot z\right) \cdot \frac{1}{2}}} \]
      9. lower-exp.f64N/A

        \[\leadsto 2 \cdot \color{blue}{e^{\log \left(\left(x \cdot y + x \cdot z\right) + y \cdot z\right) \cdot \frac{1}{2}}} \]
      10. lower-*.f64N/A

        \[\leadsto 2 \cdot e^{\color{blue}{\log \left(\left(x \cdot y + x \cdot z\right) + y \cdot z\right) \cdot \frac{1}{2}}} \]
    3. Applied rewrites63.8%

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

      \[\leadsto 2 \cdot e^{\color{blue}{\left(\log \left(-1 \cdot y + -1 \cdot z\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right)} \cdot \frac{1}{2}} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

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

        \[\leadsto 2 \cdot e^{\left(\log \left(-1 \cdot y + -1 \cdot z\right) + \color{blue}{-1} \cdot \log \left(\frac{-1}{x}\right)\right) \cdot \frac{1}{2}} \]
      3. lower-fma.f64N/A

        \[\leadsto 2 \cdot e^{\left(\log \left(\mathsf{fma}\left(-1, y, -1 \cdot z\right)\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \cdot \frac{1}{2}} \]
      4. lower-*.f64N/A

        \[\leadsto 2 \cdot e^{\left(\log \left(\mathsf{fma}\left(-1, y, -1 \cdot z\right)\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \cdot \frac{1}{2}} \]
      5. lower-*.f64N/A

        \[\leadsto 2 \cdot e^{\left(\log \left(\mathsf{fma}\left(-1, y, -1 \cdot z\right)\right) + -1 \cdot \color{blue}{\log \left(\frac{-1}{x}\right)}\right) \cdot \frac{1}{2}} \]
      6. lower-log.f64N/A

        \[\leadsto 2 \cdot e^{\left(\log \left(\mathsf{fma}\left(-1, y, -1 \cdot z\right)\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \cdot \frac{1}{2}} \]
      7. lower-/.f6490.5

        \[\leadsto 2 \cdot e^{\left(\log \left(\mathsf{fma}\left(-1, y, -1 \cdot z\right)\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \cdot 0.5} \]
    6. Applied rewrites90.5%

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

    if 2.55e-300 < y

    1. Initial program 71.0%

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

      \[\leadsto \color{blue}{z \cdot \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right)} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right) \cdot \color{blue}{z} \]
      2. lower-*.f64N/A

        \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right) \cdot \color{blue}{z} \]
    4. Applied rewrites78.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot x, \sqrt{\frac{1}{\left(y + x\right) \cdot \left(\left(z \cdot z\right) \cdot z\right)}}, \sqrt{\frac{y + x}{z}} \cdot 2\right) \cdot z} \]
    5. Taylor expanded in z around inf

      \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
      2. lower-sqrt.f64N/A

        \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
      3. lower-/.f64N/A

        \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
      4. lower-+.f6488.4

        \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
    7. Applied rewrites88.4%

      \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
    8. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
      2. lift-+.f64N/A

        \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
      3. lift-/.f64N/A

        \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
      4. sqrt-divN/A

        \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
      5. lower-/.f64N/A

        \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
      6. lower-sqrt.f64N/A

        \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
      7. lift-+.f64N/A

        \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
      8. lower-sqrt.f6499.3

        \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
    9. Applied rewrites99.3%

      \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 83.5% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 3.1 \cdot 10^{-283}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(x, z, y \cdot x\right)} \cdot 2\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z\\ \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 3.1e-283)
   (* (sqrt (fma x z (* y x))) 2.0)
   (* (* 2.0 (/ (sqrt (+ x y)) (sqrt z))) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= 3.1e-283) {
		tmp = sqrt(fma(x, z, (y * x))) * 2.0;
	} else {
		tmp = (2.0 * (sqrt((x + y)) / sqrt(z))) * z;
	}
	return tmp;
}
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= 3.1e-283)
		tmp = Float64(sqrt(fma(x, z, Float64(y * x))) * 2.0);
	else
		tmp = Float64(Float64(2.0 * Float64(sqrt(Float64(x + y)) / sqrt(z))) * z);
	end
	return tmp
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[y, 3.1e-283], N[(N[Sqrt[N[(x * z + N[(y * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], N[(N[(2.0 * N[(N[Sqrt[N[(x + y), $MachinePrecision]], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.1 \cdot 10^{-283}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(x, z, y \cdot x\right)} \cdot 2\\

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


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

    1. Initial program 68.3%

      \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}} \]
      2. lift-sqrt.f64N/A

        \[\leadsto 2 \cdot \color{blue}{\sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}} \]
      3. lift-*.f64N/A

        \[\leadsto 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + \color{blue}{y \cdot z}} \]
      4. lift-+.f64N/A

        \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right) + y \cdot z}} \]
      5. lift-*.f64N/A

        \[\leadsto 2 \cdot \sqrt{\left(\color{blue}{x \cdot y} + x \cdot z\right) + y \cdot z} \]
      6. lift-*.f64N/A

        \[\leadsto 2 \cdot \sqrt{\left(x \cdot y + \color{blue}{x \cdot z}\right) + y \cdot z} \]
      7. lift-+.f64N/A

        \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right)} + y \cdot z} \]
      8. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \cdot 2} \]
      9. lower-*.f64N/A

        \[\leadsto \color{blue}{\sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \cdot 2} \]
    3. Applied rewrites68.5%

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

      \[\leadsto \sqrt{\mathsf{fma}\left(\color{blue}{x}, z, y \cdot x\right)} \cdot 2 \]
    5. Step-by-step derivation
      1. Applied rewrites68.2%

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

      if 3.10000000000000004e-283 < y

      1. Initial program 71.1%

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

        \[\leadsto \color{blue}{z \cdot \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right)} \]
      3. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right) \cdot \color{blue}{z} \]
        2. lower-*.f64N/A

          \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right) \cdot \color{blue}{z} \]
      4. Applied rewrites79.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot x, \sqrt{\frac{1}{\left(y + x\right) \cdot \left(\left(z \cdot z\right) \cdot z\right)}}, \sqrt{\frac{y + x}{z}} \cdot 2\right) \cdot z} \]
      5. Taylor expanded in z around inf

        \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
      6. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
        2. lower-sqrt.f64N/A

          \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
        3. lower-/.f64N/A

          \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
        4. lower-+.f6488.6

          \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
      7. Applied rewrites88.6%

        \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
      8. Step-by-step derivation
        1. lift-sqrt.f64N/A

          \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
        2. lift-+.f64N/A

          \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
        3. lift-/.f64N/A

          \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
        4. sqrt-divN/A

          \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
        5. lower-/.f64N/A

          \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
        6. lower-sqrt.f64N/A

          \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
        7. lift-+.f64N/A

          \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
        8. lower-sqrt.f6499.3

          \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
      9. Applied rewrites99.3%

        \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
    6. Recombined 2 regimes into one program.
    7. Add Preprocessing

    Alternative 3: 82.2% accurate, 1.0× speedup?

    \[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 4.1 \cdot 10^{+61}:\\ \;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(z, y, \left(z + y\right) \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z\\ \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 4.1e+61)
       (* 2.0 (sqrt (fma z y (* (+ z y) x))))
       (* (* 2.0 (sqrt (/ (+ x y) z))) z)))
    assert(x < y && y < z);
    double code(double x, double y, double z) {
    	double tmp;
    	if (y <= 4.1e+61) {
    		tmp = 2.0 * sqrt(fma(z, y, ((z + y) * x)));
    	} else {
    		tmp = (2.0 * sqrt(((x + y) / z))) * z;
    	}
    	return tmp;
    }
    
    x, y, z = sort([x, y, z])
    function code(x, y, z)
    	tmp = 0.0
    	if (y <= 4.1e+61)
    		tmp = Float64(2.0 * sqrt(fma(z, y, Float64(Float64(z + y) * x))));
    	else
    		tmp = Float64(Float64(2.0 * sqrt(Float64(Float64(x + y) / z))) * z);
    	end
    	return tmp
    end
    
    NOTE: x, y, and z should be sorted in increasing order before calling this function.
    code[x_, y_, z_] := If[LessEqual[y, 4.1e+61], N[(2.0 * N[Sqrt[N[(z * y + N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Sqrt[N[(N[(x + y), $MachinePrecision] / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
    
    \begin{array}{l}
    [x, y, z] = \mathsf{sort}([x, y, z])\\
    \\
    \begin{array}{l}
    \mathbf{if}\;y \leq 4.1 \cdot 10^{+61}:\\
    \;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(z, y, \left(z + y\right) \cdot x\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < 4.09999999999999972e61

      1. Initial program 78.1%

        \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
      2. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + \color{blue}{y \cdot z}} \]
        2. lift-+.f64N/A

          \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right) + y \cdot z}} \]
        3. lift-*.f64N/A

          \[\leadsto 2 \cdot \sqrt{\left(\color{blue}{x \cdot y} + x \cdot z\right) + y \cdot z} \]
        4. lift-*.f64N/A

          \[\leadsto 2 \cdot \sqrt{\left(x \cdot y + \color{blue}{x \cdot z}\right) + y \cdot z} \]
        5. lift-+.f64N/A

          \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right)} + y \cdot z} \]
        6. +-commutativeN/A

          \[\leadsto 2 \cdot \sqrt{\color{blue}{y \cdot z + \left(x \cdot y + x \cdot z\right)}} \]
        7. *-commutativeN/A

          \[\leadsto 2 \cdot \sqrt{\color{blue}{z \cdot y} + \left(x \cdot y + x \cdot z\right)} \]
        8. lower-fma.f64N/A

          \[\leadsto 2 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(z, y, x \cdot y + x \cdot z\right)}} \]
        9. distribute-lft-inN/A

          \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{x \cdot \left(y + z\right)}\right)} \]
        10. *-commutativeN/A

          \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{\left(y + z\right) \cdot x}\right)} \]
        11. lower-*.f64N/A

          \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{\left(y + z\right) \cdot x}\right)} \]
        12. +-commutativeN/A

          \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{\left(z + y\right)} \cdot x\right)} \]
        13. lower-+.f6478.2

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

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

      if 4.09999999999999972e61 < y

      1. Initial program 28.9%

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

        \[\leadsto \color{blue}{z \cdot \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right)} \]
      3. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right) \cdot \color{blue}{z} \]
        2. lower-*.f64N/A

          \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right) \cdot \color{blue}{z} \]
      4. Applied rewrites90.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot x, \sqrt{\frac{1}{\left(y + x\right) \cdot \left(\left(z \cdot z\right) \cdot z\right)}}, \sqrt{\frac{y + x}{z}} \cdot 2\right) \cdot z} \]
      5. Taylor expanded in z around inf

        \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
      6. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
        2. lower-sqrt.f64N/A

          \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
        3. lower-/.f64N/A

          \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
        4. lower-+.f6499.5

          \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
      7. Applied rewrites99.5%

        \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 4: 81.8% accurate, 0.9× speedup?

    \[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{-267}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(x, z, y \cdot x\right)} \cdot 2\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{+61}:\\ \;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(z, y, z \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z\\ \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.8e-267)
       (* (sqrt (fma x z (* y x))) 2.0)
       (if (<= y 4.1e+61)
         (* 2.0 (sqrt (fma z y (* z x))))
         (* (* 2.0 (sqrt (/ y z))) z))))
    assert(x < y && y < z);
    double code(double x, double y, double z) {
    	double tmp;
    	if (y <= -1.8e-267) {
    		tmp = sqrt(fma(x, z, (y * x))) * 2.0;
    	} else if (y <= 4.1e+61) {
    		tmp = 2.0 * sqrt(fma(z, y, (z * x)));
    	} else {
    		tmp = (2.0 * sqrt((y / z))) * z;
    	}
    	return tmp;
    }
    
    x, y, z = sort([x, y, z])
    function code(x, y, z)
    	tmp = 0.0
    	if (y <= -1.8e-267)
    		tmp = Float64(sqrt(fma(x, z, Float64(y * x))) * 2.0);
    	elseif (y <= 4.1e+61)
    		tmp = Float64(2.0 * sqrt(fma(z, y, Float64(z * x))));
    	else
    		tmp = Float64(Float64(2.0 * sqrt(Float64(y / z))) * z);
    	end
    	return 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.8e-267], N[(N[Sqrt[N[(x * z + N[(y * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], If[LessEqual[y, 4.1e+61], N[(2.0 * N[Sqrt[N[(z * y + N[(z * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]]
    
    \begin{array}{l}
    [x, y, z] = \mathsf{sort}([x, y, z])\\
    \\
    \begin{array}{l}
    \mathbf{if}\;y \leq -1.8 \cdot 10^{-267}:\\
    \;\;\;\;\sqrt{\mathsf{fma}\left(x, z, y \cdot x\right)} \cdot 2\\
    
    \mathbf{elif}\;y \leq 4.1 \cdot 10^{+61}:\\
    \;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(z, y, z \cdot x\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if y < -1.8000000000000001e-267

      1. Initial program 68.5%

        \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
      2. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}} \]
        2. lift-sqrt.f64N/A

          \[\leadsto 2 \cdot \color{blue}{\sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}} \]
        3. lift-*.f64N/A

          \[\leadsto 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + \color{blue}{y \cdot z}} \]
        4. lift-+.f64N/A

          \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right) + y \cdot z}} \]
        5. lift-*.f64N/A

          \[\leadsto 2 \cdot \sqrt{\left(\color{blue}{x \cdot y} + x \cdot z\right) + y \cdot z} \]
        6. lift-*.f64N/A

          \[\leadsto 2 \cdot \sqrt{\left(x \cdot y + \color{blue}{x \cdot z}\right) + y \cdot z} \]
        7. lift-+.f64N/A

          \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right)} + y \cdot z} \]
        8. *-commutativeN/A

          \[\leadsto \color{blue}{\sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \cdot 2} \]
        9. lower-*.f64N/A

          \[\leadsto \color{blue}{\sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \cdot 2} \]
      3. Applied rewrites68.7%

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

        \[\leadsto \sqrt{\mathsf{fma}\left(\color{blue}{x}, z, y \cdot x\right)} \cdot 2 \]
      5. Step-by-step derivation
        1. Applied rewrites68.7%

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

        if -1.8000000000000001e-267 < y < 4.09999999999999972e61

        1. Initial program 92.4%

          \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
        2. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + \color{blue}{y \cdot z}} \]
          2. lift-+.f64N/A

            \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right) + y \cdot z}} \]
          3. lift-*.f64N/A

            \[\leadsto 2 \cdot \sqrt{\left(\color{blue}{x \cdot y} + x \cdot z\right) + y \cdot z} \]
          4. lift-*.f64N/A

            \[\leadsto 2 \cdot \sqrt{\left(x \cdot y + \color{blue}{x \cdot z}\right) + y \cdot z} \]
          5. lift-+.f64N/A

            \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right)} + y \cdot z} \]
          6. +-commutativeN/A

            \[\leadsto 2 \cdot \sqrt{\color{blue}{y \cdot z + \left(x \cdot y + x \cdot z\right)}} \]
          7. *-commutativeN/A

            \[\leadsto 2 \cdot \sqrt{\color{blue}{z \cdot y} + \left(x \cdot y + x \cdot z\right)} \]
          8. lower-fma.f64N/A

            \[\leadsto 2 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(z, y, x \cdot y + x \cdot z\right)}} \]
          9. distribute-lft-inN/A

            \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{x \cdot \left(y + z\right)}\right)} \]
          10. *-commutativeN/A

            \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{\left(y + z\right) \cdot x}\right)} \]
          11. lower-*.f64N/A

            \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{\left(y + z\right) \cdot x}\right)} \]
          12. +-commutativeN/A

            \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{\left(z + y\right)} \cdot x\right)} \]
          13. lower-+.f6492.4

            \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{\left(z + y\right)} \cdot x\right)} \]
        3. Applied rewrites92.4%

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

          \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{z} \cdot x\right)} \]
        5. Step-by-step derivation
          1. Applied rewrites91.1%

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

          if 4.09999999999999972e61 < y

          1. Initial program 28.9%

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

            \[\leadsto \color{blue}{z \cdot \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right)} \]
          3. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right) \cdot \color{blue}{z} \]
            2. lower-*.f64N/A

              \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right) \cdot \color{blue}{z} \]
          4. Applied rewrites90.9%

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

            \[\leadsto \left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z \]
          6. Step-by-step derivation
            1. lower-*.f64N/A

              \[\leadsto \left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z \]
            2. lower-sqrt.f64N/A

              \[\leadsto \left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z \]
            3. lower-/.f6498.2

              \[\leadsto \left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z \]
          7. Applied rewrites98.2%

            \[\leadsto \left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z \]
        6. Recombined 3 regimes into one program.
        7. Add Preprocessing

        Alternative 5: 81.2% accurate, 0.9× speedup?

        \[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{-267}:\\ \;\;\;\;2 \cdot \sqrt{\left(z + y\right) \cdot x}\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{+61}:\\ \;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(z, y, z \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z\\ \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.8e-267)
           (* 2.0 (sqrt (* (+ z y) x)))
           (if (<= y 4.1e+61)
             (* 2.0 (sqrt (fma z y (* z x))))
             (* (* 2.0 (sqrt (/ y z))) z))))
        assert(x < y && y < z);
        double code(double x, double y, double z) {
        	double tmp;
        	if (y <= -1.8e-267) {
        		tmp = 2.0 * sqrt(((z + y) * x));
        	} else if (y <= 4.1e+61) {
        		tmp = 2.0 * sqrt(fma(z, y, (z * x)));
        	} else {
        		tmp = (2.0 * sqrt((y / z))) * z;
        	}
        	return tmp;
        }
        
        x, y, z = sort([x, y, z])
        function code(x, y, z)
        	tmp = 0.0
        	if (y <= -1.8e-267)
        		tmp = Float64(2.0 * sqrt(Float64(Float64(z + y) * x)));
        	elseif (y <= 4.1e+61)
        		tmp = Float64(2.0 * sqrt(fma(z, y, Float64(z * x))));
        	else
        		tmp = Float64(Float64(2.0 * sqrt(Float64(y / z))) * z);
        	end
        	return 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.8e-267], N[(2.0 * N[Sqrt[N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.1e+61], N[(2.0 * N[Sqrt[N[(z * y + N[(z * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]]
        
        \begin{array}{l}
        [x, y, z] = \mathsf{sort}([x, y, z])\\
        \\
        \begin{array}{l}
        \mathbf{if}\;y \leq -1.8 \cdot 10^{-267}:\\
        \;\;\;\;2 \cdot \sqrt{\left(z + y\right) \cdot x}\\
        
        \mathbf{elif}\;y \leq 4.1 \cdot 10^{+61}:\\
        \;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(z, y, z \cdot x\right)}\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if y < -1.8000000000000001e-267

          1. Initial program 68.5%

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

            \[\leadsto 2 \cdot \sqrt{\color{blue}{x \cdot \left(y + z\right)}} \]
          3. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto 2 \cdot \sqrt{\left(y + z\right) \cdot \color{blue}{x}} \]
            2. lower-*.f64N/A

              \[\leadsto 2 \cdot \sqrt{\left(y + z\right) \cdot \color{blue}{x}} \]
            3. +-commutativeN/A

              \[\leadsto 2 \cdot \sqrt{\left(z + y\right) \cdot x} \]
            4. lower-+.f6468.7

              \[\leadsto 2 \cdot \sqrt{\left(z + y\right) \cdot x} \]
          4. Applied rewrites68.7%

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

          if -1.8000000000000001e-267 < y < 4.09999999999999972e61

          1. Initial program 92.4%

            \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
          2. Step-by-step derivation
            1. lift-*.f64N/A

              \[\leadsto 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + \color{blue}{y \cdot z}} \]
            2. lift-+.f64N/A

              \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right) + y \cdot z}} \]
            3. lift-*.f64N/A

              \[\leadsto 2 \cdot \sqrt{\left(\color{blue}{x \cdot y} + x \cdot z\right) + y \cdot z} \]
            4. lift-*.f64N/A

              \[\leadsto 2 \cdot \sqrt{\left(x \cdot y + \color{blue}{x \cdot z}\right) + y \cdot z} \]
            5. lift-+.f64N/A

              \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right)} + y \cdot z} \]
            6. +-commutativeN/A

              \[\leadsto 2 \cdot \sqrt{\color{blue}{y \cdot z + \left(x \cdot y + x \cdot z\right)}} \]
            7. *-commutativeN/A

              \[\leadsto 2 \cdot \sqrt{\color{blue}{z \cdot y} + \left(x \cdot y + x \cdot z\right)} \]
            8. lower-fma.f64N/A

              \[\leadsto 2 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(z, y, x \cdot y + x \cdot z\right)}} \]
            9. distribute-lft-inN/A

              \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{x \cdot \left(y + z\right)}\right)} \]
            10. *-commutativeN/A

              \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{\left(y + z\right) \cdot x}\right)} \]
            11. lower-*.f64N/A

              \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{\left(y + z\right) \cdot x}\right)} \]
            12. +-commutativeN/A

              \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{\left(z + y\right)} \cdot x\right)} \]
            13. lower-+.f6492.4

              \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{\left(z + y\right)} \cdot x\right)} \]
          3. Applied rewrites92.4%

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

            \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(z, y, \color{blue}{z} \cdot x\right)} \]
          5. Step-by-step derivation
            1. Applied rewrites91.1%

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

            if 4.09999999999999972e61 < y

            1. Initial program 28.9%

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

              \[\leadsto \color{blue}{z \cdot \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right)} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right) \cdot \color{blue}{z} \]
              2. lower-*.f64N/A

                \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right) \cdot \color{blue}{z} \]
            4. Applied rewrites90.9%

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

              \[\leadsto \left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z \]
            6. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto \left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z \]
              2. lower-sqrt.f64N/A

                \[\leadsto \left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z \]
              3. lower-/.f6498.2

                \[\leadsto \left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z \]
            7. Applied rewrites98.2%

              \[\leadsto \left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z \]
          6. Recombined 3 regimes into one program.
          7. Add Preprocessing

          Alternative 6: 81.2% accurate, 1.0× speedup?

          \[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{-267}:\\ \;\;\;\;2 \cdot \sqrt{\left(z + y\right) \cdot x}\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{+61}:\\ \;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z\\ \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.8e-267)
             (* 2.0 (sqrt (* (+ z y) x)))
             (if (<= y 4.1e+61)
               (* 2.0 (sqrt (* (+ y x) z)))
               (* (* 2.0 (sqrt (/ y z))) z))))
          assert(x < y && y < z);
          double code(double x, double y, double z) {
          	double tmp;
          	if (y <= -1.8e-267) {
          		tmp = 2.0 * sqrt(((z + y) * x));
          	} else if (y <= 4.1e+61) {
          		tmp = 2.0 * sqrt(((y + x) * z));
          	} else {
          		tmp = (2.0 * sqrt((y / z))) * z;
          	}
          	return tmp;
          }
          
          NOTE: x, y, and z should be sorted in increasing order before calling this function.
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(x, y, z)
          use fmin_fmax_functions
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8), intent (in) :: z
              real(8) :: tmp
              if (y <= (-1.8d-267)) then
                  tmp = 2.0d0 * sqrt(((z + y) * x))
              else if (y <= 4.1d+61) then
                  tmp = 2.0d0 * sqrt(((y + x) * z))
              else
                  tmp = (2.0d0 * sqrt((y / z))) * z
              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.8e-267) {
          		tmp = 2.0 * Math.sqrt(((z + y) * x));
          	} else if (y <= 4.1e+61) {
          		tmp = 2.0 * Math.sqrt(((y + x) * z));
          	} else {
          		tmp = (2.0 * Math.sqrt((y / z))) * z;
          	}
          	return tmp;
          }
          
          [x, y, z] = sort([x, y, z])
          def code(x, y, z):
          	tmp = 0
          	if y <= -1.8e-267:
          		tmp = 2.0 * math.sqrt(((z + y) * x))
          	elif y <= 4.1e+61:
          		tmp = 2.0 * math.sqrt(((y + x) * z))
          	else:
          		tmp = (2.0 * math.sqrt((y / z))) * z
          	return tmp
          
          x, y, z = sort([x, y, z])
          function code(x, y, z)
          	tmp = 0.0
          	if (y <= -1.8e-267)
          		tmp = Float64(2.0 * sqrt(Float64(Float64(z + y) * x)));
          	elseif (y <= 4.1e+61)
          		tmp = Float64(2.0 * sqrt(Float64(Float64(y + x) * z)));
          	else
          		tmp = Float64(Float64(2.0 * sqrt(Float64(y / z))) * z);
          	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.8e-267)
          		tmp = 2.0 * sqrt(((z + y) * x));
          	elseif (y <= 4.1e+61)
          		tmp = 2.0 * sqrt(((y + x) * z));
          	else
          		tmp = (2.0 * sqrt((y / z))) * z;
          	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.8e-267], N[(2.0 * N[Sqrt[N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.1e+61], N[(2.0 * N[Sqrt[N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]]
          
          \begin{array}{l}
          [x, y, z] = \mathsf{sort}([x, y, z])\\
          \\
          \begin{array}{l}
          \mathbf{if}\;y \leq -1.8 \cdot 10^{-267}:\\
          \;\;\;\;2 \cdot \sqrt{\left(z + y\right) \cdot x}\\
          
          \mathbf{elif}\;y \leq 4.1 \cdot 10^{+61}:\\
          \;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\
          
          \mathbf{else}:\\
          \;\;\;\;\left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if y < -1.8000000000000001e-267

            1. Initial program 68.5%

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

              \[\leadsto 2 \cdot \sqrt{\color{blue}{x \cdot \left(y + z\right)}} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto 2 \cdot \sqrt{\left(y + z\right) \cdot \color{blue}{x}} \]
              2. lower-*.f64N/A

                \[\leadsto 2 \cdot \sqrt{\left(y + z\right) \cdot \color{blue}{x}} \]
              3. +-commutativeN/A

                \[\leadsto 2 \cdot \sqrt{\left(z + y\right) \cdot x} \]
              4. lower-+.f6468.7

                \[\leadsto 2 \cdot \sqrt{\left(z + y\right) \cdot x} \]
            4. Applied rewrites68.7%

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

            if -1.8000000000000001e-267 < y < 4.09999999999999972e61

            1. Initial program 92.4%

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

              \[\leadsto 2 \cdot \sqrt{\color{blue}{z \cdot \left(x + y\right)}} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto 2 \cdot \sqrt{\left(x + y\right) \cdot \color{blue}{z}} \]
              2. lower-*.f64N/A

                \[\leadsto 2 \cdot \sqrt{\left(x + y\right) \cdot \color{blue}{z}} \]
              3. +-commutativeN/A

                \[\leadsto 2 \cdot \sqrt{\left(y + x\right) \cdot z} \]
              4. lower-+.f6491.1

                \[\leadsto 2 \cdot \sqrt{\left(y + x\right) \cdot z} \]
            4. Applied rewrites91.1%

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

            if 4.09999999999999972e61 < y

            1. Initial program 28.9%

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

              \[\leadsto \color{blue}{z \cdot \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right)} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right) \cdot \color{blue}{z} \]
              2. lower-*.f64N/A

                \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right) \cdot \color{blue}{z} \]
            4. Applied rewrites90.9%

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

              \[\leadsto \left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z \]
            6. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto \left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z \]
              2. lower-sqrt.f64N/A

                \[\leadsto \left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z \]
              3. lower-/.f6498.2

                \[\leadsto \left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z \]
            7. Applied rewrites98.2%

              \[\leadsto \left(2 \cdot \sqrt{\frac{y}{z}}\right) \cdot z \]
          3. Recombined 3 regimes into one program.
          4. Add Preprocessing

          Alternative 7: 81.2% accurate, 1.1× speedup?

          \[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 3.2 \cdot 10^{-283}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(x, z, y \cdot x\right)} \cdot 2\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot z\\ \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 3.2e-283)
             (* (sqrt (fma x z (* y x))) 2.0)
             (* (* 2.0 (/ (sqrt y) (sqrt z))) z)))
          assert(x < y && y < z);
          double code(double x, double y, double z) {
          	double tmp;
          	if (y <= 3.2e-283) {
          		tmp = sqrt(fma(x, z, (y * x))) * 2.0;
          	} else {
          		tmp = (2.0 * (sqrt(y) / sqrt(z))) * z;
          	}
          	return tmp;
          }
          
          x, y, z = sort([x, y, z])
          function code(x, y, z)
          	tmp = 0.0
          	if (y <= 3.2e-283)
          		tmp = Float64(sqrt(fma(x, z, Float64(y * x))) * 2.0);
          	else
          		tmp = Float64(Float64(2.0 * Float64(sqrt(y) / sqrt(z))) * z);
          	end
          	return tmp
          end
          
          NOTE: x, y, and z should be sorted in increasing order before calling this function.
          code[x_, y_, z_] := If[LessEqual[y, 3.2e-283], N[(N[Sqrt[N[(x * z + N[(y * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision], N[(N[(2.0 * N[(N[Sqrt[y], $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
          
          \begin{array}{l}
          [x, y, z] = \mathsf{sort}([x, y, z])\\
          \\
          \begin{array}{l}
          \mathbf{if}\;y \leq 3.2 \cdot 10^{-283}:\\
          \;\;\;\;\sqrt{\mathsf{fma}\left(x, z, y \cdot x\right)} \cdot 2\\
          
          \mathbf{else}:\\
          \;\;\;\;\left(2 \cdot \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot z\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < 3.20000000000000012e-283

            1. Initial program 68.3%

              \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
            2. Step-by-step derivation
              1. lift-*.f64N/A

                \[\leadsto \color{blue}{2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}} \]
              2. lift-sqrt.f64N/A

                \[\leadsto 2 \cdot \color{blue}{\sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}} \]
              3. lift-*.f64N/A

                \[\leadsto 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + \color{blue}{y \cdot z}} \]
              4. lift-+.f64N/A

                \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right) + y \cdot z}} \]
              5. lift-*.f64N/A

                \[\leadsto 2 \cdot \sqrt{\left(\color{blue}{x \cdot y} + x \cdot z\right) + y \cdot z} \]
              6. lift-*.f64N/A

                \[\leadsto 2 \cdot \sqrt{\left(x \cdot y + \color{blue}{x \cdot z}\right) + y \cdot z} \]
              7. lift-+.f64N/A

                \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right)} + y \cdot z} \]
              8. *-commutativeN/A

                \[\leadsto \color{blue}{\sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \cdot 2} \]
              9. lower-*.f64N/A

                \[\leadsto \color{blue}{\sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \cdot 2} \]
            3. Applied rewrites68.5%

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

              \[\leadsto \sqrt{\mathsf{fma}\left(\color{blue}{x}, z, y \cdot x\right)} \cdot 2 \]
            5. Step-by-step derivation
              1. Applied rewrites68.2%

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

              if 3.20000000000000012e-283 < y

              1. Initial program 71.1%

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

                \[\leadsto \color{blue}{z \cdot \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right)} \]
              3. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right) \cdot \color{blue}{z} \]
                2. lower-*.f64N/A

                  \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}} + \left(x \cdot y\right) \cdot \sqrt{\frac{1}{{z}^{3} \cdot \left(x + y\right)}}\right) \cdot \color{blue}{z} \]
              4. Applied rewrites79.0%

                \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot x, \sqrt{\frac{1}{\left(y + x\right) \cdot \left(\left(z \cdot z\right) \cdot z\right)}}, \sqrt{\frac{y + x}{z}} \cdot 2\right) \cdot z} \]
              5. Taylor expanded in z around inf

                \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
              6. Step-by-step derivation
                1. lower-*.f64N/A

                  \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
                2. lower-sqrt.f64N/A

                  \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
                3. lower-/.f64N/A

                  \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
                4. lower-+.f6488.6

                  \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
              7. Applied rewrites88.6%

                \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
              8. Step-by-step derivation
                1. lift-sqrt.f64N/A

                  \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
                2. lift-+.f64N/A

                  \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
                3. lift-/.f64N/A

                  \[\leadsto \left(2 \cdot \sqrt{\frac{x + y}{z}}\right) \cdot z \]
                4. sqrt-divN/A

                  \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
                5. lower-/.f64N/A

                  \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
                6. lower-sqrt.f64N/A

                  \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
                7. lift-+.f64N/A

                  \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
                8. lower-sqrt.f6499.3

                  \[\leadsto \left(2 \cdot \frac{\sqrt{x + y}}{\sqrt{z}}\right) \cdot z \]
              9. Applied rewrites99.3%

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

                \[\leadsto \left(2 \cdot \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot z \]
              11. Step-by-step derivation
                1. Applied rewrites96.6%

                  \[\leadsto \left(2 \cdot \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot z \]
              12. Recombined 2 regimes into one program.
              13. Add Preprocessing

              Alternative 8: 69.4% accurate, 1.3× speedup?

              \[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{-267}:\\ \;\;\;\;2 \cdot \sqrt{\left(z + y\right) \cdot x}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\ \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.8e-267)
                 (* 2.0 (sqrt (* (+ z y) x)))
                 (* 2.0 (sqrt (* (+ y x) z)))))
              assert(x < y && y < z);
              double code(double x, double y, double z) {
              	double tmp;
              	if (y <= -1.8e-267) {
              		tmp = 2.0 * sqrt(((z + y) * x));
              	} else {
              		tmp = 2.0 * sqrt(((y + x) * z));
              	}
              	return tmp;
              }
              
              NOTE: x, y, and z should be sorted in increasing order before calling this function.
              module fmin_fmax_functions
                  implicit none
                  private
                  public fmax
                  public fmin
              
                  interface fmax
                      module procedure fmax88
                      module procedure fmax44
                      module procedure fmax84
                      module procedure fmax48
                  end interface
                  interface fmin
                      module procedure fmin88
                      module procedure fmin44
                      module procedure fmin84
                      module procedure fmin48
                  end interface
              contains
                  real(8) function fmax88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmax44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmax84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmax48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                  end function
                  real(8) function fmin88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmin44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmin84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmin48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                  end function
              end module
              
              real(8) function code(x, y, z)
              use fmin_fmax_functions
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  real(8), intent (in) :: z
                  real(8) :: tmp
                  if (y <= (-1.8d-267)) then
                      tmp = 2.0d0 * sqrt(((z + y) * x))
                  else
                      tmp = 2.0d0 * sqrt(((y + x) * z))
                  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.8e-267) {
              		tmp = 2.0 * Math.sqrt(((z + y) * x));
              	} else {
              		tmp = 2.0 * Math.sqrt(((y + x) * z));
              	}
              	return tmp;
              }
              
              [x, y, z] = sort([x, y, z])
              def code(x, y, z):
              	tmp = 0
              	if y <= -1.8e-267:
              		tmp = 2.0 * math.sqrt(((z + y) * x))
              	else:
              		tmp = 2.0 * math.sqrt(((y + x) * z))
              	return tmp
              
              x, y, z = sort([x, y, z])
              function code(x, y, z)
              	tmp = 0.0
              	if (y <= -1.8e-267)
              		tmp = Float64(2.0 * sqrt(Float64(Float64(z + y) * x)));
              	else
              		tmp = Float64(2.0 * sqrt(Float64(Float64(y + x) * z)));
              	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.8e-267)
              		tmp = 2.0 * sqrt(((z + y) * x));
              	else
              		tmp = 2.0 * sqrt(((y + x) * z));
              	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.8e-267], N[(2.0 * N[Sqrt[N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              [x, y, z] = \mathsf{sort}([x, y, z])\\
              \\
              \begin{array}{l}
              \mathbf{if}\;y \leq -1.8 \cdot 10^{-267}:\\
              \;\;\;\;2 \cdot \sqrt{\left(z + y\right) \cdot x}\\
              
              \mathbf{else}:\\
              \;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if y < -1.8000000000000001e-267

                1. Initial program 68.5%

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

                  \[\leadsto 2 \cdot \sqrt{\color{blue}{x \cdot \left(y + z\right)}} \]
                3. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto 2 \cdot \sqrt{\left(y + z\right) \cdot \color{blue}{x}} \]
                  2. lower-*.f64N/A

                    \[\leadsto 2 \cdot \sqrt{\left(y + z\right) \cdot \color{blue}{x}} \]
                  3. +-commutativeN/A

                    \[\leadsto 2 \cdot \sqrt{\left(z + y\right) \cdot x} \]
                  4. lower-+.f6468.7

                    \[\leadsto 2 \cdot \sqrt{\left(z + y\right) \cdot x} \]
                4. Applied rewrites68.7%

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

                if -1.8000000000000001e-267 < y

                1. Initial program 70.8%

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

                  \[\leadsto 2 \cdot \sqrt{\color{blue}{z \cdot \left(x + y\right)}} \]
                3. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto 2 \cdot \sqrt{\left(x + y\right) \cdot \color{blue}{z}} \]
                  2. lower-*.f64N/A

                    \[\leadsto 2 \cdot \sqrt{\left(x + y\right) \cdot \color{blue}{z}} \]
                  3. +-commutativeN/A

                    \[\leadsto 2 \cdot \sqrt{\left(y + x\right) \cdot z} \]
                  4. lower-+.f6470.2

                    \[\leadsto 2 \cdot \sqrt{\left(y + x\right) \cdot z} \]
                4. Applied rewrites70.2%

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

              Alternative 9: 68.5% accurate, 1.3× speedup?

              \[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -3.2 \cdot 10^{-267}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\ \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 -3.2e-267) (* 2.0 (sqrt (* y x))) (* 2.0 (sqrt (* (+ y x) z)))))
              assert(x < y && y < z);
              double code(double x, double y, double z) {
              	double tmp;
              	if (y <= -3.2e-267) {
              		tmp = 2.0 * sqrt((y * x));
              	} else {
              		tmp = 2.0 * sqrt(((y + x) * z));
              	}
              	return tmp;
              }
              
              NOTE: x, y, and z should be sorted in increasing order before calling this function.
              module fmin_fmax_functions
                  implicit none
                  private
                  public fmax
                  public fmin
              
                  interface fmax
                      module procedure fmax88
                      module procedure fmax44
                      module procedure fmax84
                      module procedure fmax48
                  end interface
                  interface fmin
                      module procedure fmin88
                      module procedure fmin44
                      module procedure fmin84
                      module procedure fmin48
                  end interface
              contains
                  real(8) function fmax88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmax44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmax84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmax48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                  end function
                  real(8) function fmin88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmin44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmin84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmin48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                  end function
              end module
              
              real(8) function code(x, y, z)
              use fmin_fmax_functions
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  real(8), intent (in) :: z
                  real(8) :: tmp
                  if (y <= (-3.2d-267)) then
                      tmp = 2.0d0 * sqrt((y * x))
                  else
                      tmp = 2.0d0 * sqrt(((y + x) * z))
                  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 <= -3.2e-267) {
              		tmp = 2.0 * Math.sqrt((y * x));
              	} else {
              		tmp = 2.0 * Math.sqrt(((y + x) * z));
              	}
              	return tmp;
              }
              
              [x, y, z] = sort([x, y, z])
              def code(x, y, z):
              	tmp = 0
              	if y <= -3.2e-267:
              		tmp = 2.0 * math.sqrt((y * x))
              	else:
              		tmp = 2.0 * math.sqrt(((y + x) * z))
              	return tmp
              
              x, y, z = sort([x, y, z])
              function code(x, y, z)
              	tmp = 0.0
              	if (y <= -3.2e-267)
              		tmp = Float64(2.0 * sqrt(Float64(y * x)));
              	else
              		tmp = Float64(2.0 * sqrt(Float64(Float64(y + x) * z)));
              	end
              	return tmp
              end
              
              x, y, z = num2cell(sort([x, y, z])){:}
              function tmp_2 = code(x, y, z)
              	tmp = 0.0;
              	if (y <= -3.2e-267)
              		tmp = 2.0 * sqrt((y * x));
              	else
              		tmp = 2.0 * sqrt(((y + x) * z));
              	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, -3.2e-267], N[(2.0 * N[Sqrt[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              [x, y, z] = \mathsf{sort}([x, y, z])\\
              \\
              \begin{array}{l}
              \mathbf{if}\;y \leq -3.2 \cdot 10^{-267}:\\
              \;\;\;\;2 \cdot \sqrt{y \cdot x}\\
              
              \mathbf{else}:\\
              \;\;\;\;2 \cdot \sqrt{\left(y + x\right) \cdot z}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if y < -3.19999999999999986e-267

                1. Initial program 68.5%

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

                  \[\leadsto 2 \cdot \sqrt{\color{blue}{x \cdot y}} \]
                3. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto 2 \cdot \sqrt{y \cdot \color{blue}{x}} \]
                  2. lower-*.f6466.7

                    \[\leadsto 2 \cdot \sqrt{y \cdot \color{blue}{x}} \]
                4. Applied rewrites66.7%

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

                if -3.19999999999999986e-267 < y

                1. Initial program 70.8%

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

                  \[\leadsto 2 \cdot \sqrt{\color{blue}{z \cdot \left(x + y\right)}} \]
                3. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto 2 \cdot \sqrt{\left(x + y\right) \cdot \color{blue}{z}} \]
                  2. lower-*.f64N/A

                    \[\leadsto 2 \cdot \sqrt{\left(x + y\right) \cdot \color{blue}{z}} \]
                  3. +-commutativeN/A

                    \[\leadsto 2 \cdot \sqrt{\left(y + x\right) \cdot z} \]
                  4. lower-+.f6470.2

                    \[\leadsto 2 \cdot \sqrt{\left(y + x\right) \cdot z} \]
                4. Applied rewrites70.2%

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

              Alternative 10: 67.7% accurate, 1.8× speedup?

              \[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ 2 \cdot \sqrt{\left(z + x\right) \cdot y} \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 (* (+ z x) y))))
              assert(x < y && y < z);
              double code(double x, double y, double z) {
              	return 2.0 * sqrt(((z + x) * y));
              }
              
              NOTE: x, y, and z should be sorted in increasing order before calling this function.
              module fmin_fmax_functions
                  implicit none
                  private
                  public fmax
                  public fmin
              
                  interface fmax
                      module procedure fmax88
                      module procedure fmax44
                      module procedure fmax84
                      module procedure fmax48
                  end interface
                  interface fmin
                      module procedure fmin88
                      module procedure fmin44
                      module procedure fmin84
                      module procedure fmin48
                  end interface
              contains
                  real(8) function fmax88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmax44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmax84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmax48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                  end function
                  real(8) function fmin88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmin44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmin84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmin48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                  end function
              end module
              
              real(8) function code(x, y, z)
              use fmin_fmax_functions
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  real(8), intent (in) :: z
                  code = 2.0d0 * sqrt(((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(((z + x) * y));
              }
              
              [x, y, z] = sort([x, y, z])
              def code(x, y, z):
              	return 2.0 * math.sqrt(((z + x) * y))
              
              x, y, z = sort([x, y, z])
              function code(x, y, z)
              	return Float64(2.0 * sqrt(Float64(Float64(z + x) * y)))
              end
              
              x, y, z = num2cell(sort([x, y, z])){:}
              function tmp = code(x, y, z)
              	tmp = 2.0 * sqrt(((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[(z + x), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              [x, y, z] = \mathsf{sort}([x, y, z])\\
              \\
              2 \cdot \sqrt{\left(z + x\right) \cdot y}
              \end{array}
              
              Derivation
              1. Initial program 69.7%

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

                \[\leadsto 2 \cdot \sqrt{\color{blue}{y \cdot \left(x + z\right)}} \]
              3. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto 2 \cdot \sqrt{\left(x + z\right) \cdot \color{blue}{y}} \]
                2. lower-*.f64N/A

                  \[\leadsto 2 \cdot \sqrt{\left(x + z\right) \cdot \color{blue}{y}} \]
                3. +-commutativeN/A

                  \[\leadsto 2 \cdot \sqrt{\left(z + x\right) \cdot y} \]
                4. lower-+.f6467.7

                  \[\leadsto 2 \cdot \sqrt{\left(z + x\right) \cdot y} \]
              4. Applied rewrites67.7%

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

              Alternative 11: 67.4% accurate, 1.6× speedup?

              \[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{-267}:\\ \;\;\;\;2 \cdot \sqrt{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \sqrt{z \cdot 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 -1.8e-267) (* 2.0 (sqrt (* y x))) (* 2.0 (sqrt (* z y)))))
              assert(x < y && y < z);
              double code(double x, double y, double z) {
              	double tmp;
              	if (y <= -1.8e-267) {
              		tmp = 2.0 * sqrt((y * x));
              	} else {
              		tmp = 2.0 * sqrt((z * y));
              	}
              	return tmp;
              }
              
              NOTE: x, y, and z should be sorted in increasing order before calling this function.
              module fmin_fmax_functions
                  implicit none
                  private
                  public fmax
                  public fmin
              
                  interface fmax
                      module procedure fmax88
                      module procedure fmax44
                      module procedure fmax84
                      module procedure fmax48
                  end interface
                  interface fmin
                      module procedure fmin88
                      module procedure fmin44
                      module procedure fmin84
                      module procedure fmin48
                  end interface
              contains
                  real(8) function fmax88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmax44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmax84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmax48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                  end function
                  real(8) function fmin88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmin44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmin84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmin48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                  end function
              end module
              
              real(8) function code(x, y, z)
              use fmin_fmax_functions
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  real(8), intent (in) :: z
                  real(8) :: tmp
                  if (y <= (-1.8d-267)) then
                      tmp = 2.0d0 * sqrt((y * x))
                  else
                      tmp = 2.0d0 * sqrt((z * 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 <= -1.8e-267) {
              		tmp = 2.0 * Math.sqrt((y * x));
              	} else {
              		tmp = 2.0 * Math.sqrt((z * y));
              	}
              	return tmp;
              }
              
              [x, y, z] = sort([x, y, z])
              def code(x, y, z):
              	tmp = 0
              	if y <= -1.8e-267:
              		tmp = 2.0 * math.sqrt((y * x))
              	else:
              		tmp = 2.0 * math.sqrt((z * y))
              	return tmp
              
              x, y, z = sort([x, y, z])
              function code(x, y, z)
              	tmp = 0.0
              	if (y <= -1.8e-267)
              		tmp = Float64(2.0 * sqrt(Float64(y * x)));
              	else
              		tmp = Float64(2.0 * sqrt(Float64(z * 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 <= -1.8e-267)
              		tmp = 2.0 * sqrt((y * x));
              	else
              		tmp = 2.0 * sqrt((z * 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, -1.8e-267], N[(2.0 * N[Sqrt[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(z * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              [x, y, z] = \mathsf{sort}([x, y, z])\\
              \\
              \begin{array}{l}
              \mathbf{if}\;y \leq -1.8 \cdot 10^{-267}:\\
              \;\;\;\;2 \cdot \sqrt{y \cdot x}\\
              
              \mathbf{else}:\\
              \;\;\;\;2 \cdot \sqrt{z \cdot y}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if y < -1.8000000000000001e-267

                1. Initial program 68.5%

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

                  \[\leadsto 2 \cdot \sqrt{\color{blue}{x \cdot y}} \]
                3. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto 2 \cdot \sqrt{y \cdot \color{blue}{x}} \]
                  2. lower-*.f6466.7

                    \[\leadsto 2 \cdot \sqrt{y \cdot \color{blue}{x}} \]
                4. Applied rewrites66.7%

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

                if -1.8000000000000001e-267 < y

                1. Initial program 70.8%

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

                  \[\leadsto 2 \cdot \sqrt{\color{blue}{y \cdot z}} \]
                3. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto 2 \cdot \sqrt{z \cdot \color{blue}{y}} \]
                  2. lower-*.f6468.1

                    \[\leadsto 2 \cdot \sqrt{z \cdot \color{blue}{y}} \]
                4. Applied rewrites68.1%

                  \[\leadsto 2 \cdot \sqrt{\color{blue}{z \cdot y}} \]
              3. Recombined 2 regimes into one program.
              4. Add Preprocessing

              Alternative 12: 35.0% accurate, 2.3× 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.
              module fmin_fmax_functions
                  implicit none
                  private
                  public fmax
                  public fmin
              
                  interface fmax
                      module procedure fmax88
                      module procedure fmax44
                      module procedure fmax84
                      module procedure fmax48
                  end interface
                  interface fmin
                      module procedure fmin88
                      module procedure fmin44
                      module procedure fmin84
                      module procedure fmin48
                  end interface
              contains
                  real(8) function fmax88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmax44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmax84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmax48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                  end function
                  real(8) function fmin88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmin44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmin84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmin48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                  end function
              end module
              
              real(8) function code(x, y, z)
              use fmin_fmax_functions
                  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 69.7%

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

                \[\leadsto 2 \cdot \sqrt{\color{blue}{x \cdot y}} \]
              3. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto 2 \cdot \sqrt{y \cdot \color{blue}{x}} \]
                2. lower-*.f6435.0

                  \[\leadsto 2 \cdot \sqrt{y \cdot \color{blue}{x}} \]
              4. Applied rewrites35.0%

                \[\leadsto 2 \cdot \sqrt{\color{blue}{y \cdot x}} \]
              5. Add Preprocessing

              Reproduce

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