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

Percentage Accurate: 100.0% → 100.0%
Time: 8.3s
Alternatives: 9
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 9 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \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, 1.2× speedup?

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

\\
\left(0.918938533204673 - x\right) + y \cdot \left(x - 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. Step-by-step derivation
    1. associate-+l-100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 49.6% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;y \leq -1.58 \cdot 10^{-286}:\\
\;\;\;\;0.918938533204673\\

\mathbf{elif}\;y \leq 8 \cdot 10^{-277}:\\
\;\;\;\;-x\\

\mathbf{elif}\;y \leq 1.2 \cdot 10^{-159}:\\
\;\;\;\;0.918938533204673\\

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    7. Simplified54.0%

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

    if -1.75000000000000012e-8 < y < -1.57999999999999989e-286 or 7.99999999999999975e-277 < y < 1.19999999999999999e-159

    1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{0.918938533204673 - 0.5 \cdot y} \]
    5. Taylor expanded in y around 0 67.4%

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

    if -1.57999999999999989e-286 < y < 7.99999999999999975e-277 or 1.19999999999999999e-159 < 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. cancel-sign-sub-inv100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\left(1 + -1 \cdot y\right) \cdot x} \]
      3. distribute-rgt-neg-in63.9%

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

        \[\leadsto \left(1 + \color{blue}{\left(-y\right)}\right) \cdot \left(-x\right) \]
      5. unsub-neg63.9%

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

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

      \[\leadsto \color{blue}{-1 \cdot x} \]
    8. Step-by-step derivation
      1. mul-1-neg60.8%

        \[\leadsto \color{blue}{-x} \]
    9. Simplified60.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{-8}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -1.58 \cdot 10^{-286}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-277}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{-159}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 1.85:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \]

Alternative 3: 74.4% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;y \leq 1.06 \cdot 10^{-19}:\\
\;\;\;\;0.918938533204673 - x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -17 or 1.25e12 < 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. sub-neg100.0%

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    7. Simplified55.8%

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

    if -17 < y < 1.06e-19

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if 1.06e-19 < y < 1.25e12

    1. Initial program 99.8%

      \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
    2. Step-by-step derivation
      1. cancel-sign-sub-inv99.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\left(-y\right) \cdot 0.5 + \color{blue}{y \cdot x}\right) + 0.918938533204673\right) - x \]
      12. distribute-lft-neg-out99.6%

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

        \[\leadsto \left(\left(\color{blue}{y \cdot \left(-0.5\right)} + y \cdot x\right) + 0.918938533204673\right) - x \]
      14. distribute-lft-out99.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, \left(-0.5\right) + x, 0.918938533204673\right)} - x \]
      16. +-commutative99.6%

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

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

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

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

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

        \[\leadsto -\color{blue}{\left(1 + -1 \cdot y\right) \cdot x} \]
      3. distribute-rgt-neg-in86.5%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot x + x \cdot y} \]
    8. Taylor expanded in x around 0 86.5%

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

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

Alternative 4: 97.9% accurate, 1.2× speedup?

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

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

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

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

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

    if -1.30000000000000004 < y < 1.19999999999999996

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 97.8% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.72 \lor \neg \left(x \leq 0.7\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.7)))
   (* x (+ y -1.0))
   (- 0.918938533204673 (* y 0.5))))
double code(double x, double y) {
	double tmp;
	if ((x <= -0.72) || !(x <= 0.7)) {
		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.7d0))) 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.7)) {
		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.7):
		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.7))
		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.7)))
		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.7]], $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.7\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.69999999999999996 < 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. cancel-sign-sub-inv100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot x + x \cdot y} \]
    8. Taylor expanded in x around 0 98.4%

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

    if -0.71999999999999997 < x < 0.69999999999999996

    1. Initial program 100.0%

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

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

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

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

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

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

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

Alternative 6: 97.8% accurate, 1.2× speedup?

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

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

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

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


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

    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. cancel-sign-sub-inv100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot x + x \cdot y} \]
    8. Taylor expanded in x around 0 98.7%

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

    if -0.680000000000000049 < x < 0.900000000000000022

    1. Initial program 100.0%

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

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

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

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

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

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

    if 0.900000000000000022 < x

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\left(1 + -1 \cdot y\right) \cdot x} \]
      3. distribute-rgt-neg-in98.2%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot x + x \cdot y} \]
    8. Taylor expanded in x around 0 98.2%

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

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

        \[\leadsto x \cdot \left(y + \color{blue}{-1}\right) \]
      3. distribute-lft-in98.2%

        \[\leadsto \color{blue}{x \cdot y + x \cdot -1} \]
      4. *-commutative98.2%

        \[\leadsto x \cdot y + \color{blue}{-1 \cdot x} \]
      5. mul-1-neg98.2%

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

        \[\leadsto \color{blue}{x \cdot y - x} \]
    10. Simplified98.2%

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

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

Alternative 7: 74.4% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    7. Simplified54.4%

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

    if -56 < 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. sub-neg100.0%

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

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

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

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

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

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

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

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

Alternative 8: 50.0% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;x \leq 0.92:\\
\;\;\;\;0.918938533204673\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -0.92000000000000004 or 0.92000000000000004 < 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. cancel-sign-sub-inv100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot x} \]
    8. Step-by-step derivation
      1. mul-1-neg47.2%

        \[\leadsto \color{blue}{-x} \]
    9. Simplified47.2%

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

    if -0.92000000000000004 < x < 0.92000000000000004

    1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{0.918938533204673 - 0.5 \cdot y} \]
    5. Taylor expanded in y around 0 49.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.92:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \leq 0.92:\\ \;\;\;\;0.918938533204673\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 9: 26.1% accurate, 11.0× speedup?

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.918938533204673 - 0.5 \cdot y} \]
  5. Taylor expanded in y around 0 28.4%

    \[\leadsto \color{blue}{0.918938533204673} \]
  6. Final simplification28.4%

    \[\leadsto 0.918938533204673 \]

Reproduce

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