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

Percentage Accurate: 100.0% → 100.0%
Time: 6.7s
Alternatives: 11
Speedup: 1.0×

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right) \]
  6. Add Preprocessing

Alternative 2: 49.4% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.75 \cdot 10^{+218}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq -13500000000:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \leq -4.5 \cdot 10^{-146}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{-202}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-302}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 0.92:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{+79} \lor \neg \left(x \leq 4.2 \cdot 10^{+231}\right) \land x \leq 6.6 \cdot 10^{+285}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -2.75e+218)
   (* y x)
   (if (<= x -13500000000.0)
     (- x)
     (if (<= x -4.5e-146)
       (* y -0.5)
       (if (<= x -3.5e-202)
         0.918938533204673
         (if (<= x 5e-302)
           (* y -0.5)
           (if (<= x 0.92)
             0.918938533204673
             (if (or (<= x 4.5e+79)
                     (and (not (<= x 4.2e+231)) (<= x 6.6e+285)))
               (- x)
               (* y x)))))))))
double code(double x, double y) {
	double tmp;
	if (x <= -2.75e+218) {
		tmp = y * x;
	} else if (x <= -13500000000.0) {
		tmp = -x;
	} else if (x <= -4.5e-146) {
		tmp = y * -0.5;
	} else if (x <= -3.5e-202) {
		tmp = 0.918938533204673;
	} else if (x <= 5e-302) {
		tmp = y * -0.5;
	} else if (x <= 0.92) {
		tmp = 0.918938533204673;
	} else if ((x <= 4.5e+79) || (!(x <= 4.2e+231) && (x <= 6.6e+285))) {
		tmp = -x;
	} else {
		tmp = 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 <= (-2.75d+218)) then
        tmp = y * x
    else if (x <= (-13500000000.0d0)) then
        tmp = -x
    else if (x <= (-4.5d-146)) then
        tmp = y * (-0.5d0)
    else if (x <= (-3.5d-202)) then
        tmp = 0.918938533204673d0
    else if (x <= 5d-302) then
        tmp = y * (-0.5d0)
    else if (x <= 0.92d0) then
        tmp = 0.918938533204673d0
    else if ((x <= 4.5d+79) .or. (.not. (x <= 4.2d+231)) .and. (x <= 6.6d+285)) then
        tmp = -x
    else
        tmp = y * x
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -2.75e+218) {
		tmp = y * x;
	} else if (x <= -13500000000.0) {
		tmp = -x;
	} else if (x <= -4.5e-146) {
		tmp = y * -0.5;
	} else if (x <= -3.5e-202) {
		tmp = 0.918938533204673;
	} else if (x <= 5e-302) {
		tmp = y * -0.5;
	} else if (x <= 0.92) {
		tmp = 0.918938533204673;
	} else if ((x <= 4.5e+79) || (!(x <= 4.2e+231) && (x <= 6.6e+285))) {
		tmp = -x;
	} else {
		tmp = y * x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -2.75e+218:
		tmp = y * x
	elif x <= -13500000000.0:
		tmp = -x
	elif x <= -4.5e-146:
		tmp = y * -0.5
	elif x <= -3.5e-202:
		tmp = 0.918938533204673
	elif x <= 5e-302:
		tmp = y * -0.5
	elif x <= 0.92:
		tmp = 0.918938533204673
	elif (x <= 4.5e+79) or (not (x <= 4.2e+231) and (x <= 6.6e+285)):
		tmp = -x
	else:
		tmp = y * x
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -2.75e+218)
		tmp = Float64(y * x);
	elseif (x <= -13500000000.0)
		tmp = Float64(-x);
	elseif (x <= -4.5e-146)
		tmp = Float64(y * -0.5);
	elseif (x <= -3.5e-202)
		tmp = 0.918938533204673;
	elseif (x <= 5e-302)
		tmp = Float64(y * -0.5);
	elseif (x <= 0.92)
		tmp = 0.918938533204673;
	elseif ((x <= 4.5e+79) || (!(x <= 4.2e+231) && (x <= 6.6e+285)))
		tmp = Float64(-x);
	else
		tmp = Float64(y * x);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -2.75e+218)
		tmp = y * x;
	elseif (x <= -13500000000.0)
		tmp = -x;
	elseif (x <= -4.5e-146)
		tmp = y * -0.5;
	elseif (x <= -3.5e-202)
		tmp = 0.918938533204673;
	elseif (x <= 5e-302)
		tmp = y * -0.5;
	elseif (x <= 0.92)
		tmp = 0.918938533204673;
	elseif ((x <= 4.5e+79) || (~((x <= 4.2e+231)) && (x <= 6.6e+285)))
		tmp = -x;
	else
		tmp = y * x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -2.75e+218], N[(y * x), $MachinePrecision], If[LessEqual[x, -13500000000.0], (-x), If[LessEqual[x, -4.5e-146], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, -3.5e-202], 0.918938533204673, If[LessEqual[x, 5e-302], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 0.92], 0.918938533204673, If[Or[LessEqual[x, 4.5e+79], And[N[Not[LessEqual[x, 4.2e+231]], $MachinePrecision], LessEqual[x, 6.6e+285]]], (-x), N[(y * x), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.75 \cdot 10^{+218}:\\
\;\;\;\;y \cdot x\\

\mathbf{elif}\;x \leq -13500000000:\\
\;\;\;\;-x\\

\mathbf{elif}\;x \leq -4.5 \cdot 10^{-146}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;x \leq -3.5 \cdot 10^{-202}:\\
\;\;\;\;0.918938533204673\\

\mathbf{elif}\;x \leq 5 \cdot 10^{-302}:\\
\;\;\;\;y \cdot -0.5\\

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

\mathbf{elif}\;x \leq 4.5 \cdot 10^{+79} \lor \neg \left(x \leq 4.2 \cdot 10^{+231}\right) \land x \leq 6.6 \cdot 10^{+285}:\\
\;\;\;\;-x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -2.7500000000000002e218 or 4.49999999999999994e79 < x < 4.19999999999999969e231 or 6.5999999999999995e285 < 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. sub-neg100.0%

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

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

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

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

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

    if -2.7500000000000002e218 < x < -1.35e10 or 0.92000000000000004 < x < 4.49999999999999994e79 or 4.19999999999999969e231 < x < 6.5999999999999995e285

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-x} \]
    8. Simplified65.7%

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

    if -1.35e10 < x < -4.5000000000000001e-146 or -3.4999999999999999e-202 < x < 5.00000000000000033e-302

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    8. Simplified65.0%

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

    if -4.5000000000000001e-146 < x < -3.4999999999999999e-202 or 5.00000000000000033e-302 < 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. Add Preprocessing
    5. Taylor expanded in y around 0 63.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.75 \cdot 10^{+218}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq -13500000000:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \leq -4.5 \cdot 10^{-146}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{-202}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-302}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 0.92:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{+79} \lor \neg \left(x \leq 4.2 \cdot 10^{+231}\right) \land x \leq 6.6 \cdot 10^{+285}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 49.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{+219}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq -230000000:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \leq 0.92:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{+79} \lor \neg \left(x \leq 3 \cdot 10^{+243}\right) \land x \leq 4 \cdot 10^{+283}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -1.5e+219)
   (* y x)
   (if (<= x -230000000.0)
     (- x)
     (if (<= x 0.92)
       0.918938533204673
       (if (or (<= x 1.9e+79) (and (not (<= x 3e+243)) (<= x 4e+283)))
         (- x)
         (* y x))))))
double code(double x, double y) {
	double tmp;
	if (x <= -1.5e+219) {
		tmp = y * x;
	} else if (x <= -230000000.0) {
		tmp = -x;
	} else if (x <= 0.92) {
		tmp = 0.918938533204673;
	} else if ((x <= 1.9e+79) || (!(x <= 3e+243) && (x <= 4e+283))) {
		tmp = -x;
	} else {
		tmp = 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 <= (-1.5d+219)) then
        tmp = y * x
    else if (x <= (-230000000.0d0)) then
        tmp = -x
    else if (x <= 0.92d0) then
        tmp = 0.918938533204673d0
    else if ((x <= 1.9d+79) .or. (.not. (x <= 3d+243)) .and. (x <= 4d+283)) then
        tmp = -x
    else
        tmp = y * x
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -1.5e+219) {
		tmp = y * x;
	} else if (x <= -230000000.0) {
		tmp = -x;
	} else if (x <= 0.92) {
		tmp = 0.918938533204673;
	} else if ((x <= 1.9e+79) || (!(x <= 3e+243) && (x <= 4e+283))) {
		tmp = -x;
	} else {
		tmp = y * x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -1.5e+219:
		tmp = y * x
	elif x <= -230000000.0:
		tmp = -x
	elif x <= 0.92:
		tmp = 0.918938533204673
	elif (x <= 1.9e+79) or (not (x <= 3e+243) and (x <= 4e+283)):
		tmp = -x
	else:
		tmp = y * x
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -1.5e+219)
		tmp = Float64(y * x);
	elseif (x <= -230000000.0)
		tmp = Float64(-x);
	elseif (x <= 0.92)
		tmp = 0.918938533204673;
	elseif ((x <= 1.9e+79) || (!(x <= 3e+243) && (x <= 4e+283)))
		tmp = Float64(-x);
	else
		tmp = Float64(y * x);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -1.5e+219)
		tmp = y * x;
	elseif (x <= -230000000.0)
		tmp = -x;
	elseif (x <= 0.92)
		tmp = 0.918938533204673;
	elseif ((x <= 1.9e+79) || (~((x <= 3e+243)) && (x <= 4e+283)))
		tmp = -x;
	else
		tmp = y * x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -1.5e+219], N[(y * x), $MachinePrecision], If[LessEqual[x, -230000000.0], (-x), If[LessEqual[x, 0.92], 0.918938533204673, If[Or[LessEqual[x, 1.9e+79], And[N[Not[LessEqual[x, 3e+243]], $MachinePrecision], LessEqual[x, 4e+283]]], (-x), N[(y * x), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -230000000:\\
\;\;\;\;-x\\

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

\mathbf{elif}\;x \leq 1.9 \cdot 10^{+79} \lor \neg \left(x \leq 3 \cdot 10^{+243}\right) \land x \leq 4 \cdot 10^{+283}:\\
\;\;\;\;-x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.4999999999999999e219 or 1.9000000000000001e79 < x < 2.99999999999999984e243 or 3.99999999999999982e283 < 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. sub-neg100.0%

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

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

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

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

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

    if -1.4999999999999999e219 < x < -2.3e8 or 0.92000000000000004 < x < 1.9000000000000001e79 or 2.99999999999999984e243 < x < 3.99999999999999982e283

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -2.3e8 < 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. Add Preprocessing
    5. Taylor expanded in y around 0 51.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{+219}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq -230000000:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \leq 0.92:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{+79} \lor \neg \left(x \leq 3 \cdot 10^{+243}\right) \land x \leq 4 \cdot 10^{+283}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 73.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(y + -1\right)\\ \mathbf{if}\;x \leq -1.15 \cdot 10^{-10}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -3.05 \cdot 10^{-148}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq -3 \cdot 10^{-202}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{-306}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 140000:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* x (+ y -1.0))))
   (if (<= x -1.15e-10)
     t_0
     (if (<= x -3.05e-148)
       (* y -0.5)
       (if (<= x -3e-202)
         0.918938533204673
         (if (<= x 7.8e-306)
           (* y -0.5)
           (if (<= x 140000.0) (- 0.918938533204673 x) t_0)))))))
double code(double x, double y) {
	double t_0 = x * (y + -1.0);
	double tmp;
	if (x <= -1.15e-10) {
		tmp = t_0;
	} else if (x <= -3.05e-148) {
		tmp = y * -0.5;
	} else if (x <= -3e-202) {
		tmp = 0.918938533204673;
	} else if (x <= 7.8e-306) {
		tmp = y * -0.5;
	} else if (x <= 140000.0) {
		tmp = 0.918938533204673 - x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x * (y + (-1.0d0))
    if (x <= (-1.15d-10)) then
        tmp = t_0
    else if (x <= (-3.05d-148)) then
        tmp = y * (-0.5d0)
    else if (x <= (-3d-202)) then
        tmp = 0.918938533204673d0
    else if (x <= 7.8d-306) then
        tmp = y * (-0.5d0)
    else if (x <= 140000.0d0) then
        tmp = 0.918938533204673d0 - x
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x * (y + -1.0);
	double tmp;
	if (x <= -1.15e-10) {
		tmp = t_0;
	} else if (x <= -3.05e-148) {
		tmp = y * -0.5;
	} else if (x <= -3e-202) {
		tmp = 0.918938533204673;
	} else if (x <= 7.8e-306) {
		tmp = y * -0.5;
	} else if (x <= 140000.0) {
		tmp = 0.918938533204673 - x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = x * (y + -1.0)
	tmp = 0
	if x <= -1.15e-10:
		tmp = t_0
	elif x <= -3.05e-148:
		tmp = y * -0.5
	elif x <= -3e-202:
		tmp = 0.918938533204673
	elif x <= 7.8e-306:
		tmp = y * -0.5
	elif x <= 140000.0:
		tmp = 0.918938533204673 - x
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(x * Float64(y + -1.0))
	tmp = 0.0
	if (x <= -1.15e-10)
		tmp = t_0;
	elseif (x <= -3.05e-148)
		tmp = Float64(y * -0.5);
	elseif (x <= -3e-202)
		tmp = 0.918938533204673;
	elseif (x <= 7.8e-306)
		tmp = Float64(y * -0.5);
	elseif (x <= 140000.0)
		tmp = Float64(0.918938533204673 - x);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x * (y + -1.0);
	tmp = 0.0;
	if (x <= -1.15e-10)
		tmp = t_0;
	elseif (x <= -3.05e-148)
		tmp = y * -0.5;
	elseif (x <= -3e-202)
		tmp = 0.918938533204673;
	elseif (x <= 7.8e-306)
		tmp = y * -0.5;
	elseif (x <= 140000.0)
		tmp = 0.918938533204673 - x;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.15e-10], t$95$0, If[LessEqual[x, -3.05e-148], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, -3e-202], 0.918938533204673, If[LessEqual[x, 7.8e-306], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 140000.0], N[(0.918938533204673 - x), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(y + -1\right)\\
\mathbf{if}\;x \leq -1.15 \cdot 10^{-10}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -3.05 \cdot 10^{-148}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;x \leq -3 \cdot 10^{-202}:\\
\;\;\;\;0.918938533204673\\

\mathbf{elif}\;x \leq 7.8 \cdot 10^{-306}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;x \leq 140000:\\
\;\;\;\;0.918938533204673 - x\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.15000000000000004e-10 or 1.4e5 < 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. sub-neg100.0%

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

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

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

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

    if -1.15000000000000004e-10 < x < -3.04999999999999988e-148 or -3.00000000000000011e-202 < x < 7.799999999999999e-306

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    8. Simplified69.5%

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

    if -3.04999999999999988e-148 < x < -3.00000000000000011e-202

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if 7.799999999999999e-306 < x < 1.4e5

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.15 \cdot 10^{-10}:\\ \;\;\;\;x \cdot \left(y + -1\right)\\ \mathbf{elif}\;x \leq -3.05 \cdot 10^{-148}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq -3 \cdot 10^{-202}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{-306}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 140000:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y + -1\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 73.4% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.4 \cdot 10^{+270}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq -1.9 \cdot 10^{+86}:\\
\;\;\;\;y \cdot x\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -7.39999999999999988e270 or -1.89999999999999989e86 < y < -380

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    8. Simplified73.9%

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

    if -7.39999999999999988e270 < y < -1.89999999999999989e86 or 1.1000000000000001 < 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. Add Preprocessing
    5. Taylor expanded in y around 0 59.1%

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

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

    if -380 < y < 1.1000000000000001

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.4 \cdot 10^{+270}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -1.9 \cdot 10^{+86}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -380:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.1:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 98.6% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -56000000 \lor \neg \left(y \leq 1.38 \cdot 10^{+14}\right):\\
\;\;\;\;y \cdot \left(x - 0.5\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.6e7 or 1.38e14 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.6e7 < y < 1.38e14

    1. Initial program 100.0%

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

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

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

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

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

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

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

Alternative 7: 97.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.4 \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.4) (not (<= y 1.0)))
   (* y (- x 0.5))
   (- 0.918938533204673 x)))
double code(double x, double y) {
	double tmp;
	if ((y <= -1.4) || !(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.4d0)) .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.4) || !(y <= 1.0)) {
		tmp = y * (x - 0.5);
	} else {
		tmp = 0.918938533204673 - x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -1.4) 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.4) || !(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.4) || ~((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.4], 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.4 \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.3999999999999999 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. +-commutative100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.3999999999999999 < 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. +-commutative100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 97.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.74 \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.74) (not (<= x 0.62)))
   (* x (+ y -1.0))
   (- 0.918938533204673 (* y 0.5))))
double code(double x, double y) {
	double tmp;
	if ((x <= -0.74) || !(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.74d0)) .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.74) || !(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.74) 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.74) || !(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.74) || ~((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.74], 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.74 \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.73999999999999999 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. sub-neg100.0%

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

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

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

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

    if -0.73999999999999999 < 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. +-commutative100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.918938533204673 - \color{blue}{y \cdot 0.5} \]
    7. Simplified97.5%

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

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

Alternative 9: 49.3% accurate, 0.9× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

    if -2.3e8 < 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. Add Preprocessing
    5. Taylor expanded in y around 0 51.2%

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

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

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

Alternative 10: 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. Add Preprocessing
  3. Final simplification100.0%

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

Alternative 11: 26.7% 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. Add Preprocessing
  5. Taylor expanded in y around 0 76.3%

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

    \[\leadsto \color{blue}{0.918938533204673} \]
  7. Final simplification24.4%

    \[\leadsto 0.918938533204673 \]
  8. Add Preprocessing

Reproduce

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