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

Percentage Accurate: 70.8% → 96.0%
Time: 7.2s
Alternatives: 10
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 10 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.8% 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.0% accurate, N/A× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+20}:\\ \;\;\;\;2 \cdot \left(\left({\left(\frac{x + z}{y}\right)}^{0.5} \cdot -1\right) \cdot y\right)\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-291}:\\ \;\;\;\;2 \cdot {\left(\mathsf{fma}\left(z, y, \mathsf{fma}\left(z, x, y \cdot x\right)\right)\right)}^{0.5}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, 0.5 \cdot \left(x \cdot {\left(\frac{y}{z}\right)}^{0.5}\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
 (if (<= y -5e+20)
   (* 2.0 (* (* (pow (/ (+ x z) y) 0.5) -1.0) y))
   (if (<= y 7.5e-291)
     (* 2.0 (pow (fma z y (fma z x (* y x))) 0.5))
     (* 2.0 (fma (sqrt y) (sqrt z) (* 0.5 (* x (pow (/ y z) 0.5))))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= -5e+20) {
		tmp = 2.0 * ((pow(((x + z) / y), 0.5) * -1.0) * y);
	} else if (y <= 7.5e-291) {
		tmp = 2.0 * pow(fma(z, y, fma(z, x, (y * x))), 0.5);
	} else {
		tmp = 2.0 * fma(sqrt(y), sqrt(z), (0.5 * (x * pow((y / z), 0.5))));
	}
	return tmp;
}
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= -5e+20)
		tmp = Float64(2.0 * Float64(Float64((Float64(Float64(x + z) / y) ^ 0.5) * -1.0) * y));
	elseif (y <= 7.5e-291)
		tmp = Float64(2.0 * (fma(z, y, fma(z, x, Float64(y * x))) ^ 0.5));
	else
		tmp = Float64(2.0 * fma(sqrt(y), sqrt(z), Float64(0.5 * Float64(x * (Float64(y / z) ^ 0.5)))));
	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, -5e+20], N[(2.0 * N[(N[(N[Power[N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision], 0.5], $MachinePrecision] * -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.5e-291], N[(2.0 * N[Power[N[(z * y + N[(z * x + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(0.5 * N[(x * N[Power[N[(y / z), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{+20}:\\
\;\;\;\;2 \cdot \left(\left({\left(\frac{x + z}{y}\right)}^{0.5} \cdot -1\right) \cdot y\right)\\

\mathbf{elif}\;y \leq 7.5 \cdot 10^{-291}:\\
\;\;\;\;2 \cdot {\left(\mathsf{fma}\left(z, y, \mathsf{fma}\left(z, x, y \cdot x\right)\right)\right)}^{0.5}\\

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


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

    1. Initial program 59.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 rewrites1.1%

      \[\leadsto 2 \cdot \color{blue}{\left(\mathsf{fma}\left(0.5 \cdot \left(z \cdot x\right), {\left({\left(z + x\right)}^{-1} \cdot {\left({y}^{3}\right)}^{-1}\right)}^{0.5}, {\left(\frac{z + x}{y}\right)}^{0.5}\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. pow1/2N/A

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

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

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

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

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

    if -5e20 < y < 7.49999999999999981e-291

    1. Initial program 90.3%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \color{blue}{e^{\log \left(\mathsf{fma}\left(z, y, \mathsf{fma}\left(z, x, y \cdot x\right)\right)\right) \cdot 0.5}} \]
    5. Step-by-step derivation
      1. lift-exp.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot {\left(z \cdot y + \color{blue}{\mathsf{fma}\left(z, x, y \cdot x\right)}\right)}^{\frac{1}{2}} \]
      11. lift-fma.f6490.3

        \[\leadsto 2 \cdot {\color{blue}{\left(\mathsf{fma}\left(z, y, \mathsf{fma}\left(z, x, y \cdot x\right)\right)\right)}}^{0.5} \]
    6. Applied rewrites90.3%

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

    if 7.49999999999999981e-291 < y

    1. Initial program 67.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \color{blue}{\frac{\sqrt{\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)}}{\sqrt{x \cdot y - z \cdot \left(x + y\right)}}} \]
      11. lower-/.f64N/A

        \[\leadsto 2 \cdot \color{blue}{\frac{\sqrt{\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)}}{\sqrt{x \cdot y - z \cdot \left(x + y\right)}}} \]
    4. Applied rewrites11.5%

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

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

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

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

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

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

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left({x}^{2} - {z}^{2}\right)}{x - z}\right)}^{\frac{1}{2}} \]
      6. unpow2N/A

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

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left(x \cdot x - {z}^{2}\right)}{x - z}\right)}^{\frac{1}{2}} \]
      8. unpow2N/A

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

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left(x \cdot x - z \cdot z\right)}{x - z}\right)}^{\frac{1}{2}} \]
      10. lower--.f6428.8

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left(x \cdot x - z \cdot z\right)}{x - z}\right)}^{0.5} \]
    7. Applied rewrites28.8%

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, \frac{1}{2} \cdot \left(x \cdot \sqrt{\frac{y}{z}}\right)\right) \]
      7. pow1/2N/A

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

        \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, \frac{1}{2} \cdot \left(x \cdot {\left(\frac{y}{z}\right)}^{\frac{1}{2}}\right)\right) \]
      9. lower-/.f6427.3

        \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, 0.5 \cdot \left(x \cdot {\left(\frac{y}{z}\right)}^{0.5}\right)\right) \]
    10. Applied rewrites27.3%

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

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

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+20}:\\ \;\;\;\;2 \cdot \left(\left({\left(\frac{x + z}{y}\right)}^{0.5} \cdot -1\right) \cdot y\right)\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-291}:\\ \;\;\;\;2 \cdot \sqrt{\left(\frac{z \cdot x}{y} + x\right) \cdot y + y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, 0.5 \cdot \left(x \cdot {\left(\frac{y}{z}\right)}^{0.5}\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
 (if (<= y -5e+20)
   (* 2.0 (* (* (pow (/ (+ x z) y) 0.5) -1.0) y))
   (if (<= y 7.5e-291)
     (* 2.0 (sqrt (+ (* (+ (/ (* z x) y) x) y) (* y z))))
     (* 2.0 (fma (sqrt y) (sqrt z) (* 0.5 (* x (pow (/ y z) 0.5))))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= -5e+20) {
		tmp = 2.0 * ((pow(((x + z) / y), 0.5) * -1.0) * y);
	} else if (y <= 7.5e-291) {
		tmp = 2.0 * sqrt((((((z * x) / y) + x) * y) + (y * z)));
	} else {
		tmp = 2.0 * fma(sqrt(y), sqrt(z), (0.5 * (x * pow((y / z), 0.5))));
	}
	return tmp;
}
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= -5e+20)
		tmp = Float64(2.0 * Float64(Float64((Float64(Float64(x + z) / y) ^ 0.5) * -1.0) * y));
	elseif (y <= 7.5e-291)
		tmp = Float64(2.0 * sqrt(Float64(Float64(Float64(Float64(Float64(z * x) / y) + x) * y) + Float64(y * z))));
	else
		tmp = Float64(2.0 * fma(sqrt(y), sqrt(z), Float64(0.5 * Float64(x * (Float64(y / z) ^ 0.5)))));
	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, -5e+20], N[(2.0 * N[(N[(N[Power[N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision], 0.5], $MachinePrecision] * -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.5e-291], N[(2.0 * N[Sqrt[N[(N[(N[(N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision] + x), $MachinePrecision] * y), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[z], $MachinePrecision] + N[(0.5 * N[(x * N[Power[N[(y / z), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{+20}:\\
\;\;\;\;2 \cdot \left(\left({\left(\frac{x + z}{y}\right)}^{0.5} \cdot -1\right) \cdot y\right)\\

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

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


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

    1. Initial program 59.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 rewrites1.1%

      \[\leadsto 2 \cdot \color{blue}{\left(\mathsf{fma}\left(0.5 \cdot \left(z \cdot x\right), {\left({\left(z + x\right)}^{-1} \cdot {\left({y}^{3}\right)}^{-1}\right)}^{0.5}, {\left(\frac{z + x}{y}\right)}^{0.5}\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. pow1/2N/A

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

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

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

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

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

    if -5e20 < y < 7.49999999999999981e-291

    1. Initial program 90.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 \sqrt{\color{blue}{y \cdot \left(x + \frac{x \cdot z}{y}\right)} + y \cdot z} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

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

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

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

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

    if 7.49999999999999981e-291 < y

    1. Initial program 67.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \color{blue}{\frac{\sqrt{\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)}}{\sqrt{x \cdot y - z \cdot \left(x + y\right)}}} \]
      11. lower-/.f64N/A

        \[\leadsto 2 \cdot \color{blue}{\frac{\sqrt{\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)}}{\sqrt{x \cdot y - z \cdot \left(x + y\right)}}} \]
    4. Applied rewrites11.5%

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

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

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

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

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

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

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left({x}^{2} - {z}^{2}\right)}{x - z}\right)}^{\frac{1}{2}} \]
      6. unpow2N/A

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

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left(x \cdot x - {z}^{2}\right)}{x - z}\right)}^{\frac{1}{2}} \]
      8. unpow2N/A

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

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left(x \cdot x - z \cdot z\right)}{x - z}\right)}^{\frac{1}{2}} \]
      10. lower--.f6428.8

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left(x \cdot x - z \cdot z\right)}{x - z}\right)}^{0.5} \]
    7. Applied rewrites28.8%

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, \frac{1}{2} \cdot \left(x \cdot \sqrt{\frac{y}{z}}\right)\right) \]
      7. pow1/2N/A

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

        \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, \frac{1}{2} \cdot \left(x \cdot {\left(\frac{y}{z}\right)}^{\frac{1}{2}}\right)\right) \]
      9. lower-/.f6427.3

        \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, 0.5 \cdot \left(x \cdot {\left(\frac{y}{z}\right)}^{0.5}\right)\right) \]
    10. Applied rewrites27.3%

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

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

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

\mathbf{elif}\;y \leq 7.5 \cdot 10^{-291}:\\
\;\;\;\;2 \cdot e^{\left(\log \left(\mathsf{fma}\left(-1, y, -1 \cdot z\right)\right) + \log \left({\left(\frac{-1}{x}\right)}^{-1}\right)\right) \cdot 0.5}\\

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


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

    1. Initial program 68.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 rewrites1.2%

      \[\leadsto 2 \cdot \color{blue}{\left(\mathsf{fma}\left(0.5 \cdot \left(z \cdot x\right), {\left({\left(z + x\right)}^{-1} \cdot {\left({y}^{3}\right)}^{-1}\right)}^{0.5}, {\left(\frac{z + x}{y}\right)}^{0.5}\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. pow1/2N/A

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

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

        \[\leadsto 2 \cdot \left(\left({\left(\frac{x + z}{y}\right)}^{\frac{1}{2}} \cdot -1\right) \cdot y\right) \]
      8. lower-+.f6484.9

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

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

    if -2.1999999999999999e-81 < y < 7.49999999999999981e-291

    1. Initial program 86.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-sqrt.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.49999999999999981e-291 < y

    1. Initial program 67.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \color{blue}{\frac{\sqrt{\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)}}{\sqrt{x \cdot y - z \cdot \left(x + y\right)}}} \]
      11. lower-/.f64N/A

        \[\leadsto 2 \cdot \color{blue}{\frac{\sqrt{\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)}}{\sqrt{x \cdot y - z \cdot \left(x + y\right)}}} \]
    4. Applied rewrites11.5%

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

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

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

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

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

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

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left({x}^{2} - {z}^{2}\right)}{x - z}\right)}^{\frac{1}{2}} \]
      6. unpow2N/A

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

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left(x \cdot x - {z}^{2}\right)}{x - z}\right)}^{\frac{1}{2}} \]
      8. unpow2N/A

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

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left(x \cdot x - z \cdot z\right)}{x - z}\right)}^{\frac{1}{2}} \]
      10. lower--.f6428.8

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left(x \cdot x - z \cdot z\right)}{x - z}\right)}^{0.5} \]
    7. Applied rewrites28.8%

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, \frac{1}{2} \cdot \left(x \cdot \sqrt{\frac{y}{z}}\right)\right) \]
      7. pow1/2N/A

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

        \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, \frac{1}{2} \cdot \left(x \cdot {\left(\frac{y}{z}\right)}^{\frac{1}{2}}\right)\right) \]
      9. lower-/.f6427.3

        \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, 0.5 \cdot \left(x \cdot {\left(\frac{y}{z}\right)}^{0.5}\right)\right) \]
    10. Applied rewrites27.3%

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

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

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

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


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

    1. Initial program 73.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 rewrites1.1%

      \[\leadsto 2 \cdot \color{blue}{\left(\mathsf{fma}\left(0.5 \cdot \left(z \cdot x\right), {\left({\left(z + x\right)}^{-1} \cdot {\left({y}^{3}\right)}^{-1}\right)}^{0.5}, {\left(\frac{z + x}{y}\right)}^{0.5}\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. pow1/2N/A

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

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

        \[\leadsto 2 \cdot \left(\left({\left(\frac{x + z}{y}\right)}^{\frac{1}{2}} \cdot -1\right) \cdot y\right) \]
      8. lower-+.f6467.0

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

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

    if -3.999999999999988e-310 < y

    1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \color{blue}{\frac{\sqrt{\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)}}{\sqrt{x \cdot y - z \cdot \left(x + y\right)}}} \]
      11. lower-/.f64N/A

        \[\leadsto 2 \cdot \color{blue}{\frac{\sqrt{\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)}}{\sqrt{x \cdot y - z \cdot \left(x + y\right)}}} \]
    4. Applied rewrites10.9%

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

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

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

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

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

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

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left({x}^{2} - {z}^{2}\right)}{x - z}\right)}^{\frac{1}{2}} \]
      6. unpow2N/A

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

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left(x \cdot x - {z}^{2}\right)}{x - z}\right)}^{\frac{1}{2}} \]
      8. unpow2N/A

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

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left(x \cdot x - z \cdot z\right)}{x - z}\right)}^{\frac{1}{2}} \]
      10. lower--.f6427.5

        \[\leadsto 2 \cdot {\left(\frac{y \cdot \left(x \cdot x - z \cdot z\right)}{x - z}\right)}^{0.5} \]
    7. Applied rewrites27.5%

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \mathsf{fma}\left(\sqrt{y}, \sqrt{z}, \frac{1}{2} \cdot \left(x \cdot \sqrt{\frac{y}{z}}\right)\right) \]
      7. pow1/2N/A

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

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

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

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

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

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

\mathbf{elif}\;y \leq 10^{-45}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left({z}^{0.5}, {y}^{0.5}, \left(0.5 \cdot \mathsf{fma}\left(z, x, y \cdot x\right)\right) \cdot {\left({\left(z \cdot y\right)}^{-1}\right)}^{0.5}\right)\\

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


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

    1. Initial program 74.2%

      \[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 rewrites1.2%

      \[\leadsto 2 \cdot \color{blue}{\left(\mathsf{fma}\left(0.5 \cdot \left(z \cdot x\right), {\left({\left(z + x\right)}^{-1} \cdot {\left({y}^{3}\right)}^{-1}\right)}^{0.5}, {\left(\frac{z + x}{y}\right)}^{0.5}\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. pow1/2N/A

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

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

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

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

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

    if 5.6000000000000001e-281 < y < 9.99999999999999984e-46

    1. Initial program 80.8%

      \[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 \color{blue}{\left(\sqrt{y \cdot z} + \frac{1}{2} \cdot \left(\left(x \cdot \left(y + z\right)\right) \cdot \sqrt{\frac{1}{y \cdot z}}\right)\right)} \]
    4. Step-by-step derivation
      1. pow1/2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \mathsf{fma}\left({z}^{\frac{1}{2}}, {y}^{\frac{1}{2}}, \left(\frac{1}{2} \cdot \mathsf{fma}\left(z, x, y \cdot x\right)\right) \cdot \sqrt{\frac{1}{y \cdot z}}\right) \]
      16. pow1/2N/A

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

        \[\leadsto 2 \cdot \mathsf{fma}\left({z}^{\frac{1}{2}}, {y}^{\frac{1}{2}}, \left(\frac{1}{2} \cdot \mathsf{fma}\left(z, x, y \cdot x\right)\right) \cdot {\left(\frac{1}{y \cdot z}\right)}^{\frac{1}{2}}\right) \]
    5. Applied rewrites17.2%

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

    if 9.99999999999999984e-46 < y

    1. Initial program 58.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 rewrites79.4%

      \[\leadsto 2 \cdot \color{blue}{\left(\mathsf{fma}\left(0.5 \cdot \left(z \cdot x\right), {\left({\left(z + x\right)}^{-1} \cdot {\left({y}^{3}\right)}^{-1}\right)}^{0.5}, {\left(\frac{z + x}{y}\right)}^{0.5}\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. pow1/2N/A

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

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

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

        \[\leadsto 2 \cdot \left({\left(\frac{x + z}{y}\right)}^{0.5} \cdot y\right) \]
    8. Applied rewrites84.7%

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

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

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} t_0 := {\left(\frac{x + z}{y}\right)}^{0.5}\\ \mathbf{if}\;y \leq -4 \cdot 10^{-310}:\\ \;\;\;\;2 \cdot \left(\left(t\_0 \cdot -1\right) \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(t\_0 \cdot y\right)\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (pow (/ (+ x z) y) 0.5)))
   (if (<= y -4e-310) (* 2.0 (* (* t_0 -1.0) y)) (* 2.0 (* t_0 y)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double t_0 = pow(((x + z) / y), 0.5);
	double tmp;
	if (y <= -4e-310) {
		tmp = 2.0 * ((t_0 * -1.0) * y);
	} else {
		tmp = 2.0 * (t_0 * y);
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((x + z) / y) ** 0.5d0
    if (y <= (-4d-310)) then
        tmp = 2.0d0 * ((t_0 * (-1.0d0)) * y)
    else
        tmp = 2.0d0 * (t_0 * y)
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double t_0 = Math.pow(((x + z) / y), 0.5);
	double tmp;
	if (y <= -4e-310) {
		tmp = 2.0 * ((t_0 * -1.0) * y);
	} else {
		tmp = 2.0 * (t_0 * y);
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	t_0 = math.pow(((x + z) / y), 0.5)
	tmp = 0
	if y <= -4e-310:
		tmp = 2.0 * ((t_0 * -1.0) * y)
	else:
		tmp = 2.0 * (t_0 * y)
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	t_0 = Float64(Float64(x + z) / y) ^ 0.5
	tmp = 0.0
	if (y <= -4e-310)
		tmp = Float64(2.0 * Float64(Float64(t_0 * -1.0) * y));
	else
		tmp = Float64(2.0 * Float64(t_0 * y));
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	t_0 = ((x + z) / y) ^ 0.5;
	tmp = 0.0;
	if (y <= -4e-310)
		tmp = 2.0 * ((t_0 * -1.0) * y);
	else
		tmp = 2.0 * (t_0 * y);
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[Power[N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision], 0.5], $MachinePrecision]}, If[LessEqual[y, -4e-310], N[(2.0 * N[(N[(t$95$0 * -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t$95$0 * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{x + z}{y}\right)}^{0.5}\\
\mathbf{if}\;y \leq -4 \cdot 10^{-310}:\\
\;\;\;\;2 \cdot \left(\left(t\_0 \cdot -1\right) \cdot y\right)\\

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


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

    1. Initial program 73.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 rewrites1.1%

      \[\leadsto 2 \cdot \color{blue}{\left(\mathsf{fma}\left(0.5 \cdot \left(z \cdot x\right), {\left({\left(z + x\right)}^{-1} \cdot {\left({y}^{3}\right)}^{-1}\right)}^{0.5}, {\left(\frac{z + x}{y}\right)}^{0.5}\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. pow1/2N/A

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

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

        \[\leadsto 2 \cdot \left(\left({\left(\frac{x + z}{y}\right)}^{\frac{1}{2}} \cdot -1\right) \cdot y\right) \]
      8. lower-+.f6467.0

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

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

    if -3.999999999999988e-310 < y

    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 rewrites47.2%

      \[\leadsto 2 \cdot \color{blue}{\left(\mathsf{fma}\left(0.5 \cdot \left(z \cdot x\right), {\left({\left(z + x\right)}^{-1} \cdot {\left({y}^{3}\right)}^{-1}\right)}^{0.5}, {\left(\frac{z + x}{y}\right)}^{0.5}\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. pow1/2N/A

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

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

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

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({\left({\left(z \cdot x\right)}^{-1}\right)}^{0.5} \cdot y, z + x, {\left(z \cdot x\right)}^{0.5} \cdot 2\right)\\


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

    1. Initial program 74.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 rewrites12.8%

      \[\leadsto 2 \cdot \color{blue}{\left(\mathsf{fma}\left(0.5 \cdot \left(z \cdot x\right), {\left({\left(z + x\right)}^{-1} \cdot {\left({y}^{3}\right)}^{-1}\right)}^{0.5}, {\left(\frac{z + x}{y}\right)}^{0.5}\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. pow1/2N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left({\left(-1 \cdot \left(x \cdot \left(-1 \cdot \frac{z}{x \cdot y} - {y}^{-1}\right)\right)\right)}^{\frac{1}{2}} \cdot -1\right) \cdot y\right) \]
      8. lower-pow.f6436.5

        \[\leadsto 2 \cdot \left(\left({\left(-1 \cdot \left(x \cdot \left(-1 \cdot \frac{z}{x \cdot y} - {y}^{-1}\right)\right)\right)}^{0.5} \cdot -1\right) \cdot y\right) \]
    11. Applied rewrites36.5%

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

    if -2.89999999999999992e-300 < x

    1. Initial program 67.4%

      \[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. pow1/2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left({\left({\left(z \cdot x\right)}^{-1}\right)}^{0.5} \cdot y, z + x, {\left(z \cdot x\right)}^{0.5} \cdot 2\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification28.7%

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

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

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ 2 \cdot \left(\left({\left(\frac{x + z}{y}\right)}^{0.5} \cdot -1\right) \cdot y\right) \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (* 2.0 (* (* (pow (/ (+ x z) y) 0.5) -1.0) y)))
assert(x < y && y < z);
double code(double x, double y, double z) {
	return 2.0 * ((pow(((x + z) / y), 0.5) * -1.0) * y);
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = 2.0d0 * (((((x + z) / y) ** 0.5d0) * (-1.0d0)) * y)
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	return 2.0 * ((Math.pow(((x + z) / y), 0.5) * -1.0) * y);
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	return 2.0 * ((math.pow(((x + z) / y), 0.5) * -1.0) * y)
x, y, z = sort([x, y, z])
function code(x, y, z)
	return Float64(2.0 * Float64(Float64((Float64(Float64(x + z) / y) ^ 0.5) * -1.0) * y))
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
	tmp = 2.0 * (((((x + z) / y) ^ 0.5) * -1.0) * y);
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := N[(2.0 * N[(N[(N[Power[N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision], 0.5], $MachinePrecision] * -1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
2 \cdot \left(\left({\left(\frac{x + z}{y}\right)}^{0.5} \cdot -1\right) \cdot y\right)
\end{array}
Derivation
  1. Initial program 70.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 rewrites26.5%

    \[\leadsto 2 \cdot \color{blue}{\left(\mathsf{fma}\left(0.5 \cdot \left(z \cdot x\right), {\left({\left(z + x\right)}^{-1} \cdot {\left({y}^{3}\right)}^{-1}\right)}^{0.5}, {\left(\frac{z + x}{y}\right)}^{0.5}\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. pow1/2N/A

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

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

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

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

    \[\leadsto 2 \cdot \left(\left({\left(\frac{x + z}{y}\right)}^{0.5} \cdot -1\right) \cdot y\right) \]
  9. Add Preprocessing

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({\left({\left(z \cdot x\right)}^{-1}\right)}^{0.5} \cdot y, z + x, {\left(z \cdot x\right)}^{0.5} \cdot 2\right)\\


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

    1. Initial program 69.8%

      \[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 rewrites1.2%

      \[\leadsto 2 \cdot \color{blue}{\left(\mathsf{fma}\left(0.5 \cdot \left(z \cdot x\right), {\left({\left(z + x\right)}^{-1} \cdot {\left({y}^{3}\right)}^{-1}\right)}^{0.5}, {\left(\frac{z + x}{y}\right)}^{0.5}\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. pow1/2N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left({\left(-1 \cdot \left(x \cdot \left(-1 \cdot \frac{z}{x \cdot y} - {y}^{-1}\right)\right)\right)}^{\frac{1}{2}} \cdot -1\right) \cdot y\right) \]
      8. lower-pow.f6468.2

        \[\leadsto 2 \cdot \left(\left({\left(-1 \cdot \left(x \cdot \left(-1 \cdot \frac{z}{x \cdot y} - {y}^{-1}\right)\right)\right)}^{0.5} \cdot -1\right) \cdot y\right) \]
    11. Applied rewrites68.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left({\left(-1 \cdot \left(x \cdot \left(-1 \cdot \left(z \cdot \left({\left(x \cdot y\right)}^{-1} + {\left(y \cdot z\right)}^{-1}\right)\right)\right)\right)\right)}^{\frac{1}{2}} \cdot -1\right) \cdot y\right) \]
      9. lower-*.f6463.5

        \[\leadsto 2 \cdot \left(\left({\left(-1 \cdot \left(x \cdot \left(-1 \cdot \left(z \cdot \left({\left(x \cdot y\right)}^{-1} + {\left(y \cdot z\right)}^{-1}\right)\right)\right)\right)\right)}^{0.5} \cdot -1\right) \cdot y\right) \]
    14. Applied rewrites63.5%

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

    if -3.69999999999999986e-146 < y

    1. Initial program 71.2%

      \[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. pow1/2N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left({\left({\left(z \cdot x\right)}^{-1}\right)}^{\frac{1}{2}} \cdot y, z + x, {\left(z \cdot x\right)}^{\frac{1}{2}} \cdot 2\right) \]
      18. lower-*.f6432.6

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

      \[\leadsto \color{blue}{\mathsf{fma}\left({\left({\left(z \cdot x\right)}^{-1}\right)}^{0.5} \cdot y, z + x, {\left(z \cdot x\right)}^{0.5} \cdot 2\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification43.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{-146}:\\ \;\;\;\;2 \cdot \left(\left({\left(\left(-1 \cdot x\right) \cdot \left(\left(-1 \cdot z\right) \cdot \left({\left(x \cdot y\right)}^{-1} + {\left(y \cdot z\right)}^{-1}\right)\right)\right)}^{0.5} \cdot -1\right) \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left({\left({\left(z \cdot x\right)}^{-1}\right)}^{0.5} \cdot y, z + x, {\left(z \cdot x\right)}^{0.5} \cdot 2\right)\\ \end{array} \]
  5. Add Preprocessing

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

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \mathsf{fma}\left({\left({\left(z \cdot x\right)}^{-1}\right)}^{0.5} \cdot y, z + x, {\left(z \cdot x\right)}^{0.5} \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 (pow (* z x) -1.0) 0.5) y) (+ z x) (* (pow (* z x) 0.5) 2.0)))
assert(x < y && y < z);
double code(double x, double y, double z) {
	return fma((pow(pow((z * x), -1.0), 0.5) * y), (z + x), (pow((z * x), 0.5) * 2.0));
}
x, y, z = sort([x, y, z])
function code(x, y, z)
	return fma(Float64(((Float64(z * x) ^ -1.0) ^ 0.5) * y), Float64(z + x), Float64((Float64(z * x) ^ 0.5) * 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[Power[N[(z * x), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * y), $MachinePrecision] * N[(z + x), $MachinePrecision] + N[(N[Power[N[(z * x), $MachinePrecision], 0.5], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\mathsf{fma}\left({\left({\left(z \cdot x\right)}^{-1}\right)}^{0.5} \cdot y, z + x, {\left(z \cdot x\right)}^{0.5} \cdot 2\right)
\end{array}
Derivation
  1. Initial program 70.7%

    \[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. pow1/2N/A

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left({\left({\left(z \cdot x\right)}^{-1}\right)}^{\frac{1}{2}} \cdot y, z + x, {\left(z \cdot x\right)}^{\frac{1}{2}} \cdot 2\right) \]
    18. lower-*.f6423.7

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

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

Reproduce

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