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

Percentage Accurate: 100.0% → 100.0%
Time: 2.9s
Alternatives: 7
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.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}
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 \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]

Alternative 2: 97.9% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;y \leq 1.45 \cdot 10^{-29}:\\
\;\;\;\;\left(0.918938533204673 - y \cdot 0.5\right) - x\\

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


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

    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 x} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
    5. Taylor expanded in y around inf 100.0%

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

    if -8.8e8 < y < 1.45000000000000012e-29

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.45000000000000012e-29 < 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) \]
    5. Step-by-step derivation
      1. associate--r-99.7%

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

        \[\leadsto \color{blue}{y \cdot \left(x - 0.5\right)} + 0.918938533204673 \]
    6. Applied egg-rr99.7%

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

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

Alternative 3: 72.9% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{-29} \lor \neg \left(y \leq 1.85\right):\\
\;\;\;\;y \cdot \left(x - 0.5\right)\\

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


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

    1. Initial program 100.0%

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

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

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

    if -1.09999999999999995e-29 < y < 1.8500000000000001

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 74.3% accurate, 1.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.9e8 or 6e7 < 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.8%

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

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

    if -4.9e8 < y < 6e7

    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 49.1%

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

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

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

Alternative 5: 48.8% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{-29}:\\
\;\;\;\;x \cdot y\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.09999999999999995e-29 or 1.55000000000000004 < 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 x} - \left(y \cdot 0.5 - 0.918938533204673\right) \]
    5. Taylor expanded in x around inf 50.7%

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

    if -1.09999999999999995e-29 < 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 inf 49.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.1 \cdot 10^{-29}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 1.55:\\ \;\;\;\;0.918938533204673\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]

Alternative 6: 74.8% accurate, 1.6× speedup?

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(y - 1\right) - \left(y \cdot 0.5 - 0.918938533204673\right)} \]
    2. 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 77.0%

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

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

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

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

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

Alternative 7: 26.7% accurate, 11.0× speedup?

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(y - 1\right) - \left(y \cdot 0.5 - 0.918938533204673\right)} \]
    2. 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 77.0%

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

    \[\leadsto \color{blue}{0.918938533204673} \]
  6. Final simplification22.8%

    \[\leadsto 0.918938533204673 \]

Reproduce

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