Data.Colour.SRGB:invTransferFunction from colour-2.3.3

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

Specification

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

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

    \[\frac{x + y}{y + 1} \]
  2. Final simplification100.0%

    \[\leadsto \frac{x + y}{y + 1} \]

Alternative 2: 74.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{y + 1}\\ t_1 := \frac{y}{y + 1}\\ \mathbf{if}\;x \leq -1.3 \cdot 10^{+89}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -7.8 \cdot 10^{+18}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6.6 \cdot 10^{-12}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.8 \cdot 10^{-42}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (+ y 1.0))) (t_1 (/ y (+ y 1.0))))
   (if (<= x -1.3e+89)
     t_0
     (if (<= x -7.8e+18)
       t_1
       (if (<= x -6.6e-12) x (if (<= x 9.8e-42) t_1 t_0))))))
double code(double x, double y) {
	double t_0 = x / (y + 1.0);
	double t_1 = y / (y + 1.0);
	double tmp;
	if (x <= -1.3e+89) {
		tmp = t_0;
	} else if (x <= -7.8e+18) {
		tmp = t_1;
	} else if (x <= -6.6e-12) {
		tmp = x;
	} else if (x <= 9.8e-42) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x / (y + 1.0d0)
    t_1 = y / (y + 1.0d0)
    if (x <= (-1.3d+89)) then
        tmp = t_0
    else if (x <= (-7.8d+18)) then
        tmp = t_1
    else if (x <= (-6.6d-12)) then
        tmp = x
    else if (x <= 9.8d-42) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x / (y + 1.0);
	double t_1 = y / (y + 1.0);
	double tmp;
	if (x <= -1.3e+89) {
		tmp = t_0;
	} else if (x <= -7.8e+18) {
		tmp = t_1;
	} else if (x <= -6.6e-12) {
		tmp = x;
	} else if (x <= 9.8e-42) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (y + 1.0)
	t_1 = y / (y + 1.0)
	tmp = 0
	if x <= -1.3e+89:
		tmp = t_0
	elif x <= -7.8e+18:
		tmp = t_1
	elif x <= -6.6e-12:
		tmp = x
	elif x <= 9.8e-42:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(y + 1.0))
	t_1 = Float64(y / Float64(y + 1.0))
	tmp = 0.0
	if (x <= -1.3e+89)
		tmp = t_0;
	elseif (x <= -7.8e+18)
		tmp = t_1;
	elseif (x <= -6.6e-12)
		tmp = x;
	elseif (x <= 9.8e-42)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (y + 1.0);
	t_1 = y / (y + 1.0);
	tmp = 0.0;
	if (x <= -1.3e+89)
		tmp = t_0;
	elseif (x <= -7.8e+18)
		tmp = t_1;
	elseif (x <= -6.6e-12)
		tmp = x;
	elseif (x <= 9.8e-42)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.3e+89], t$95$0, If[LessEqual[x, -7.8e+18], t$95$1, If[LessEqual[x, -6.6e-12], x, If[LessEqual[x, 9.8e-42], t$95$1, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x}{y + 1}\\
t_1 := \frac{y}{y + 1}\\
\mathbf{if}\;x \leq -1.3 \cdot 10^{+89}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -7.8 \cdot 10^{+18}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -6.6 \cdot 10^{-12}:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq 9.8 \cdot 10^{-42}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.3e89 or 9.8000000000000001e-42 < x

    1. Initial program 100.0%

      \[\frac{x + y}{y + 1} \]
    2. Taylor expanded in x around inf 80.9%

      \[\leadsto \color{blue}{\frac{x}{1 + y}} \]
    3. Step-by-step derivation
      1. +-commutative80.9%

        \[\leadsto \frac{x}{\color{blue}{y + 1}} \]
    4. Simplified80.9%

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

    if -1.3e89 < x < -7.8e18 or -6.6000000000000001e-12 < x < 9.8000000000000001e-42

    1. Initial program 100.0%

      \[\frac{x + y}{y + 1} \]
    2. Taylor expanded in x around 0 81.7%

      \[\leadsto \color{blue}{\frac{y}{1 + y}} \]
    3. Step-by-step derivation
      1. +-commutative81.7%

        \[\leadsto \frac{y}{\color{blue}{y + 1}} \]
    4. Simplified81.7%

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

    if -7.8e18 < x < -6.6000000000000001e-12

    1. Initial program 100.0%

      \[\frac{x + y}{y + 1} \]
    2. Taylor expanded in y around 0 100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.3 \cdot 10^{+89}:\\ \;\;\;\;\frac{x}{y + 1}\\ \mathbf{elif}\;x \leq -7.8 \cdot 10^{+18}:\\ \;\;\;\;\frac{y}{y + 1}\\ \mathbf{elif}\;x \leq -6.6 \cdot 10^{-12}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.8 \cdot 10^{-42}:\\ \;\;\;\;\frac{y}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y + 1}\\ \end{array} \]

Alternative 3: 86.7% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -8000000 \lor \neg \left(y \leq 820000\right):\\ \;\;\;\;\frac{x + y}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y + 1}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -8000000.0) (not (<= y 820000.0)))
   (/ (+ x y) y)
   (/ x (+ y 1.0))))
double code(double x, double y) {
	double tmp;
	if ((y <= -8000000.0) || !(y <= 820000.0)) {
		tmp = (x + y) / y;
	} else {
		tmp = x / (y + 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 <= (-8000000.0d0)) .or. (.not. (y <= 820000.0d0))) then
        tmp = (x + y) / y
    else
        tmp = x / (y + 1.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((y <= -8000000.0) || !(y <= 820000.0)) {
		tmp = (x + y) / y;
	} else {
		tmp = x / (y + 1.0);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -8000000.0) or not (y <= 820000.0):
		tmp = (x + y) / y
	else:
		tmp = x / (y + 1.0)
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -8000000.0) || !(y <= 820000.0))
		tmp = Float64(Float64(x + y) / y);
	else
		tmp = Float64(x / Float64(y + 1.0));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y <= -8000000.0) || ~((y <= 820000.0)))
		tmp = (x + y) / y;
	else
		tmp = x / (y + 1.0);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -8000000.0], N[Not[LessEqual[y, 820000.0]], $MachinePrecision]], N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision], N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8e6 or 8.2e5 < y

    1. Initial program 100.0%

      \[\frac{x + y}{y + 1} \]
    2. Step-by-step derivation
      1. clear-num99.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{y + 1}{x + y}}} \]
      2. associate-/r/99.7%

        \[\leadsto \color{blue}{\frac{1}{y + 1} \cdot \left(x + y\right)} \]
    3. Applied egg-rr99.7%

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

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

        \[\leadsto \color{blue}{\left(x + y\right) \cdot \frac{1}{y}} \]
      2. div-inv99.3%

        \[\leadsto \color{blue}{\frac{x + y}{y}} \]
      3. +-commutative99.3%

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

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

    if -8e6 < y < 8.2e5

    1. Initial program 100.0%

      \[\frac{x + y}{y + 1} \]
    2. Taylor expanded in x around inf 73.0%

      \[\leadsto \color{blue}{\frac{x}{1 + y}} \]
    3. Step-by-step derivation
      1. +-commutative73.0%

        \[\leadsto \frac{x}{\color{blue}{y + 1}} \]
    4. Simplified73.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8000000 \lor \neg \left(y \leq 820000\right):\\ \;\;\;\;\frac{x + y}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y + 1}\\ \end{array} \]

Alternative 4: 72.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.45 \cdot 10^{+102}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 3 \cdot 10^{+96}:\\ \;\;\;\;\frac{x}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -1.45e+102) 1.0 (if (<= y 3e+96) (/ x (+ y 1.0)) 1.0)))
double code(double x, double y) {
	double tmp;
	if (y <= -1.45e+102) {
		tmp = 1.0;
	} else if (y <= 3e+96) {
		tmp = x / (y + 1.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) :: tmp
    if (y <= (-1.45d+102)) then
        tmp = 1.0d0
    else if (y <= 3d+96) then
        tmp = x / (y + 1.0d0)
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -1.45e+102) {
		tmp = 1.0;
	} else if (y <= 3e+96) {
		tmp = x / (y + 1.0);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -1.45e+102:
		tmp = 1.0
	elif y <= 3e+96:
		tmp = x / (y + 1.0)
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -1.45e+102)
		tmp = 1.0;
	elseif (y <= 3e+96)
		tmp = Float64(x / Float64(y + 1.0));
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -1.45e+102)
		tmp = 1.0;
	elseif (y <= 3e+96)
		tmp = x / (y + 1.0);
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -1.45e+102], 1.0, If[LessEqual[y, 3e+96], N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 3 \cdot 10^{+96}:\\
\;\;\;\;\frac{x}{y + 1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.4500000000000001e102 or 3e96 < y

    1. Initial program 100.0%

      \[\frac{x + y}{y + 1} \]
    2. Taylor expanded in y around inf 77.2%

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

    if -1.4500000000000001e102 < y < 3e96

    1. Initial program 100.0%

      \[\frac{x + y}{y + 1} \]
    2. Taylor expanded in x around inf 70.6%

      \[\leadsto \color{blue}{\frac{x}{1 + y}} \]
    3. Step-by-step derivation
      1. +-commutative70.6%

        \[\leadsto \frac{x}{\color{blue}{y + 1}} \]
    4. Simplified70.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.45 \cdot 10^{+102}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 3 \cdot 10^{+96}:\\ \;\;\;\;\frac{x}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 5: 70.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{+102}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -920000000000:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-29}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -3.5e+102)
   1.0
   (if (<= y -920000000000.0) (/ x y) (if (<= y 1.4e-29) x 1.0))))
double code(double x, double y) {
	double tmp;
	if (y <= -3.5e+102) {
		tmp = 1.0;
	} else if (y <= -920000000000.0) {
		tmp = x / y;
	} else if (y <= 1.4e-29) {
		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 <= (-3.5d+102)) then
        tmp = 1.0d0
    else if (y <= (-920000000000.0d0)) then
        tmp = x / y
    else if (y <= 1.4d-29) 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 <= -3.5e+102) {
		tmp = 1.0;
	} else if (y <= -920000000000.0) {
		tmp = x / y;
	} else if (y <= 1.4e-29) {
		tmp = x;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -3.5e+102:
		tmp = 1.0
	elif y <= -920000000000.0:
		tmp = x / y
	elif y <= 1.4e-29:
		tmp = x
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -3.5e+102)
		tmp = 1.0;
	elseif (y <= -920000000000.0)
		tmp = Float64(x / y);
	elseif (y <= 1.4e-29)
		tmp = x;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -3.5e+102)
		tmp = 1.0;
	elseif (y <= -920000000000.0)
		tmp = x / y;
	elseif (y <= 1.4e-29)
		tmp = x;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -3.5e+102], 1.0, If[LessEqual[y, -920000000000.0], N[(x / y), $MachinePrecision], If[LessEqual[y, 1.4e-29], x, 1.0]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -920000000000:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;y \leq 1.4 \cdot 10^{-29}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -3.50000000000000011e102 or 1.4000000000000001e-29 < y

    1. Initial program 100.0%

      \[\frac{x + y}{y + 1} \]
    2. Taylor expanded in y around inf 70.4%

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

    if -3.50000000000000011e102 < y < -9.2e11

    1. Initial program 99.9%

      \[\frac{x + y}{y + 1} \]
    2. Taylor expanded in x around inf 67.1%

      \[\leadsto \color{blue}{\frac{x}{1 + y}} \]
    3. Step-by-step derivation
      1. +-commutative67.1%

        \[\leadsto \frac{x}{\color{blue}{y + 1}} \]
    4. Simplified67.1%

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

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

    if -9.2e11 < y < 1.4000000000000001e-29

    1. Initial program 100.0%

      \[\frac{x + y}{y + 1} \]
    2. Taylor expanded in y around 0 73.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{+102}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -920000000000:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-29}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 6: 72.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-29}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -1.0) 1.0 (if (<= y 1.4e-29) x 1.0)))
double code(double x, double y) {
	double tmp;
	if (y <= -1.0) {
		tmp = 1.0;
	} else if (y <= 1.4e-29) {
		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 <= (-1.0d0)) then
        tmp = 1.0d0
    else if (y <= 1.4d-29) 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 <= -1.0) {
		tmp = 1.0;
	} else if (y <= 1.4e-29) {
		tmp = x;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -1.0:
		tmp = 1.0
	elif y <= 1.4e-29:
		tmp = x
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -1.0)
		tmp = 1.0;
	elseif (y <= 1.4e-29)
		tmp = x;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -1.0)
		tmp = 1.0;
	elseif (y <= 1.4e-29)
		tmp = x;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, 1.4e-29], x, 1.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq 1.4 \cdot 10^{-29}:\\
\;\;\;\;x\\

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


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

    1. Initial program 100.0%

      \[\frac{x + y}{y + 1} \]
    2. Taylor expanded in y around inf 65.6%

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

    if -1 < y < 1.4000000000000001e-29

    1. Initial program 100.0%

      \[\frac{x + y}{y + 1} \]
    2. Taylor expanded in y around 0 74.4%

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

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

Alternative 7: 38.7% 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}{y + 1} \]
  2. Taylor expanded in y around inf 36.2%

    \[\leadsto \color{blue}{1} \]
  3. Final simplification36.2%

    \[\leadsto 1 \]

Reproduce

?
herbie shell --seed 2023257 
(FPCore (x y)
  :name "Data.Colour.SRGB:invTransferFunction from colour-2.3.3"
  :precision binary64
  (/ (+ x y) (+ y 1.0)))