Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3

Percentage Accurate: 99.9% → 99.9%
Time: 9.3s
Alternatives: 10
Speedup: 1.0×

Specification

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

\\
x + \frac{\left|y - x\right|}{2}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 99.9% accurate, 1.0× speedup?

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

\\
x + \frac{\left|y - x\right|}{2}
\end{array}

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

    \[x + \frac{\left|y - x\right|}{2} \]
  2. Add Preprocessing
  3. Final simplification100.0%

    \[\leadsto x + \frac{\left|x - y\right|}{2} \]
  4. Add Preprocessing

Alternative 2: 84.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.1 \cdot 10^{-198}:\\ \;\;\;\;y \cdot -0.5 + x \cdot 1.5\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-99}:\\ \;\;\;\;x + \frac{\left|x\right|}{2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -1.1e-198)
   (+ (* y -0.5) (* x 1.5))
   (if (<= y 1.25e-99) (+ x (/ (fabs x) 2.0)) (* 0.5 (+ x y)))))
double code(double x, double y) {
	double tmp;
	if (y <= -1.1e-198) {
		tmp = (y * -0.5) + (x * 1.5);
	} else if (y <= 1.25e-99) {
		tmp = x + (fabs(x) / 2.0);
	} else {
		tmp = 0.5 * (x + y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-1.1d-198)) then
        tmp = (y * (-0.5d0)) + (x * 1.5d0)
    else if (y <= 1.25d-99) then
        tmp = x + (abs(x) / 2.0d0)
    else
        tmp = 0.5d0 * (x + y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -1.1e-198) {
		tmp = (y * -0.5) + (x * 1.5);
	} else if (y <= 1.25e-99) {
		tmp = x + (Math.abs(x) / 2.0);
	} else {
		tmp = 0.5 * (x + y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -1.1e-198:
		tmp = (y * -0.5) + (x * 1.5)
	elif y <= 1.25e-99:
		tmp = x + (math.fabs(x) / 2.0)
	else:
		tmp = 0.5 * (x + y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -1.1e-198)
		tmp = Float64(Float64(y * -0.5) + Float64(x * 1.5));
	elseif (y <= 1.25e-99)
		tmp = Float64(x + Float64(abs(x) / 2.0));
	else
		tmp = Float64(0.5 * Float64(x + y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -1.1e-198)
		tmp = (y * -0.5) + (x * 1.5);
	elseif (y <= 1.25e-99)
		tmp = x + (abs(x) / 2.0);
	else
		tmp = 0.5 * (x + y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -1.1e-198], N[(N[(y * -0.5), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.25e-99], N[(x + N[(N[Abs[x], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{-198}:\\
\;\;\;\;y \cdot -0.5 + x \cdot 1.5\\

\mathbf{elif}\;y \leq 1.25 \cdot 10^{-99}:\\
\;\;\;\;x + \frac{\left|x\right|}{2}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\


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

    1. Initial program 99.9%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 90.8%

      \[\leadsto x + \frac{\left|\color{blue}{y \cdot \left(1 + -1 \cdot \frac{x}{y}\right)}\right|}{2} \]
    4. Step-by-step derivation
      1. mul-1-neg90.8%

        \[\leadsto x + \frac{\left|y \cdot \left(1 + \color{blue}{\left(-\frac{x}{y}\right)}\right)\right|}{2} \]
      2. unsub-neg90.8%

        \[\leadsto x + \frac{\left|y \cdot \color{blue}{\left(1 - \frac{x}{y}\right)}\right|}{2} \]
    5. Simplified90.8%

      \[\leadsto x + \frac{\left|\color{blue}{y \cdot \left(1 - \frac{x}{y}\right)}\right|}{2} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt14.2%

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt{y \cdot \left(1 - \frac{x}{y}\right)} \cdot \sqrt{y \cdot \left(1 - \frac{x}{y}\right)}}\right|}{2} \]
      2. fabs-sqr14.2%

        \[\leadsto x + \frac{\color{blue}{\sqrt{y \cdot \left(1 - \frac{x}{y}\right)} \cdot \sqrt{y \cdot \left(1 - \frac{x}{y}\right)}}}{2} \]
      3. add-sqr-sqrt18.0%

        \[\leadsto x + \frac{\color{blue}{y \cdot \left(1 - \frac{x}{y}\right)}}{2} \]
      4. div-inv17.9%

        \[\leadsto x + \frac{y \cdot \left(1 - \color{blue}{x \cdot \frac{1}{y}}\right)}{2} \]
      5. cancel-sign-sub-inv17.9%

        \[\leadsto x + \frac{y \cdot \color{blue}{\left(1 + \left(-x\right) \cdot \frac{1}{y}\right)}}{2} \]
      6. add-sqr-sqrt14.4%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\left(\sqrt{-x} \cdot \sqrt{-x}\right)} \cdot \frac{1}{y}\right)}{2} \]
      7. sqrt-unprod18.0%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}} \cdot \frac{1}{y}\right)}{2} \]
      8. sqr-neg18.0%

        \[\leadsto x + \frac{y \cdot \left(1 + \sqrt{\color{blue}{x \cdot x}} \cdot \frac{1}{y}\right)}{2} \]
      9. sqrt-unprod17.9%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \cdot \frac{1}{y}\right)}{2} \]
      10. add-sqr-sqrt21.0%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{x} \cdot \frac{1}{y}\right)}{2} \]
      11. div-inv21.0%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\frac{x}{y}}\right)}{2} \]
      12. flip-+14.2%

        \[\leadsto x + \frac{y \cdot \color{blue}{\frac{1 \cdot 1 - \frac{x}{y} \cdot \frac{x}{y}}{1 - \frac{x}{y}}}}{2} \]
      13. associate-*r/11.4%

        \[\leadsto x + \frac{\color{blue}{\frac{y \cdot \left(1 \cdot 1 - \frac{x}{y} \cdot \frac{x}{y}\right)}{1 - \frac{x}{y}}}}{2} \]
    7. Applied egg-rr11.5%

      \[\leadsto x + \frac{\color{blue}{\frac{y \cdot \left(1 + {\left(\frac{x}{y}\right)}^{2}\right)}{1 + \frac{x}{y}}}}{2} \]
    8. Step-by-step derivation
      1. distribute-lft-in11.5%

        \[\leadsto x + \frac{\frac{\color{blue}{y \cdot 1 + y \cdot {\left(\frac{x}{y}\right)}^{2}}}{1 + \frac{x}{y}}}{2} \]
      2. *-rgt-identity11.5%

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

        \[\leadsto x + \frac{\frac{y + y \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)}}{1 + \frac{x}{y}}}{2} \]
      4. associate-*r*13.7%

        \[\leadsto x + \frac{\frac{y + \color{blue}{\left(y \cdot \frac{x}{y}\right) \cdot \frac{x}{y}}}{1 + \frac{x}{y}}}{2} \]
      5. *-commutative13.7%

        \[\leadsto x + \frac{\frac{y + \color{blue}{\left(\frac{x}{y} \cdot y\right)} \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
      6. associate-*l/11.7%

        \[\leadsto x + \frac{\frac{y + \color{blue}{\frac{x \cdot y}{y}} \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
      7. associate-/l*13.7%

        \[\leadsto x + \frac{\frac{y + \color{blue}{\left(x \cdot \frac{y}{y}\right)} \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
      8. *-inverses13.7%

        \[\leadsto x + \frac{\frac{y + \left(x \cdot \color{blue}{1}\right) \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
      9. *-rgt-identity13.7%

        \[\leadsto x + \frac{\frac{y + \color{blue}{x} \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
    9. Simplified13.7%

      \[\leadsto x + \frac{\color{blue}{\frac{y + x \cdot \frac{x}{y}}{1 + \frac{x}{y}}}}{2} \]
    10. Taylor expanded in y around 0 85.1%

      \[\leadsto \color{blue}{x + \left(-0.5 \cdot y + 0.5 \cdot x\right)} \]
    11. Step-by-step derivation
      1. +-commutative85.1%

        \[\leadsto \color{blue}{\left(-0.5 \cdot y + 0.5 \cdot x\right) + x} \]
      2. *-commutative85.1%

        \[\leadsto \left(-0.5 \cdot y + \color{blue}{x \cdot 0.5}\right) + x \]
      3. associate-+l+85.1%

        \[\leadsto \color{blue}{-0.5 \cdot y + \left(x \cdot 0.5 + x\right)} \]
      4. *-commutative85.1%

        \[\leadsto \color{blue}{y \cdot -0.5} + \left(x \cdot 0.5 + x\right) \]
      5. *-commutative85.1%

        \[\leadsto y \cdot -0.5 + \left(\color{blue}{0.5 \cdot x} + x\right) \]
      6. distribute-lft1-in85.1%

        \[\leadsto y \cdot -0.5 + \color{blue}{\left(0.5 + 1\right) \cdot x} \]
      7. metadata-eval85.1%

        \[\leadsto y \cdot -0.5 + \color{blue}{1.5} \cdot x \]
      8. *-commutative85.1%

        \[\leadsto y \cdot -0.5 + \color{blue}{x \cdot 1.5} \]
    12. Simplified85.1%

      \[\leadsto \color{blue}{y \cdot -0.5 + x \cdot 1.5} \]

    if -1.1e-198 < y < 1.24999999999999992e-99

    1. Initial program 100.0%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 89.5%

      \[\leadsto x + \frac{\left|\color{blue}{-1 \cdot x}\right|}{2} \]
    4. Step-by-step derivation
      1. neg-mul-189.5%

        \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    5. Simplified89.5%

      \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]

    if 1.24999999999999992e-99 < y

    1. Initial program 100.0%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around -inf 100.0%

      \[\leadsto x + \frac{\color{blue}{\left|-\left(x + -1 \cdot y\right)\right|}}{2} \]
    4. Step-by-step derivation
      1. fabs-neg100.0%

        \[\leadsto x + \frac{\color{blue}{\left|x + -1 \cdot y\right|}}{2} \]
      2. mul-1-neg100.0%

        \[\leadsto x + \frac{\left|x + \color{blue}{\left(-y\right)}\right|}{2} \]
      3. sub-neg100.0%

        \[\leadsto x + \frac{\left|\color{blue}{x - y}\right|}{2} \]
      4. fabs-sub100.0%

        \[\leadsto x + \frac{\color{blue}{\left|y - x\right|}}{2} \]
      5. rem-square-sqrt78.9%

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}\right|}{2} \]
      6. fabs-sqr78.9%

        \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
      7. rem-square-sqrt83.1%

        \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    5. Simplified83.1%

      \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    6. Taylor expanded in x around 0 83.1%

      \[\leadsto \color{blue}{0.5 \cdot x + 0.5 \cdot y} \]
    7. Step-by-step derivation
      1. +-commutative83.1%

        \[\leadsto \color{blue}{0.5 \cdot y + 0.5 \cdot x} \]
      2. distribute-lft-in83.1%

        \[\leadsto \color{blue}{0.5 \cdot \left(y + x\right)} \]
    8. Simplified83.1%

      \[\leadsto \color{blue}{0.5 \cdot \left(y + x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.1 \cdot 10^{-198}:\\ \;\;\;\;y \cdot -0.5 + x \cdot 1.5\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-99}:\\ \;\;\;\;x + \frac{\left|x\right|}{2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 82.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{+59}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-87}:\\ \;\;\;\;x + \frac{\left|y\right|}{2}\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5 + x \cdot 1.5\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -2.4e+59)
   (* 0.5 (+ x y))
   (if (<= x 5.8e-87) (+ x (/ (fabs y) 2.0)) (+ (* y -0.5) (* x 1.5)))))
double code(double x, double y) {
	double tmp;
	if (x <= -2.4e+59) {
		tmp = 0.5 * (x + y);
	} else if (x <= 5.8e-87) {
		tmp = x + (fabs(y) / 2.0);
	} else {
		tmp = (y * -0.5) + (x * 1.5);
	}
	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+59)) then
        tmp = 0.5d0 * (x + y)
    else if (x <= 5.8d-87) then
        tmp = x + (abs(y) / 2.0d0)
    else
        tmp = (y * (-0.5d0)) + (x * 1.5d0)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -2.4e+59) {
		tmp = 0.5 * (x + y);
	} else if (x <= 5.8e-87) {
		tmp = x + (Math.abs(y) / 2.0);
	} else {
		tmp = (y * -0.5) + (x * 1.5);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -2.4e+59:
		tmp = 0.5 * (x + y)
	elif x <= 5.8e-87:
		tmp = x + (math.fabs(y) / 2.0)
	else:
		tmp = (y * -0.5) + (x * 1.5)
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -2.4e+59)
		tmp = Float64(0.5 * Float64(x + y));
	elseif (x <= 5.8e-87)
		tmp = Float64(x + Float64(abs(y) / 2.0));
	else
		tmp = Float64(Float64(y * -0.5) + Float64(x * 1.5));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -2.4e+59)
		tmp = 0.5 * (x + y);
	elseif (x <= 5.8e-87)
		tmp = x + (abs(y) / 2.0);
	else
		tmp = (y * -0.5) + (x * 1.5);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -2.4e+59], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.8e-87], N[(x + N[(N[Abs[y], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(y * -0.5), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \cdot 10^{+59}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\

\mathbf{elif}\;x \leq 5.8 \cdot 10^{-87}:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\

\mathbf{else}:\\
\;\;\;\;y \cdot -0.5 + x \cdot 1.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.4000000000000002e59

    1. Initial program 100.0%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around -inf 100.0%

      \[\leadsto x + \frac{\color{blue}{\left|-\left(x + -1 \cdot y\right)\right|}}{2} \]
    4. Step-by-step derivation
      1. fabs-neg100.0%

        \[\leadsto x + \frac{\color{blue}{\left|x + -1 \cdot y\right|}}{2} \]
      2. mul-1-neg100.0%

        \[\leadsto x + \frac{\left|x + \color{blue}{\left(-y\right)}\right|}{2} \]
      3. sub-neg100.0%

        \[\leadsto x + \frac{\left|\color{blue}{x - y}\right|}{2} \]
      4. fabs-sub100.0%

        \[\leadsto x + \frac{\color{blue}{\left|y - x\right|}}{2} \]
      5. rem-square-sqrt91.8%

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}\right|}{2} \]
      6. fabs-sqr91.8%

        \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
      7. rem-square-sqrt92.6%

        \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    5. Simplified92.6%

      \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    6. Taylor expanded in x around 0 92.6%

      \[\leadsto \color{blue}{0.5 \cdot x + 0.5 \cdot y} \]
    7. Step-by-step derivation
      1. +-commutative92.6%

        \[\leadsto \color{blue}{0.5 \cdot y + 0.5 \cdot x} \]
      2. distribute-lft-in92.6%

        \[\leadsto \color{blue}{0.5 \cdot \left(y + x\right)} \]
    8. Simplified92.6%

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

    if -2.4000000000000002e59 < x < 5.7999999999999998e-87

    1. Initial program 100.0%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 79.5%

      \[\leadsto x + \frac{\left|\color{blue}{y}\right|}{2} \]

    if 5.7999999999999998e-87 < x

    1. Initial program 99.9%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 78.5%

      \[\leadsto x + \frac{\left|\color{blue}{y \cdot \left(1 + -1 \cdot \frac{x}{y}\right)}\right|}{2} \]
    4. Step-by-step derivation
      1. mul-1-neg78.5%

        \[\leadsto x + \frac{\left|y \cdot \left(1 + \color{blue}{\left(-\frac{x}{y}\right)}\right)\right|}{2} \]
      2. unsub-neg78.5%

        \[\leadsto x + \frac{\left|y \cdot \color{blue}{\left(1 - \frac{x}{y}\right)}\right|}{2} \]
    5. Simplified78.5%

      \[\leadsto x + \frac{\left|\color{blue}{y \cdot \left(1 - \frac{x}{y}\right)}\right|}{2} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt16.0%

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt{y \cdot \left(1 - \frac{x}{y}\right)} \cdot \sqrt{y \cdot \left(1 - \frac{x}{y}\right)}}\right|}{2} \]
      2. fabs-sqr16.0%

        \[\leadsto x + \frac{\color{blue}{\sqrt{y \cdot \left(1 - \frac{x}{y}\right)} \cdot \sqrt{y \cdot \left(1 - \frac{x}{y}\right)}}}{2} \]
      3. add-sqr-sqrt24.6%

        \[\leadsto x + \frac{\color{blue}{y \cdot \left(1 - \frac{x}{y}\right)}}{2} \]
      4. div-inv24.6%

        \[\leadsto x + \frac{y \cdot \left(1 - \color{blue}{x \cdot \frac{1}{y}}\right)}{2} \]
      5. cancel-sign-sub-inv24.6%

        \[\leadsto x + \frac{y \cdot \color{blue}{\left(1 + \left(-x\right) \cdot \frac{1}{y}\right)}}{2} \]
      6. add-sqr-sqrt0.0%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\left(\sqrt{-x} \cdot \sqrt{-x}\right)} \cdot \frac{1}{y}\right)}{2} \]
      7. sqrt-unprod39.5%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}} \cdot \frac{1}{y}\right)}{2} \]
      8. sqr-neg39.5%

        \[\leadsto x + \frac{y \cdot \left(1 + \sqrt{\color{blue}{x \cdot x}} \cdot \frac{1}{y}\right)}{2} \]
      9. sqrt-unprod64.0%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \cdot \frac{1}{y}\right)}{2} \]
      10. add-sqr-sqrt64.1%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{x} \cdot \frac{1}{y}\right)}{2} \]
      11. div-inv64.1%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\frac{x}{y}}\right)}{2} \]
      12. flip-+41.8%

        \[\leadsto x + \frac{y \cdot \color{blue}{\frac{1 \cdot 1 - \frac{x}{y} \cdot \frac{x}{y}}{1 - \frac{x}{y}}}}{2} \]
      13. associate-*r/32.2%

        \[\leadsto x + \frac{\color{blue}{\frac{y \cdot \left(1 \cdot 1 - \frac{x}{y} \cdot \frac{x}{y}\right)}{1 - \frac{x}{y}}}}{2} \]
    7. Applied egg-rr32.5%

      \[\leadsto x + \frac{\color{blue}{\frac{y \cdot \left(1 + {\left(\frac{x}{y}\right)}^{2}\right)}{1 + \frac{x}{y}}}}{2} \]
    8. Step-by-step derivation
      1. distribute-lft-in32.5%

        \[\leadsto x + \frac{\frac{\color{blue}{y \cdot 1 + y \cdot {\left(\frac{x}{y}\right)}^{2}}}{1 + \frac{x}{y}}}{2} \]
      2. *-rgt-identity32.5%

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

        \[\leadsto x + \frac{\frac{y + y \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)}}{1 + \frac{x}{y}}}{2} \]
      4. associate-*r*39.2%

        \[\leadsto x + \frac{\frac{y + \color{blue}{\left(y \cdot \frac{x}{y}\right) \cdot \frac{x}{y}}}{1 + \frac{x}{y}}}{2} \]
      5. *-commutative39.2%

        \[\leadsto x + \frac{\frac{y + \color{blue}{\left(\frac{x}{y} \cdot y\right)} \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
      6. associate-*l/27.7%

        \[\leadsto x + \frac{\frac{y + \color{blue}{\frac{x \cdot y}{y}} \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
      7. associate-/l*39.2%

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

        \[\leadsto x + \frac{\frac{y + \left(x \cdot \color{blue}{1}\right) \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
      9. *-rgt-identity39.2%

        \[\leadsto x + \frac{\frac{y + \color{blue}{x} \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
    9. Simplified39.2%

      \[\leadsto x + \frac{\color{blue}{\frac{y + x \cdot \frac{x}{y}}{1 + \frac{x}{y}}}}{2} \]
    10. Taylor expanded in y around 0 83.9%

      \[\leadsto \color{blue}{x + \left(-0.5 \cdot y + 0.5 \cdot x\right)} \]
    11. Step-by-step derivation
      1. +-commutative83.9%

        \[\leadsto \color{blue}{\left(-0.5 \cdot y + 0.5 \cdot x\right) + x} \]
      2. *-commutative83.9%

        \[\leadsto \left(-0.5 \cdot y + \color{blue}{x \cdot 0.5}\right) + x \]
      3. associate-+l+83.9%

        \[\leadsto \color{blue}{-0.5 \cdot y + \left(x \cdot 0.5 + x\right)} \]
      4. *-commutative83.9%

        \[\leadsto \color{blue}{y \cdot -0.5} + \left(x \cdot 0.5 + x\right) \]
      5. *-commutative83.9%

        \[\leadsto y \cdot -0.5 + \left(\color{blue}{0.5 \cdot x} + x\right) \]
      6. distribute-lft1-in83.9%

        \[\leadsto y \cdot -0.5 + \color{blue}{\left(0.5 + 1\right) \cdot x} \]
      7. metadata-eval83.9%

        \[\leadsto y \cdot -0.5 + \color{blue}{1.5} \cdot x \]
      8. *-commutative83.9%

        \[\leadsto y \cdot -0.5 + \color{blue}{x \cdot 1.5} \]
    12. Simplified83.9%

      \[\leadsto \color{blue}{y \cdot -0.5 + x \cdot 1.5} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification83.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{+59}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-87}:\\ \;\;\;\;x + \frac{\left|y\right|}{2}\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5 + x \cdot 1.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 57.4% accurate, 8.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{-201}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-84}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1.5\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -4.8e-201) (* x 0.5) (if (<= x 1.75e-84) (* y 0.5) (* x 1.5))))
double code(double x, double y) {
	double tmp;
	if (x <= -4.8e-201) {
		tmp = x * 0.5;
	} else if (x <= 1.75e-84) {
		tmp = y * 0.5;
	} else {
		tmp = x * 1.5;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-4.8d-201)) then
        tmp = x * 0.5d0
    else if (x <= 1.75d-84) then
        tmp = y * 0.5d0
    else
        tmp = x * 1.5d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -4.8e-201) {
		tmp = x * 0.5;
	} else if (x <= 1.75e-84) {
		tmp = y * 0.5;
	} else {
		tmp = x * 1.5;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -4.8e-201:
		tmp = x * 0.5
	elif x <= 1.75e-84:
		tmp = y * 0.5
	else:
		tmp = x * 1.5
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -4.8e-201)
		tmp = Float64(x * 0.5);
	elseif (x <= 1.75e-84)
		tmp = Float64(y * 0.5);
	else
		tmp = Float64(x * 1.5);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -4.8e-201)
		tmp = x * 0.5;
	elseif (x <= 1.75e-84)
		tmp = y * 0.5;
	else
		tmp = x * 1.5;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -4.8e-201], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.75e-84], N[(y * 0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{-201}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq 1.75 \cdot 10^{-84}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.80000000000000018e-201

    1. Initial program 100.0%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around -inf 100.0%

      \[\leadsto x + \frac{\color{blue}{\left|-\left(x + -1 \cdot y\right)\right|}}{2} \]
    4. Step-by-step derivation
      1. fabs-neg100.0%

        \[\leadsto x + \frac{\color{blue}{\left|x + -1 \cdot y\right|}}{2} \]
      2. mul-1-neg100.0%

        \[\leadsto x + \frac{\left|x + \color{blue}{\left(-y\right)}\right|}{2} \]
      3. sub-neg100.0%

        \[\leadsto x + \frac{\left|\color{blue}{x - y}\right|}{2} \]
      4. fabs-sub100.0%

        \[\leadsto x + \frac{\color{blue}{\left|y - x\right|}}{2} \]
      5. rem-square-sqrt76.8%

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}\right|}{2} \]
      6. fabs-sqr76.8%

        \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
      7. rem-square-sqrt77.6%

        \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    5. Simplified77.6%

      \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    6. Taylor expanded in x around inf 63.6%

      \[\leadsto \color{blue}{0.5 \cdot x} \]

    if -4.80000000000000018e-201 < x < 1.7500000000000001e-84

    1. Initial program 99.9%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around -inf 99.9%

      \[\leadsto x + \frac{\color{blue}{\left|-\left(x + -1 \cdot y\right)\right|}}{2} \]
    4. Step-by-step derivation
      1. fabs-neg99.9%

        \[\leadsto x + \frac{\color{blue}{\left|x + -1 \cdot y\right|}}{2} \]
      2. mul-1-neg99.9%

        \[\leadsto x + \frac{\left|x + \color{blue}{\left(-y\right)}\right|}{2} \]
      3. sub-neg99.9%

        \[\leadsto x + \frac{\left|\color{blue}{x - y}\right|}{2} \]
      4. fabs-sub99.9%

        \[\leadsto x + \frac{\color{blue}{\left|y - x\right|}}{2} \]
      5. rem-square-sqrt47.1%

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}\right|}{2} \]
      6. fabs-sqr47.1%

        \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
      7. rem-square-sqrt50.4%

        \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    5. Simplified50.4%

      \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    6. Taylor expanded in x around 0 46.0%

      \[\leadsto \color{blue}{0.5 \cdot y} \]

    if 1.7500000000000001e-84 < x

    1. Initial program 99.9%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 71.1%

      \[\leadsto x + \frac{\left|\color{blue}{-1 \cdot x}\right|}{2} \]
    4. Step-by-step derivation
      1. neg-mul-171.1%

        \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    5. Simplified71.1%

      \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    6. Taylor expanded in x around 0 71.1%

      \[\leadsto \color{blue}{x + 0.5 \cdot \left|-x\right|} \]
    7. Step-by-step derivation
      1. +-commutative71.1%

        \[\leadsto \color{blue}{0.5 \cdot \left|-x\right| + x} \]
      2. fma-define71.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, \left|-x\right|, x\right)} \]
      3. fabs-neg71.1%

        \[\leadsto \mathsf{fma}\left(0.5, \color{blue}{\left|x\right|}, x\right) \]
      4. rem-square-sqrt71.0%

        \[\leadsto \mathsf{fma}\left(0.5, \left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|, x\right) \]
      5. fabs-sqr71.0%

        \[\leadsto \mathsf{fma}\left(0.5, \color{blue}{\sqrt{x} \cdot \sqrt{x}}, x\right) \]
      6. rem-square-sqrt71.1%

        \[\leadsto \mathsf{fma}\left(0.5, \color{blue}{x}, x\right) \]
      7. fma-define71.1%

        \[\leadsto \color{blue}{0.5 \cdot x + x} \]
      8. *-lft-identity71.1%

        \[\leadsto 0.5 \cdot x + \color{blue}{1 \cdot x} \]
      9. distribute-rgt-out71.1%

        \[\leadsto \color{blue}{x \cdot \left(0.5 + 1\right)} \]
      10. metadata-eval71.1%

        \[\leadsto x \cdot \color{blue}{1.5} \]
    8. Simplified71.1%

      \[\leadsto \color{blue}{x \cdot 1.5} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification60.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{-201}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-84}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 78.8% accurate, 8.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{-227}:\\ \;\;\;\;y \cdot -0.5 + x \cdot 1.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -3.7e-227) (+ (* y -0.5) (* x 1.5)) (* 0.5 (+ x y))))
double code(double x, double y) {
	double tmp;
	if (y <= -3.7e-227) {
		tmp = (y * -0.5) + (x * 1.5);
	} else {
		tmp = 0.5 * (x + 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.7d-227)) then
        tmp = (y * (-0.5d0)) + (x * 1.5d0)
    else
        tmp = 0.5d0 * (x + y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -3.7e-227) {
		tmp = (y * -0.5) + (x * 1.5);
	} else {
		tmp = 0.5 * (x + y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -3.7e-227:
		tmp = (y * -0.5) + (x * 1.5)
	else:
		tmp = 0.5 * (x + y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -3.7e-227)
		tmp = Float64(Float64(y * -0.5) + Float64(x * 1.5));
	else
		tmp = Float64(0.5 * Float64(x + y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -3.7e-227)
		tmp = (y * -0.5) + (x * 1.5);
	else
		tmp = 0.5 * (x + y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -3.7e-227], N[(N[(y * -0.5), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{-227}:\\
\;\;\;\;y \cdot -0.5 + x \cdot 1.5\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\


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

    1. Initial program 99.9%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 86.9%

      \[\leadsto x + \frac{\left|\color{blue}{y \cdot \left(1 + -1 \cdot \frac{x}{y}\right)}\right|}{2} \]
    4. Step-by-step derivation
      1. mul-1-neg86.9%

        \[\leadsto x + \frac{\left|y \cdot \left(1 + \color{blue}{\left(-\frac{x}{y}\right)}\right)\right|}{2} \]
      2. unsub-neg86.9%

        \[\leadsto x + \frac{\left|y \cdot \color{blue}{\left(1 - \frac{x}{y}\right)}\right|}{2} \]
    5. Simplified86.9%

      \[\leadsto x + \frac{\left|\color{blue}{y \cdot \left(1 - \frac{x}{y}\right)}\right|}{2} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt14.3%

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt{y \cdot \left(1 - \frac{x}{y}\right)} \cdot \sqrt{y \cdot \left(1 - \frac{x}{y}\right)}}\right|}{2} \]
      2. fabs-sqr14.3%

        \[\leadsto x + \frac{\color{blue}{\sqrt{y \cdot \left(1 - \frac{x}{y}\right)} \cdot \sqrt{y \cdot \left(1 - \frac{x}{y}\right)}}}{2} \]
      3. add-sqr-sqrt18.4%

        \[\leadsto x + \frac{\color{blue}{y \cdot \left(1 - \frac{x}{y}\right)}}{2} \]
      4. div-inv18.4%

        \[\leadsto x + \frac{y \cdot \left(1 - \color{blue}{x \cdot \frac{1}{y}}\right)}{2} \]
      5. cancel-sign-sub-inv18.4%

        \[\leadsto x + \frac{y \cdot \color{blue}{\left(1 + \left(-x\right) \cdot \frac{1}{y}\right)}}{2} \]
      6. add-sqr-sqrt14.5%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\left(\sqrt{-x} \cdot \sqrt{-x}\right)} \cdot \frac{1}{y}\right)}{2} \]
      7. sqrt-unprod20.2%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}} \cdot \frac{1}{y}\right)}{2} \]
      8. sqr-neg20.2%

        \[\leadsto x + \frac{y \cdot \left(1 + \sqrt{\color{blue}{x \cdot x}} \cdot \frac{1}{y}\right)}{2} \]
      9. sqrt-unprod20.3%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \cdot \frac{1}{y}\right)}{2} \]
      10. add-sqr-sqrt23.5%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{x} \cdot \frac{1}{y}\right)}{2} \]
      11. div-inv23.5%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\frac{x}{y}}\right)}{2} \]
      12. flip-+14.7%

        \[\leadsto x + \frac{y \cdot \color{blue}{\frac{1 \cdot 1 - \frac{x}{y} \cdot \frac{x}{y}}{1 - \frac{x}{y}}}}{2} \]
      13. associate-*r/12.3%

        \[\leadsto x + \frac{\color{blue}{\frac{y \cdot \left(1 \cdot 1 - \frac{x}{y} \cdot \frac{x}{y}\right)}{1 - \frac{x}{y}}}}{2} \]
    7. Applied egg-rr12.3%

      \[\leadsto x + \frac{\color{blue}{\frac{y \cdot \left(1 + {\left(\frac{x}{y}\right)}^{2}\right)}{1 + \frac{x}{y}}}}{2} \]
    8. Step-by-step derivation
      1. distribute-lft-in12.3%

        \[\leadsto x + \frac{\frac{\color{blue}{y \cdot 1 + y \cdot {\left(\frac{x}{y}\right)}^{2}}}{1 + \frac{x}{y}}}{2} \]
      2. *-rgt-identity12.3%

        \[\leadsto x + \frac{\frac{\color{blue}{y} + y \cdot {\left(\frac{x}{y}\right)}^{2}}{1 + \frac{x}{y}}}{2} \]
      3. unpow212.3%

        \[\leadsto x + \frac{\frac{y + y \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)}}{1 + \frac{x}{y}}}{2} \]
      4. associate-*r*15.9%

        \[\leadsto x + \frac{\frac{y + \color{blue}{\left(y \cdot \frac{x}{y}\right) \cdot \frac{x}{y}}}{1 + \frac{x}{y}}}{2} \]
      5. *-commutative15.9%

        \[\leadsto x + \frac{\frac{y + \color{blue}{\left(\frac{x}{y} \cdot y\right)} \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
      6. associate-*l/12.7%

        \[\leadsto x + \frac{\frac{y + \color{blue}{\frac{x \cdot y}{y}} \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
      7. associate-/l*15.9%

        \[\leadsto x + \frac{\frac{y + \color{blue}{\left(x \cdot \frac{y}{y}\right)} \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
      8. *-inverses15.9%

        \[\leadsto x + \frac{\frac{y + \left(x \cdot \color{blue}{1}\right) \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
      9. *-rgt-identity15.9%

        \[\leadsto x + \frac{\frac{y + \color{blue}{x} \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
    9. Simplified15.9%

      \[\leadsto x + \frac{\color{blue}{\frac{y + x \cdot \frac{x}{y}}{1 + \frac{x}{y}}}}{2} \]
    10. Taylor expanded in y around 0 83.9%

      \[\leadsto \color{blue}{x + \left(-0.5 \cdot y + 0.5 \cdot x\right)} \]
    11. Step-by-step derivation
      1. +-commutative83.9%

        \[\leadsto \color{blue}{\left(-0.5 \cdot y + 0.5 \cdot x\right) + x} \]
      2. *-commutative83.9%

        \[\leadsto \left(-0.5 \cdot y + \color{blue}{x \cdot 0.5}\right) + x \]
      3. associate-+l+83.9%

        \[\leadsto \color{blue}{-0.5 \cdot y + \left(x \cdot 0.5 + x\right)} \]
      4. *-commutative83.9%

        \[\leadsto \color{blue}{y \cdot -0.5} + \left(x \cdot 0.5 + x\right) \]
      5. *-commutative83.9%

        \[\leadsto y \cdot -0.5 + \left(\color{blue}{0.5 \cdot x} + x\right) \]
      6. distribute-lft1-in83.9%

        \[\leadsto y \cdot -0.5 + \color{blue}{\left(0.5 + 1\right) \cdot x} \]
      7. metadata-eval83.9%

        \[\leadsto y \cdot -0.5 + \color{blue}{1.5} \cdot x \]
      8. *-commutative83.9%

        \[\leadsto y \cdot -0.5 + \color{blue}{x \cdot 1.5} \]
    12. Simplified83.9%

      \[\leadsto \color{blue}{y \cdot -0.5 + x \cdot 1.5} \]

    if -3.69999999999999978e-227 < y

    1. Initial program 100.0%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around -inf 100.0%

      \[\leadsto x + \frac{\color{blue}{\left|-\left(x + -1 \cdot y\right)\right|}}{2} \]
    4. Step-by-step derivation
      1. fabs-neg100.0%

        \[\leadsto x + \frac{\color{blue}{\left|x + -1 \cdot y\right|}}{2} \]
      2. mul-1-neg100.0%

        \[\leadsto x + \frac{\left|x + \color{blue}{\left(-y\right)}\right|}{2} \]
      3. sub-neg100.0%

        \[\leadsto x + \frac{\left|\color{blue}{x - y}\right|}{2} \]
      4. fabs-sub100.0%

        \[\leadsto x + \frac{\color{blue}{\left|y - x\right|}}{2} \]
      5. rem-square-sqrt71.2%

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}\right|}{2} \]
      6. fabs-sqr71.2%

        \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
      7. rem-square-sqrt76.7%

        \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    5. Simplified76.7%

      \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    6. Taylor expanded in x around 0 76.7%

      \[\leadsto \color{blue}{0.5 \cdot x + 0.5 \cdot y} \]
    7. Step-by-step derivation
      1. +-commutative76.7%

        \[\leadsto \color{blue}{0.5 \cdot y + 0.5 \cdot x} \]
      2. distribute-lft-in76.7%

        \[\leadsto \color{blue}{0.5 \cdot \left(y + x\right)} \]
    8. Simplified76.7%

      \[\leadsto \color{blue}{0.5 \cdot \left(y + x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{-227}:\\ \;\;\;\;y \cdot -0.5 + x \cdot 1.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 78.8% accurate, 8.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{-227}:\\ \;\;\;\;x + \frac{x - y}{2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -3.7e-227) (+ x (/ (- x y) 2.0)) (* 0.5 (+ x y))))
double code(double x, double y) {
	double tmp;
	if (y <= -3.7e-227) {
		tmp = x + ((x - y) / 2.0);
	} else {
		tmp = 0.5 * (x + 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.7d-227)) then
        tmp = x + ((x - y) / 2.0d0)
    else
        tmp = 0.5d0 * (x + y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -3.7e-227) {
		tmp = x + ((x - y) / 2.0);
	} else {
		tmp = 0.5 * (x + y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -3.7e-227:
		tmp = x + ((x - y) / 2.0)
	else:
		tmp = 0.5 * (x + y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -3.7e-227)
		tmp = Float64(x + Float64(Float64(x - y) / 2.0));
	else
		tmp = Float64(0.5 * Float64(x + y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -3.7e-227)
		tmp = x + ((x - y) / 2.0);
	else
		tmp = 0.5 * (x + y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -3.7e-227], N[(x + N[(N[(x - y), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{-227}:\\
\;\;\;\;x + \frac{x - y}{2}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\


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

    1. Initial program 99.9%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 86.9%

      \[\leadsto x + \frac{\left|\color{blue}{y \cdot \left(1 + -1 \cdot \frac{x}{y}\right)}\right|}{2} \]
    4. Step-by-step derivation
      1. mul-1-neg86.9%

        \[\leadsto x + \frac{\left|y \cdot \left(1 + \color{blue}{\left(-\frac{x}{y}\right)}\right)\right|}{2} \]
      2. unsub-neg86.9%

        \[\leadsto x + \frac{\left|y \cdot \color{blue}{\left(1 - \frac{x}{y}\right)}\right|}{2} \]
    5. Simplified86.9%

      \[\leadsto x + \frac{\left|\color{blue}{y \cdot \left(1 - \frac{x}{y}\right)}\right|}{2} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt14.3%

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt{y \cdot \left(1 - \frac{x}{y}\right)} \cdot \sqrt{y \cdot \left(1 - \frac{x}{y}\right)}}\right|}{2} \]
      2. fabs-sqr14.3%

        \[\leadsto x + \frac{\color{blue}{\sqrt{y \cdot \left(1 - \frac{x}{y}\right)} \cdot \sqrt{y \cdot \left(1 - \frac{x}{y}\right)}}}{2} \]
      3. add-sqr-sqrt18.4%

        \[\leadsto x + \frac{\color{blue}{y \cdot \left(1 - \frac{x}{y}\right)}}{2} \]
      4. div-inv18.4%

        \[\leadsto x + \frac{y \cdot \left(1 - \color{blue}{x \cdot \frac{1}{y}}\right)}{2} \]
      5. cancel-sign-sub-inv18.4%

        \[\leadsto x + \frac{y \cdot \color{blue}{\left(1 + \left(-x\right) \cdot \frac{1}{y}\right)}}{2} \]
      6. add-sqr-sqrt14.5%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\left(\sqrt{-x} \cdot \sqrt{-x}\right)} \cdot \frac{1}{y}\right)}{2} \]
      7. sqrt-unprod20.2%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}} \cdot \frac{1}{y}\right)}{2} \]
      8. sqr-neg20.2%

        \[\leadsto x + \frac{y \cdot \left(1 + \sqrt{\color{blue}{x \cdot x}} \cdot \frac{1}{y}\right)}{2} \]
      9. sqrt-unprod20.3%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \cdot \frac{1}{y}\right)}{2} \]
      10. add-sqr-sqrt23.5%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{x} \cdot \frac{1}{y}\right)}{2} \]
      11. div-inv23.5%

        \[\leadsto x + \frac{y \cdot \left(1 + \color{blue}{\frac{x}{y}}\right)}{2} \]
      12. flip-+14.7%

        \[\leadsto x + \frac{y \cdot \color{blue}{\frac{1 \cdot 1 - \frac{x}{y} \cdot \frac{x}{y}}{1 - \frac{x}{y}}}}{2} \]
      13. associate-*r/12.3%

        \[\leadsto x + \frac{\color{blue}{\frac{y \cdot \left(1 \cdot 1 - \frac{x}{y} \cdot \frac{x}{y}\right)}{1 - \frac{x}{y}}}}{2} \]
    7. Applied egg-rr12.3%

      \[\leadsto x + \frac{\color{blue}{\frac{y \cdot \left(1 + {\left(\frac{x}{y}\right)}^{2}\right)}{1 + \frac{x}{y}}}}{2} \]
    8. Step-by-step derivation
      1. distribute-lft-in12.3%

        \[\leadsto x + \frac{\frac{\color{blue}{y \cdot 1 + y \cdot {\left(\frac{x}{y}\right)}^{2}}}{1 + \frac{x}{y}}}{2} \]
      2. *-rgt-identity12.3%

        \[\leadsto x + \frac{\frac{\color{blue}{y} + y \cdot {\left(\frac{x}{y}\right)}^{2}}{1 + \frac{x}{y}}}{2} \]
      3. unpow212.3%

        \[\leadsto x + \frac{\frac{y + y \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)}}{1 + \frac{x}{y}}}{2} \]
      4. associate-*r*15.9%

        \[\leadsto x + \frac{\frac{y + \color{blue}{\left(y \cdot \frac{x}{y}\right) \cdot \frac{x}{y}}}{1 + \frac{x}{y}}}{2} \]
      5. *-commutative15.9%

        \[\leadsto x + \frac{\frac{y + \color{blue}{\left(\frac{x}{y} \cdot y\right)} \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
      6. associate-*l/12.7%

        \[\leadsto x + \frac{\frac{y + \color{blue}{\frac{x \cdot y}{y}} \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
      7. associate-/l*15.9%

        \[\leadsto x + \frac{\frac{y + \color{blue}{\left(x \cdot \frac{y}{y}\right)} \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
      8. *-inverses15.9%

        \[\leadsto x + \frac{\frac{y + \left(x \cdot \color{blue}{1}\right) \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
      9. *-rgt-identity15.9%

        \[\leadsto x + \frac{\frac{y + \color{blue}{x} \cdot \frac{x}{y}}{1 + \frac{x}{y}}}{2} \]
    9. Simplified15.9%

      \[\leadsto x + \frac{\color{blue}{\frac{y + x \cdot \frac{x}{y}}{1 + \frac{x}{y}}}}{2} \]
    10. Taylor expanded in y around 0 83.9%

      \[\leadsto x + \frac{\color{blue}{x + -1 \cdot y}}{2} \]
    11. Step-by-step derivation
      1. neg-mul-183.9%

        \[\leadsto x + \frac{x + \color{blue}{\left(-y\right)}}{2} \]
      2. unsub-neg83.9%

        \[\leadsto x + \frac{\color{blue}{x - y}}{2} \]
    12. Simplified83.9%

      \[\leadsto x + \frac{\color{blue}{x - y}}{2} \]

    if -3.69999999999999978e-227 < y

    1. Initial program 100.0%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around -inf 100.0%

      \[\leadsto x + \frac{\color{blue}{\left|-\left(x + -1 \cdot y\right)\right|}}{2} \]
    4. Step-by-step derivation
      1. fabs-neg100.0%

        \[\leadsto x + \frac{\color{blue}{\left|x + -1 \cdot y\right|}}{2} \]
      2. mul-1-neg100.0%

        \[\leadsto x + \frac{\left|x + \color{blue}{\left(-y\right)}\right|}{2} \]
      3. sub-neg100.0%

        \[\leadsto x + \frac{\left|\color{blue}{x - y}\right|}{2} \]
      4. fabs-sub100.0%

        \[\leadsto x + \frac{\color{blue}{\left|y - x\right|}}{2} \]
      5. rem-square-sqrt71.2%

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}\right|}{2} \]
      6. fabs-sqr71.2%

        \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
      7. rem-square-sqrt76.7%

        \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    5. Simplified76.7%

      \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    6. Taylor expanded in x around 0 76.7%

      \[\leadsto \color{blue}{0.5 \cdot x + 0.5 \cdot y} \]
    7. Step-by-step derivation
      1. +-commutative76.7%

        \[\leadsto \color{blue}{0.5 \cdot y + 0.5 \cdot x} \]
      2. distribute-lft-in76.7%

        \[\leadsto \color{blue}{0.5 \cdot \left(y + x\right)} \]
    8. Simplified76.7%

      \[\leadsto \color{blue}{0.5 \cdot \left(y + x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.0%

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

Alternative 7: 68.0% accurate, 10.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 7.2 \cdot 10^{-81}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1.5\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x 7.2e-81) (* 0.5 (+ x y)) (* x 1.5)))
double code(double x, double y) {
	double tmp;
	if (x <= 7.2e-81) {
		tmp = 0.5 * (x + y);
	} else {
		tmp = x * 1.5;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= 7.2d-81) then
        tmp = 0.5d0 * (x + y)
    else
        tmp = x * 1.5d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= 7.2e-81) {
		tmp = 0.5 * (x + y);
	} else {
		tmp = x * 1.5;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= 7.2e-81:
		tmp = 0.5 * (x + y)
	else:
		tmp = x * 1.5
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= 7.2e-81)
		tmp = Float64(0.5 * Float64(x + y));
	else
		tmp = Float64(x * 1.5);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= 7.2e-81)
		tmp = 0.5 * (x + y);
	else
		tmp = x * 1.5;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, 7.2e-81], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.2 \cdot 10^{-81}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\


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

    1. Initial program 100.0%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around -inf 100.0%

      \[\leadsto x + \frac{\color{blue}{\left|-\left(x + -1 \cdot y\right)\right|}}{2} \]
    4. Step-by-step derivation
      1. fabs-neg100.0%

        \[\leadsto x + \frac{\color{blue}{\left|x + -1 \cdot y\right|}}{2} \]
      2. mul-1-neg100.0%

        \[\leadsto x + \frac{\left|x + \color{blue}{\left(-y\right)}\right|}{2} \]
      3. sub-neg100.0%

        \[\leadsto x + \frac{\left|\color{blue}{x - y}\right|}{2} \]
      4. fabs-sub100.0%

        \[\leadsto x + \frac{\color{blue}{\left|y - x\right|}}{2} \]
      5. rem-square-sqrt63.4%

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}\right|}{2} \]
      6. fabs-sqr63.4%

        \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
      7. rem-square-sqrt65.4%

        \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    5. Simplified65.4%

      \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    6. Taylor expanded in x around 0 65.4%

      \[\leadsto \color{blue}{0.5 \cdot x + 0.5 \cdot y} \]
    7. Step-by-step derivation
      1. +-commutative65.4%

        \[\leadsto \color{blue}{0.5 \cdot y + 0.5 \cdot x} \]
      2. distribute-lft-in65.4%

        \[\leadsto \color{blue}{0.5 \cdot \left(y + x\right)} \]
    8. Simplified65.4%

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

    if 7.1999999999999997e-81 < x

    1. Initial program 99.9%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 71.1%

      \[\leadsto x + \frac{\left|\color{blue}{-1 \cdot x}\right|}{2} \]
    4. Step-by-step derivation
      1. neg-mul-171.1%

        \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    5. Simplified71.1%

      \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    6. Taylor expanded in x around 0 71.1%

      \[\leadsto \color{blue}{x + 0.5 \cdot \left|-x\right|} \]
    7. Step-by-step derivation
      1. +-commutative71.1%

        \[\leadsto \color{blue}{0.5 \cdot \left|-x\right| + x} \]
      2. fma-define71.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, \left|-x\right|, x\right)} \]
      3. fabs-neg71.1%

        \[\leadsto \mathsf{fma}\left(0.5, \color{blue}{\left|x\right|}, x\right) \]
      4. rem-square-sqrt71.0%

        \[\leadsto \mathsf{fma}\left(0.5, \left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|, x\right) \]
      5. fabs-sqr71.0%

        \[\leadsto \mathsf{fma}\left(0.5, \color{blue}{\sqrt{x} \cdot \sqrt{x}}, x\right) \]
      6. rem-square-sqrt71.1%

        \[\leadsto \mathsf{fma}\left(0.5, \color{blue}{x}, x\right) \]
      7. fma-define71.1%

        \[\leadsto \color{blue}{0.5 \cdot x + x} \]
      8. *-lft-identity71.1%

        \[\leadsto 0.5 \cdot x + \color{blue}{1 \cdot x} \]
      9. distribute-rgt-out71.1%

        \[\leadsto \color{blue}{x \cdot \left(0.5 + 1\right)} \]
      10. metadata-eval71.1%

        \[\leadsto x \cdot \color{blue}{1.5} \]
    8. Simplified71.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 7.2 \cdot 10^{-81}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 45.7% accurate, 13.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.5 \cdot 10^{-98}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\


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

    1. Initial program 99.9%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around -inf 99.9%

      \[\leadsto x + \frac{\color{blue}{\left|-\left(x + -1 \cdot y\right)\right|}}{2} \]
    4. Step-by-step derivation
      1. fabs-neg99.9%

        \[\leadsto x + \frac{\color{blue}{\left|x + -1 \cdot y\right|}}{2} \]
      2. mul-1-neg99.9%

        \[\leadsto x + \frac{\left|x + \color{blue}{\left(-y\right)}\right|}{2} \]
      3. sub-neg99.9%

        \[\leadsto x + \frac{\left|\color{blue}{x - y}\right|}{2} \]
      4. fabs-sub99.9%

        \[\leadsto x + \frac{\color{blue}{\left|y - x\right|}}{2} \]
      5. rem-square-sqrt33.8%

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}\right|}{2} \]
      6. fabs-sqr33.8%

        \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
      7. rem-square-sqrt40.0%

        \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    5. Simplified40.0%

      \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    6. Taylor expanded in x around inf 36.4%

      \[\leadsto \color{blue}{0.5 \cdot x} \]

    if 8.4999999999999997e-98 < y

    1. Initial program 100.0%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around -inf 100.0%

      \[\leadsto x + \frac{\color{blue}{\left|-\left(x + -1 \cdot y\right)\right|}}{2} \]
    4. Step-by-step derivation
      1. fabs-neg100.0%

        \[\leadsto x + \frac{\color{blue}{\left|x + -1 \cdot y\right|}}{2} \]
      2. mul-1-neg100.0%

        \[\leadsto x + \frac{\left|x + \color{blue}{\left(-y\right)}\right|}{2} \]
      3. sub-neg100.0%

        \[\leadsto x + \frac{\left|\color{blue}{x - y}\right|}{2} \]
      4. fabs-sub100.0%

        \[\leadsto x + \frac{\color{blue}{\left|y - x\right|}}{2} \]
      5. rem-square-sqrt78.6%

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}\right|}{2} \]
      6. fabs-sqr78.6%

        \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
      7. rem-square-sqrt82.9%

        \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    5. Simplified82.9%

      \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
    6. Taylor expanded in x around 0 68.7%

      \[\leadsto \color{blue}{0.5 \cdot y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification46.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 8.5 \cdot 10^{-98}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 30.7% accurate, 35.7× speedup?

\[\begin{array}{l} \\ x \cdot 0.5 \end{array} \]
(FPCore (x y) :precision binary64 (* x 0.5))
double code(double x, double y) {
	return x * 0.5;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = x * 0.5d0
end function
public static double code(double x, double y) {
	return x * 0.5;
}
def code(x, y):
	return x * 0.5
function code(x, y)
	return Float64(x * 0.5)
end
function tmp = code(x, y)
	tmp = x * 0.5;
end
code[x_, y_] := N[(x * 0.5), $MachinePrecision]
\begin{array}{l}

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

    \[x + \frac{\left|y - x\right|}{2} \]
  2. Add Preprocessing
  3. Taylor expanded in y around -inf 100.0%

    \[\leadsto x + \frac{\color{blue}{\left|-\left(x + -1 \cdot y\right)\right|}}{2} \]
  4. Step-by-step derivation
    1. fabs-neg100.0%

      \[\leadsto x + \frac{\color{blue}{\left|x + -1 \cdot y\right|}}{2} \]
    2. mul-1-neg100.0%

      \[\leadsto x + \frac{\left|x + \color{blue}{\left(-y\right)}\right|}{2} \]
    3. sub-neg100.0%

      \[\leadsto x + \frac{\left|\color{blue}{x - y}\right|}{2} \]
    4. fabs-sub100.0%

      \[\leadsto x + \frac{\color{blue}{\left|y - x\right|}}{2} \]
    5. rem-square-sqrt47.3%

      \[\leadsto x + \frac{\left|\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}\right|}{2} \]
    6. fabs-sqr47.3%

      \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
    7. rem-square-sqrt52.9%

      \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
  5. Simplified52.9%

    \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
  6. Taylor expanded in x around inf 30.4%

    \[\leadsto \color{blue}{0.5 \cdot x} \]
  7. Final simplification30.4%

    \[\leadsto x \cdot 0.5 \]
  8. Add Preprocessing

Alternative 10: 11.4% accurate, 107.0× speedup?

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

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

    \[x + \frac{\left|y - x\right|}{2} \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf 11.9%

    \[\leadsto \color{blue}{x} \]
  4. Add Preprocessing

Reproduce

?
herbie shell --seed 2024145 
(FPCore (x y)
  :name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
  :precision binary64
  (+ x (/ (fabs (- y x)) 2.0)))