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

Percentage Accurate: 100.0% → 100.0%
Time: 4.8s
Alternatives: 11
Speedup: 1.2×

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(y, x + -0.5, 0.918938533204673 - x\right) \end{array} \]
(FPCore (x y) :precision binary64 (fma y (+ x -0.5) (- 0.918938533204673 x)))
double code(double x, double y) {
	return fma(y, (x + -0.5), (0.918938533204673 - x));
}
function code(x, y)
	return fma(y, Float64(x + -0.5), Float64(0.918938533204673 - x))
end
code[x_, y_] := N[(y * N[(x + -0.5), $MachinePrecision] + N[(0.918938533204673 - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(y, x + -0.5, 0.918938533204673 - x\right)
\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. sub-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \mathsf{fma}\left(y, x + -0.5, 0.918938533204673 - x\right) \]

Alternative 2: 98.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -440 \lor \neg \left(x \leq 1.5 \cdot 10^{+15}\right):\\
\;\;\;\;x \cdot \left(y + -1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -440 or 1.5e15 < 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. associate-+l-100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in x around 0 100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0.918938533204673 + -1 \cdot \left(y \cdot \left(0.5 + -1 \cdot x\right)\right)\right) - x} \]
    8. Step-by-step derivation
      1. mul-1-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\left(1 + -1 \cdot y\right) \cdot x} \]
      2. neg-mul-198.7%

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

        \[\leadsto -\color{blue}{\left(1 - y\right)} \cdot x \]
      4. neg-sub098.7%

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

        \[\leadsto 0 - \color{blue}{\left(1 + \left(-y\right)\right)} \cdot x \]
      6. +-commutative98.7%

        \[\leadsto 0 - \color{blue}{\left(\left(-y\right) + 1\right)} \cdot x \]
      7. distribute-rgt1-in98.7%

        \[\leadsto 0 - \color{blue}{\left(x + \left(-y\right) \cdot x\right)} \]
      8. distribute-lft-neg-in98.7%

        \[\leadsto 0 - \left(x + \color{blue}{\left(-y \cdot x\right)}\right) \]
      9. unsub-neg98.7%

        \[\leadsto 0 - \color{blue}{\left(x - y \cdot x\right)} \]
      10. associate-+l-98.7%

        \[\leadsto \color{blue}{\left(0 - x\right) + y \cdot x} \]
      11. *-rgt-identity98.7%

        \[\leadsto \left(0 - \color{blue}{x \cdot 1}\right) + y \cdot x \]
      12. neg-sub098.7%

        \[\leadsto \color{blue}{\left(-x \cdot 1\right)} + y \cdot x \]
      13. *-rgt-identity98.7%

        \[\leadsto \left(-\color{blue}{x}\right) + y \cdot x \]
      14. mul-1-neg98.7%

        \[\leadsto \color{blue}{-1 \cdot x} + y \cdot x \]
      15. distribute-rgt-in98.7%

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

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

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

    if -440 < x < 1.5e15

    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. fma-neg100.0%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in y around 0 99.5%

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

        \[\leadsto \color{blue}{\left(-x\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
    6. Simplified99.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -440 \lor \neg \left(x \leq 1.5 \cdot 10^{+15}\right):\\ \;\;\;\;x \cdot \left(y + -1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.918938533204673 + y \cdot -0.5\right) - x\\ \end{array} \]

Alternative 3: 100.0% accurate, 1.0× speedup?

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

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

    \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
  2. Final simplification100.0%

    \[\leadsto 0.918938533204673 + \left(x \cdot \left(y + -1\right) - y \cdot 0.5\right) \]

Alternative 4: 97.7% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.25 \lor \neg \left(y \leq 1\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.25) (not (<= y 1.0)))
   (* y (- x 0.5))
   (- 0.918938533204673 x)))
double code(double x, double y) {
	double tmp;
	if ((y <= -1.25) || !(y <= 1.0)) {
		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.25d0)) .or. (.not. (y <= 1.0d0))) 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.25) || !(y <= 1.0)) {
		tmp = y * (x - 0.5);
	} else {
		tmp = 0.918938533204673 - x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -1.25) or not (y <= 1.0):
		tmp = y * (x - 0.5)
	else:
		tmp = 0.918938533204673 - x
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -1.25) || !(y <= 1.0))
		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.25) || ~((y <= 1.0)))
		tmp = y * (x - 0.5);
	else
		tmp = 0.918938533204673 - x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -1.25], N[Not[LessEqual[y, 1.0]], $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.25 \lor \neg \left(y \leq 1\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.25 or 1 < 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. associate-+l-100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in y around inf 96.4%

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

    if -1.25 < y < 1

    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. fma-neg100.0%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in y around 0 98.3%

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

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

        \[\leadsto \color{blue}{0.918938533204673 - x} \]
    6. Simplified98.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.25 \lor \neg \left(y \leq 1\right):\\ \;\;\;\;y \cdot \left(x - 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;0.918938533204673 - x\\ \end{array} \]

Alternative 5: 97.9% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.72 \lor \neg \left(x \leq 0.62\right):\\
\;\;\;\;x \cdot \left(y + -1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -0.71999999999999997 or 0.619999999999999996 < 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. associate-+l-100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in x around 0 100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0.918938533204673 + -1 \cdot \left(y \cdot \left(0.5 + -1 \cdot x\right)\right)\right) - x} \]
    8. Step-by-step derivation
      1. mul-1-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\left(1 + -1 \cdot y\right) \cdot x} \]
      2. neg-mul-196.4%

        \[\leadsto -\left(1 + \color{blue}{\left(-y\right)}\right) \cdot x \]
      3. sub-neg96.4%

        \[\leadsto -\color{blue}{\left(1 - y\right)} \cdot x \]
      4. neg-sub096.4%

        \[\leadsto \color{blue}{0 - \left(1 - y\right) \cdot x} \]
      5. sub-neg96.4%

        \[\leadsto 0 - \color{blue}{\left(1 + \left(-y\right)\right)} \cdot x \]
      6. +-commutative96.4%

        \[\leadsto 0 - \color{blue}{\left(\left(-y\right) + 1\right)} \cdot x \]
      7. distribute-rgt1-in96.4%

        \[\leadsto 0 - \color{blue}{\left(x + \left(-y\right) \cdot x\right)} \]
      8. distribute-lft-neg-in96.4%

        \[\leadsto 0 - \left(x + \color{blue}{\left(-y \cdot x\right)}\right) \]
      9. unsub-neg96.4%

        \[\leadsto 0 - \color{blue}{\left(x - y \cdot x\right)} \]
      10. associate-+l-96.4%

        \[\leadsto \color{blue}{\left(0 - x\right) + y \cdot x} \]
      11. *-rgt-identity96.4%

        \[\leadsto \left(0 - \color{blue}{x \cdot 1}\right) + y \cdot x \]
      12. neg-sub096.4%

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

        \[\leadsto \left(-\color{blue}{x}\right) + y \cdot x \]
      14. mul-1-neg96.4%

        \[\leadsto \color{blue}{-1 \cdot x} + y \cdot x \]
      15. distribute-rgt-in96.4%

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

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

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

    if -0.71999999999999997 < x < 0.619999999999999996

    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. fma-neg100.0%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in x around 0 98.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.72 \lor \neg \left(x \leq 0.62\right):\\ \;\;\;\;x \cdot \left(y + -1\right)\\ \mathbf{else}:\\ \;\;\;\;0.918938533204673 - y \cdot 0.5\\ \end{array} \]

Alternative 6: 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. associate-+l-100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
    11. 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. Taylor expanded in x around 0 100.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(0.918938533204673 + -1 \cdot \left(y \cdot \left(0.5 + -1 \cdot x\right)\right)\right) - x} \]
  8. Step-by-step derivation
    1. mul-1-neg100.0%

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

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

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

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

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

    \[\leadsto \left(0.918938533204673 + y \cdot \left(x - 0.5\right)\right) - x \]

Alternative 7: 49.8% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.7:\\
\;\;\;\;-x\\

\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;y \cdot -0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -0.69999999999999996 or 0.5 < 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. associate-+l-100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in y around 0 50.6%

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

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

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

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

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

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

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

    if -0.69999999999999996 < x < 0.5

    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. fma-neg100.0%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in y around inf 48.5%

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

      \[\leadsto \color{blue}{-0.5 \cdot y} \]
    6. Step-by-step derivation
      1. *-commutative47.9%

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    7. Simplified47.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.7:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 8: 49.5% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -12600:\\
\;\;\;\;y \cdot x\\

\mathbf{elif}\;y \leq 1.25:\\
\;\;\;\;-x\\

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


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

    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. fma-neg100.0%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in x around 0 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(y \cdot x - x\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
    6. Simplified99.9%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\left(1 + -1 \cdot y\right) \cdot x} \]
      2. neg-mul-157.6%

        \[\leadsto -\left(1 + \color{blue}{\left(-y\right)}\right) \cdot x \]
      3. sub-neg57.6%

        \[\leadsto -\color{blue}{\left(1 - y\right)} \cdot x \]
      4. neg-sub057.6%

        \[\leadsto \color{blue}{0 - \left(1 - y\right) \cdot x} \]
      5. sub-neg57.6%

        \[\leadsto 0 - \color{blue}{\left(1 + \left(-y\right)\right)} \cdot x \]
      6. +-commutative57.6%

        \[\leadsto 0 - \color{blue}{\left(\left(-y\right) + 1\right)} \cdot x \]
      7. distribute-rgt1-in57.6%

        \[\leadsto 0 - \color{blue}{\left(x + \left(-y\right) \cdot x\right)} \]
      8. distribute-lft-neg-in57.6%

        \[\leadsto 0 - \left(x + \color{blue}{\left(-y \cdot x\right)}\right) \]
      9. unsub-neg57.6%

        \[\leadsto 0 - \color{blue}{\left(x - y \cdot x\right)} \]
      10. associate-+l-57.6%

        \[\leadsto \color{blue}{\left(0 - x\right) + y \cdot x} \]
      11. *-rgt-identity57.6%

        \[\leadsto \left(0 - \color{blue}{x \cdot 1}\right) + y \cdot x \]
      12. neg-sub057.6%

        \[\leadsto \color{blue}{\left(-x \cdot 1\right)} + y \cdot x \]
      13. *-rgt-identity57.6%

        \[\leadsto \left(-\color{blue}{x}\right) + y \cdot x \]
      14. mul-1-neg57.6%

        \[\leadsto \color{blue}{-1 \cdot x} + y \cdot x \]
      15. distribute-rgt-in57.6%

        \[\leadsto \color{blue}{x \cdot \left(-1 + y\right)} \]
      16. +-commutative57.6%

        \[\leadsto x \cdot \color{blue}{\left(y + -1\right)} \]
    12. Simplified57.6%

      \[\leadsto \color{blue}{x \cdot \left(y + -1\right)} \]
    13. Taylor expanded in y around inf 56.1%

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

    if -12600 < y < 1.25

    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. fma-neg100.0%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in y around 0 99.4%

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

        \[\leadsto \color{blue}{\left(-x\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
    6. Simplified99.4%

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

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

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

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

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

    if 1.25 < 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. associate-+l-100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in y around inf 97.1%

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

      \[\leadsto \color{blue}{-0.5 \cdot y} \]
    6. Step-by-step derivation
      1. *-commutative50.1%

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    7. Simplified50.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -12600:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 1.25:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \]

Alternative 9: 73.5% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -58000:\\
\;\;\;\;y \cdot x\\

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

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


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

    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. fma-neg100.0%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in x around 0 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(y \cdot x - x\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
    6. Simplified99.9%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\left(1 + -1 \cdot y\right) \cdot x} \]
      2. neg-mul-158.3%

        \[\leadsto -\left(1 + \color{blue}{\left(-y\right)}\right) \cdot x \]
      3. sub-neg58.3%

        \[\leadsto -\color{blue}{\left(1 - y\right)} \cdot x \]
      4. neg-sub058.3%

        \[\leadsto \color{blue}{0 - \left(1 - y\right) \cdot x} \]
      5. sub-neg58.3%

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

        \[\leadsto 0 - \color{blue}{\left(\left(-y\right) + 1\right)} \cdot x \]
      7. distribute-rgt1-in58.3%

        \[\leadsto 0 - \color{blue}{\left(x + \left(-y\right) \cdot x\right)} \]
      8. distribute-lft-neg-in58.3%

        \[\leadsto 0 - \left(x + \color{blue}{\left(-y \cdot x\right)}\right) \]
      9. unsub-neg58.3%

        \[\leadsto 0 - \color{blue}{\left(x - y \cdot x\right)} \]
      10. associate-+l-58.3%

        \[\leadsto \color{blue}{\left(0 - x\right) + y \cdot x} \]
      11. *-rgt-identity58.3%

        \[\leadsto \left(0 - \color{blue}{x \cdot 1}\right) + y \cdot x \]
      12. neg-sub058.3%

        \[\leadsto \color{blue}{\left(-x \cdot 1\right)} + y \cdot x \]
      13. *-rgt-identity58.3%

        \[\leadsto \left(-\color{blue}{x}\right) + y \cdot x \]
      14. mul-1-neg58.3%

        \[\leadsto \color{blue}{-1 \cdot x} + y \cdot x \]
      15. distribute-rgt-in58.3%

        \[\leadsto \color{blue}{x \cdot \left(-1 + y\right)} \]
      16. +-commutative58.3%

        \[\leadsto x \cdot \color{blue}{\left(y + -1\right)} \]
    12. Simplified58.3%

      \[\leadsto \color{blue}{x \cdot \left(y + -1\right)} \]
    13. Taylor expanded in y around inf 56.8%

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

    if -58000 < 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. associate-+l-100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in y around 0 97.0%

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

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

        \[\leadsto \color{blue}{0.918938533204673 - x} \]
    6. Simplified97.0%

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

    if 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. associate-+l-100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in y around inf 97.1%

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

      \[\leadsto \color{blue}{-0.5 \cdot y} \]
    6. Step-by-step derivation
      1. *-commutative50.1%

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    7. Simplified50.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -58000:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 1.85:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \]

Alternative 10: 73.9% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.9 \cdot 10^{-9}:\\
\;\;\;\;x \cdot \left(y + -1\right)\\

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

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


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

    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. fma-neg100.0%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in x around 0 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(y \cdot x - x\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
    6. Simplified99.9%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\left(1 + -1 \cdot y\right) \cdot x} \]
      2. neg-mul-156.8%

        \[\leadsto -\left(1 + \color{blue}{\left(-y\right)}\right) \cdot x \]
      3. sub-neg56.8%

        \[\leadsto -\color{blue}{\left(1 - y\right)} \cdot x \]
      4. neg-sub056.8%

        \[\leadsto \color{blue}{0 - \left(1 - y\right) \cdot x} \]
      5. sub-neg56.8%

        \[\leadsto 0 - \color{blue}{\left(1 + \left(-y\right)\right)} \cdot x \]
      6. +-commutative56.8%

        \[\leadsto 0 - \color{blue}{\left(\left(-y\right) + 1\right)} \cdot x \]
      7. distribute-rgt1-in56.8%

        \[\leadsto 0 - \color{blue}{\left(x + \left(-y\right) \cdot x\right)} \]
      8. distribute-lft-neg-in56.8%

        \[\leadsto 0 - \left(x + \color{blue}{\left(-y \cdot x\right)}\right) \]
      9. unsub-neg56.8%

        \[\leadsto 0 - \color{blue}{\left(x - y \cdot x\right)} \]
      10. associate-+l-56.8%

        \[\leadsto \color{blue}{\left(0 - x\right) + y \cdot x} \]
      11. *-rgt-identity56.8%

        \[\leadsto \left(0 - \color{blue}{x \cdot 1}\right) + y \cdot x \]
      12. neg-sub056.8%

        \[\leadsto \color{blue}{\left(-x \cdot 1\right)} + y \cdot x \]
      13. *-rgt-identity56.8%

        \[\leadsto \left(-\color{blue}{x}\right) + y \cdot x \]
      14. mul-1-neg56.8%

        \[\leadsto \color{blue}{-1 \cdot x} + y \cdot x \]
      15. distribute-rgt-in56.8%

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

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

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

    if -6.89999999999999975e-9 < 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. associate-+l-100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in y around 0 99.2%

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

        \[\leadsto 0.918938533204673 + \color{blue}{\left(-x\right)} \]
      2. unsub-neg99.2%

        \[\leadsto \color{blue}{0.918938533204673 - x} \]
    6. Simplified99.2%

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

    if 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. associate-+l-100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
      11. 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. Taylor expanded in y around inf 97.1%

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

      \[\leadsto \color{blue}{-0.5 \cdot y} \]
    6. Step-by-step derivation
      1. *-commutative50.1%

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    7. Simplified50.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.9 \cdot 10^{-9}:\\ \;\;\;\;x \cdot \left(y + -1\right)\\ \mathbf{elif}\;y \leq 1.85:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \]

Alternative 11: 25.9% accurate, 5.5× 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 Float64(-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%

    \[\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. fma-neg100.0%

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

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

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

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

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

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

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

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

      \[\leadsto x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
    11. 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. Taylor expanded in y around 0 74.3%

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

      \[\leadsto \color{blue}{\left(-x\right)} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
  6. Simplified74.3%

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

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

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

      \[\leadsto \color{blue}{-x} \]
  10. Simplified26.4%

    \[\leadsto \color{blue}{-x} \]
  11. Final simplification26.4%

    \[\leadsto -x \]

Reproduce

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