Optimisation.CirclePacking:place from circle-packing-0.1.0.4, C

Percentage Accurate: 100.0% → 100.0%
Time: 5.6s
Alternatives: 9
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \sqrt{\left|x - y\right|} \end{array} \]
(FPCore (x y) :precision binary64 (sqrt (fabs (- x y))))
double code(double x, double y) {
	return sqrt(fabs((x - y)));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = sqrt(abs((x - y)))
end function
public static double code(double x, double y) {
	return Math.sqrt(Math.abs((x - y)));
}
def code(x, y):
	return math.sqrt(math.fabs((x - y)))
function code(x, y)
	return sqrt(abs(Float64(x - y)))
end
function tmp = code(x, y)
	tmp = sqrt(abs((x - y)));
end
code[x_, y_] := N[Sqrt[N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{\left|x - y\right|}
\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 9 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: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sqrt{\left|x - y\right|} \end{array} \]
(FPCore (x y) :precision binary64 (sqrt (fabs (- x y))))
double code(double x, double y) {
	return sqrt(fabs((x - y)));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = sqrt(abs((x - y)))
end function
public static double code(double x, double y) {
	return Math.sqrt(Math.abs((x - y)));
}
def code(x, y):
	return math.sqrt(math.fabs((x - y)))
function code(x, y)
	return sqrt(abs(Float64(x - y)))
end
function tmp = code(x, y)
	tmp = sqrt(abs((x - y)));
end
code[x_, y_] := N[Sqrt[N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{\left|x - y\right|}
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sqrt{\left|x - y\right|} \end{array} \]
(FPCore (x y) :precision binary64 (sqrt (fabs (- x y))))
double code(double x, double y) {
	return sqrt(fabs((x - y)));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = sqrt(abs((x - y)))
end function
public static double code(double x, double y) {
	return Math.sqrt(Math.abs((x - y)));
}
def code(x, y):
	return math.sqrt(math.fabs((x - y)))
function code(x, y)
	return sqrt(abs(Float64(x - y)))
end
function tmp = code(x, y)
	tmp = sqrt(abs((x - y)));
end
code[x_, y_] := N[Sqrt[N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{\left|x - y\right|}
\end{array}
Derivation
  1. Initial program 100.0%

    \[\sqrt{\left|x - y\right|} \]
  2. Final simplification100.0%

    \[\leadsto \sqrt{\left|x - y\right|} \]

Alternative 2: 74.7% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(x \cdot \left(x + y \cdot -2\right)\right)}^{0.25}\\ \mathbf{if}\;x - y \leq -6 \cdot 10^{+147}:\\ \;\;\;\;\sqrt{y}\\ \mathbf{elif}\;x - y \leq -500000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x - y \leq -5 \cdot 10^{-53}:\\ \;\;\;\;{\left(y \cdot y\right)}^{0.25}\\ \mathbf{elif}\;x - y \leq -5 \cdot 10^{-130}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x - y \leq -2 \cdot 10^{-183}:\\ \;\;\;\;\sqrt{y}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x - y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (pow (* x (+ x (* y -2.0))) 0.25)))
   (if (<= (- x y) -6e+147)
     (sqrt y)
     (if (<= (- x y) -500000.0)
       t_0
       (if (<= (- x y) -5e-53)
         (pow (* y y) 0.25)
         (if (<= (- x y) -5e-130)
           t_0
           (if (<= (- x y) -2e-183) (sqrt y) (sqrt (- x y)))))))))
double code(double x, double y) {
	double t_0 = pow((x * (x + (y * -2.0))), 0.25);
	double tmp;
	if ((x - y) <= -6e+147) {
		tmp = sqrt(y);
	} else if ((x - y) <= -500000.0) {
		tmp = t_0;
	} else if ((x - y) <= -5e-53) {
		tmp = pow((y * y), 0.25);
	} else if ((x - y) <= -5e-130) {
		tmp = t_0;
	} else if ((x - y) <= -2e-183) {
		tmp = sqrt(y);
	} else {
		tmp = sqrt((x - y));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x * (x + (y * (-2.0d0)))) ** 0.25d0
    if ((x - y) <= (-6d+147)) then
        tmp = sqrt(y)
    else if ((x - y) <= (-500000.0d0)) then
        tmp = t_0
    else if ((x - y) <= (-5d-53)) then
        tmp = (y * y) ** 0.25d0
    else if ((x - y) <= (-5d-130)) then
        tmp = t_0
    else if ((x - y) <= (-2d-183)) then
        tmp = sqrt(y)
    else
        tmp = sqrt((x - y))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = Math.pow((x * (x + (y * -2.0))), 0.25);
	double tmp;
	if ((x - y) <= -6e+147) {
		tmp = Math.sqrt(y);
	} else if ((x - y) <= -500000.0) {
		tmp = t_0;
	} else if ((x - y) <= -5e-53) {
		tmp = Math.pow((y * y), 0.25);
	} else if ((x - y) <= -5e-130) {
		tmp = t_0;
	} else if ((x - y) <= -2e-183) {
		tmp = Math.sqrt(y);
	} else {
		tmp = Math.sqrt((x - y));
	}
	return tmp;
}
def code(x, y):
	t_0 = math.pow((x * (x + (y * -2.0))), 0.25)
	tmp = 0
	if (x - y) <= -6e+147:
		tmp = math.sqrt(y)
	elif (x - y) <= -500000.0:
		tmp = t_0
	elif (x - y) <= -5e-53:
		tmp = math.pow((y * y), 0.25)
	elif (x - y) <= -5e-130:
		tmp = t_0
	elif (x - y) <= -2e-183:
		tmp = math.sqrt(y)
	else:
		tmp = math.sqrt((x - y))
	return tmp
function code(x, y)
	t_0 = Float64(x * Float64(x + Float64(y * -2.0))) ^ 0.25
	tmp = 0.0
	if (Float64(x - y) <= -6e+147)
		tmp = sqrt(y);
	elseif (Float64(x - y) <= -500000.0)
		tmp = t_0;
	elseif (Float64(x - y) <= -5e-53)
		tmp = Float64(y * y) ^ 0.25;
	elseif (Float64(x - y) <= -5e-130)
		tmp = t_0;
	elseif (Float64(x - y) <= -2e-183)
		tmp = sqrt(y);
	else
		tmp = sqrt(Float64(x - y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (x * (x + (y * -2.0))) ^ 0.25;
	tmp = 0.0;
	if ((x - y) <= -6e+147)
		tmp = sqrt(y);
	elseif ((x - y) <= -500000.0)
		tmp = t_0;
	elseif ((x - y) <= -5e-53)
		tmp = (y * y) ^ 0.25;
	elseif ((x - y) <= -5e-130)
		tmp = t_0;
	elseif ((x - y) <= -2e-183)
		tmp = sqrt(y);
	else
		tmp = sqrt((x - y));
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[Power[N[(x * N[(x + N[(y * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision]}, If[LessEqual[N[(x - y), $MachinePrecision], -6e+147], N[Sqrt[y], $MachinePrecision], If[LessEqual[N[(x - y), $MachinePrecision], -500000.0], t$95$0, If[LessEqual[N[(x - y), $MachinePrecision], -5e-53], N[Power[N[(y * y), $MachinePrecision], 0.25], $MachinePrecision], If[LessEqual[N[(x - y), $MachinePrecision], -5e-130], t$95$0, If[LessEqual[N[(x - y), $MachinePrecision], -2e-183], N[Sqrt[y], $MachinePrecision], N[Sqrt[N[(x - y), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(x \cdot \left(x + y \cdot -2\right)\right)}^{0.25}\\
\mathbf{if}\;x - y \leq -6 \cdot 10^{+147}:\\
\;\;\;\;\sqrt{y}\\

\mathbf{elif}\;x - y \leq -500000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x - y \leq -5 \cdot 10^{-53}:\\
\;\;\;\;{\left(y \cdot y\right)}^{0.25}\\

\mathbf{elif}\;x - y \leq -5 \cdot 10^{-130}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x - y \leq -2 \cdot 10^{-183}:\\
\;\;\;\;\sqrt{y}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{x - y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (-.f64 x y) < -5.99999999999999987e147 or -4.9999999999999996e-130 < (-.f64 x y) < -2.00000000000000001e-183

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.2%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down11.2%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs11.2%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs11.2%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs11.2%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg11.2%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative11.2%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in11.2%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg11.2%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg11.2%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg11.2%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative11.2%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in11.2%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg11.2%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg11.2%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval11.2%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr11.2%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Taylor expanded in x around 0 59.1%

      \[\leadsto \color{blue}{{1}^{0.25} \cdot \sqrt{y}} \]
    7. Step-by-step derivation
      1. pow-base-159.1%

        \[\leadsto \color{blue}{1} \cdot \sqrt{y} \]
      2. *-lft-identity59.1%

        \[\leadsto \color{blue}{\sqrt{y}} \]
    8. Simplified59.1%

      \[\leadsto \color{blue}{\sqrt{y}} \]

    if -5.99999999999999987e147 < (-.f64 x y) < -5e5 or -5e-53 < (-.f64 x y) < -4.9999999999999996e-130

    1. Initial program 99.9%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub99.9%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/299.9%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.1%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down99.9%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs99.9%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs99.9%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs99.9%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg99.9%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative99.9%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in99.9%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg99.9%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg99.9%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg99.9%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative99.9%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in99.9%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg99.9%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg99.9%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval99.9%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr99.9%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Step-by-step derivation
      1. sub-neg99.9%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x + \left(-y\right)\right)}\right)}^{0.25} \]
      2. +-commutative99.9%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-y\right) + x\right)}\right)}^{0.25} \]
      3. distribute-rgt-in100.0%

        \[\leadsto {\color{blue}{\left(\left(-y\right) \cdot \left(x - y\right) + x \cdot \left(x - y\right)\right)}}^{0.25} \]
      4. sub-neg100.0%

        \[\leadsto {\left(\left(-y\right) \cdot \color{blue}{\left(x + \left(-y\right)\right)} + x \cdot \left(x - y\right)\right)}^{0.25} \]
      5. +-commutative100.0%

        \[\leadsto {\left(\left(-y\right) \cdot \color{blue}{\left(\left(-y\right) + x\right)} + x \cdot \left(x - y\right)\right)}^{0.25} \]
      6. distribute-lft-in100.0%

        \[\leadsto {\left(\color{blue}{\left(\left(-y\right) \cdot \left(-y\right) + \left(-y\right) \cdot x\right)} + x \cdot \left(x - y\right)\right)}^{0.25} \]
      7. sqr-neg100.0%

        \[\leadsto {\left(\left(\color{blue}{y \cdot y} + \left(-y\right) \cdot x\right) + x \cdot \left(x - y\right)\right)}^{0.25} \]
      8. cancel-sign-sub-inv100.0%

        \[\leadsto {\left(\color{blue}{\left(y \cdot y - y \cdot x\right)} + x \cdot \left(x - y\right)\right)}^{0.25} \]
      9. distribute-lft-out--100.0%

        \[\leadsto {\left(\color{blue}{y \cdot \left(y - x\right)} + x \cdot \left(x - y\right)\right)}^{0.25} \]
    7. Applied egg-rr100.0%

      \[\leadsto {\color{blue}{\left(y \cdot \left(y - x\right) + x \cdot \left(x - y\right)\right)}}^{0.25} \]
    8. Taylor expanded in y around 0 63.8%

      \[\leadsto {\color{blue}{\left(-2 \cdot \left(x \cdot y\right) + {x}^{2}\right)}}^{0.25} \]
    9. Step-by-step derivation
      1. +-commutative63.8%

        \[\leadsto {\color{blue}{\left({x}^{2} + -2 \cdot \left(x \cdot y\right)\right)}}^{0.25} \]
      2. unpow263.8%

        \[\leadsto {\left(\color{blue}{x \cdot x} + -2 \cdot \left(x \cdot y\right)\right)}^{0.25} \]
      3. *-commutative63.8%

        \[\leadsto {\left(x \cdot x + \color{blue}{\left(x \cdot y\right) \cdot -2}\right)}^{0.25} \]
      4. associate-*l*63.8%

        \[\leadsto {\left(x \cdot x + \color{blue}{x \cdot \left(y \cdot -2\right)}\right)}^{0.25} \]
      5. metadata-eval63.8%

        \[\leadsto {\left(x \cdot x + x \cdot \left(y \cdot \color{blue}{\left(-1 + -1\right)}\right)\right)}^{0.25} \]
      6. distribute-rgt-out63.8%

        \[\leadsto {\left(x \cdot x + x \cdot \color{blue}{\left(-1 \cdot y + -1 \cdot y\right)}\right)}^{0.25} \]
      7. mul-1-neg63.8%

        \[\leadsto {\left(x \cdot x + x \cdot \left(-1 \cdot y + \color{blue}{\left(-y\right)}\right)\right)}^{0.25} \]
      8. fma-def63.8%

        \[\leadsto {\left(x \cdot x + x \cdot \color{blue}{\mathsf{fma}\left(-1, y, -y\right)}\right)}^{0.25} \]
      9. fma-neg63.8%

        \[\leadsto {\left(x \cdot x + x \cdot \color{blue}{\left(-1 \cdot y - y\right)}\right)}^{0.25} \]
      10. distribute-lft-out63.8%

        \[\leadsto {\color{blue}{\left(x \cdot \left(x + \left(-1 \cdot y - y\right)\right)\right)}}^{0.25} \]
      11. fma-neg63.8%

        \[\leadsto {\left(x \cdot \left(x + \color{blue}{\mathsf{fma}\left(-1, y, -y\right)}\right)\right)}^{0.25} \]
      12. fma-def63.8%

        \[\leadsto {\left(x \cdot \left(x + \color{blue}{\left(-1 \cdot y + \left(-y\right)\right)}\right)\right)}^{0.25} \]
      13. mul-1-neg63.8%

        \[\leadsto {\left(x \cdot \left(x + \left(-1 \cdot y + \color{blue}{-1 \cdot y}\right)\right)\right)}^{0.25} \]
      14. distribute-rgt-out63.8%

        \[\leadsto {\left(x \cdot \left(x + \color{blue}{y \cdot \left(-1 + -1\right)}\right)\right)}^{0.25} \]
      15. metadata-eval63.8%

        \[\leadsto {\left(x \cdot \left(x + y \cdot \color{blue}{-2}\right)\right)}^{0.25} \]
    10. Simplified63.8%

      \[\leadsto {\color{blue}{\left(x \cdot \left(x + y \cdot -2\right)\right)}}^{0.25} \]

    if -5e5 < (-.f64 x y) < -5e-53

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.5%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs100.0%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs100.0%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs100.0%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg100.0%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative100.0%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in100.0%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg100.0%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg100.0%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg100.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative100.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in100.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg100.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg100.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval100.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr100.0%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Step-by-step derivation
      1. sub-neg100.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x + \left(-y\right)\right)}\right)}^{0.25} \]
      2. +-commutative100.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-y\right) + x\right)}\right)}^{0.25} \]
      3. distribute-rgt-in100.0%

        \[\leadsto {\color{blue}{\left(\left(-y\right) \cdot \left(x - y\right) + x \cdot \left(x - y\right)\right)}}^{0.25} \]
      4. sub-neg100.0%

        \[\leadsto {\left(\left(-y\right) \cdot \color{blue}{\left(x + \left(-y\right)\right)} + x \cdot \left(x - y\right)\right)}^{0.25} \]
      5. +-commutative100.0%

        \[\leadsto {\left(\left(-y\right) \cdot \color{blue}{\left(\left(-y\right) + x\right)} + x \cdot \left(x - y\right)\right)}^{0.25} \]
      6. distribute-lft-in100.0%

        \[\leadsto {\left(\color{blue}{\left(\left(-y\right) \cdot \left(-y\right) + \left(-y\right) \cdot x\right)} + x \cdot \left(x - y\right)\right)}^{0.25} \]
      7. sqr-neg100.0%

        \[\leadsto {\left(\left(\color{blue}{y \cdot y} + \left(-y\right) \cdot x\right) + x \cdot \left(x - y\right)\right)}^{0.25} \]
      8. cancel-sign-sub-inv100.0%

        \[\leadsto {\left(\color{blue}{\left(y \cdot y - y \cdot x\right)} + x \cdot \left(x - y\right)\right)}^{0.25} \]
      9. distribute-lft-out--100.0%

        \[\leadsto {\left(\color{blue}{y \cdot \left(y - x\right)} + x \cdot \left(x - y\right)\right)}^{0.25} \]
    7. Applied egg-rr100.0%

      \[\leadsto {\color{blue}{\left(y \cdot \left(y - x\right) + x \cdot \left(x - y\right)\right)}}^{0.25} \]
    8. Taylor expanded in y around inf 81.1%

      \[\leadsto {\color{blue}{\left({y}^{2}\right)}}^{0.25} \]
    9. Step-by-step derivation
      1. unpow281.1%

        \[\leadsto {\color{blue}{\left(y \cdot y\right)}}^{0.25} \]
    10. Simplified81.1%

      \[\leadsto {\color{blue}{\left(y \cdot y\right)}}^{0.25} \]

    if -2.00000000000000001e-183 < (-.f64 x y)

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.1%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down54.6%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs54.6%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs54.6%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs54.6%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg54.6%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative54.6%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in54.6%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg54.6%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg54.6%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr54.6%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Step-by-step derivation
      1. unpow-prod-down98.3%

        \[\leadsto \color{blue}{{\left(x - y\right)}^{0.25} \cdot {\left(x - y\right)}^{0.25}} \]
      2. pow-sqr99.2%

        \[\leadsto \color{blue}{{\left(x - y\right)}^{\left(2 \cdot 0.25\right)}} \]
      3. metadata-eval99.2%

        \[\leadsto {\left(x - y\right)}^{\color{blue}{0.5}} \]
      4. unpow1/299.2%

        \[\leadsto \color{blue}{\sqrt{x - y}} \]
    7. Applied egg-rr99.2%

      \[\leadsto \color{blue}{\sqrt{x - y}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification80.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x - y \leq -6 \cdot 10^{+147}:\\ \;\;\;\;\sqrt{y}\\ \mathbf{elif}\;x - y \leq -500000:\\ \;\;\;\;{\left(x \cdot \left(x + y \cdot -2\right)\right)}^{0.25}\\ \mathbf{elif}\;x - y \leq -5 \cdot 10^{-53}:\\ \;\;\;\;{\left(y \cdot y\right)}^{0.25}\\ \mathbf{elif}\;x - y \leq -5 \cdot 10^{-130}:\\ \;\;\;\;{\left(x \cdot \left(x + y \cdot -2\right)\right)}^{0.25}\\ \mathbf{elif}\;x - y \leq -2 \cdot 10^{-183}:\\ \;\;\;\;\sqrt{y}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x - y}\\ \end{array} \]

Alternative 3: 86.7% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x - y \leq -1 \cdot 10^{+155}:\\ \;\;\;\;\sqrt{y}\\ \mathbf{elif}\;x - y \leq -1 \cdot 10^{-189}:\\ \;\;\;\;{\left(y \cdot \left(y - x\right) + x \cdot \left(x - y\right)\right)}^{0.25}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x - y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (- x y) -1e+155)
   (sqrt y)
   (if (<= (- x y) -1e-189)
     (pow (+ (* y (- y x)) (* x (- x y))) 0.25)
     (sqrt (- x y)))))
double code(double x, double y) {
	double tmp;
	if ((x - y) <= -1e+155) {
		tmp = sqrt(y);
	} else if ((x - y) <= -1e-189) {
		tmp = pow(((y * (y - x)) + (x * (x - y))), 0.25);
	} else {
		tmp = sqrt((x - y));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x - y) <= (-1d+155)) then
        tmp = sqrt(y)
    else if ((x - y) <= (-1d-189)) then
        tmp = ((y * (y - x)) + (x * (x - y))) ** 0.25d0
    else
        tmp = sqrt((x - y))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x - y) <= -1e+155) {
		tmp = Math.sqrt(y);
	} else if ((x - y) <= -1e-189) {
		tmp = Math.pow(((y * (y - x)) + (x * (x - y))), 0.25);
	} else {
		tmp = Math.sqrt((x - y));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x - y) <= -1e+155:
		tmp = math.sqrt(y)
	elif (x - y) <= -1e-189:
		tmp = math.pow(((y * (y - x)) + (x * (x - y))), 0.25)
	else:
		tmp = math.sqrt((x - y))
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64(x - y) <= -1e+155)
		tmp = sqrt(y);
	elseif (Float64(x - y) <= -1e-189)
		tmp = Float64(Float64(y * Float64(y - x)) + Float64(x * Float64(x - y))) ^ 0.25;
	else
		tmp = sqrt(Float64(x - y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x - y) <= -1e+155)
		tmp = sqrt(y);
	elseif ((x - y) <= -1e-189)
		tmp = ((y * (y - x)) + (x * (x - y))) ^ 0.25;
	else
		tmp = sqrt((x - y));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[(x - y), $MachinePrecision], -1e+155], N[Sqrt[y], $MachinePrecision], If[LessEqual[N[(x - y), $MachinePrecision], -1e-189], N[Power[N[(N[(y * N[(y - x), $MachinePrecision]), $MachinePrecision] + N[(x * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision], N[Sqrt[N[(x - y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x - y \leq -1 \cdot 10^{+155}:\\
\;\;\;\;\sqrt{y}\\

\mathbf{elif}\;x - y \leq -1 \cdot 10^{-189}:\\
\;\;\;\;{\left(y \cdot \left(y - x\right) + x \cdot \left(x - y\right)\right)}^{0.25}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{x - y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 x y) < -1.00000000000000001e155

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.3%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down4.3%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs4.3%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs4.3%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs4.3%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg4.3%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative4.3%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in4.3%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg4.3%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg4.3%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg4.3%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative4.3%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in4.3%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg4.3%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg4.3%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval4.3%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr4.3%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Taylor expanded in x around 0 57.1%

      \[\leadsto \color{blue}{{1}^{0.25} \cdot \sqrt{y}} \]
    7. Step-by-step derivation
      1. pow-base-157.1%

        \[\leadsto \color{blue}{1} \cdot \sqrt{y} \]
      2. *-lft-identity57.1%

        \[\leadsto \color{blue}{\sqrt{y}} \]
    8. Simplified57.1%

      \[\leadsto \color{blue}{\sqrt{y}} \]

    if -1.00000000000000001e155 < (-.f64 x y) < -1.00000000000000007e-189

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.2%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down94.8%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs94.8%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs94.8%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs94.8%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg94.8%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative94.8%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in94.8%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg94.8%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg94.8%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg94.8%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative94.8%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in94.8%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg94.8%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg94.8%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval94.8%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr94.8%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Step-by-step derivation
      1. sub-neg94.8%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x + \left(-y\right)\right)}\right)}^{0.25} \]
      2. +-commutative94.8%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-y\right) + x\right)}\right)}^{0.25} \]
      3. distribute-rgt-in94.8%

        \[\leadsto {\color{blue}{\left(\left(-y\right) \cdot \left(x - y\right) + x \cdot \left(x - y\right)\right)}}^{0.25} \]
      4. sub-neg94.8%

        \[\leadsto {\left(\left(-y\right) \cdot \color{blue}{\left(x + \left(-y\right)\right)} + x \cdot \left(x - y\right)\right)}^{0.25} \]
      5. +-commutative94.8%

        \[\leadsto {\left(\left(-y\right) \cdot \color{blue}{\left(\left(-y\right) + x\right)} + x \cdot \left(x - y\right)\right)}^{0.25} \]
      6. distribute-lft-in94.8%

        \[\leadsto {\left(\color{blue}{\left(\left(-y\right) \cdot \left(-y\right) + \left(-y\right) \cdot x\right)} + x \cdot \left(x - y\right)\right)}^{0.25} \]
      7. sqr-neg94.8%

        \[\leadsto {\left(\left(\color{blue}{y \cdot y} + \left(-y\right) \cdot x\right) + x \cdot \left(x - y\right)\right)}^{0.25} \]
      8. cancel-sign-sub-inv94.8%

        \[\leadsto {\left(\color{blue}{\left(y \cdot y - y \cdot x\right)} + x \cdot \left(x - y\right)\right)}^{0.25} \]
      9. distribute-lft-out--94.8%

        \[\leadsto {\left(\color{blue}{y \cdot \left(y - x\right)} + x \cdot \left(x - y\right)\right)}^{0.25} \]
    7. Applied egg-rr94.8%

      \[\leadsto {\color{blue}{\left(y \cdot \left(y - x\right) + x \cdot \left(x - y\right)\right)}}^{0.25} \]

    if -1.00000000000000007e-189 < (-.f64 x y)

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.1%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down55.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs55.0%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs55.0%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs55.0%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg55.0%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative55.0%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in55.0%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg55.0%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg55.0%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg55.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative55.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in55.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg55.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg55.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval55.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr55.0%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Step-by-step derivation
      1. unpow-prod-down99.1%

        \[\leadsto \color{blue}{{\left(x - y\right)}^{0.25} \cdot {\left(x - y\right)}^{0.25}} \]
      2. pow-sqr100.0%

        \[\leadsto \color{blue}{{\left(x - y\right)}^{\left(2 \cdot 0.25\right)}} \]
      3. metadata-eval100.0%

        \[\leadsto {\left(x - y\right)}^{\color{blue}{0.5}} \]
      4. unpow1/2100.0%

        \[\leadsto \color{blue}{\sqrt{x - y}} \]
    7. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\sqrt{x - y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x - y \leq -1 \cdot 10^{+155}:\\ \;\;\;\;\sqrt{y}\\ \mathbf{elif}\;x - y \leq -1 \cdot 10^{-189}:\\ \;\;\;\;{\left(y \cdot \left(y - x\right) + x \cdot \left(x - y\right)\right)}^{0.25}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x - y}\\ \end{array} \]

Alternative 4: 86.7% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x - y \leq -1 \cdot 10^{+155}:\\ \;\;\;\;\sqrt{y}\\ \mathbf{elif}\;x - y \leq -1 \cdot 10^{-189}:\\ \;\;\;\;{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x - y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (- x y) -1e+155)
   (sqrt y)
   (if (<= (- x y) -1e-189) (pow (* (- x y) (- x y)) 0.25) (sqrt (- x y)))))
double code(double x, double y) {
	double tmp;
	if ((x - y) <= -1e+155) {
		tmp = sqrt(y);
	} else if ((x - y) <= -1e-189) {
		tmp = pow(((x - y) * (x - y)), 0.25);
	} else {
		tmp = sqrt((x - y));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x - y) <= (-1d+155)) then
        tmp = sqrt(y)
    else if ((x - y) <= (-1d-189)) then
        tmp = ((x - y) * (x - y)) ** 0.25d0
    else
        tmp = sqrt((x - y))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x - y) <= -1e+155) {
		tmp = Math.sqrt(y);
	} else if ((x - y) <= -1e-189) {
		tmp = Math.pow(((x - y) * (x - y)), 0.25);
	} else {
		tmp = Math.sqrt((x - y));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x - y) <= -1e+155:
		tmp = math.sqrt(y)
	elif (x - y) <= -1e-189:
		tmp = math.pow(((x - y) * (x - y)), 0.25)
	else:
		tmp = math.sqrt((x - y))
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64(x - y) <= -1e+155)
		tmp = sqrt(y);
	elseif (Float64(x - y) <= -1e-189)
		tmp = Float64(Float64(x - y) * Float64(x - y)) ^ 0.25;
	else
		tmp = sqrt(Float64(x - y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x - y) <= -1e+155)
		tmp = sqrt(y);
	elseif ((x - y) <= -1e-189)
		tmp = ((x - y) * (x - y)) ^ 0.25;
	else
		tmp = sqrt((x - y));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[(x - y), $MachinePrecision], -1e+155], N[Sqrt[y], $MachinePrecision], If[LessEqual[N[(x - y), $MachinePrecision], -1e-189], N[Power[N[(N[(x - y), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision], N[Sqrt[N[(x - y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x - y \leq -1 \cdot 10^{+155}:\\
\;\;\;\;\sqrt{y}\\

\mathbf{elif}\;x - y \leq -1 \cdot 10^{-189}:\\
\;\;\;\;{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{x - y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 x y) < -1.00000000000000001e155

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.3%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down4.3%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs4.3%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs4.3%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs4.3%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg4.3%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative4.3%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in4.3%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg4.3%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg4.3%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg4.3%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative4.3%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in4.3%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg4.3%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg4.3%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval4.3%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr4.3%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Taylor expanded in x around 0 57.1%

      \[\leadsto \color{blue}{{1}^{0.25} \cdot \sqrt{y}} \]
    7. Step-by-step derivation
      1. pow-base-157.1%

        \[\leadsto \color{blue}{1} \cdot \sqrt{y} \]
      2. *-lft-identity57.1%

        \[\leadsto \color{blue}{\sqrt{y}} \]
    8. Simplified57.1%

      \[\leadsto \color{blue}{\sqrt{y}} \]

    if -1.00000000000000001e155 < (-.f64 x y) < -1.00000000000000007e-189

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.2%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down94.8%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs94.8%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs94.8%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs94.8%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg94.8%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative94.8%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in94.8%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg94.8%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg94.8%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg94.8%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative94.8%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in94.8%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg94.8%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg94.8%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval94.8%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr94.8%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]

    if -1.00000000000000007e-189 < (-.f64 x y)

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.1%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down55.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs55.0%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs55.0%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs55.0%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg55.0%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative55.0%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in55.0%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg55.0%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg55.0%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg55.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative55.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in55.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg55.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg55.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval55.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr55.0%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Step-by-step derivation
      1. unpow-prod-down99.1%

        \[\leadsto \color{blue}{{\left(x - y\right)}^{0.25} \cdot {\left(x - y\right)}^{0.25}} \]
      2. pow-sqr100.0%

        \[\leadsto \color{blue}{{\left(x - y\right)}^{\left(2 \cdot 0.25\right)}} \]
      3. metadata-eval100.0%

        \[\leadsto {\left(x - y\right)}^{\color{blue}{0.5}} \]
      4. unpow1/2100.0%

        \[\leadsto \color{blue}{\sqrt{x - y}} \]
    7. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\sqrt{x - y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x - y \leq -1 \cdot 10^{+155}:\\ \;\;\;\;\sqrt{y}\\ \mathbf{elif}\;x - y \leq -1 \cdot 10^{-189}:\\ \;\;\;\;{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x - y}\\ \end{array} \]

Alternative 5: 74.6% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x - y \leq -6 \cdot 10^{+147}:\\ \;\;\;\;\sqrt{y}\\ \mathbf{elif}\;x - y \leq -500000:\\ \;\;\;\;{\left(x \cdot x\right)}^{0.25}\\ \mathbf{elif}\;x - y \leq -2 \cdot 10^{-183}:\\ \;\;\;\;\sqrt{y}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x - y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (- x y) -6e+147)
   (sqrt y)
   (if (<= (- x y) -500000.0)
     (pow (* x x) 0.25)
     (if (<= (- x y) -2e-183) (sqrt y) (sqrt (- x y))))))
double code(double x, double y) {
	double tmp;
	if ((x - y) <= -6e+147) {
		tmp = sqrt(y);
	} else if ((x - y) <= -500000.0) {
		tmp = pow((x * x), 0.25);
	} else if ((x - y) <= -2e-183) {
		tmp = sqrt(y);
	} else {
		tmp = sqrt((x - y));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x - y) <= (-6d+147)) then
        tmp = sqrt(y)
    else if ((x - y) <= (-500000.0d0)) then
        tmp = (x * x) ** 0.25d0
    else if ((x - y) <= (-2d-183)) then
        tmp = sqrt(y)
    else
        tmp = sqrt((x - y))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x - y) <= -6e+147) {
		tmp = Math.sqrt(y);
	} else if ((x - y) <= -500000.0) {
		tmp = Math.pow((x * x), 0.25);
	} else if ((x - y) <= -2e-183) {
		tmp = Math.sqrt(y);
	} else {
		tmp = Math.sqrt((x - y));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x - y) <= -6e+147:
		tmp = math.sqrt(y)
	elif (x - y) <= -500000.0:
		tmp = math.pow((x * x), 0.25)
	elif (x - y) <= -2e-183:
		tmp = math.sqrt(y)
	else:
		tmp = math.sqrt((x - y))
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64(x - y) <= -6e+147)
		tmp = sqrt(y);
	elseif (Float64(x - y) <= -500000.0)
		tmp = Float64(x * x) ^ 0.25;
	elseif (Float64(x - y) <= -2e-183)
		tmp = sqrt(y);
	else
		tmp = sqrt(Float64(x - y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x - y) <= -6e+147)
		tmp = sqrt(y);
	elseif ((x - y) <= -500000.0)
		tmp = (x * x) ^ 0.25;
	elseif ((x - y) <= -2e-183)
		tmp = sqrt(y);
	else
		tmp = sqrt((x - y));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[(x - y), $MachinePrecision], -6e+147], N[Sqrt[y], $MachinePrecision], If[LessEqual[N[(x - y), $MachinePrecision], -500000.0], N[Power[N[(x * x), $MachinePrecision], 0.25], $MachinePrecision], If[LessEqual[N[(x - y), $MachinePrecision], -2e-183], N[Sqrt[y], $MachinePrecision], N[Sqrt[N[(x - y), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x - y \leq -6 \cdot 10^{+147}:\\
\;\;\;\;\sqrt{y}\\

\mathbf{elif}\;x - y \leq -500000:\\
\;\;\;\;{\left(x \cdot x\right)}^{0.25}\\

\mathbf{elif}\;x - y \leq -2 \cdot 10^{-183}:\\
\;\;\;\;\sqrt{y}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{x - y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 x y) < -5.99999999999999987e147 or -5e5 < (-.f64 x y) < -2.00000000000000001e-183

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.3%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down32.6%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs32.6%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs32.6%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs32.6%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg32.6%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative32.6%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in32.6%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg32.6%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg32.6%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg32.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative32.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in32.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg32.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg32.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval32.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr32.6%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Taylor expanded in x around 0 57.5%

      \[\leadsto \color{blue}{{1}^{0.25} \cdot \sqrt{y}} \]
    7. Step-by-step derivation
      1. pow-base-157.5%

        \[\leadsto \color{blue}{1} \cdot \sqrt{y} \]
      2. *-lft-identity57.5%

        \[\leadsto \color{blue}{\sqrt{y}} \]
    8. Simplified57.5%

      \[\leadsto \color{blue}{\sqrt{y}} \]

    if -5.99999999999999987e147 < (-.f64 x y) < -5e5

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.1%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs100.0%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs100.0%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs100.0%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg100.0%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative100.0%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in100.0%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg100.0%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg100.0%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg100.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative100.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in100.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg100.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg100.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval100.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr100.0%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Taylor expanded in x around inf 63.1%

      \[\leadsto {\color{blue}{\left({x}^{2}\right)}}^{0.25} \]
    7. Step-by-step derivation
      1. unpow263.1%

        \[\leadsto {\color{blue}{\left(x \cdot x\right)}}^{0.25} \]
    8. Simplified63.1%

      \[\leadsto {\color{blue}{\left(x \cdot x\right)}}^{0.25} \]

    if -2.00000000000000001e-183 < (-.f64 x y)

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.1%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down54.6%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs54.6%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs54.6%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs54.6%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg54.6%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative54.6%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in54.6%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg54.6%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg54.6%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr54.6%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Step-by-step derivation
      1. unpow-prod-down98.3%

        \[\leadsto \color{blue}{{\left(x - y\right)}^{0.25} \cdot {\left(x - y\right)}^{0.25}} \]
      2. pow-sqr99.2%

        \[\leadsto \color{blue}{{\left(x - y\right)}^{\left(2 \cdot 0.25\right)}} \]
      3. metadata-eval99.2%

        \[\leadsto {\left(x - y\right)}^{\color{blue}{0.5}} \]
      4. unpow1/299.2%

        \[\leadsto \color{blue}{\sqrt{x - y}} \]
    7. Applied egg-rr99.2%

      \[\leadsto \color{blue}{\sqrt{x - y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification78.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x - y \leq -6 \cdot 10^{+147}:\\ \;\;\;\;\sqrt{y}\\ \mathbf{elif}\;x - y \leq -500000:\\ \;\;\;\;{\left(x \cdot x\right)}^{0.25}\\ \mathbf{elif}\;x - y \leq -2 \cdot 10^{-183}:\\ \;\;\;\;\sqrt{y}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x - y}\\ \end{array} \]

Alternative 6: 74.4% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x - y \leq -2 \cdot 10^{-183}:\\ \;\;\;\;\sqrt{y}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x - y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (- x y) -2e-183) (sqrt y) (sqrt (- x y))))
double code(double x, double y) {
	double tmp;
	if ((x - y) <= -2e-183) {
		tmp = sqrt(y);
	} else {
		tmp = sqrt((x - y));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x - y) <= (-2d-183)) then
        tmp = sqrt(y)
    else
        tmp = sqrt((x - y))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x - y) <= -2e-183) {
		tmp = Math.sqrt(y);
	} else {
		tmp = Math.sqrt((x - y));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x - y) <= -2e-183:
		tmp = math.sqrt(y)
	else:
		tmp = math.sqrt((x - y))
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64(x - y) <= -2e-183)
		tmp = sqrt(y);
	else
		tmp = sqrt(Float64(x - y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x - y) <= -2e-183)
		tmp = sqrt(y);
	else
		tmp = sqrt((x - y));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[(x - y), $MachinePrecision], -2e-183], N[Sqrt[y], $MachinePrecision], N[Sqrt[N[(x - y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x - y \leq -2 \cdot 10^{-183}:\\
\;\;\;\;\sqrt{y}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{x - y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 x y) < -2.00000000000000001e-183

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.2%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down54.2%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs54.2%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs54.2%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs54.2%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg54.2%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative54.2%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in54.2%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg54.2%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg54.2%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg54.2%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative54.2%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in54.2%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg54.2%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg54.2%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval54.2%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr54.2%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Taylor expanded in x around 0 51.3%

      \[\leadsto \color{blue}{{1}^{0.25} \cdot \sqrt{y}} \]
    7. Step-by-step derivation
      1. pow-base-151.3%

        \[\leadsto \color{blue}{1} \cdot \sqrt{y} \]
      2. *-lft-identity51.3%

        \[\leadsto \color{blue}{\sqrt{y}} \]
    8. Simplified51.3%

      \[\leadsto \color{blue}{\sqrt{y}} \]

    if -2.00000000000000001e-183 < (-.f64 x y)

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.1%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down54.6%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs54.6%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs54.6%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs54.6%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg54.6%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative54.6%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in54.6%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg54.6%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg54.6%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval54.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr54.6%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Step-by-step derivation
      1. unpow-prod-down98.3%

        \[\leadsto \color{blue}{{\left(x - y\right)}^{0.25} \cdot {\left(x - y\right)}^{0.25}} \]
      2. pow-sqr99.2%

        \[\leadsto \color{blue}{{\left(x - y\right)}^{\left(2 \cdot 0.25\right)}} \]
      3. metadata-eval99.2%

        \[\leadsto {\left(x - y\right)}^{\color{blue}{0.5}} \]
      4. unpow1/299.2%

        \[\leadsto \color{blue}{\sqrt{x - y}} \]
    7. Applied egg-rr99.2%

      \[\leadsto \color{blue}{\sqrt{x - y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification74.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x - y \leq -2 \cdot 10^{-183}:\\ \;\;\;\;\sqrt{y}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x - y}\\ \end{array} \]

Alternative 7: 29.0% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2.4 \cdot 10^{-164}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x}\\ \end{array} \end{array} \]
(FPCore (x y) :precision binary64 (if (<= x 2.4e-164) 1.0 (sqrt x)))
double code(double x, double y) {
	double tmp;
	if (x <= 2.4e-164) {
		tmp = 1.0;
	} else {
		tmp = sqrt(x);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= 2.4d-164) then
        tmp = 1.0d0
    else
        tmp = sqrt(x)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= 2.4e-164) {
		tmp = 1.0;
	} else {
		tmp = Math.sqrt(x);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= 2.4e-164:
		tmp = 1.0
	else:
		tmp = math.sqrt(x)
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= 2.4e-164)
		tmp = 1.0;
	else
		tmp = sqrt(x);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= 2.4e-164)
		tmp = 1.0;
	else
		tmp = sqrt(x);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, 2.4e-164], 1.0, N[Sqrt[x], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.4 \cdot 10^{-164}:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;\sqrt{x}\\


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

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.2%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down52.4%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs52.4%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs52.4%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs52.4%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg52.4%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative52.4%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in52.4%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg52.4%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg52.4%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg52.4%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative52.4%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in52.4%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg52.4%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg52.4%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval52.4%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr52.4%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Taylor expanded in x around inf 25.2%

      \[\leadsto {\color{blue}{\left({x}^{2}\right)}}^{0.25} \]
    7. Step-by-step derivation
      1. unpow225.2%

        \[\leadsto {\color{blue}{\left(x \cdot x\right)}}^{0.25} \]
    8. Simplified25.2%

      \[\leadsto {\color{blue}{\left(x \cdot x\right)}}^{0.25} \]
    9. Applied egg-rr6.9%

      \[\leadsto \color{blue}{\frac{-x}{-x}} \]
    10. Simplified6.9%

      \[\leadsto \color{blue}{1} \]

    if 2.39999999999999983e-164 < x

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.2%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down58.1%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs58.1%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs58.1%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs58.1%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg58.1%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative58.1%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in58.1%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg58.1%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg58.1%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg58.1%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative58.1%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in58.1%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg58.1%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg58.1%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval58.1%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr58.1%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Taylor expanded in x around inf 67.4%

      \[\leadsto \color{blue}{\sqrt{x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification28.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.4 \cdot 10^{-164}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x}\\ \end{array} \]

Alternative 8: 42.8% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 3.2 \cdot 10^{-156}:\\ \;\;\;\;\sqrt{x}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{y}\\ \end{array} \end{array} \]
(FPCore (x y) :precision binary64 (if (<= y 3.2e-156) (sqrt x) (sqrt y)))
double code(double x, double y) {
	double tmp;
	if (y <= 3.2e-156) {
		tmp = sqrt(x);
	} else {
		tmp = sqrt(y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= 3.2d-156) then
        tmp = sqrt(x)
    else
        tmp = sqrt(y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= 3.2e-156) {
		tmp = Math.sqrt(x);
	} else {
		tmp = Math.sqrt(y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= 3.2e-156:
		tmp = math.sqrt(x)
	else:
		tmp = math.sqrt(y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= 3.2e-156)
		tmp = sqrt(x);
	else
		tmp = sqrt(y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 3.2e-156)
		tmp = sqrt(x);
	else
		tmp = sqrt(y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, 3.2e-156], N[Sqrt[x], $MachinePrecision], N[Sqrt[y], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.2 \cdot 10^{-156}:\\
\;\;\;\;\sqrt{x}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{y}\\


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

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.1%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down59.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs59.0%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs59.0%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs59.0%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg59.0%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative59.0%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in59.0%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg59.0%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg59.0%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg59.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative59.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in59.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg59.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg59.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval59.0%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr59.0%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Taylor expanded in x around inf 32.0%

      \[\leadsto \color{blue}{\sqrt{x}} \]

    if 3.19999999999999982e-156 < y

    1. Initial program 100.0%

      \[\sqrt{\left|x - y\right|} \]
    2. Step-by-step derivation
      1. fabs-sub100.0%

        \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
    4. Step-by-step derivation
      1. pow1/2100.0%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
      2. sqr-pow99.3%

        \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      3. pow-prod-down45.6%

        \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. neg-fabs45.6%

        \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
      5. neg-fabs45.6%

        \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. sqr-abs45.6%

        \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
      7. sub-neg45.6%

        \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      8. +-commutative45.6%

        \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      9. distribute-neg-in45.6%

        \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      10. remove-double-neg45.6%

        \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      11. sub-neg45.6%

        \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      12. sub-neg45.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      13. +-commutative45.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      14. distribute-neg-in45.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      15. remove-double-neg45.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
      16. sub-neg45.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
      17. metadata-eval45.6%

        \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
    5. Applied egg-rr45.6%

      \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
    6. Taylor expanded in x around 0 75.8%

      \[\leadsto \color{blue}{{1}^{0.25} \cdot \sqrt{y}} \]
    7. Step-by-step derivation
      1. pow-base-175.8%

        \[\leadsto \color{blue}{1} \cdot \sqrt{y} \]
      2. *-lft-identity75.8%

        \[\leadsto \color{blue}{\sqrt{y}} \]
    8. Simplified75.8%

      \[\leadsto \color{blue}{\sqrt{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification47.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 3.2 \cdot 10^{-156}:\\ \;\;\;\;\sqrt{x}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{y}\\ \end{array} \]

Alternative 9: 6.9% accurate, 203.0× speedup?

\[\begin{array}{l} \\ 1 \end{array} \]
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
	return 1.0;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = 1.0d0
end function
public static double code(double x, double y) {
	return 1.0;
}
def code(x, y):
	return 1.0
function code(x, y)
	return 1.0
end
function tmp = code(x, y)
	tmp = 1.0;
end
code[x_, y_] := 1.0
\begin{array}{l}

\\
1
\end{array}
Derivation
  1. Initial program 100.0%

    \[\sqrt{\left|x - y\right|} \]
  2. Step-by-step derivation
    1. fabs-sub100.0%

      \[\leadsto \sqrt{\color{blue}{\left|y - x\right|}} \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\sqrt{\left|y - x\right|}} \]
  4. Step-by-step derivation
    1. pow1/2100.0%

      \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{0.5}} \]
    2. sqr-pow99.2%

      \[\leadsto \color{blue}{{\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left(\left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
    3. pow-prod-down54.4%

      \[\leadsto \color{blue}{{\left(\left|y - x\right| \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)}} \]
    4. neg-fabs54.4%

      \[\leadsto {\left(\color{blue}{\left|-\left(y - x\right)\right|} \cdot \left|y - x\right|\right)}^{\left(\frac{0.5}{2}\right)} \]
    5. neg-fabs54.4%

      \[\leadsto {\left(\left|-\left(y - x\right)\right| \cdot \color{blue}{\left|-\left(y - x\right)\right|}\right)}^{\left(\frac{0.5}{2}\right)} \]
    6. sqr-abs54.4%

      \[\leadsto {\color{blue}{\left(\left(-\left(y - x\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}}^{\left(\frac{0.5}{2}\right)} \]
    7. sub-neg54.4%

      \[\leadsto {\left(\left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
    8. +-commutative54.4%

      \[\leadsto {\left(\left(-\color{blue}{\left(\left(-x\right) + y\right)}\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
    9. distribute-neg-in54.4%

      \[\leadsto {\left(\color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
    10. remove-double-neg54.4%

      \[\leadsto {\left(\left(\color{blue}{x} + \left(-y\right)\right) \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
    11. sub-neg54.4%

      \[\leadsto {\left(\color{blue}{\left(x - y\right)} \cdot \left(-\left(y - x\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
    12. sub-neg54.4%

      \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
    13. +-commutative54.4%

      \[\leadsto {\left(\left(x - y\right) \cdot \left(-\color{blue}{\left(\left(-x\right) + y\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
    14. distribute-neg-in54.4%

      \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-y\right)\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
    15. remove-double-neg54.4%

      \[\leadsto {\left(\left(x - y\right) \cdot \left(\color{blue}{x} + \left(-y\right)\right)\right)}^{\left(\frac{0.5}{2}\right)} \]
    16. sub-neg54.4%

      \[\leadsto {\left(\left(x - y\right) \cdot \color{blue}{\left(x - y\right)}\right)}^{\left(\frac{0.5}{2}\right)} \]
    17. metadata-eval54.4%

      \[\leadsto {\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{\color{blue}{0.25}} \]
  5. Applied egg-rr54.4%

    \[\leadsto \color{blue}{{\left(\left(x - y\right) \cdot \left(x - y\right)\right)}^{0.25}} \]
  6. Taylor expanded in x around inf 31.3%

    \[\leadsto {\color{blue}{\left({x}^{2}\right)}}^{0.25} \]
  7. Step-by-step derivation
    1. unpow231.3%

      \[\leadsto {\color{blue}{\left(x \cdot x\right)}}^{0.25} \]
  8. Simplified31.3%

    \[\leadsto {\color{blue}{\left(x \cdot x\right)}}^{0.25} \]
  9. Applied egg-rr7.0%

    \[\leadsto \color{blue}{\frac{-x}{-x}} \]
  10. Simplified7.0%

    \[\leadsto \color{blue}{1} \]
  11. Final simplification7.0%

    \[\leadsto 1 \]

Reproduce

?
herbie shell --seed 2023297 
(FPCore (x y)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, C"
  :precision binary64
  (sqrt (fabs (- x y))))