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

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

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 49.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+45}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -1:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{-68}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -5 \cdot 10^{-87}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq -2.3 \cdot 10^{-123}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{-301}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{-150}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 1.76:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 8.8 \cdot 10^{+220}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -5e+45)
   (* y -0.5)
   (if (<= y -1.0)
     (* y x)
     (if (<= y -4.5e-68)
       (- x)
       (if (<= y -5e-87)
         0.918938533204673
         (if (<= y -2.3e-123)
           (- x)
           (if (<= y -1.45e-301)
             0.918938533204673
             (if (<= y 1.65e-150)
               (- x)
               (if (<= y 1.76)
                 0.918938533204673
                 (if (<= y 8.8e+220) (* y x) (* y -0.5)))))))))))
double code(double x, double y) {
	double tmp;
	if (y <= -5e+45) {
		tmp = y * -0.5;
	} else if (y <= -1.0) {
		tmp = y * x;
	} else if (y <= -4.5e-68) {
		tmp = -x;
	} else if (y <= -5e-87) {
		tmp = 0.918938533204673;
	} else if (y <= -2.3e-123) {
		tmp = -x;
	} else if (y <= -1.45e-301) {
		tmp = 0.918938533204673;
	} else if (y <= 1.65e-150) {
		tmp = -x;
	} else if (y <= 1.76) {
		tmp = 0.918938533204673;
	} else if (y <= 8.8e+220) {
		tmp = y * 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 <= (-5d+45)) then
        tmp = y * (-0.5d0)
    else if (y <= (-1.0d0)) then
        tmp = y * x
    else if (y <= (-4.5d-68)) then
        tmp = -x
    else if (y <= (-5d-87)) then
        tmp = 0.918938533204673d0
    else if (y <= (-2.3d-123)) then
        tmp = -x
    else if (y <= (-1.45d-301)) then
        tmp = 0.918938533204673d0
    else if (y <= 1.65d-150) then
        tmp = -x
    else if (y <= 1.76d0) then
        tmp = 0.918938533204673d0
    else if (y <= 8.8d+220) then
        tmp = y * x
    else
        tmp = y * (-0.5d0)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -5e+45) {
		tmp = y * -0.5;
	} else if (y <= -1.0) {
		tmp = y * x;
	} else if (y <= -4.5e-68) {
		tmp = -x;
	} else if (y <= -5e-87) {
		tmp = 0.918938533204673;
	} else if (y <= -2.3e-123) {
		tmp = -x;
	} else if (y <= -1.45e-301) {
		tmp = 0.918938533204673;
	} else if (y <= 1.65e-150) {
		tmp = -x;
	} else if (y <= 1.76) {
		tmp = 0.918938533204673;
	} else if (y <= 8.8e+220) {
		tmp = y * x;
	} else {
		tmp = y * -0.5;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -5e+45:
		tmp = y * -0.5
	elif y <= -1.0:
		tmp = y * x
	elif y <= -4.5e-68:
		tmp = -x
	elif y <= -5e-87:
		tmp = 0.918938533204673
	elif y <= -2.3e-123:
		tmp = -x
	elif y <= -1.45e-301:
		tmp = 0.918938533204673
	elif y <= 1.65e-150:
		tmp = -x
	elif y <= 1.76:
		tmp = 0.918938533204673
	elif y <= 8.8e+220:
		tmp = y * x
	else:
		tmp = y * -0.5
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -5e+45)
		tmp = Float64(y * -0.5);
	elseif (y <= -1.0)
		tmp = Float64(y * x);
	elseif (y <= -4.5e-68)
		tmp = Float64(-x);
	elseif (y <= -5e-87)
		tmp = 0.918938533204673;
	elseif (y <= -2.3e-123)
		tmp = Float64(-x);
	elseif (y <= -1.45e-301)
		tmp = 0.918938533204673;
	elseif (y <= 1.65e-150)
		tmp = Float64(-x);
	elseif (y <= 1.76)
		tmp = 0.918938533204673;
	elseif (y <= 8.8e+220)
		tmp = Float64(y * x);
	else
		tmp = Float64(y * -0.5);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -5e+45)
		tmp = y * -0.5;
	elseif (y <= -1.0)
		tmp = y * x;
	elseif (y <= -4.5e-68)
		tmp = -x;
	elseif (y <= -5e-87)
		tmp = 0.918938533204673;
	elseif (y <= -2.3e-123)
		tmp = -x;
	elseif (y <= -1.45e-301)
		tmp = 0.918938533204673;
	elseif (y <= 1.65e-150)
		tmp = -x;
	elseif (y <= 1.76)
		tmp = 0.918938533204673;
	elseif (y <= 8.8e+220)
		tmp = y * x;
	else
		tmp = y * -0.5;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -5e+45], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -1.0], N[(y * x), $MachinePrecision], If[LessEqual[y, -4.5e-68], (-x), If[LessEqual[y, -5e-87], 0.918938533204673, If[LessEqual[y, -2.3e-123], (-x), If[LessEqual[y, -1.45e-301], 0.918938533204673, If[LessEqual[y, 1.65e-150], (-x), If[LessEqual[y, 1.76], 0.918938533204673, If[LessEqual[y, 8.8e+220], N[(y * x), $MachinePrecision], N[(y * -0.5), $MachinePrecision]]]]]]]]]]
\begin{array}{l}

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

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

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

\mathbf{elif}\;y \leq -5 \cdot 10^{-87}:\\
\;\;\;\;0.918938533204673\\

\mathbf{elif}\;y \leq -2.3 \cdot 10^{-123}:\\
\;\;\;\;-x\\

\mathbf{elif}\;y \leq -1.45 \cdot 10^{-301}:\\
\;\;\;\;0.918938533204673\\

\mathbf{elif}\;y \leq 1.65 \cdot 10^{-150}:\\
\;\;\;\;-x\\

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

\mathbf{elif}\;y \leq 8.8 \cdot 10^{+220}:\\
\;\;\;\;y \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -5e45 or 8.79999999999999957e220 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5e45 < y < -1 or 1.76000000000000001 < y < 8.79999999999999957e220

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1 < y < -4.49999999999999999e-68 or -5.00000000000000042e-87 < y < -2.29999999999999987e-123 or -1.44999999999999992e-301 < y < 1.6500000000000001e-150

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-x} \]
    7. Simplified62.9%

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

    if -4.49999999999999999e-68 < y < -5.00000000000000042e-87 or -2.29999999999999987e-123 < y < -1.44999999999999992e-301 or 1.6500000000000001e-150 < y < 1.76000000000000001

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+45}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -1:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{-68}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -5 \cdot 10^{-87}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq -2.3 \cdot 10^{-123}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{-301}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{-150}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 1.76:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 8.8 \cdot 10^{+220}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \]

Alternative 3: 49.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -31000000000000:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -5.2 \cdot 10^{-56}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -6.6 \cdot 10^{-87}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq -1.35 \cdot 10^{-121}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -3.95 \cdot 10^{-302}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-151}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 37000000:\\ \;\;\;\;0.918938533204673\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -31000000000000.0)
   (* y -0.5)
   (if (<= y -5.2e-56)
     (- x)
     (if (<= y -6.6e-87)
       0.918938533204673
       (if (<= y -1.35e-121)
         (- x)
         (if (<= y -3.95e-302)
           0.918938533204673
           (if (<= y 2.4e-151)
             (- x)
             (if (<= y 37000000.0) 0.918938533204673 (* y -0.5)))))))))
double code(double x, double y) {
	double tmp;
	if (y <= -31000000000000.0) {
		tmp = y * -0.5;
	} else if (y <= -5.2e-56) {
		tmp = -x;
	} else if (y <= -6.6e-87) {
		tmp = 0.918938533204673;
	} else if (y <= -1.35e-121) {
		tmp = -x;
	} else if (y <= -3.95e-302) {
		tmp = 0.918938533204673;
	} else if (y <= 2.4e-151) {
		tmp = -x;
	} else if (y <= 37000000.0) {
		tmp = 0.918938533204673;
	} else {
		tmp = y * -0.5;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-31000000000000.0d0)) then
        tmp = y * (-0.5d0)
    else if (y <= (-5.2d-56)) then
        tmp = -x
    else if (y <= (-6.6d-87)) then
        tmp = 0.918938533204673d0
    else if (y <= (-1.35d-121)) then
        tmp = -x
    else if (y <= (-3.95d-302)) then
        tmp = 0.918938533204673d0
    else if (y <= 2.4d-151) then
        tmp = -x
    else if (y <= 37000000.0d0) then
        tmp = 0.918938533204673d0
    else
        tmp = y * (-0.5d0)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -31000000000000.0) {
		tmp = y * -0.5;
	} else if (y <= -5.2e-56) {
		tmp = -x;
	} else if (y <= -6.6e-87) {
		tmp = 0.918938533204673;
	} else if (y <= -1.35e-121) {
		tmp = -x;
	} else if (y <= -3.95e-302) {
		tmp = 0.918938533204673;
	} else if (y <= 2.4e-151) {
		tmp = -x;
	} else if (y <= 37000000.0) {
		tmp = 0.918938533204673;
	} else {
		tmp = y * -0.5;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -31000000000000.0:
		tmp = y * -0.5
	elif y <= -5.2e-56:
		tmp = -x
	elif y <= -6.6e-87:
		tmp = 0.918938533204673
	elif y <= -1.35e-121:
		tmp = -x
	elif y <= -3.95e-302:
		tmp = 0.918938533204673
	elif y <= 2.4e-151:
		tmp = -x
	elif y <= 37000000.0:
		tmp = 0.918938533204673
	else:
		tmp = y * -0.5
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -31000000000000.0)
		tmp = Float64(y * -0.5);
	elseif (y <= -5.2e-56)
		tmp = Float64(-x);
	elseif (y <= -6.6e-87)
		tmp = 0.918938533204673;
	elseif (y <= -1.35e-121)
		tmp = Float64(-x);
	elseif (y <= -3.95e-302)
		tmp = 0.918938533204673;
	elseif (y <= 2.4e-151)
		tmp = Float64(-x);
	elseif (y <= 37000000.0)
		tmp = 0.918938533204673;
	else
		tmp = Float64(y * -0.5);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -31000000000000.0)
		tmp = y * -0.5;
	elseif (y <= -5.2e-56)
		tmp = -x;
	elseif (y <= -6.6e-87)
		tmp = 0.918938533204673;
	elseif (y <= -1.35e-121)
		tmp = -x;
	elseif (y <= -3.95e-302)
		tmp = 0.918938533204673;
	elseif (y <= 2.4e-151)
		tmp = -x;
	elseif (y <= 37000000.0)
		tmp = 0.918938533204673;
	else
		tmp = y * -0.5;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -31000000000000.0], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -5.2e-56], (-x), If[LessEqual[y, -6.6e-87], 0.918938533204673, If[LessEqual[y, -1.35e-121], (-x), If[LessEqual[y, -3.95e-302], 0.918938533204673, If[LessEqual[y, 2.4e-151], (-x), If[LessEqual[y, 37000000.0], 0.918938533204673, N[(y * -0.5), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -5.2 \cdot 10^{-56}:\\
\;\;\;\;-x\\

\mathbf{elif}\;y \leq -6.6 \cdot 10^{-87}:\\
\;\;\;\;0.918938533204673\\

\mathbf{elif}\;y \leq -1.35 \cdot 10^{-121}:\\
\;\;\;\;-x\\

\mathbf{elif}\;y \leq -3.95 \cdot 10^{-302}:\\
\;\;\;\;0.918938533204673\\

\mathbf{elif}\;y \leq 2.4 \cdot 10^{-151}:\\
\;\;\;\;-x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -3.1e13 or 3.7e7 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.1e13 < y < -5.19999999999999994e-56 or -6.6000000000000001e-87 < y < -1.3500000000000001e-121 or -3.94999999999999988e-302 < y < 2.4e-151

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-x} \]
    7. Simplified57.9%

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

    if -5.19999999999999994e-56 < y < -6.6000000000000001e-87 or -1.3500000000000001e-121 < y < -3.94999999999999988e-302 or 2.4e-151 < y < 3.7e7

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -31000000000000:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -5.2 \cdot 10^{-56}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -6.6 \cdot 10^{-87}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq -1.35 \cdot 10^{-121}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -3.95 \cdot 10^{-302}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-151}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 37000000:\\ \;\;\;\;0.918938533204673\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \]

Alternative 4: 98.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -31000000000000 \lor \neg \left(y \leq 4.2 \cdot 10^{-7}\right):\\
\;\;\;\;y \cdot x + \left(0.918938533204673 - y \cdot 0.5\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.1e13 or 4.2e-7 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.1e13 < y < 4.2e-7

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 74.3% accurate, 1.0× speedup?

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

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

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

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

\mathbf{elif}\;y \leq 2.1 \cdot 10^{+221}:\\
\;\;\;\;y \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.20000000000000014e45 or 2.10000000000000002e221 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.20000000000000014e45 < y < -23 or 1.55000000000000004 < y < 2.10000000000000002e221

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -23 < y < 1.55000000000000004

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+45}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -23:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 1.55:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{+221}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \]

Alternative 6: 97.9% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.3999999999999999 < y < 1.3500000000000001

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3500000000000001 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(x - 0.5\right)} \]
    5. Step-by-step derivation
      1. distribute-lft-out--98.7%

        \[\leadsto \color{blue}{y \cdot x - y \cdot 0.5} \]
    6. Applied egg-rr98.7%

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

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

Alternative 7: 98.6% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3e4 < y < 3.9e6

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.9e6 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(x - 0.5\right)} \]
    5. Step-by-step derivation
      1. distribute-lft-out--98.7%

        \[\leadsto \color{blue}{y \cdot x - y \cdot 0.5} \]
    6. Applied egg-rr98.7%

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

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

Alternative 8: 98.5% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.1e13 < y < 5.9e7

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.9e7 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(x - 0.5\right)} \]
    5. Step-by-step derivation
      1. distribute-lft-out--99.3%

        \[\leadsto \color{blue}{y \cdot x - y \cdot 0.5} \]
    6. Applied egg-rr99.3%

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

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

Alternative 9: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 10: 97.9% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.3 \lor \neg \left(y \leq 1.05\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.05)))
   (* y (- x 0.5))
   (- 0.918938533204673 x)))
double code(double x, double y) {
	double tmp;
	if ((y <= -1.3) || !(y <= 1.05)) {
		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.05d0))) 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.05)) {
		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.05):
		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.05))
		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.05)))
		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.05]], $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.05\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.05000000000000004 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.30000000000000004 < y < 1.05000000000000004

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 100.0% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 49.9% accurate, 1.8× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-x} \]
    7. Simplified41.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 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. sub-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.918938533204673} \]
  7. Final simplification27.0%

    \[\leadsto 0.918938533204673 \]

Reproduce

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