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

Percentage Accurate: 70.7% → 96.7%
Time: 13.7s
Alternatives: 11
Speedup: N/A×

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}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 70.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: 96.7% accurate, N/A× speedup?

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

\mathbf{elif}\;y \leq 3.1 \cdot 10^{+27}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(x, 2 \cdot z + \left(y - z\right), y \cdot z\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.2e37

    1. Initial program 50.4%

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{\left(\frac{2}{2}\right)}\right) \cdot y\right) \]
      2. metadata-evalN/A

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{1}\right) \cdot y\right) \]
      3. metadata-evalN/A

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right) \]
      7. lower-+.f6483.9

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right) \]
    8. Applied rewrites83.9%

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

    if -1.2e37 < y < 3.09999999999999996e27

    1. Initial program 81.7%

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

        \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right) + 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{\left(x \cdot y + x \cdot z\right) + \color{blue}{y \cdot z}} \]
      6. associate-+l+N/A

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

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

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

        \[\leadsto 2 \cdot \sqrt{\color{blue}{\frac{\left(x \cdot y\right) \cdot \left(x \cdot y\right) - \left(z \cdot \left(x + y\right)\right) \cdot \left(z \cdot \left(x + y\right)\right)}{x \cdot y - z \cdot \left(x + y\right)}}} \]
    4. Applied rewrites51.5%

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

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

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

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

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

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

        \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(x, 2 \cdot z - -1 \cdot \left(y - \color{blue}{z}\right), y \cdot z\right)} \]
      6. lower-*.f6481.7

        \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(x, 2 \cdot z - -1 \cdot \left(y - z\right), y \cdot z\right)} \]
    7. Applied rewrites81.7%

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

    if 3.09999999999999996e27 < y

    1. Initial program 52.2%

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

        \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right) + 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{\left(x \cdot y + x \cdot z\right) + \color{blue}{y \cdot z}} \]
      6. associate-+l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(z \cdot \left(\sqrt{\frac{x + y}{z}} + \frac{1}{2} \cdot \left(\left(x \cdot y\right) \cdot \frac{1}{\sqrt{{z}^{3} \cdot \left(x + y\right)}}\right)\right)\right) \]
    7. Applied rewrites30.2%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.2 \cdot 10^{+37}:\\ \;\;\;\;2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right)\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{+27}:\\ \;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(x, 2 \cdot z + \left(y - z\right), y \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot \sqrt{\frac{x + y}{z}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 94.2% accurate, N/A× speedup?

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

\mathbf{elif}\;y \leq 3.2 \cdot 10^{-287}:\\
\;\;\;\;2 \cdot \sqrt{\left(\mathsf{fma}\left(y, \frac{z}{x}, z\right) + y\right) \cdot x}\\

\mathbf{elif}\;y \leq 9.5 \cdot 10^{-123}:\\
\;\;\;\;2 \cdot \sqrt{z \cdot y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.2e37

    1. Initial program 50.4%

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{\left(\frac{2}{2}\right)}\right) \cdot y\right) \]
      2. metadata-evalN/A

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{1}\right) \cdot y\right) \]
      3. metadata-evalN/A

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right) \]
      7. lower-+.f6483.9

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right) \]
    8. Applied rewrites83.9%

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

    if -1.2e37 < y < 3.20000000000000018e-287

    1. Initial program 82.6%

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

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

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

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

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

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

        \[\leadsto 2 \cdot \sqrt{\left(\left(\frac{y \cdot z}{x} + z\right) + y\right) \cdot x} \]
      6. associate-/l*N/A

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

        \[\leadsto 2 \cdot \sqrt{\left(\mathsf{fma}\left(y, \frac{z}{x}, z\right) + y\right) \cdot x} \]
      8. lower-/.f6474.0

        \[\leadsto 2 \cdot \sqrt{\left(\mathsf{fma}\left(y, \frac{z}{x}, z\right) + y\right) \cdot x} \]
    5. Applied rewrites74.0%

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

    if 3.20000000000000018e-287 < y < 9.5000000000000002e-123

    1. Initial program 75.0%

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

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

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

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

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

    if 9.5000000000000002e-123 < y

    1. Initial program 64.1%

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

        \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right) + 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{\left(x \cdot y + x \cdot z\right) + \color{blue}{y \cdot z}} \]
      6. associate-+l+N/A

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

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

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

        \[\leadsto 2 \cdot \sqrt{\color{blue}{\frac{\left(x \cdot y\right) \cdot \left(x \cdot y\right) - \left(z \cdot \left(x + y\right)\right) \cdot \left(z \cdot \left(x + y\right)\right)}{x \cdot y - z \cdot \left(x + y\right)}}} \]
    4. Applied rewrites37.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(z \cdot \left(\sqrt{\frac{x + y}{z}} + \frac{1}{2} \cdot \left(\left(x \cdot y\right) \cdot \frac{1}{\sqrt{{z}^{3} \cdot \left(x + y\right)}}\right)\right)\right) \]
    7. Applied rewrites34.2%

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

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

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

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

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

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

Alternative 3: 88.8% accurate, N/A× speedup?

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

\mathbf{elif}\;y \leq 9.5 \cdot 10^{-123}:\\
\;\;\;\;2 \cdot \sqrt{z \cdot y}\\

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


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

    1. Initial program 66.9%

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{\left(\frac{2}{2}\right)}\right) \cdot y\right) \]
      2. metadata-evalN/A

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{1}\right) \cdot y\right) \]
      3. metadata-evalN/A

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right) \]
    8. Applied rewrites62.2%

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

    if -7.10000000000000005e-308 < y < 9.5000000000000002e-123

    1. Initial program 74.0%

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

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

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

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

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

    if 9.5000000000000002e-123 < y

    1. Initial program 64.1%

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

        \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right) + 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{\left(x \cdot y + x \cdot z\right) + \color{blue}{y \cdot z}} \]
      6. associate-+l+N/A

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

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

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

        \[\leadsto 2 \cdot \sqrt{\color{blue}{\frac{\left(x \cdot y\right) \cdot \left(x \cdot y\right) - \left(z \cdot \left(x + y\right)\right) \cdot \left(z \cdot \left(x + y\right)\right)}{x \cdot y - z \cdot \left(x + y\right)}}} \]
    4. Applied rewrites37.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(z \cdot \left(\sqrt{\frac{x + y}{z}} + \frac{1}{2} \cdot \left(\left(x \cdot y\right) \cdot \frac{1}{\sqrt{{z}^{3} \cdot \left(x + y\right)}}\right)\right)\right) \]
    7. Applied rewrites34.2%

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

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

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

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

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

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

Alternative 4: 88.4% accurate, N/A× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{y}{z}}\\ \mathbf{if}\;y \leq 7.2 \cdot 10^{-287}:\\ \;\;\;\;2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right)\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{-90}:\\ \;\;\;\;2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot t\_0, 0.5 \cdot \sqrt{y \cdot z}\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot t\_0\right)\right)\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot \sqrt{\frac{x + y}{z}}\right)\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (sqrt (/ y z))))
   (if (<= y 7.2e-287)
     (* 2.0 (* (* (sqrt (/ (+ x z) y)) -1.0) y))
     (if (<= y 4.5e-90)
       (*
        2.0
        (/
         (fma
          x
          (fma -0.25 (* x t_0) (* 0.5 (sqrt (* y z))))
          (*
           y
           (fma
            (sqrt y)
            (sqrt z)
            (* x (fma -0.125 (* x (sqrt (/ y (pow z 3.0)))) (* 0.5 t_0))))))
         y))
       (* 2.0 (* z (sqrt (/ (+ x y) z))))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double t_0 = sqrt((y / z));
	double tmp;
	if (y <= 7.2e-287) {
		tmp = 2.0 * ((sqrt(((x + z) / y)) * -1.0) * y);
	} else if (y <= 4.5e-90) {
		tmp = 2.0 * (fma(x, fma(-0.25, (x * t_0), (0.5 * sqrt((y * z)))), (y * fma(sqrt(y), sqrt(z), (x * fma(-0.125, (x * sqrt((y / pow(z, 3.0)))), (0.5 * t_0)))))) / y);
	} else {
		tmp = 2.0 * (z * sqrt(((x + y) / z)));
	}
	return tmp;
}
x, y, z = sort([x, y, z])
function code(x, y, z)
	t_0 = sqrt(Float64(y / z))
	tmp = 0.0
	if (y <= 7.2e-287)
		tmp = Float64(2.0 * Float64(Float64(sqrt(Float64(Float64(x + z) / y)) * -1.0) * y));
	elseif (y <= 4.5e-90)
		tmp = Float64(2.0 * Float64(fma(x, fma(-0.25, Float64(x * t_0), Float64(0.5 * sqrt(Float64(y * z)))), Float64(y * fma(sqrt(y), sqrt(z), Float64(x * fma(-0.125, Float64(x * sqrt(Float64(y / (z ^ 3.0)))), Float64(0.5 * t_0)))))) / y));
	else
		tmp = Float64(2.0 * Float64(z * sqrt(Float64(Float64(x + y) / z))));
	end
	return tmp
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 7.2e-287], N[(2.0 * N[(N[(N[Sqrt[N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision] * -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.5e-90], N[(2.0 * N[(N[(x * N[(-0.25 * N[(x * t$95$0), $MachinePrecision] + N[(0.5 * N[Sqrt[N[(y * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(-0.125 * N[(x * N[Sqrt[N[(y / N[Power[z, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(z * N[Sqrt[N[(N[(x + y), $MachinePrecision] / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{y}{z}}\\
\mathbf{if}\;y \leq 7.2 \cdot 10^{-287}:\\
\;\;\;\;2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right)\\

\mathbf{elif}\;y \leq 4.5 \cdot 10^{-90}:\\
\;\;\;\;2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot t\_0, 0.5 \cdot \sqrt{y \cdot z}\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot t\_0\right)\right)\right)}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 7.2000000000000003e-287

    1. Initial program 66.5%

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{\left(\frac{2}{2}\right)}\right) \cdot y\right) \]
      2. metadata-evalN/A

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{1}\right) \cdot y\right) \]
      3. metadata-evalN/A

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right) \]
      7. lower-+.f6459.0

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right) \]
    8. Applied rewrites59.0%

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

    if 7.2000000000000003e-287 < y < 4.50000000000000009e-90

    1. Initial program 81.0%

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

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

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

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

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

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

      \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \color{blue}{\sqrt{z}}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{\sqrt{y \cdot z}}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right) \]
    8. Taylor expanded in y around 0

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

        \[\leadsto 2 \cdot \frac{x \cdot \left(\frac{-1}{4} \cdot \left(x \cdot \sqrt{\frac{y}{z}}\right) + \frac{1}{2} \cdot \sqrt{y \cdot z}\right) + y \cdot \left(\sqrt{y \cdot z} + x \cdot \left(\frac{-1}{8} \cdot \left(x \cdot \sqrt{\frac{y}{{z}^{3}}}\right) + \frac{1}{2} \cdot \sqrt{\frac{y}{z}}\right)\right)}{y} \]
    10. Applied rewrites18.4%

      \[\leadsto 2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot \sqrt{\frac{y}{z}}, 0.5 \cdot \sqrt{y \cdot z}\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot \sqrt{\frac{y}{z}}\right)\right)\right)}{y} \]

    if 4.50000000000000009e-90 < y

    1. Initial program 61.0%

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

        \[\leadsto 2 \cdot \sqrt{\color{blue}{\left(x \cdot y + x \cdot z\right) + 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{\left(x \cdot y + x \cdot z\right) + \color{blue}{y \cdot z}} \]
      6. associate-+l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(z \cdot \left(\sqrt{\frac{x + y}{z}} + \frac{1}{2} \cdot \left(\left(x \cdot y\right) \cdot \frac{1}{\sqrt{{z}^{3} \cdot \left(x + y\right)}}\right)\right)\right) \]
    7. Applied rewrites31.7%

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

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

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

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

        \[\leadsto 2 \cdot \left(z \cdot \sqrt{\frac{x + y}{z}}\right) \]
    10. Applied rewrites44.8%

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

Alternative 5: 88.8% accurate, N/A× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{y}{z}}\\ t_1 := \sqrt{y \cdot z}\\ \mathbf{if}\;y \leq 7.2 \cdot 10^{-287}:\\ \;\;\;\;2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right)\\ \mathbf{elif}\;y \leq 2.45 \cdot 10^{-18}:\\ \;\;\;\;2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot t\_0, 0.5 \cdot t\_1\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot t\_0\right)\right)\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{t\_1}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (sqrt (/ y z))) (t_1 (sqrt (* y z))))
   (if (<= y 7.2e-287)
     (* 2.0 (* (* (sqrt (/ (+ x z) y)) -1.0) y))
     (if (<= y 2.45e-18)
       (*
        2.0
        (/
         (fma
          x
          (fma -0.25 (* x t_0) (* 0.5 t_1))
          (*
           y
           (fma
            (sqrt y)
            (sqrt z)
            (* x (fma -0.125 (* x (sqrt (/ y (pow z 3.0)))) (* 0.5 t_0))))))
         y))
       (*
        2.0
        (fma
         (sqrt y)
         (sqrt z)
         (*
          x
          (fma
           x
           (*
            y
            (fma
             -0.25
             (sqrt (pow (* (pow y 3.0) z) -1.0))
             (* -0.125 (sqrt (pow (* y (pow z 3.0)) -1.0)))))
           (* y (fma 0.5 (/ 1.0 t_1) (* 0.5 (sqrt (/ z (pow y 3.0))))))))))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double t_0 = sqrt((y / z));
	double t_1 = sqrt((y * z));
	double tmp;
	if (y <= 7.2e-287) {
		tmp = 2.0 * ((sqrt(((x + z) / y)) * -1.0) * y);
	} else if (y <= 2.45e-18) {
		tmp = 2.0 * (fma(x, fma(-0.25, (x * t_0), (0.5 * t_1)), (y * fma(sqrt(y), sqrt(z), (x * fma(-0.125, (x * sqrt((y / pow(z, 3.0)))), (0.5 * t_0)))))) / y);
	} else {
		tmp = 2.0 * fma(sqrt(y), sqrt(z), (x * fma(x, (y * fma(-0.25, sqrt(pow((pow(y, 3.0) * z), -1.0)), (-0.125 * sqrt(pow((y * pow(z, 3.0)), -1.0))))), (y * fma(0.5, (1.0 / t_1), (0.5 * sqrt((z / pow(y, 3.0)))))))));
	}
	return tmp;
}
x, y, z = sort([x, y, z])
function code(x, y, z)
	t_0 = sqrt(Float64(y / z))
	t_1 = sqrt(Float64(y * z))
	tmp = 0.0
	if (y <= 7.2e-287)
		tmp = Float64(2.0 * Float64(Float64(sqrt(Float64(Float64(x + z) / y)) * -1.0) * y));
	elseif (y <= 2.45e-18)
		tmp = Float64(2.0 * Float64(fma(x, fma(-0.25, Float64(x * t_0), Float64(0.5 * t_1)), Float64(y * fma(sqrt(y), sqrt(z), Float64(x * fma(-0.125, Float64(x * sqrt(Float64(y / (z ^ 3.0)))), Float64(0.5 * t_0)))))) / y));
	else
		tmp = Float64(2.0 * fma(sqrt(y), sqrt(z), Float64(x * fma(x, Float64(y * fma(-0.25, sqrt((Float64((y ^ 3.0) * z) ^ -1.0)), Float64(-0.125 * sqrt((Float64(y * (z ^ 3.0)) ^ -1.0))))), Float64(y * fma(0.5, Float64(1.0 / t_1), Float64(0.5 * sqrt(Float64(z / (y ^ 3.0))))))))));
	end
	return tmp
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(y * z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 7.2e-287], N[(2.0 * N[(N[(N[Sqrt[N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision] * -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.45e-18], N[(2.0 * N[(N[(x * N[(-0.25 * N[(x * t$95$0), $MachinePrecision] + N[(0.5 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(y * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(-0.125 * N[(x * N[Sqrt[N[(y / N[Power[z, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(x * N[(y * N[(-0.25 * N[Sqrt[N[Power[N[(N[Power[y, 3.0], $MachinePrecision] * z), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] + N[(-0.125 * N[Sqrt[N[Power[N[(y * N[Power[z, 3.0], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * N[(0.5 * N[(1.0 / t$95$1), $MachinePrecision] + N[(0.5 * N[Sqrt[N[(z / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{y}{z}}\\
t_1 := \sqrt{y \cdot z}\\
\mathbf{if}\;y \leq 7.2 \cdot 10^{-287}:\\
\;\;\;\;2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right)\\

\mathbf{elif}\;y \leq 2.45 \cdot 10^{-18}:\\
\;\;\;\;2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot t\_0, 0.5 \cdot t\_1\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot t\_0\right)\right)\right)}{y}\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{t\_1}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 7.2000000000000003e-287

    1. Initial program 66.5%

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{\left(\frac{2}{2}\right)}\right) \cdot y\right) \]
      2. metadata-evalN/A

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{1}\right) \cdot y\right) \]
      3. metadata-evalN/A

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right) \]
      7. lower-+.f6459.0

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right) \]
    8. Applied rewrites59.0%

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

    if 7.2000000000000003e-287 < y < 2.4500000000000001e-18

    1. Initial program 82.7%

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

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

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

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

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

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

      \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \color{blue}{\sqrt{z}}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{\sqrt{y \cdot z}}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right) \]
    8. Taylor expanded in y around 0

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

        \[\leadsto 2 \cdot \frac{x \cdot \left(\frac{-1}{4} \cdot \left(x \cdot \sqrt{\frac{y}{z}}\right) + \frac{1}{2} \cdot \sqrt{y \cdot z}\right) + y \cdot \left(\sqrt{y \cdot z} + x \cdot \left(\frac{-1}{8} \cdot \left(x \cdot \sqrt{\frac{y}{{z}^{3}}}\right) + \frac{1}{2} \cdot \sqrt{\frac{y}{z}}\right)\right)}{y} \]
    10. Applied rewrites17.7%

      \[\leadsto 2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot \sqrt{\frac{y}{z}}, 0.5 \cdot \sqrt{y \cdot z}\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot \sqrt{\frac{y}{z}}\right)\right)\right)}{y} \]

    if 2.4500000000000001e-18 < y

    1. Initial program 55.1%

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

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

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

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

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

      \[\leadsto 2 \cdot \left(\sqrt{y \cdot z} + \color{blue}{x \cdot \left(x \cdot \left(y \cdot \left(\frac{-1}{4} \cdot \sqrt{\frac{1}{{y}^{3} \cdot z}} + \frac{-1}{8} \cdot \sqrt{\frac{1}{y \cdot {z}^{3}}}\right)\right) + y \cdot \left(\frac{1}{2} \cdot \sqrt{\frac{1}{y \cdot z}} + \frac{1}{2} \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)}\right) \]
    7. Applied rewrites28.5%

      \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \color{blue}{\sqrt{z}}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{\sqrt{y \cdot z}}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 88.2% accurate, N/A× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{y}{z}}\\ t_1 := \sqrt{y \cdot z}\\ \mathbf{if}\;y \leq -9.8 \cdot 10^{-172}:\\ \;\;\;\;2 \cdot \left(\left(\sqrt{x \cdot \left({y}^{-1} + \frac{z}{x \cdot y}\right)} \cdot -1\right) \cdot y\right)\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-287}:\\ \;\;\;\;2 \cdot \left(\left(\sqrt{\frac{z \cdot \left(1 + \frac{x}{z}\right)}{y}} \cdot -1\right) \cdot y\right)\\ \mathbf{elif}\;y \leq 2.45 \cdot 10^{-18}:\\ \;\;\;\;2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot t\_0, 0.5 \cdot t\_1\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot t\_0\right)\right)\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{t\_1}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (sqrt (/ y z))) (t_1 (sqrt (* y z))))
   (if (<= y -9.8e-172)
     (* 2.0 (* (* (sqrt (* x (+ (pow y -1.0) (/ z (* x y))))) -1.0) y))
     (if (<= y 7.2e-287)
       (* 2.0 (* (* (sqrt (/ (* z (+ 1.0 (/ x z))) y)) -1.0) y))
       (if (<= y 2.45e-18)
         (*
          2.0
          (/
           (fma
            x
            (fma -0.25 (* x t_0) (* 0.5 t_1))
            (*
             y
             (fma
              (sqrt y)
              (sqrt z)
              (* x (fma -0.125 (* x (sqrt (/ y (pow z 3.0)))) (* 0.5 t_0))))))
           y))
         (*
          2.0
          (fma
           (sqrt y)
           (sqrt z)
           (*
            x
            (fma
             x
             (*
              y
              (fma
               -0.25
               (sqrt (pow (* (pow y 3.0) z) -1.0))
               (* -0.125 (sqrt (pow (* y (pow z 3.0)) -1.0)))))
             (*
              y
              (fma 0.5 (/ 1.0 t_1) (* 0.5 (sqrt (/ z (pow y 3.0)))))))))))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double t_0 = sqrt((y / z));
	double t_1 = sqrt((y * z));
	double tmp;
	if (y <= -9.8e-172) {
		tmp = 2.0 * ((sqrt((x * (pow(y, -1.0) + (z / (x * y))))) * -1.0) * y);
	} else if (y <= 7.2e-287) {
		tmp = 2.0 * ((sqrt(((z * (1.0 + (x / z))) / y)) * -1.0) * y);
	} else if (y <= 2.45e-18) {
		tmp = 2.0 * (fma(x, fma(-0.25, (x * t_0), (0.5 * t_1)), (y * fma(sqrt(y), sqrt(z), (x * fma(-0.125, (x * sqrt((y / pow(z, 3.0)))), (0.5 * t_0)))))) / y);
	} else {
		tmp = 2.0 * fma(sqrt(y), sqrt(z), (x * fma(x, (y * fma(-0.25, sqrt(pow((pow(y, 3.0) * z), -1.0)), (-0.125 * sqrt(pow((y * pow(z, 3.0)), -1.0))))), (y * fma(0.5, (1.0 / t_1), (0.5 * sqrt((z / pow(y, 3.0)))))))));
	}
	return tmp;
}
x, y, z = sort([x, y, z])
function code(x, y, z)
	t_0 = sqrt(Float64(y / z))
	t_1 = sqrt(Float64(y * z))
	tmp = 0.0
	if (y <= -9.8e-172)
		tmp = Float64(2.0 * Float64(Float64(sqrt(Float64(x * Float64((y ^ -1.0) + Float64(z / Float64(x * y))))) * -1.0) * y));
	elseif (y <= 7.2e-287)
		tmp = Float64(2.0 * Float64(Float64(sqrt(Float64(Float64(z * Float64(1.0 + Float64(x / z))) / y)) * -1.0) * y));
	elseif (y <= 2.45e-18)
		tmp = Float64(2.0 * Float64(fma(x, fma(-0.25, Float64(x * t_0), Float64(0.5 * t_1)), Float64(y * fma(sqrt(y), sqrt(z), Float64(x * fma(-0.125, Float64(x * sqrt(Float64(y / (z ^ 3.0)))), Float64(0.5 * t_0)))))) / y));
	else
		tmp = Float64(2.0 * fma(sqrt(y), sqrt(z), Float64(x * fma(x, Float64(y * fma(-0.25, sqrt((Float64((y ^ 3.0) * z) ^ -1.0)), Float64(-0.125 * sqrt((Float64(y * (z ^ 3.0)) ^ -1.0))))), Float64(y * fma(0.5, Float64(1.0 / t_1), Float64(0.5 * sqrt(Float64(z / (y ^ 3.0))))))))));
	end
	return tmp
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(y * z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, -9.8e-172], N[(2.0 * N[(N[(N[Sqrt[N[(x * N[(N[Power[y, -1.0], $MachinePrecision] + N[(z / N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.2e-287], N[(2.0 * N[(N[(N[Sqrt[N[(N[(z * N[(1.0 + N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision] * -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.45e-18], N[(2.0 * N[(N[(x * N[(-0.25 * N[(x * t$95$0), $MachinePrecision] + N[(0.5 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(y * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(-0.125 * N[(x * N[Sqrt[N[(y / N[Power[z, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(x * N[(y * N[(-0.25 * N[Sqrt[N[Power[N[(N[Power[y, 3.0], $MachinePrecision] * z), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] + N[(-0.125 * N[Sqrt[N[Power[N[(y * N[Power[z, 3.0], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * N[(0.5 * N[(1.0 / t$95$1), $MachinePrecision] + N[(0.5 * N[Sqrt[N[(z / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{y}{z}}\\
t_1 := \sqrt{y \cdot z}\\
\mathbf{if}\;y \leq -9.8 \cdot 10^{-172}:\\
\;\;\;\;2 \cdot \left(\left(\sqrt{x \cdot \left({y}^{-1} + \frac{z}{x \cdot y}\right)} \cdot -1\right) \cdot y\right)\\

\mathbf{elif}\;y \leq 7.2 \cdot 10^{-287}:\\
\;\;\;\;2 \cdot \left(\left(\sqrt{\frac{z \cdot \left(1 + \frac{x}{z}\right)}{y}} \cdot -1\right) \cdot y\right)\\

\mathbf{elif}\;y \leq 2.45 \cdot 10^{-18}:\\
\;\;\;\;2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot t\_0, 0.5 \cdot t\_1\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot t\_0\right)\right)\right)}{y}\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{t\_1}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -9.8000000000000001e-172

    1. Initial program 65.9%

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{\left(\frac{2}{2}\right)}\right) \cdot y\right) \]
      2. metadata-evalN/A

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{1}\right) \cdot y\right) \]
      3. metadata-evalN/A

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right) \]
      7. lower-+.f6474.9

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right) \]
    8. Applied rewrites74.9%

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{x \cdot \left({y}^{-1} + \frac{z}{x \cdot y}\right)} \cdot -1\right) \cdot y\right) \]
      6. lift-*.f6461.3

        \[\leadsto 2 \cdot \left(\left(\sqrt{x \cdot \left({y}^{-1} + \frac{z}{x \cdot y}\right)} \cdot -1\right) \cdot y\right) \]
    11. Applied rewrites61.3%

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

    if -9.8000000000000001e-172 < y < 7.2000000000000003e-287

    1. Initial program 68.5%

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{\left(\frac{2}{2}\right)}\right) \cdot y\right) \]
      2. metadata-evalN/A

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{1}\right) \cdot y\right) \]
      3. metadata-evalN/A

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right) \]
      7. lower-+.f647.9

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right) \]
    8. Applied rewrites7.9%

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{z \cdot \left(1 + \frac{x}{z}\right)}{y}} \cdot -1\right) \cdot y\right) \]
    11. Applied rewrites7.9%

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

    if 7.2000000000000003e-287 < y < 2.4500000000000001e-18

    1. Initial program 82.7%

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

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

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

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

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

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

      \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \color{blue}{\sqrt{z}}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{\sqrt{y \cdot z}}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right) \]
    8. Taylor expanded in y around 0

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

        \[\leadsto 2 \cdot \frac{x \cdot \left(\frac{-1}{4} \cdot \left(x \cdot \sqrt{\frac{y}{z}}\right) + \frac{1}{2} \cdot \sqrt{y \cdot z}\right) + y \cdot \left(\sqrt{y \cdot z} + x \cdot \left(\frac{-1}{8} \cdot \left(x \cdot \sqrt{\frac{y}{{z}^{3}}}\right) + \frac{1}{2} \cdot \sqrt{\frac{y}{z}}\right)\right)}{y} \]
    10. Applied rewrites17.7%

      \[\leadsto 2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot \sqrt{\frac{y}{z}}, 0.5 \cdot \sqrt{y \cdot z}\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot \sqrt{\frac{y}{z}}\right)\right)\right)}{y} \]

    if 2.4500000000000001e-18 < y

    1. Initial program 55.1%

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

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

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

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

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

      \[\leadsto 2 \cdot \left(\sqrt{y \cdot z} + \color{blue}{x \cdot \left(x \cdot \left(y \cdot \left(\frac{-1}{4} \cdot \sqrt{\frac{1}{{y}^{3} \cdot z}} + \frac{-1}{8} \cdot \sqrt{\frac{1}{y \cdot {z}^{3}}}\right)\right) + y \cdot \left(\frac{1}{2} \cdot \sqrt{\frac{1}{y \cdot z}} + \frac{1}{2} \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)}\right) \]
    7. Applied rewrites28.5%

      \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \color{blue}{\sqrt{z}}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{\sqrt{y \cdot z}}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right) \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 7: 87.8% accurate, N/A× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} t_0 := \sqrt{y \cdot z}\\ t_1 := \sqrt{\frac{y}{z}}\\ \mathbf{if}\;y \leq 3.3 \cdot 10^{-287}:\\ \;\;\;\;2 \cdot \left(\left(\sqrt{x \cdot \left({y}^{-1} + \frac{z}{x \cdot y}\right)} \cdot -1\right) \cdot y\right)\\ \mathbf{elif}\;y \leq 2.45 \cdot 10^{-18}:\\ \;\;\;\;2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot t\_1, 0.5 \cdot t\_0\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot t\_1\right)\right)\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{t\_0}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (sqrt (* y z))) (t_1 (sqrt (/ y z))))
   (if (<= y 3.3e-287)
     (* 2.0 (* (* (sqrt (* x (+ (pow y -1.0) (/ z (* x y))))) -1.0) y))
     (if (<= y 2.45e-18)
       (*
        2.0
        (/
         (fma
          x
          (fma -0.25 (* x t_1) (* 0.5 t_0))
          (*
           y
           (fma
            (sqrt y)
            (sqrt z)
            (* x (fma -0.125 (* x (sqrt (/ y (pow z 3.0)))) (* 0.5 t_1))))))
         y))
       (*
        2.0
        (fma
         (sqrt y)
         (sqrt z)
         (*
          x
          (fma
           x
           (*
            y
            (fma
             -0.25
             (sqrt (pow (* (pow y 3.0) z) -1.0))
             (* -0.125 (sqrt (pow (* y (pow z 3.0)) -1.0)))))
           (* y (fma 0.5 (/ 1.0 t_0) (* 0.5 (sqrt (/ z (pow y 3.0))))))))))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double t_0 = sqrt((y * z));
	double t_1 = sqrt((y / z));
	double tmp;
	if (y <= 3.3e-287) {
		tmp = 2.0 * ((sqrt((x * (pow(y, -1.0) + (z / (x * y))))) * -1.0) * y);
	} else if (y <= 2.45e-18) {
		tmp = 2.0 * (fma(x, fma(-0.25, (x * t_1), (0.5 * t_0)), (y * fma(sqrt(y), sqrt(z), (x * fma(-0.125, (x * sqrt((y / pow(z, 3.0)))), (0.5 * t_1)))))) / y);
	} else {
		tmp = 2.0 * fma(sqrt(y), sqrt(z), (x * fma(x, (y * fma(-0.25, sqrt(pow((pow(y, 3.0) * z), -1.0)), (-0.125 * sqrt(pow((y * pow(z, 3.0)), -1.0))))), (y * fma(0.5, (1.0 / t_0), (0.5 * sqrt((z / pow(y, 3.0)))))))));
	}
	return tmp;
}
x, y, z = sort([x, y, z])
function code(x, y, z)
	t_0 = sqrt(Float64(y * z))
	t_1 = sqrt(Float64(y / z))
	tmp = 0.0
	if (y <= 3.3e-287)
		tmp = Float64(2.0 * Float64(Float64(sqrt(Float64(x * Float64((y ^ -1.0) + Float64(z / Float64(x * y))))) * -1.0) * y));
	elseif (y <= 2.45e-18)
		tmp = Float64(2.0 * Float64(fma(x, fma(-0.25, Float64(x * t_1), Float64(0.5 * t_0)), Float64(y * fma(sqrt(y), sqrt(z), Float64(x * fma(-0.125, Float64(x * sqrt(Float64(y / (z ^ 3.0)))), Float64(0.5 * t_1)))))) / y));
	else
		tmp = Float64(2.0 * fma(sqrt(y), sqrt(z), Float64(x * fma(x, Float64(y * fma(-0.25, sqrt((Float64((y ^ 3.0) * z) ^ -1.0)), Float64(-0.125 * sqrt((Float64(y * (z ^ 3.0)) ^ -1.0))))), Float64(y * fma(0.5, Float64(1.0 / t_0), Float64(0.5 * sqrt(Float64(z / (y ^ 3.0))))))))));
	end
	return tmp
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[N[(y * z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 3.3e-287], N[(2.0 * N[(N[(N[Sqrt[N[(x * N[(N[Power[y, -1.0], $MachinePrecision] + N[(z / N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.45e-18], N[(2.0 * N[(N[(x * N[(-0.25 * N[(x * t$95$1), $MachinePrecision] + N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(y * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(-0.125 * N[(x * N[Sqrt[N[(y / N[Power[z, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(0.5 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(x * N[(y * N[(-0.25 * N[Sqrt[N[Power[N[(N[Power[y, 3.0], $MachinePrecision] * z), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] + N[(-0.125 * N[Sqrt[N[Power[N[(y * N[Power[z, 3.0], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * N[(0.5 * N[(1.0 / t$95$0), $MachinePrecision] + N[(0.5 * N[Sqrt[N[(z / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := \sqrt{y \cdot z}\\
t_1 := \sqrt{\frac{y}{z}}\\
\mathbf{if}\;y \leq 3.3 \cdot 10^{-287}:\\
\;\;\;\;2 \cdot \left(\left(\sqrt{x \cdot \left({y}^{-1} + \frac{z}{x \cdot y}\right)} \cdot -1\right) \cdot y\right)\\

\mathbf{elif}\;y \leq 2.45 \cdot 10^{-18}:\\
\;\;\;\;2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot t\_1, 0.5 \cdot t\_0\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot t\_1\right)\right)\right)}{y}\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{t\_0}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 3.29999999999999973e-287

    1. Initial program 67.0%

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{\left(\frac{2}{2}\right)}\right) \cdot y\right) \]
      2. metadata-evalN/A

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot {-1}^{1}\right) \cdot y\right) \]
      3. metadata-evalN/A

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\frac{x + z}{y}} \cdot -1\right) \cdot y\right) \]
    8. Applied rewrites59.5%

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{x \cdot \left({y}^{-1} + \frac{z}{x \cdot y}\right)} \cdot -1\right) \cdot y\right) \]
      6. lift-*.f6447.4

        \[\leadsto 2 \cdot \left(\left(\sqrt{x \cdot \left({y}^{-1} + \frac{z}{x \cdot y}\right)} \cdot -1\right) \cdot y\right) \]
    11. Applied rewrites47.4%

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

    if 3.29999999999999973e-287 < y < 2.4500000000000001e-18

    1. Initial program 81.3%

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

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

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

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

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

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

      \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \color{blue}{\sqrt{z}}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{\sqrt{y \cdot z}}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right) \]
    8. Taylor expanded in y around 0

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

        \[\leadsto 2 \cdot \frac{x \cdot \left(\frac{-1}{4} \cdot \left(x \cdot \sqrt{\frac{y}{z}}\right) + \frac{1}{2} \cdot \sqrt{y \cdot z}\right) + y \cdot \left(\sqrt{y \cdot z} + x \cdot \left(\frac{-1}{8} \cdot \left(x \cdot \sqrt{\frac{y}{{z}^{3}}}\right) + \frac{1}{2} \cdot \sqrt{\frac{y}{z}}\right)\right)}{y} \]
    10. Applied rewrites17.4%

      \[\leadsto 2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot \sqrt{\frac{y}{z}}, 0.5 \cdot \sqrt{y \cdot z}\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot \sqrt{\frac{y}{z}}\right)\right)\right)}{y} \]

    if 2.4500000000000001e-18 < y

    1. Initial program 55.1%

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

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

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

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

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

      \[\leadsto 2 \cdot \left(\sqrt{y \cdot z} + \color{blue}{x \cdot \left(x \cdot \left(y \cdot \left(\frac{-1}{4} \cdot \sqrt{\frac{1}{{y}^{3} \cdot z}} + \frac{-1}{8} \cdot \sqrt{\frac{1}{y \cdot {z}^{3}}}\right)\right) + y \cdot \left(\frac{1}{2} \cdot \sqrt{\frac{1}{y \cdot z}} + \frac{1}{2} \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)}\right) \]
    7. Applied rewrites28.5%

      \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \color{blue}{\sqrt{z}}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{\sqrt{y \cdot z}}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 48.1% accurate, N/A× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} t_0 := \sqrt{y \cdot z}\\ t_1 := 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\\ t_2 := \sqrt{\frac{y}{z}}\\ \mathbf{if}\;t\_1 \leq 10^{-81}:\\ \;\;\;\;2 \cdot \left(\sqrt{\frac{x + z}{y}} \cdot y\right)\\ \mathbf{elif}\;t\_1 \leq 10^{+118}:\\ \;\;\;\;2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot t\_2, 0.5 \cdot t\_0\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot t\_2\right)\right)\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{t\_0}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (sqrt (* y z)))
        (t_1 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
        (t_2 (sqrt (/ y z))))
   (if (<= t_1 1e-81)
     (* 2.0 (* (sqrt (/ (+ x z) y)) y))
     (if (<= t_1 1e+118)
       (*
        2.0
        (/
         (fma
          x
          (fma -0.25 (* x t_2) (* 0.5 t_0))
          (*
           y
           (fma
            (sqrt y)
            (sqrt z)
            (* x (fma -0.125 (* x (sqrt (/ y (pow z 3.0)))) (* 0.5 t_2))))))
         y))
       (*
        2.0
        (fma
         (sqrt y)
         (sqrt z)
         (*
          x
          (fma
           x
           (*
            y
            (fma
             -0.25
             (sqrt (pow (* (pow y 3.0) z) -1.0))
             (* -0.125 (sqrt (pow (* y (pow z 3.0)) -1.0)))))
           (* y (fma 0.5 (/ 1.0 t_0) (* 0.5 (sqrt (/ z (pow y 3.0))))))))))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double t_0 = sqrt((y * z));
	double t_1 = 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
	double t_2 = sqrt((y / z));
	double tmp;
	if (t_1 <= 1e-81) {
		tmp = 2.0 * (sqrt(((x + z) / y)) * y);
	} else if (t_1 <= 1e+118) {
		tmp = 2.0 * (fma(x, fma(-0.25, (x * t_2), (0.5 * t_0)), (y * fma(sqrt(y), sqrt(z), (x * fma(-0.125, (x * sqrt((y / pow(z, 3.0)))), (0.5 * t_2)))))) / y);
	} else {
		tmp = 2.0 * fma(sqrt(y), sqrt(z), (x * fma(x, (y * fma(-0.25, sqrt(pow((pow(y, 3.0) * z), -1.0)), (-0.125 * sqrt(pow((y * pow(z, 3.0)), -1.0))))), (y * fma(0.5, (1.0 / t_0), (0.5 * sqrt((z / pow(y, 3.0)))))))));
	}
	return tmp;
}
x, y, z = sort([x, y, z])
function code(x, y, z)
	t_0 = sqrt(Float64(y * z))
	t_1 = Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z))))
	t_2 = sqrt(Float64(y / z))
	tmp = 0.0
	if (t_1 <= 1e-81)
		tmp = Float64(2.0 * Float64(sqrt(Float64(Float64(x + z) / y)) * y));
	elseif (t_1 <= 1e+118)
		tmp = Float64(2.0 * Float64(fma(x, fma(-0.25, Float64(x * t_2), Float64(0.5 * t_0)), Float64(y * fma(sqrt(y), sqrt(z), Float64(x * fma(-0.125, Float64(x * sqrt(Float64(y / (z ^ 3.0)))), Float64(0.5 * t_2)))))) / y));
	else
		tmp = Float64(2.0 * fma(sqrt(y), sqrt(z), Float64(x * fma(x, Float64(y * fma(-0.25, sqrt((Float64((y ^ 3.0) * z) ^ -1.0)), Float64(-0.125 * sqrt((Float64(y * (z ^ 3.0)) ^ -1.0))))), Float64(y * fma(0.5, Float64(1.0 / t_0), Float64(0.5 * sqrt(Float64(z / (y ^ 3.0))))))))));
	end
	return tmp
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[N[(y * z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[Sqrt[N[(N[(N[(x * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, 1e-81], N[(2.0 * N[(N[Sqrt[N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+118], N[(2.0 * N[(N[(x * N[(-0.25 * N[(x * t$95$2), $MachinePrecision] + N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(y * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(-0.125 * N[(x * N[Sqrt[N[(y / N[Power[z, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(0.5 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(x * N[(y * N[(-0.25 * N[Sqrt[N[Power[N[(N[Power[y, 3.0], $MachinePrecision] * z), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] + N[(-0.125 * N[Sqrt[N[Power[N[(y * N[Power[z, 3.0], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * N[(0.5 * N[(1.0 / t$95$0), $MachinePrecision] + N[(0.5 * N[Sqrt[N[(z / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := \sqrt{y \cdot z}\\
t_1 := 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\\
t_2 := \sqrt{\frac{y}{z}}\\
\mathbf{if}\;t\_1 \leq 10^{-81}:\\
\;\;\;\;2 \cdot \left(\sqrt{\frac{x + z}{y}} \cdot y\right)\\

\mathbf{elif}\;t\_1 \leq 10^{+118}:\\
\;\;\;\;2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot t\_2, 0.5 \cdot t\_0\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot t\_2\right)\right)\right)}{y}\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{t\_0}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 #s(literal 2 binary64) (sqrt.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 x z)) (*.f64 y z)))) < 9.9999999999999996e-82

    1. Initial program 68.7%

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999996e-82 < (*.f64 #s(literal 2 binary64) (sqrt.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 x z)) (*.f64 y z)))) < 9.99999999999999967e117

    1. Initial program 99.9%

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

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

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

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

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

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

      \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \color{blue}{\sqrt{z}}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{\sqrt{y \cdot z}}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right) \]
    8. Taylor expanded in y around 0

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

        \[\leadsto 2 \cdot \frac{x \cdot \left(\frac{-1}{4} \cdot \left(x \cdot \sqrt{\frac{y}{z}}\right) + \frac{1}{2} \cdot \sqrt{y \cdot z}\right) + y \cdot \left(\sqrt{y \cdot z} + x \cdot \left(\frac{-1}{8} \cdot \left(x \cdot \sqrt{\frac{y}{{z}^{3}}}\right) + \frac{1}{2} \cdot \sqrt{\frac{y}{z}}\right)\right)}{y} \]
    10. Applied rewrites10.0%

      \[\leadsto 2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot \sqrt{\frac{y}{z}}, 0.5 \cdot \sqrt{y \cdot z}\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot \sqrt{\frac{y}{z}}\right)\right)\right)}{y} \]

    if 9.99999999999999967e117 < (*.f64 #s(literal 2 binary64) (sqrt.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 x z)) (*.f64 y z))))

    1. Initial program 30.7%

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

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

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

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

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

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

      \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \color{blue}{\sqrt{z}}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{\sqrt{y \cdot z}}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 9: 48.3% accurate, N/A× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{y}{z}}\\ t_1 := \sqrt{y \cdot z}\\ \mathbf{if}\;y \leq 7.5 \cdot 10^{-270}:\\ \;\;\;\;\mathsf{fma}\left({\left(z \cdot x\right)}^{-0.5} \cdot y, z + x, \sqrt{z \cdot x} \cdot 2\right)\\ \mathbf{elif}\;y \leq 2.45 \cdot 10^{-18}:\\ \;\;\;\;2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot t\_0, 0.5 \cdot t\_1\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot t\_0\right)\right)\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{t\_1}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (sqrt (/ y z))) (t_1 (sqrt (* y z))))
   (if (<= y 7.5e-270)
     (fma (* (pow (* z x) -0.5) y) (+ z x) (* (sqrt (* z x)) 2.0))
     (if (<= y 2.45e-18)
       (*
        2.0
        (/
         (fma
          x
          (fma -0.25 (* x t_0) (* 0.5 t_1))
          (*
           y
           (fma
            (sqrt y)
            (sqrt z)
            (* x (fma -0.125 (* x (sqrt (/ y (pow z 3.0)))) (* 0.5 t_0))))))
         y))
       (*
        2.0
        (fma
         (sqrt y)
         (sqrt z)
         (*
          x
          (fma
           x
           (*
            y
            (fma
             -0.25
             (sqrt (pow (* (pow y 3.0) z) -1.0))
             (* -0.125 (sqrt (pow (* y (pow z 3.0)) -1.0)))))
           (* y (fma 0.5 (/ 1.0 t_1) (* 0.5 (sqrt (/ z (pow y 3.0))))))))))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double t_0 = sqrt((y / z));
	double t_1 = sqrt((y * z));
	double tmp;
	if (y <= 7.5e-270) {
		tmp = fma((pow((z * x), -0.5) * y), (z + x), (sqrt((z * x)) * 2.0));
	} else if (y <= 2.45e-18) {
		tmp = 2.0 * (fma(x, fma(-0.25, (x * t_0), (0.5 * t_1)), (y * fma(sqrt(y), sqrt(z), (x * fma(-0.125, (x * sqrt((y / pow(z, 3.0)))), (0.5 * t_0)))))) / y);
	} else {
		tmp = 2.0 * fma(sqrt(y), sqrt(z), (x * fma(x, (y * fma(-0.25, sqrt(pow((pow(y, 3.0) * z), -1.0)), (-0.125 * sqrt(pow((y * pow(z, 3.0)), -1.0))))), (y * fma(0.5, (1.0 / t_1), (0.5 * sqrt((z / pow(y, 3.0)))))))));
	}
	return tmp;
}
x, y, z = sort([x, y, z])
function code(x, y, z)
	t_0 = sqrt(Float64(y / z))
	t_1 = sqrt(Float64(y * z))
	tmp = 0.0
	if (y <= 7.5e-270)
		tmp = fma(Float64((Float64(z * x) ^ -0.5) * y), Float64(z + x), Float64(sqrt(Float64(z * x)) * 2.0));
	elseif (y <= 2.45e-18)
		tmp = Float64(2.0 * Float64(fma(x, fma(-0.25, Float64(x * t_0), Float64(0.5 * t_1)), Float64(y * fma(sqrt(y), sqrt(z), Float64(x * fma(-0.125, Float64(x * sqrt(Float64(y / (z ^ 3.0)))), Float64(0.5 * t_0)))))) / y));
	else
		tmp = Float64(2.0 * fma(sqrt(y), sqrt(z), Float64(x * fma(x, Float64(y * fma(-0.25, sqrt((Float64((y ^ 3.0) * z) ^ -1.0)), Float64(-0.125 * sqrt((Float64(y * (z ^ 3.0)) ^ -1.0))))), Float64(y * fma(0.5, Float64(1.0 / t_1), Float64(0.5 * sqrt(Float64(z / (y ^ 3.0))))))))));
	end
	return tmp
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[N[(y / z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(y * z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 7.5e-270], N[(N[(N[Power[N[(z * x), $MachinePrecision], -0.5], $MachinePrecision] * y), $MachinePrecision] * N[(z + x), $MachinePrecision] + N[(N[Sqrt[N[(z * x), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.45e-18], N[(2.0 * N[(N[(x * N[(-0.25 * N[(x * t$95$0), $MachinePrecision] + N[(0.5 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(y * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(-0.125 * N[(x * N[Sqrt[N[(y / N[Power[z, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(x * N[(x * N[(y * N[(-0.25 * N[Sqrt[N[Power[N[(N[Power[y, 3.0], $MachinePrecision] * z), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] + N[(-0.125 * N[Sqrt[N[Power[N[(y * N[Power[z, 3.0], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * N[(0.5 * N[(1.0 / t$95$1), $MachinePrecision] + N[(0.5 * N[Sqrt[N[(z / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{y}{z}}\\
t_1 := \sqrt{y \cdot z}\\
\mathbf{if}\;y \leq 7.5 \cdot 10^{-270}:\\
\;\;\;\;\mathsf{fma}\left({\left(z \cdot x\right)}^{-0.5} \cdot y, z + x, \sqrt{z \cdot x} \cdot 2\right)\\

\mathbf{elif}\;y \leq 2.45 \cdot 10^{-18}:\\
\;\;\;\;2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot t\_0, 0.5 \cdot t\_1\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot t\_0\right)\right)\right)}{y}\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{t\_1}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 7.4999999999999997e-270

    1. Initial program 66.6%

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

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

        \[\leadsto \sqrt{\frac{1}{x \cdot z}} \cdot \left(y \cdot \left(x + z\right)\right) + \color{blue}{2 \cdot \sqrt{x \cdot z}} \]
      2. associate-*r*N/A

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt{\frac{1}{x \cdot z}} \cdot y, \color{blue}{x} + z, 2 \cdot \sqrt{x \cdot z}\right) \]
      5. inv-powN/A

        \[\leadsto \mathsf{fma}\left(\sqrt{{\left(x \cdot z\right)}^{-1}} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
      6. sqrt-pow1N/A

        \[\leadsto \mathsf{fma}\left({\left(x \cdot z\right)}^{\left(\frac{-1}{2}\right)} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left({\left(x \cdot z\right)}^{\frac{-1}{2}} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left({\left(x \cdot z\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
      9. lower-pow.f64N/A

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

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

        \[\leadsto \mathsf{fma}\left({\left(z \cdot x\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left({\left(z \cdot x\right)}^{\frac{-1}{2}} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
      13. +-commutativeN/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left({\left(z \cdot x\right)}^{\frac{-1}{2}} \cdot y, z + x, \sqrt{x \cdot z} \cdot 2\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left({\left(z \cdot x\right)}^{\frac{-1}{2}} \cdot y, z + x, \sqrt{z \cdot x} \cdot 2\right) \]
      19. lower-*.f6426.0

        \[\leadsto \mathsf{fma}\left({\left(z \cdot x\right)}^{-0.5} \cdot y, z + x, \sqrt{z \cdot x} \cdot 2\right) \]
    5. Applied rewrites26.0%

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

    if 7.4999999999999997e-270 < y < 2.4500000000000001e-18

    1. Initial program 83.4%

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

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

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

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

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

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

      \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \color{blue}{\sqrt{z}}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{\sqrt{y \cdot z}}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right) \]
    8. Taylor expanded in y around 0

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

        \[\leadsto 2 \cdot \frac{x \cdot \left(\frac{-1}{4} \cdot \left(x \cdot \sqrt{\frac{y}{z}}\right) + \frac{1}{2} \cdot \sqrt{y \cdot z}\right) + y \cdot \left(\sqrt{y \cdot z} + x \cdot \left(\frac{-1}{8} \cdot \left(x \cdot \sqrt{\frac{y}{{z}^{3}}}\right) + \frac{1}{2} \cdot \sqrt{\frac{y}{z}}\right)\right)}{y} \]
    10. Applied rewrites18.6%

      \[\leadsto 2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot \sqrt{\frac{y}{z}}, 0.5 \cdot \sqrt{y \cdot z}\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot \sqrt{\frac{y}{z}}\right)\right)\right)}{y} \]

    if 2.4500000000000001e-18 < y

    1. Initial program 55.1%

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

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

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

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

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

      \[\leadsto 2 \cdot \left(\sqrt{y \cdot z} + \color{blue}{x \cdot \left(x \cdot \left(y \cdot \left(\frac{-1}{4} \cdot \sqrt{\frac{1}{{y}^{3} \cdot z}} + \frac{-1}{8} \cdot \sqrt{\frac{1}{y \cdot {z}^{3}}}\right)\right) + y \cdot \left(\frac{1}{2} \cdot \sqrt{\frac{1}{y \cdot z}} + \frac{1}{2} \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)}\right) \]
    7. Applied rewrites28.5%

      \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \color{blue}{\sqrt{z}}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{\sqrt{y \cdot z}}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 10: 34.9% accurate, N/A× speedup?

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

\mathbf{else}:\\
\;\;\;\;2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot t\_0, 0.5 \cdot \sqrt{y \cdot z}\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot t\_0\right)\right)\right)}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 5.4999999999999998e-116

    1. Initial program 72.0%

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

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

        \[\leadsto \sqrt{\frac{1}{x \cdot z}} \cdot \left(y \cdot \left(x + z\right)\right) + \color{blue}{2 \cdot \sqrt{x \cdot z}} \]
      2. associate-*r*N/A

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt{\frac{1}{x \cdot z}} \cdot y, \color{blue}{x} + z, 2 \cdot \sqrt{x \cdot z}\right) \]
      5. inv-powN/A

        \[\leadsto \mathsf{fma}\left(\sqrt{{\left(x \cdot z\right)}^{-1}} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
      6. sqrt-pow1N/A

        \[\leadsto \mathsf{fma}\left({\left(x \cdot z\right)}^{\left(\frac{-1}{2}\right)} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left({\left(x \cdot z\right)}^{\frac{-1}{2}} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left({\left(x \cdot z\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
      9. lower-pow.f64N/A

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

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

        \[\leadsto \mathsf{fma}\left({\left(z \cdot x\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left({\left(z \cdot x\right)}^{\frac{-1}{2}} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
      13. +-commutativeN/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left({\left(z \cdot x\right)}^{\frac{-1}{2}} \cdot y, z + x, \sqrt{x \cdot z} \cdot 2\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left({\left(z \cdot x\right)}^{\frac{-1}{2}} \cdot y, z + x, \sqrt{z \cdot x} \cdot 2\right) \]
      19. lower-*.f6421.9

        \[\leadsto \mathsf{fma}\left({\left(z \cdot x\right)}^{-0.5} \cdot y, z + x, \sqrt{z \cdot x} \cdot 2\right) \]
    5. Applied rewrites21.9%

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

    if 5.4999999999999998e-116 < z

    1. Initial program 57.6%

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

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

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

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

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

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

      \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \color{blue}{\sqrt{z}}, x \cdot \mathsf{fma}\left(x, y \cdot \mathsf{fma}\left(-0.25, \sqrt{{\left({y}^{3} \cdot z\right)}^{-1}}, -0.125 \cdot \sqrt{{\left(y \cdot {z}^{3}\right)}^{-1}}\right), y \cdot \mathsf{fma}\left(0.5, \frac{1}{\sqrt{y \cdot z}}, 0.5 \cdot \sqrt{\frac{z}{{y}^{3}}}\right)\right)\right) \]
    8. Taylor expanded in y around 0

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

        \[\leadsto 2 \cdot \frac{x \cdot \left(\frac{-1}{4} \cdot \left(x \cdot \sqrt{\frac{y}{z}}\right) + \frac{1}{2} \cdot \sqrt{y \cdot z}\right) + y \cdot \left(\sqrt{y \cdot z} + x \cdot \left(\frac{-1}{8} \cdot \left(x \cdot \sqrt{\frac{y}{{z}^{3}}}\right) + \frac{1}{2} \cdot \sqrt{\frac{y}{z}}\right)\right)}{y} \]
    10. Applied rewrites16.4%

      \[\leadsto 2 \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(-0.25, x \cdot \sqrt{\frac{y}{z}}, 0.5 \cdot \sqrt{y \cdot z}\right), y \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, x \cdot \mathsf{fma}\left(-0.125, x \cdot \sqrt{\frac{y}{{z}^{3}}}, 0.5 \cdot \sqrt{\frac{y}{z}}\right)\right)\right)}{y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 3.5% accurate, N/A× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \mathsf{fma}\left({\left(z \cdot x\right)}^{-0.5} \cdot y, z + x, \sqrt{z \cdot x} \cdot 2\right) \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (fma (* (pow (* z x) -0.5) y) (+ z x) (* (sqrt (* z x)) 2.0)))
assert(x < y && y < z);
double code(double x, double y, double z) {
	return fma((pow((z * x), -0.5) * y), (z + x), (sqrt((z * x)) * 2.0));
}
x, y, z = sort([x, y, z])
function code(x, y, z)
	return fma(Float64((Float64(z * x) ^ -0.5) * y), Float64(z + x), Float64(sqrt(Float64(z * x)) * 2.0))
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := N[(N[(N[Power[N[(z * x), $MachinePrecision], -0.5], $MachinePrecision] * y), $MachinePrecision] * N[(z + x), $MachinePrecision] + N[(N[Sqrt[N[(z * x), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\mathsf{fma}\left({\left(z \cdot x\right)}^{-0.5} \cdot y, z + x, \sqrt{z \cdot x} \cdot 2\right)
\end{array}
Derivation
  1. Initial program 67.1%

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

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

      \[\leadsto \sqrt{\frac{1}{x \cdot z}} \cdot \left(y \cdot \left(x + z\right)\right) + \color{blue}{2 \cdot \sqrt{x \cdot z}} \]
    2. associate-*r*N/A

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

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

      \[\leadsto \mathsf{fma}\left(\sqrt{\frac{1}{x \cdot z}} \cdot y, \color{blue}{x} + z, 2 \cdot \sqrt{x \cdot z}\right) \]
    5. inv-powN/A

      \[\leadsto \mathsf{fma}\left(\sqrt{{\left(x \cdot z\right)}^{-1}} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
    6. sqrt-pow1N/A

      \[\leadsto \mathsf{fma}\left({\left(x \cdot z\right)}^{\left(\frac{-1}{2}\right)} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
    7. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left({\left(x \cdot z\right)}^{\frac{-1}{2}} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
    8. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left({\left(x \cdot z\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
    9. lower-pow.f64N/A

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

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

      \[\leadsto \mathsf{fma}\left({\left(z \cdot x\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
    12. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left({\left(z \cdot x\right)}^{\frac{-1}{2}} \cdot y, x + z, 2 \cdot \sqrt{x \cdot z}\right) \]
    13. +-commutativeN/A

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

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

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

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

      \[\leadsto \mathsf{fma}\left({\left(z \cdot x\right)}^{\frac{-1}{2}} \cdot y, z + x, \sqrt{x \cdot z} \cdot 2\right) \]
    18. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left({\left(z \cdot x\right)}^{\frac{-1}{2}} \cdot y, z + x, \sqrt{z \cdot x} \cdot 2\right) \]
    19. lower-*.f6426.3

      \[\leadsto \mathsf{fma}\left({\left(z \cdot x\right)}^{-0.5} \cdot y, z + x, \sqrt{z \cdot x} \cdot 2\right) \]
  5. Applied rewrites26.3%

    \[\leadsto \color{blue}{\mathsf{fma}\left({\left(z \cdot x\right)}^{-0.5} \cdot y, z + x, \sqrt{z \cdot x} \cdot 2\right)} \]
  6. Add Preprocessing

Reproduce

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

  :alt
  (! :herbie-platform default (if (< z 763695009057367500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* 2 (sqrt (+ (* (+ x y) z) (* x y)))) (* (* (+ (* 1/4 (* (* (pow y -3/4) (* (pow z -3/4) x)) (+ y z))) (* (pow z 1/4) (pow y 1/4))) (+ (* 1/4 (* (* (pow y -3/4) (* (pow z -3/4) x)) (+ y z))) (* (pow z 1/4) (pow y 1/4)))) 2)))

  (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))