Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, A

Percentage Accurate: 100.0% → 100.0%
Time: 7.7s
Alternatives: 11
Speedup: 0.1×

Specification

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

\\
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

\\
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
\end{array}

Alternative 1: 100.0% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(x, y + -1, y \cdot -0.5\right) + 0.918938533204673 \end{array} \]
(FPCore (x y)
 :precision binary64
 (+ (fma x (+ y -1.0) (* y -0.5)) 0.918938533204673))
double code(double x, double y) {
	return fma(x, (y + -1.0), (y * -0.5)) + 0.918938533204673;
}
function code(x, y)
	return Float64(fma(x, Float64(y + -1.0), Float64(y * -0.5)) + 0.918938533204673)
end
code[x_, y_] := N[(N[(x * N[(y + -1.0), $MachinePrecision] + N[(y * -0.5), $MachinePrecision]), $MachinePrecision] + 0.918938533204673), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(x, y + -1, y \cdot -0.5\right) + 0.918938533204673
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
  2. Step-by-step derivation
    1. fmm-def100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y - 1, -y \cdot 0.5\right)} + 0.918938533204673 \]
    2. sub-neg100.0%

      \[\leadsto \mathsf{fma}\left(x, \color{blue}{y + \left(-1\right)}, -y \cdot 0.5\right) + 0.918938533204673 \]
    3. metadata-eval100.0%

      \[\leadsto \mathsf{fma}\left(x, y + \color{blue}{-1}, -y \cdot 0.5\right) + 0.918938533204673 \]
    4. distribute-rgt-neg-in100.0%

      \[\leadsto \mathsf{fma}\left(x, y + -1, \color{blue}{y \cdot \left(-0.5\right)}\right) + 0.918938533204673 \]
    5. metadata-eval100.0%

      \[\leadsto \mathsf{fma}\left(x, y + -1, y \cdot \color{blue}{-0.5}\right) + 0.918938533204673 \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, y + -1, y \cdot -0.5\right) + 0.918938533204673} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 2: 48.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -6.6 \cdot 10^{-9}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{-218}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-111}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 1.85:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{+268}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -6.6e-9)
   (* y -0.5)
   (if (<= y -2.5e-218)
     0.918938533204673
     (if (<= y 3.2e-111)
       (- x)
       (if (<= y 1.85)
         0.918938533204673
         (if (<= y 1.75e+268) (* y -0.5) (* x y)))))))
double code(double x, double y) {
	double tmp;
	if (y <= -6.6e-9) {
		tmp = y * -0.5;
	} else if (y <= -2.5e-218) {
		tmp = 0.918938533204673;
	} else if (y <= 3.2e-111) {
		tmp = -x;
	} else if (y <= 1.85) {
		tmp = 0.918938533204673;
	} else if (y <= 1.75e+268) {
		tmp = y * -0.5;
	} else {
		tmp = 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 <= (-6.6d-9)) then
        tmp = y * (-0.5d0)
    else if (y <= (-2.5d-218)) then
        tmp = 0.918938533204673d0
    else if (y <= 3.2d-111) then
        tmp = -x
    else if (y <= 1.85d0) then
        tmp = 0.918938533204673d0
    else if (y <= 1.75d+268) then
        tmp = y * (-0.5d0)
    else
        tmp = x * y
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -6.6e-9) {
		tmp = y * -0.5;
	} else if (y <= -2.5e-218) {
		tmp = 0.918938533204673;
	} else if (y <= 3.2e-111) {
		tmp = -x;
	} else if (y <= 1.85) {
		tmp = 0.918938533204673;
	} else if (y <= 1.75e+268) {
		tmp = y * -0.5;
	} else {
		tmp = x * y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -6.6e-9:
		tmp = y * -0.5
	elif y <= -2.5e-218:
		tmp = 0.918938533204673
	elif y <= 3.2e-111:
		tmp = -x
	elif y <= 1.85:
		tmp = 0.918938533204673
	elif y <= 1.75e+268:
		tmp = y * -0.5
	else:
		tmp = x * y
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -6.6e-9)
		tmp = Float64(y * -0.5);
	elseif (y <= -2.5e-218)
		tmp = 0.918938533204673;
	elseif (y <= 3.2e-111)
		tmp = Float64(-x);
	elseif (y <= 1.85)
		tmp = 0.918938533204673;
	elseif (y <= 1.75e+268)
		tmp = Float64(y * -0.5);
	else
		tmp = Float64(x * y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -6.6e-9)
		tmp = y * -0.5;
	elseif (y <= -2.5e-218)
		tmp = 0.918938533204673;
	elseif (y <= 3.2e-111)
		tmp = -x;
	elseif (y <= 1.85)
		tmp = 0.918938533204673;
	elseif (y <= 1.75e+268)
		tmp = y * -0.5;
	else
		tmp = x * y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -6.6e-9], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -2.5e-218], 0.918938533204673, If[LessEqual[y, 3.2e-111], (-x), If[LessEqual[y, 1.85], 0.918938533204673, If[LessEqual[y, 1.75e+268], N[(y * -0.5), $MachinePrecision], N[(x * y), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.6 \cdot 10^{-9}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq -2.5 \cdot 10^{-218}:\\
\;\;\;\;0.918938533204673\\

\mathbf{elif}\;y \leq 3.2 \cdot 10^{-111}:\\
\;\;\;\;-x\\

\mathbf{elif}\;y \leq 1.85:\\
\;\;\;\;0.918938533204673\\

\mathbf{elif}\;y \leq 1.75 \cdot 10^{+268}:\\
\;\;\;\;y \cdot -0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -6.60000000000000037e-9 or 1.8500000000000001 < y < 1.74999999999999986e268

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{0.918938533204673 + \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right)} \]
      2. cancel-sign-sub-inv100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
      3. +-commutative100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
      4. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 + \left(-y\right) \cdot 0.5\right) + x \cdot \left(y - 1\right)} \]
      5. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
      6. associate-+l-100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      8. distribute-rgt-in100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
      10. neg-mul-1100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
      11. associate--r+100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
      12. distribute-lft-out--100.0%

        \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
      13. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
      14. fmm-def100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
      15. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
      16. remove-double-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 100.0%

      \[\leadsto \color{blue}{\left(0.918938533204673 + y \cdot \left(x - 0.5\right)\right) - x} \]
    6. Taylor expanded in y around inf 96.2%

      \[\leadsto \color{blue}{y \cdot \left(x - 0.5\right)} \]
    7. Taylor expanded in x around 0 59.6%

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

    if -6.60000000000000037e-9 < y < -2.50000000000000021e-218 or 3.1999999999999998e-111 < y < 1.8500000000000001

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{0.918938533204673 + \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right)} \]
      2. cancel-sign-sub-inv100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
      3. +-commutative100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
      4. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 + \left(-y\right) \cdot 0.5\right) + x \cdot \left(y - 1\right)} \]
      5. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
      6. associate-+l-100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      8. distribute-rgt-in100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
      10. neg-mul-1100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
      11. associate--r+100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
      12. distribute-lft-out--100.0%

        \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
      13. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
      14. fmm-def100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
      15. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
      16. remove-double-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 67.3%

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

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

    if -2.50000000000000021e-218 < y < 3.1999999999999998e-111

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. fmm-def100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, y - 1, -y \cdot 0.5\right)} + 0.918938533204673 \]
      2. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{y + \left(-1\right)}, -y \cdot 0.5\right) + 0.918938533204673 \]
      3. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, y + \color{blue}{-1}, -y \cdot 0.5\right) + 0.918938533204673 \]
      4. distribute-rgt-neg-in100.0%

        \[\leadsto \mathsf{fma}\left(x, y + -1, \color{blue}{y \cdot \left(-0.5\right)}\right) + 0.918938533204673 \]
      5. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, y + -1, y \cdot \color{blue}{-0.5}\right) + 0.918938533204673 \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y + -1, y \cdot -0.5\right) + 0.918938533204673} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 100.0%

      \[\leadsto \color{blue}{0.918938533204673 + -1 \cdot x} \]
    6. Step-by-step derivation
      1. neg-mul-1100.0%

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

        \[\leadsto \color{blue}{0.918938533204673 - x} \]
    7. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - x} \]
    8. Taylor expanded in x around inf 65.2%

      \[\leadsto \color{blue}{-1 \cdot x} \]
    9. Step-by-step derivation
      1. neg-mul-165.2%

        \[\leadsto \color{blue}{-x} \]
    10. Simplified65.2%

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

    if 1.74999999999999986e268 < y

    1. Initial program 99.9%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. +-commutative99.9%

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

        \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
      3. +-commutative99.9%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
      4. associate-+r+99.9%

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

        \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
      6. associate-+l-99.9%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      8. distribute-rgt-in99.9%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
      10. neg-mul-199.9%

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
      11. associate--r+99.9%

        \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
      12. distribute-lft-out--100.0%

        \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
      13. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
      14. fmm-def100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
      15. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
      16. remove-double-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 100.0%

      \[\leadsto \color{blue}{\left(0.918938533204673 + y \cdot \left(x - 0.5\right)\right) - x} \]
    6. Taylor expanded in y around inf 100.0%

      \[\leadsto \color{blue}{y \cdot \left(x - 0.5\right)} \]
    7. Taylor expanded in x around inf 63.3%

      \[\leadsto \color{blue}{x \cdot y} \]
    8. Step-by-step derivation
      1. *-commutative63.3%

        \[\leadsto \color{blue}{y \cdot x} \]
    9. Simplified63.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.6 \cdot 10^{-9}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{-218}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-111}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 1.85:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{+268}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 49.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -6.6 \cdot 10^{-9}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -2.05 \cdot 10^{-218}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-111}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 1.85:\\ \;\;\;\;0.918938533204673\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -6.6e-9)
   (* y -0.5)
   (if (<= y -2.05e-218)
     0.918938533204673
     (if (<= y 1.05e-111)
       (- x)
       (if (<= y 1.85) 0.918938533204673 (* y -0.5))))))
double code(double x, double y) {
	double tmp;
	if (y <= -6.6e-9) {
		tmp = y * -0.5;
	} else if (y <= -2.05e-218) {
		tmp = 0.918938533204673;
	} else if (y <= 1.05e-111) {
		tmp = -x;
	} else if (y <= 1.85) {
		tmp = 0.918938533204673;
	} 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 <= (-6.6d-9)) then
        tmp = y * (-0.5d0)
    else if (y <= (-2.05d-218)) then
        tmp = 0.918938533204673d0
    else if (y <= 1.05d-111) then
        tmp = -x
    else if (y <= 1.85d0) then
        tmp = 0.918938533204673d0
    else
        tmp = y * (-0.5d0)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -6.6e-9) {
		tmp = y * -0.5;
	} else if (y <= -2.05e-218) {
		tmp = 0.918938533204673;
	} else if (y <= 1.05e-111) {
		tmp = -x;
	} else if (y <= 1.85) {
		tmp = 0.918938533204673;
	} else {
		tmp = y * -0.5;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -6.6e-9:
		tmp = y * -0.5
	elif y <= -2.05e-218:
		tmp = 0.918938533204673
	elif y <= 1.05e-111:
		tmp = -x
	elif y <= 1.85:
		tmp = 0.918938533204673
	else:
		tmp = y * -0.5
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -6.6e-9)
		tmp = Float64(y * -0.5);
	elseif (y <= -2.05e-218)
		tmp = 0.918938533204673;
	elseif (y <= 1.05e-111)
		tmp = Float64(-x);
	elseif (y <= 1.85)
		tmp = 0.918938533204673;
	else
		tmp = Float64(y * -0.5);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -6.6e-9)
		tmp = y * -0.5;
	elseif (y <= -2.05e-218)
		tmp = 0.918938533204673;
	elseif (y <= 1.05e-111)
		tmp = -x;
	elseif (y <= 1.85)
		tmp = 0.918938533204673;
	else
		tmp = y * -0.5;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -6.6e-9], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -2.05e-218], 0.918938533204673, If[LessEqual[y, 1.05e-111], (-x), If[LessEqual[y, 1.85], 0.918938533204673, N[(y * -0.5), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.6 \cdot 10^{-9}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq -2.05 \cdot 10^{-218}:\\
\;\;\;\;0.918938533204673\\

\mathbf{elif}\;y \leq 1.05 \cdot 10^{-111}:\\
\;\;\;\;-x\\

\mathbf{elif}\;y \leq 1.85:\\
\;\;\;\;0.918938533204673\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -6.60000000000000037e-9 or 1.8500000000000001 < y

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{0.918938533204673 + \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right)} \]
      2. cancel-sign-sub-inv100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
      3. +-commutative100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
      4. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 + \left(-y\right) \cdot 0.5\right) + x \cdot \left(y - 1\right)} \]
      5. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
      6. associate-+l-100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      8. distribute-rgt-in100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
      10. neg-mul-1100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
      11. associate--r+100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
      12. distribute-lft-out--100.0%

        \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
      13. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
      14. fmm-def100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
      15. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
      16. remove-double-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 100.0%

      \[\leadsto \color{blue}{\left(0.918938533204673 + y \cdot \left(x - 0.5\right)\right) - x} \]
    6. Taylor expanded in y around inf 96.5%

      \[\leadsto \color{blue}{y \cdot \left(x - 0.5\right)} \]
    7. Taylor expanded in x around 0 55.9%

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

    if -6.60000000000000037e-9 < y < -2.0499999999999999e-218 or 1.0499999999999999e-111 < y < 1.8500000000000001

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{0.918938533204673 + \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right)} \]
      2. cancel-sign-sub-inv100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
      3. +-commutative100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
      4. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 + \left(-y\right) \cdot 0.5\right) + x \cdot \left(y - 1\right)} \]
      5. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
      6. associate-+l-100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      8. distribute-rgt-in100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
      10. neg-mul-1100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
      11. associate--r+100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
      12. distribute-lft-out--100.0%

        \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
      13. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
      14. fmm-def100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
      15. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
      16. remove-double-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 67.3%

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

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

    if -2.0499999999999999e-218 < y < 1.0499999999999999e-111

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. fmm-def100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, y - 1, -y \cdot 0.5\right)} + 0.918938533204673 \]
      2. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{y + \left(-1\right)}, -y \cdot 0.5\right) + 0.918938533204673 \]
      3. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, y + \color{blue}{-1}, -y \cdot 0.5\right) + 0.918938533204673 \]
      4. distribute-rgt-neg-in100.0%

        \[\leadsto \mathsf{fma}\left(x, y + -1, \color{blue}{y \cdot \left(-0.5\right)}\right) + 0.918938533204673 \]
      5. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, y + -1, y \cdot \color{blue}{-0.5}\right) + 0.918938533204673 \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y + -1, y \cdot -0.5\right) + 0.918938533204673} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 100.0%

      \[\leadsto \color{blue}{0.918938533204673 + -1 \cdot x} \]
    6. Step-by-step derivation
      1. neg-mul-1100.0%

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

        \[\leadsto \color{blue}{0.918938533204673 - x} \]
    7. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - x} \]
    8. Taylor expanded in x around inf 65.2%

      \[\leadsto \color{blue}{-1 \cdot x} \]
    9. Step-by-step derivation
      1. neg-mul-165.2%

        \[\leadsto \color{blue}{-x} \]
    10. Simplified65.2%

      \[\leadsto \color{blue}{-x} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 73.1% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -255:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 1.85:\\
\;\;\;\;0.918938533204673 - x\\

\mathbf{elif}\;y \leq 1.2 \cdot 10^{+268}:\\
\;\;\;\;y \cdot -0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -255 or 1.8500000000000001 < y < 1.2e268

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{0.918938533204673 + \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right)} \]
      2. cancel-sign-sub-inv100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
      3. +-commutative100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
      4. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 + \left(-y\right) \cdot 0.5\right) + x \cdot \left(y - 1\right)} \]
      5. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
      6. associate-+l-100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      8. distribute-rgt-in100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
      10. neg-mul-1100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
      11. associate--r+100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
      12. distribute-lft-out--100.0%

        \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
      13. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
      14. fmm-def100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
      15. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
      16. remove-double-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 100.0%

      \[\leadsto \color{blue}{\left(0.918938533204673 + y \cdot \left(x - 0.5\right)\right) - x} \]
    6. Taylor expanded in y around inf 97.6%

      \[\leadsto \color{blue}{y \cdot \left(x - 0.5\right)} \]
    7. Taylor expanded in x around 0 60.6%

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

    if -255 < y < 1.8500000000000001

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. fmm-def100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, y - 1, -y \cdot 0.5\right)} + 0.918938533204673 \]
      2. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{y + \left(-1\right)}, -y \cdot 0.5\right) + 0.918938533204673 \]
      3. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, y + \color{blue}{-1}, -y \cdot 0.5\right) + 0.918938533204673 \]
      4. distribute-rgt-neg-in100.0%

        \[\leadsto \mathsf{fma}\left(x, y + -1, \color{blue}{y \cdot \left(-0.5\right)}\right) + 0.918938533204673 \]
      5. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, y + -1, y \cdot \color{blue}{-0.5}\right) + 0.918938533204673 \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y + -1, y \cdot -0.5\right) + 0.918938533204673} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 98.1%

      \[\leadsto \color{blue}{0.918938533204673 + -1 \cdot x} \]
    6. Step-by-step derivation
      1. neg-mul-198.1%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(-x\right)} \]
      2. sub-neg98.1%

        \[\leadsto \color{blue}{0.918938533204673 - x} \]
    7. Simplified98.1%

      \[\leadsto \color{blue}{0.918938533204673 - x} \]

    if 1.2e268 < y

    1. Initial program 99.9%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. +-commutative99.9%

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

        \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
      3. +-commutative99.9%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
      4. associate-+r+99.9%

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

        \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
      6. associate-+l-99.9%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      8. distribute-rgt-in99.9%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
      10. neg-mul-199.9%

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
      11. associate--r+99.9%

        \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
      12. distribute-lft-out--100.0%

        \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
      13. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
      14. fmm-def100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
      15. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
      16. remove-double-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 100.0%

      \[\leadsto \color{blue}{\left(0.918938533204673 + y \cdot \left(x - 0.5\right)\right) - x} \]
    6. Taylor expanded in y around inf 100.0%

      \[\leadsto \color{blue}{y \cdot \left(x - 0.5\right)} \]
    7. Taylor expanded in x around inf 63.3%

      \[\leadsto \color{blue}{x \cdot y} \]
    8. Step-by-step derivation
      1. *-commutative63.3%

        \[\leadsto \color{blue}{y \cdot x} \]
    9. Simplified63.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -255:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.85:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+268}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 98.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -0.35 \lor \neg \left(y \leq 44\right):\\ \;\;\;\;0.918938533204673 + y \cdot \left(x - 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;0.918938533204673 + x \cdot \left(y + -1\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -0.35) (not (<= y 44.0)))
   (+ 0.918938533204673 (* y (- x 0.5)))
   (+ 0.918938533204673 (* x (+ y -1.0)))))
double code(double x, double y) {
	double tmp;
	if ((y <= -0.35) || !(y <= 44.0)) {
		tmp = 0.918938533204673 + (y * (x - 0.5));
	} else {
		tmp = 0.918938533204673 + (x * (y + -1.0));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((y <= (-0.35d0)) .or. (.not. (y <= 44.0d0))) then
        tmp = 0.918938533204673d0 + (y * (x - 0.5d0))
    else
        tmp = 0.918938533204673d0 + (x * (y + (-1.0d0)))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((y <= -0.35) || !(y <= 44.0)) {
		tmp = 0.918938533204673 + (y * (x - 0.5));
	} else {
		tmp = 0.918938533204673 + (x * (y + -1.0));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -0.35) or not (y <= 44.0):
		tmp = 0.918938533204673 + (y * (x - 0.5))
	else:
		tmp = 0.918938533204673 + (x * (y + -1.0))
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -0.35) || !(y <= 44.0))
		tmp = Float64(0.918938533204673 + Float64(y * Float64(x - 0.5)));
	else
		tmp = Float64(0.918938533204673 + Float64(x * Float64(y + -1.0)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y <= -0.35) || ~((y <= 44.0)))
		tmp = 0.918938533204673 + (y * (x - 0.5));
	else
		tmp = 0.918938533204673 + (x * (y + -1.0));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -0.35], N[Not[LessEqual[y, 44.0]], $MachinePrecision]], N[(0.918938533204673 + N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.918938533204673 + N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.35 \lor \neg \left(y \leq 44\right):\\
\;\;\;\;0.918938533204673 + y \cdot \left(x - 0.5\right)\\

\mathbf{else}:\\
\;\;\;\;0.918938533204673 + x \cdot \left(y + -1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -0.34999999999999998 or 44 < y

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{0.918938533204673 + \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right)} \]
      2. cancel-sign-sub-inv100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
      3. +-commutative100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
      4. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 + \left(-y\right) \cdot 0.5\right) + x \cdot \left(y - 1\right)} \]
      5. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
      6. associate-+l-100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      8. distribute-rgt-in100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
      10. neg-mul-1100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
      11. associate--r+100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
      12. distribute-lft-out--100.0%

        \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
      13. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
      14. fmm-def100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
      15. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
      16. remove-double-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 100.0%

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

    if -0.34999999999999998 < y < 44

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{0.918938533204673 + \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right)} \]
      2. cancel-sign-sub-inv100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
      3. +-commutative100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
      4. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 + \left(-y\right) \cdot 0.5\right) + x \cdot \left(y - 1\right)} \]
      5. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
      6. associate-+l-100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      8. distribute-rgt-in100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
      10. neg-mul-1100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
      11. associate--r+100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
      12. distribute-lft-out--100.0%

        \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
      13. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
      14. fmm-def100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
      15. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
      16. remove-double-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 98.9%

      \[\leadsto 0.918938533204673 - \color{blue}{x \cdot \left(1 + -1 \cdot y\right)} \]
    6. Step-by-step derivation
      1. neg-mul-198.9%

        \[\leadsto 0.918938533204673 - x \cdot \left(1 + \color{blue}{\left(-y\right)}\right) \]
      2. sub-neg98.9%

        \[\leadsto 0.918938533204673 - x \cdot \color{blue}{\left(1 - y\right)} \]
    7. Simplified98.9%

      \[\leadsto 0.918938533204673 - \color{blue}{x \cdot \left(1 - y\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -0.35 \lor \neg \left(y \leq 44\right):\\ \;\;\;\;0.918938533204673 + y \cdot \left(x - 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;0.918938533204673 + x \cdot \left(y + -1\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 98.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -59000 \lor \neg \left(y \leq 32000\right):\\ \;\;\;\;y \cdot \left(x - 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;0.918938533204673 + x \cdot \left(y + -1\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -59000.0) (not (<= y 32000.0)))
   (* y (- x 0.5))
   (+ 0.918938533204673 (* x (+ y -1.0)))))
double code(double x, double y) {
	double tmp;
	if ((y <= -59000.0) || !(y <= 32000.0)) {
		tmp = y * (x - 0.5);
	} else {
		tmp = 0.918938533204673 + (x * (y + -1.0));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((y <= (-59000.0d0)) .or. (.not. (y <= 32000.0d0))) then
        tmp = y * (x - 0.5d0)
    else
        tmp = 0.918938533204673d0 + (x * (y + (-1.0d0)))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((y <= -59000.0) || !(y <= 32000.0)) {
		tmp = y * (x - 0.5);
	} else {
		tmp = 0.918938533204673 + (x * (y + -1.0));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -59000.0) or not (y <= 32000.0):
		tmp = y * (x - 0.5)
	else:
		tmp = 0.918938533204673 + (x * (y + -1.0))
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -59000.0) || !(y <= 32000.0))
		tmp = Float64(y * Float64(x - 0.5));
	else
		tmp = Float64(0.918938533204673 + Float64(x * Float64(y + -1.0)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y <= -59000.0) || ~((y <= 32000.0)))
		tmp = y * (x - 0.5);
	else
		tmp = 0.918938533204673 + (x * (y + -1.0));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -59000.0], N[Not[LessEqual[y, 32000.0]], $MachinePrecision]], N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision], N[(0.918938533204673 + N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -59000 \lor \neg \left(y \leq 32000\right):\\
\;\;\;\;y \cdot \left(x - 0.5\right)\\

\mathbf{else}:\\
\;\;\;\;0.918938533204673 + x \cdot \left(y + -1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -59000 or 32000 < y

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{0.918938533204673 + \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right)} \]
      2. cancel-sign-sub-inv100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
      3. +-commutative100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
      4. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 + \left(-y\right) \cdot 0.5\right) + x \cdot \left(y - 1\right)} \]
      5. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
      6. associate-+l-100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      8. distribute-rgt-in100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
      10. neg-mul-1100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
      11. associate--r+100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
      12. distribute-lft-out--100.0%

        \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
      13. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
      14. fmm-def100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
      15. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
      16. remove-double-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 100.0%

      \[\leadsto \color{blue}{\left(0.918938533204673 + y \cdot \left(x - 0.5\right)\right) - x} \]
    6. Taylor expanded in y around inf 98.3%

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

    if -59000 < y < 32000

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{0.918938533204673 + \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right)} \]
      2. cancel-sign-sub-inv100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
      3. +-commutative100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
      4. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 + \left(-y\right) \cdot 0.5\right) + x \cdot \left(y - 1\right)} \]
      5. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
      6. associate-+l-100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      8. distribute-rgt-in100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
      10. neg-mul-1100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
      11. associate--r+100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
      12. distribute-lft-out--100.0%

        \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
      13. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
      14. fmm-def100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
      15. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
      16. remove-double-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 98.9%

      \[\leadsto 0.918938533204673 - \color{blue}{x \cdot \left(1 + -1 \cdot y\right)} \]
    6. Step-by-step derivation
      1. neg-mul-198.9%

        \[\leadsto 0.918938533204673 - x \cdot \left(1 + \color{blue}{\left(-y\right)}\right) \]
      2. sub-neg98.9%

        \[\leadsto 0.918938533204673 - x \cdot \color{blue}{\left(1 - y\right)} \]
    7. Simplified98.9%

      \[\leadsto 0.918938533204673 - \color{blue}{x \cdot \left(1 - y\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -59000 \lor \neg \left(y \leq 32000\right):\\ \;\;\;\;y \cdot \left(x - 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;0.918938533204673 + x \cdot \left(y + -1\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 98.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -0.0017:\\ \;\;\;\;x \cdot y + \left(0.918938533204673 - y \cdot 0.5\right)\\ \mathbf{elif}\;y \leq 56:\\ \;\;\;\;0.918938533204673 + x \cdot \left(y + -1\right)\\ \mathbf{else}:\\ \;\;\;\;0.918938533204673 + y \cdot \left(x - 0.5\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -0.0017)
   (+ (* x y) (- 0.918938533204673 (* y 0.5)))
   (if (<= y 56.0)
     (+ 0.918938533204673 (* x (+ y -1.0)))
     (+ 0.918938533204673 (* y (- x 0.5))))))
double code(double x, double y) {
	double tmp;
	if (y <= -0.0017) {
		tmp = (x * y) + (0.918938533204673 - (y * 0.5));
	} else if (y <= 56.0) {
		tmp = 0.918938533204673 + (x * (y + -1.0));
	} else {
		tmp = 0.918938533204673 + (y * (x - 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 <= (-0.0017d0)) then
        tmp = (x * y) + (0.918938533204673d0 - (y * 0.5d0))
    else if (y <= 56.0d0) then
        tmp = 0.918938533204673d0 + (x * (y + (-1.0d0)))
    else
        tmp = 0.918938533204673d0 + (y * (x - 0.5d0))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -0.0017) {
		tmp = (x * y) + (0.918938533204673 - (y * 0.5));
	} else if (y <= 56.0) {
		tmp = 0.918938533204673 + (x * (y + -1.0));
	} else {
		tmp = 0.918938533204673 + (y * (x - 0.5));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -0.0017:
		tmp = (x * y) + (0.918938533204673 - (y * 0.5))
	elif y <= 56.0:
		tmp = 0.918938533204673 + (x * (y + -1.0))
	else:
		tmp = 0.918938533204673 + (y * (x - 0.5))
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -0.0017)
		tmp = Float64(Float64(x * y) + Float64(0.918938533204673 - Float64(y * 0.5)));
	elseif (y <= 56.0)
		tmp = Float64(0.918938533204673 + Float64(x * Float64(y + -1.0)));
	else
		tmp = Float64(0.918938533204673 + Float64(y * Float64(x - 0.5)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -0.0017)
		tmp = (x * y) + (0.918938533204673 - (y * 0.5));
	elseif (y <= 56.0)
		tmp = 0.918938533204673 + (x * (y + -1.0));
	else
		tmp = 0.918938533204673 + (y * (x - 0.5));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -0.0017], N[(N[(x * y), $MachinePrecision] + N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 56.0], N[(0.918938533204673 + N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.918938533204673 + N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.0017:\\
\;\;\;\;x \cdot y + \left(0.918938533204673 - y \cdot 0.5\right)\\

\mathbf{elif}\;y \leq 56:\\
\;\;\;\;0.918938533204673 + x \cdot \left(y + -1\right)\\

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


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

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. associate-+l-100.0%

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      3. metadata-eval100.0%

        \[\leadsto x \cdot \left(y + \color{blue}{-1}\right) - \left(y \cdot 0.5 - 0.918938533204673\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{x \cdot \left(y + -1\right) - \left(y \cdot 0.5 - 0.918938533204673\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 100.0%

      \[\leadsto \color{blue}{x \cdot y} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
    6. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \color{blue}{y \cdot x} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
    7. Simplified100.0%

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

    if -0.00169999999999999991 < y < 56

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{0.918938533204673 + \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right)} \]
      2. cancel-sign-sub-inv100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
      3. +-commutative100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
      4. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 + \left(-y\right) \cdot 0.5\right) + x \cdot \left(y - 1\right)} \]
      5. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
      6. associate-+l-100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      8. distribute-rgt-in100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
      10. neg-mul-1100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
      11. associate--r+100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
      12. distribute-lft-out--100.0%

        \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
      13. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
      14. fmm-def100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
      15. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
      16. remove-double-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 98.9%

      \[\leadsto 0.918938533204673 - \color{blue}{x \cdot \left(1 + -1 \cdot y\right)} \]
    6. Step-by-step derivation
      1. neg-mul-198.9%

        \[\leadsto 0.918938533204673 - x \cdot \left(1 + \color{blue}{\left(-y\right)}\right) \]
      2. sub-neg98.9%

        \[\leadsto 0.918938533204673 - x \cdot \color{blue}{\left(1 - y\right)} \]
    7. Simplified98.9%

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

    if 56 < y

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{0.918938533204673 + \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right)} \]
      2. cancel-sign-sub-inv100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
      3. +-commutative100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
      4. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 + \left(-y\right) \cdot 0.5\right) + x \cdot \left(y - 1\right)} \]
      5. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
      6. associate-+l-100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      8. distribute-rgt-in100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
      10. neg-mul-1100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
      11. associate--r+100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
      12. distribute-lft-out--100.0%

        \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
      13. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
      14. fmm-def100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
      15. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
      16. remove-double-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 100.0%

      \[\leadsto 0.918938533204673 - \color{blue}{y \cdot \left(0.5 - x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -0.0017:\\ \;\;\;\;x \cdot y + \left(0.918938533204673 - y \cdot 0.5\right)\\ \mathbf{elif}\;y \leq 56:\\ \;\;\;\;0.918938533204673 + x \cdot \left(y + -1\right)\\ \mathbf{else}:\\ \;\;\;\;0.918938533204673 + y \cdot \left(x - 0.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 97.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.35 \lor \neg \left(y \leq 1.6\right):\\ \;\;\;\;y \cdot \left(x - 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;0.918938533204673 - x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -1.35) (not (<= y 1.6)))
   (* y (- x 0.5))
   (- 0.918938533204673 x)))
double code(double x, double y) {
	double tmp;
	if ((y <= -1.35) || !(y <= 1.6)) {
		tmp = y * (x - 0.5);
	} else {
		tmp = 0.918938533204673 - x;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((y <= (-1.35d0)) .or. (.not. (y <= 1.6d0))) then
        tmp = y * (x - 0.5d0)
    else
        tmp = 0.918938533204673d0 - x
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((y <= -1.35) || !(y <= 1.6)) {
		tmp = y * (x - 0.5);
	} else {
		tmp = 0.918938533204673 - x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -1.35) or not (y <= 1.6):
		tmp = y * (x - 0.5)
	else:
		tmp = 0.918938533204673 - x
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -1.35) || !(y <= 1.6))
		tmp = Float64(y * Float64(x - 0.5));
	else
		tmp = Float64(0.918938533204673 - x);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y <= -1.35) || ~((y <= 1.6)))
		tmp = y * (x - 0.5);
	else
		tmp = 0.918938533204673 - x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -1.35], N[Not[LessEqual[y, 1.6]], $MachinePrecision]], N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision], N[(0.918938533204673 - x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \lor \neg \left(y \leq 1.6\right):\\
\;\;\;\;y \cdot \left(x - 0.5\right)\\

\mathbf{else}:\\
\;\;\;\;0.918938533204673 - x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.3500000000000001 or 1.6000000000000001 < y

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{0.918938533204673 + \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right)} \]
      2. cancel-sign-sub-inv100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
      3. +-commutative100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
      4. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 + \left(-y\right) \cdot 0.5\right) + x \cdot \left(y - 1\right)} \]
      5. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
      6. associate-+l-100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      8. distribute-rgt-in100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
      10. neg-mul-1100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
      11. associate--r+100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
      12. distribute-lft-out--100.0%

        \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
      13. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
      14. fmm-def100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
      15. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
      16. remove-double-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 100.0%

      \[\leadsto \color{blue}{\left(0.918938533204673 + y \cdot \left(x - 0.5\right)\right) - x} \]
    6. Taylor expanded in y around inf 97.8%

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

    if -1.3500000000000001 < y < 1.6000000000000001

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. fmm-def100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, y - 1, -y \cdot 0.5\right)} + 0.918938533204673 \]
      2. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{y + \left(-1\right)}, -y \cdot 0.5\right) + 0.918938533204673 \]
      3. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, y + \color{blue}{-1}, -y \cdot 0.5\right) + 0.918938533204673 \]
      4. distribute-rgt-neg-in100.0%

        \[\leadsto \mathsf{fma}\left(x, y + -1, \color{blue}{y \cdot \left(-0.5\right)}\right) + 0.918938533204673 \]
      5. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, y + -1, y \cdot \color{blue}{-0.5}\right) + 0.918938533204673 \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y + -1, y \cdot -0.5\right) + 0.918938533204673} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 98.1%

      \[\leadsto \color{blue}{0.918938533204673 + -1 \cdot x} \]
    6. Step-by-step derivation
      1. neg-mul-198.1%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(-x\right)} \]
      2. sub-neg98.1%

        \[\leadsto \color{blue}{0.918938533204673 - x} \]
    7. Simplified98.1%

      \[\leadsto \color{blue}{0.918938533204673 - x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.35 \lor \neg \left(y \leq 1.6\right):\\ \;\;\;\;y \cdot \left(x - 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;0.918938533204673 - x\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 49.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -9000000 \lor \neg \left(x \leq 2750\right):\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;0.918938533204673\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -9000000.0) (not (<= x 2750.0))) (- x) 0.918938533204673))
double code(double x, double y) {
	double tmp;
	if ((x <= -9000000.0) || !(x <= 2750.0)) {
		tmp = -x;
	} else {
		tmp = 0.918938533204673;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x <= (-9000000.0d0)) .or. (.not. (x <= 2750.0d0))) then
        tmp = -x
    else
        tmp = 0.918938533204673d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x <= -9000000.0) || !(x <= 2750.0)) {
		tmp = -x;
	} else {
		tmp = 0.918938533204673;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -9000000.0) or not (x <= 2750.0):
		tmp = -x
	else:
		tmp = 0.918938533204673
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -9000000.0) || !(x <= 2750.0))
		tmp = Float64(-x);
	else
		tmp = 0.918938533204673;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= -9000000.0) || ~((x <= 2750.0)))
		tmp = -x;
	else
		tmp = 0.918938533204673;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, -9000000.0], N[Not[LessEqual[x, 2750.0]], $MachinePrecision]], (-x), 0.918938533204673]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -9000000 \lor \neg \left(x \leq 2750\right):\\
\;\;\;\;-x\\

\mathbf{else}:\\
\;\;\;\;0.918938533204673\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9e6 or 2750 < x

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. fmm-def100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, y - 1, -y \cdot 0.5\right)} + 0.918938533204673 \]
      2. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{y + \left(-1\right)}, -y \cdot 0.5\right) + 0.918938533204673 \]
      3. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, y + \color{blue}{-1}, -y \cdot 0.5\right) + 0.918938533204673 \]
      4. distribute-rgt-neg-in100.0%

        \[\leadsto \mathsf{fma}\left(x, y + -1, \color{blue}{y \cdot \left(-0.5\right)}\right) + 0.918938533204673 \]
      5. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, y + -1, y \cdot \color{blue}{-0.5}\right) + 0.918938533204673 \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y + -1, y \cdot -0.5\right) + 0.918938533204673} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 55.4%

      \[\leadsto \color{blue}{0.918938533204673 + -1 \cdot x} \]
    6. Step-by-step derivation
      1. neg-mul-155.4%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(-x\right)} \]
      2. sub-neg55.4%

        \[\leadsto \color{blue}{0.918938533204673 - x} \]
    7. Simplified55.4%

      \[\leadsto \color{blue}{0.918938533204673 - x} \]
    8. Taylor expanded in x around inf 54.6%

      \[\leadsto \color{blue}{-1 \cdot x} \]
    9. Step-by-step derivation
      1. neg-mul-154.6%

        \[\leadsto \color{blue}{-x} \]
    10. Simplified54.6%

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

    if -9e6 < x < 2750

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{0.918938533204673 + \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right)} \]
      2. cancel-sign-sub-inv100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
      3. +-commutative100.0%

        \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
      4. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 + \left(-y\right) \cdot 0.5\right) + x \cdot \left(y - 1\right)} \]
      5. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
      6. associate-+l-100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      8. distribute-rgt-in100.0%

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

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
      10. neg-mul-1100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
      11. associate--r+100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
      12. distribute-lft-out--100.0%

        \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
      13. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
      14. fmm-def100.0%

        \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
      15. unsub-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
      16. remove-double-neg100.0%

        \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 98.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9000000 \lor \neg \left(x \leq 2750\right):\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;0.918938533204673\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 100.0% accurate, 1.2× speedup?

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

\\
\left(0.918938533204673 + y \cdot \left(x - 0.5\right)\right) - x
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
  2. Step-by-step derivation
    1. +-commutative100.0%

      \[\leadsto \color{blue}{0.918938533204673 + \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right)} \]
    2. cancel-sign-sub-inv100.0%

      \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
    3. +-commutative100.0%

      \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
    4. associate-+r+100.0%

      \[\leadsto \color{blue}{\left(0.918938533204673 + \left(-y\right) \cdot 0.5\right) + x \cdot \left(y - 1\right)} \]
    5. cancel-sign-sub-inv100.0%

      \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
    6. associate-+l-100.0%

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

      \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
    8. distribute-rgt-in100.0%

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

      \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
    10. neg-mul-1100.0%

      \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
    11. associate--r+100.0%

      \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
    12. distribute-lft-out--100.0%

      \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
    13. unsub-neg100.0%

      \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
    14. fmm-def100.0%

      \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
    15. unsub-neg100.0%

      \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
    16. remove-double-neg100.0%

      \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in y around 0 100.0%

    \[\leadsto \color{blue}{\left(0.918938533204673 + y \cdot \left(x - 0.5\right)\right) - x} \]
  6. Add Preprocessing

Alternative 11: 26.6% accurate, 11.0× speedup?

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

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

    \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
  2. Step-by-step derivation
    1. +-commutative100.0%

      \[\leadsto \color{blue}{0.918938533204673 + \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right)} \]
    2. cancel-sign-sub-inv100.0%

      \[\leadsto 0.918938533204673 + \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y\right) \cdot 0.5\right)} \]
    3. +-commutative100.0%

      \[\leadsto 0.918938533204673 + \color{blue}{\left(\left(-y\right) \cdot 0.5 + x \cdot \left(y - 1\right)\right)} \]
    4. associate-+r+100.0%

      \[\leadsto \color{blue}{\left(0.918938533204673 + \left(-y\right) \cdot 0.5\right) + x \cdot \left(y - 1\right)} \]
    5. cancel-sign-sub-inv100.0%

      \[\leadsto \color{blue}{\left(0.918938533204673 - y \cdot 0.5\right)} + x \cdot \left(y - 1\right) \]
    6. associate-+l-100.0%

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

      \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
    8. distribute-rgt-in100.0%

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

      \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{-1} \cdot x\right)\right) \]
    10. neg-mul-1100.0%

      \[\leadsto 0.918938533204673 - \left(y \cdot 0.5 - \left(y \cdot x + \color{blue}{\left(-x\right)}\right)\right) \]
    11. associate--r+100.0%

      \[\leadsto 0.918938533204673 - \color{blue}{\left(\left(y \cdot 0.5 - y \cdot x\right) - \left(-x\right)\right)} \]
    12. distribute-lft-out--100.0%

      \[\leadsto 0.918938533204673 - \left(\color{blue}{y \cdot \left(0.5 - x\right)} - \left(-x\right)\right) \]
    13. unsub-neg100.0%

      \[\leadsto 0.918938533204673 - \left(y \cdot \color{blue}{\left(0.5 + \left(-x\right)\right)} - \left(-x\right)\right) \]
    14. fmm-def100.0%

      \[\leadsto 0.918938533204673 - \color{blue}{\mathsf{fma}\left(y, 0.5 + \left(-x\right), -\left(-x\right)\right)} \]
    15. unsub-neg100.0%

      \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5 - x}, -\left(-x\right)\right) \]
    16. remove-double-neg100.0%

      \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, \color{blue}{x}\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in y around inf 75.4%

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

    \[\leadsto \color{blue}{0.918938533204673} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2024177 
(FPCore (x y)
  :name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, A"
  :precision binary64
  (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))