Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, C

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

Specification

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

\\
\frac{x - y}{1 - y}
\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} \\ \frac{x - y}{1 - y} \end{array} \]
(FPCore (x y) :precision binary64 (/ (- x y) (- 1.0 y)))
double code(double x, double y) {
	return (x - y) / (1.0 - y);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x - y) / (1.0d0 - y)
end function
public static double code(double x, double y) {
	return (x - y) / (1.0 - y);
}
def code(x, y):
	return (x - y) / (1.0 - y)
function code(x, y)
	return Float64(Float64(x - y) / Float64(1.0 - y))
end
function tmp = code(x, y)
	tmp = (x - y) / (1.0 - y);
end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x - y}{1 - y}
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

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

\\
\frac{x - y}{1 - y}
\end{array}
Derivation
  1. Initial program 100.0%

    \[\frac{x - y}{1 - y} \]
  2. Add Preprocessing
  3. Final simplification100.0%

    \[\leadsto \frac{x - y}{1 - y} \]
  4. Add Preprocessing

Alternative 2: 73.2% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{1 - y}\\ \mathbf{if}\;x \leq -8 \cdot 10^{-16}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 7.3 \cdot 10^{-40}:\\ \;\;\;\;\frac{y}{y + -1}\\ \mathbf{elif}\;x \leq 580:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{+27}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{+144} \lor \neg \left(x \leq 1.6 \cdot 10^{+170}\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (- 1.0 y))))
   (if (<= x -8e-16)
     t_0
     (if (<= x 7.3e-40)
       (/ y (+ y -1.0))
       (if (<= x 580.0)
         x
         (if (<= x 9.6e+27)
           1.0
           (if (or (<= x 4.6e+144) (not (<= x 1.6e+170))) t_0 1.0)))))))
double code(double x, double y) {
	double t_0 = x / (1.0 - y);
	double tmp;
	if (x <= -8e-16) {
		tmp = t_0;
	} else if (x <= 7.3e-40) {
		tmp = y / (y + -1.0);
	} else if (x <= 580.0) {
		tmp = x;
	} else if (x <= 9.6e+27) {
		tmp = 1.0;
	} else if ((x <= 4.6e+144) || !(x <= 1.6e+170)) {
		tmp = t_0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x / (1.0d0 - y)
    if (x <= (-8d-16)) then
        tmp = t_0
    else if (x <= 7.3d-40) then
        tmp = y / (y + (-1.0d0))
    else if (x <= 580.0d0) then
        tmp = x
    else if (x <= 9.6d+27) then
        tmp = 1.0d0
    else if ((x <= 4.6d+144) .or. (.not. (x <= 1.6d+170))) then
        tmp = t_0
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x / (1.0 - y);
	double tmp;
	if (x <= -8e-16) {
		tmp = t_0;
	} else if (x <= 7.3e-40) {
		tmp = y / (y + -1.0);
	} else if (x <= 580.0) {
		tmp = x;
	} else if (x <= 9.6e+27) {
		tmp = 1.0;
	} else if ((x <= 4.6e+144) || !(x <= 1.6e+170)) {
		tmp = t_0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (1.0 - y)
	tmp = 0
	if x <= -8e-16:
		tmp = t_0
	elif x <= 7.3e-40:
		tmp = y / (y + -1.0)
	elif x <= 580.0:
		tmp = x
	elif x <= 9.6e+27:
		tmp = 1.0
	elif (x <= 4.6e+144) or not (x <= 1.6e+170):
		tmp = t_0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(1.0 - y))
	tmp = 0.0
	if (x <= -8e-16)
		tmp = t_0;
	elseif (x <= 7.3e-40)
		tmp = Float64(y / Float64(y + -1.0));
	elseif (x <= 580.0)
		tmp = x;
	elseif (x <= 9.6e+27)
		tmp = 1.0;
	elseif ((x <= 4.6e+144) || !(x <= 1.6e+170))
		tmp = t_0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (1.0 - y);
	tmp = 0.0;
	if (x <= -8e-16)
		tmp = t_0;
	elseif (x <= 7.3e-40)
		tmp = y / (y + -1.0);
	elseif (x <= 580.0)
		tmp = x;
	elseif (x <= 9.6e+27)
		tmp = 1.0;
	elseif ((x <= 4.6e+144) || ~((x <= 1.6e+170)))
		tmp = t_0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -8e-16], t$95$0, If[LessEqual[x, 7.3e-40], N[(y / N[(y + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 580.0], x, If[LessEqual[x, 9.6e+27], 1.0, If[Or[LessEqual[x, 4.6e+144], N[Not[LessEqual[x, 1.6e+170]], $MachinePrecision]], t$95$0, 1.0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x}{1 - y}\\
\mathbf{if}\;x \leq -8 \cdot 10^{-16}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 7.3 \cdot 10^{-40}:\\
\;\;\;\;\frac{y}{y + -1}\\

\mathbf{elif}\;x \leq 580:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq 9.6 \cdot 10^{+27}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 4.6 \cdot 10^{+144} \lor \neg \left(x \leq 1.6 \cdot 10^{+170}\right):\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -7.9999999999999998e-16 or 9.59999999999999991e27 < x < 4.6000000000000003e144 or 1.59999999999999989e170 < x

    1. Initial program 100.0%

      \[\frac{x - y}{1 - y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 84.4%

      \[\leadsto \color{blue}{\frac{x}{1 - y}} \]

    if -7.9999999999999998e-16 < x < 7.30000000000000005e-40

    1. Initial program 100.0%

      \[\frac{x - y}{1 - y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 80.2%

      \[\leadsto \color{blue}{-1 \cdot \frac{y}{1 - y}} \]
    4. Step-by-step derivation
      1. neg-mul-180.2%

        \[\leadsto \color{blue}{-\frac{y}{1 - y}} \]
      2. distribute-neg-frac280.2%

        \[\leadsto \color{blue}{\frac{y}{-\left(1 - y\right)}} \]
      3. neg-sub080.2%

        \[\leadsto \frac{y}{\color{blue}{0 - \left(1 - y\right)}} \]
      4. associate--r-80.2%

        \[\leadsto \frac{y}{\color{blue}{\left(0 - 1\right) + y}} \]
      5. metadata-eval80.2%

        \[\leadsto \frac{y}{\color{blue}{-1} + y} \]
    5. Simplified80.2%

      \[\leadsto \color{blue}{\frac{y}{-1 + y}} \]

    if 7.30000000000000005e-40 < x < 580

    1. Initial program 100.0%

      \[\frac{x - y}{1 - y} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 72.9%

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

    if 580 < x < 9.59999999999999991e27 or 4.6000000000000003e144 < x < 1.59999999999999989e170

    1. Initial program 99.9%

      \[\frac{x - y}{1 - y} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 89.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -8 \cdot 10^{-16}:\\ \;\;\;\;\frac{x}{1 - y}\\ \mathbf{elif}\;x \leq 7.3 \cdot 10^{-40}:\\ \;\;\;\;\frac{y}{y + -1}\\ \mathbf{elif}\;x \leq 580:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{+27}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{+144} \lor \neg \left(x \leq 1.6 \cdot 10^{+170}\right):\\ \;\;\;\;\frac{x}{1 - y}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 87.2% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1600 \lor \neg \left(y \leq 7000000000000\right):\\
\;\;\;\;1 + \frac{1 - x}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{1 - y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1600 or 7e12 < y

    1. Initial program 100.0%

      \[\frac{x - y}{1 - y} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 99.6%

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

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

        \[\leadsto 1 + \left(\frac{1}{y} + \color{blue}{\left(-\frac{x}{y}\right)}\right) \]
      3. unsub-neg99.6%

        \[\leadsto 1 + \color{blue}{\left(\frac{1}{y} - \frac{x}{y}\right)} \]
      4. div-sub99.6%

        \[\leadsto 1 + \color{blue}{\frac{1 - x}{y}} \]
    5. Simplified99.6%

      \[\leadsto \color{blue}{1 + \frac{1 - x}{y}} \]

    if -1600 < y < 7e12

    1. Initial program 100.0%

      \[\frac{x - y}{1 - y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 70.8%

      \[\leadsto \color{blue}{\frac{x}{1 - y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification84.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1600 \lor \neg \left(y \leq 7000000000000\right):\\ \;\;\;\;1 + \frac{1 - x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{1 - y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 87.1% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -620 \lor \neg \left(y \leq 7000000000000\right):\\
\;\;\;\;1 - \frac{x}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{1 - y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -620 or 7e12 < y

    1. Initial program 100.0%

      \[\frac{x - y}{1 - y} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 99.6%

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

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

        \[\leadsto 1 + \left(\frac{1}{y} + \color{blue}{\left(-\frac{x}{y}\right)}\right) \]
      3. unsub-neg99.6%

        \[\leadsto 1 + \color{blue}{\left(\frac{1}{y} - \frac{x}{y}\right)} \]
      4. div-sub99.6%

        \[\leadsto 1 + \color{blue}{\frac{1 - x}{y}} \]
    5. Simplified99.6%

      \[\leadsto \color{blue}{1 + \frac{1 - x}{y}} \]
    6. Taylor expanded in x around inf 99.1%

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

        \[\leadsto 1 + \color{blue}{\left(-\frac{x}{y}\right)} \]
      2. distribute-neg-frac299.1%

        \[\leadsto 1 + \color{blue}{\frac{x}{-y}} \]
    8. Simplified99.1%

      \[\leadsto 1 + \color{blue}{\frac{x}{-y}} \]

    if -620 < y < 7e12

    1. Initial program 100.0%

      \[\frac{x - y}{1 - y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 70.8%

      \[\leadsto \color{blue}{\frac{x}{1 - y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification84.5%

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

Alternative 5: 75.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+57}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq 4 \cdot 10^{+48}:\\
\;\;\;\;\frac{x}{1 - y}\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.9999999999999999e57 or 4.00000000000000018e48 < y

    1. Initial program 100.0%

      \[\frac{x - y}{1 - y} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 78.1%

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

    if -5.9999999999999999e57 < y < 4.00000000000000018e48

    1. Initial program 100.0%

      \[\frac{x - y}{1 - y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 68.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6 \cdot 10^{+57}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+48}:\\ \;\;\;\;\frac{x}{1 - y}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 73.7% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{-27}:\\
\;\;\;\;1\\

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

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -7.50000000000000029e-27 or 1 < y

    1. Initial program 100.0%

      \[\frac{x - y}{1 - y} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 68.3%

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

    if -7.50000000000000029e-27 < y < 1

    1. Initial program 100.0%

      \[\frac{x - y}{1 - y} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 72.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.5 \cdot 10^{-27}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 38.9% accurate, 7.0× speedup?

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

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

    \[\frac{x - y}{1 - y} \]
  2. Add Preprocessing
  3. Taylor expanded in y around inf 37.1%

    \[\leadsto \color{blue}{1} \]
  4. Final simplification37.1%

    \[\leadsto 1 \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2024040 
(FPCore (x y)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, C"
  :precision binary64
  (/ (- x y) (- 1.0 y)))