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

Percentage Accurate: 100.0% → 100.0%
Time: 5.4s
Alternatives: 10
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 10 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: 50.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -4.5 \cdot 10^{+238}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{+125}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -6.8 \cdot 10^{+81}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -3700000000000:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 1.85:\\ \;\;\;\;0.918938533204673\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -4.5e+238)
   (* y -0.5)
   (if (<= y -2.5e+125)
     (* x y)
     (if (<= y -6.8e+81)
       (* y -0.5)
       (if (<= y -3700000000000.0)
         (* x y)
         (if (<= y 1.85) 0.918938533204673 (* y -0.5)))))))
double code(double x, double y) {
	double tmp;
	if (y <= -4.5e+238) {
		tmp = y * -0.5;
	} else if (y <= -2.5e+125) {
		tmp = x * y;
	} else if (y <= -6.8e+81) {
		tmp = y * -0.5;
	} else if (y <= -3700000000000.0) {
		tmp = x * y;
	} else if (y <= 1.85) {
		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 <= (-4.5d+238)) then
        tmp = y * (-0.5d0)
    else if (y <= (-2.5d+125)) then
        tmp = x * y
    else if (y <= (-6.8d+81)) then
        tmp = y * (-0.5d0)
    else if (y <= (-3700000000000.0d0)) then
        tmp = x * y
    else if (y <= 1.85d0) 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 <= -4.5e+238) {
		tmp = y * -0.5;
	} else if (y <= -2.5e+125) {
		tmp = x * y;
	} else if (y <= -6.8e+81) {
		tmp = y * -0.5;
	} else if (y <= -3700000000000.0) {
		tmp = x * y;
	} else if (y <= 1.85) {
		tmp = 0.918938533204673;
	} else {
		tmp = y * -0.5;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -4.5e+238:
		tmp = y * -0.5
	elif y <= -2.5e+125:
		tmp = x * y
	elif y <= -6.8e+81:
		tmp = y * -0.5
	elif y <= -3700000000000.0:
		tmp = x * y
	elif y <= 1.85:
		tmp = 0.918938533204673
	else:
		tmp = y * -0.5
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -4.5e+238)
		tmp = Float64(y * -0.5);
	elseif (y <= -2.5e+125)
		tmp = Float64(x * y);
	elseif (y <= -6.8e+81)
		tmp = Float64(y * -0.5);
	elseif (y <= -3700000000000.0)
		tmp = Float64(x * y);
	elseif (y <= 1.85)
		tmp = 0.918938533204673;
	else
		tmp = Float64(y * -0.5);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -4.5e+238)
		tmp = y * -0.5;
	elseif (y <= -2.5e+125)
		tmp = x * y;
	elseif (y <= -6.8e+81)
		tmp = y * -0.5;
	elseif (y <= -3700000000000.0)
		tmp = x * y;
	elseif (y <= 1.85)
		tmp = 0.918938533204673;
	else
		tmp = y * -0.5;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -4.5e+238], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -2.5e+125], N[(x * y), $MachinePrecision], If[LessEqual[y, -6.8e+81], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -3700000000000.0], N[(x * y), $MachinePrecision], If[LessEqual[y, 1.85], 0.918938533204673, N[(y * -0.5), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -2.5 \cdot 10^{+125}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;y \leq -6.8 \cdot 10^{+81}:\\
\;\;\;\;y \cdot -0.5\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -4.5e238 or -2.49999999999999981e125 < y < -6.80000000000000005e81 or 1.8500000000000001 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if -4.5e238 < y < -2.49999999999999981e125 or -6.80000000000000005e81 < y < -3.7e12

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot x} \]
    7. Simplified72.4%

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

    if -3.7e12 < y < 1.8500000000000001

    1. Initial program 100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.5 \cdot 10^{+238}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{+125}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -6.8 \cdot 10^{+81}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -3700000000000:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 1.85:\\ \;\;\;\;0.918938533204673\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \]

Alternative 3: 98.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
t_0 := 0.918938533204673 - y \cdot 0.5\\
\mathbf{if}\;y \leq -4200000000000:\\
\;\;\;\;x \cdot y + y \cdot -0.5\\

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot y} - \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)} \]
    6. Step-by-step derivation
      1. sub-neg100.0%

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

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

        \[\leadsto \color{blue}{y \cdot x + y \cdot -0.5} \]
    7. Applied egg-rr100.0%

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

    if -4.2e12 < y < 1

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if 1 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

Alternative 4: 74.8% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.7e12 or 4.3e8 < y

    1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot y} - \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)} \]
    6. Step-by-step derivation
      1. sub-neg100.0%

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

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

        \[\leadsto \color{blue}{y \cdot x + y \cdot -0.5} \]
    7. Applied egg-rr100.0%

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

    if -3.7e12 < y < 4.3e8

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

Alternative 5: 98.4% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot y} - \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)} \]
    6. Step-by-step derivation
      1. sub-neg100.0%

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

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

        \[\leadsto \color{blue}{y \cdot x + y \cdot -0.5} \]
    7. Applied egg-rr100.0%

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

    if -3.7e12 < y < 3e7

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

Alternative 6: 73.9% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{-21} \lor \neg \left(y \leq 1.8\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 < -2.99999999999999991e-21 or 1.80000000000000004 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if -2.99999999999999991e-21 < y < 1.80000000000000004

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

Alternative 7: 74.8% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3700000000000 \lor \neg \left(y \leq 3800000\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 -3700000000000.0) (not (<= y 3800000.0)))
   (* y (- x 0.5))
   (- 0.918938533204673 (* y 0.5))))
double code(double x, double y) {
	double tmp;
	if ((y <= -3700000000000.0) || !(y <= 3800000.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 <= (-3700000000000.0d0)) .or. (.not. (y <= 3800000.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 <= -3700000000000.0) || !(y <= 3800000.0)) {
		tmp = y * (x - 0.5);
	} else {
		tmp = 0.918938533204673 - (y * 0.5);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -3700000000000.0) or not (y <= 3800000.0):
		tmp = y * (x - 0.5)
	else:
		tmp = 0.918938533204673 - (y * 0.5)
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -3700000000000.0) || !(y <= 3800000.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 <= -3700000000000.0) || ~((y <= 3800000.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, -3700000000000.0], N[Not[LessEqual[y, 3800000.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 -3700000000000 \lor \neg \left(y \leq 3800000\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 < -3.7e12 or 3.8e6 < y

    1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot y} - \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 -3.7e12 < y < 3.8e6

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

Alternative 8: 49.5% accurate, 1.5× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if -1.82000000000000006 < y < 1.8500000000000001

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 25.7% accurate, 11.0× speedup?

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.918938533204673} \]
  6. Final simplification25.2%

    \[\leadsto 0.918938533204673 \]

Reproduce

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