Data.Colour.SRGB:invTransferFunction from colour-2.3.3

Percentage Accurate: 100.0% → 100.0%
Time: 1.7s
Alternatives: 9
Speedup: 0.8×

Specification

?
\[\frac{x + y}{y + 1} \]
(FPCore (x y)
  :precision binary64
  :pre TRUE
  (/ (+ x y) (+ y 1.0)))
double code(double x, double y) {
	return (x + y) / (y + 1.0);
}
real(8) function code(x, y)
use fmin_fmax_functions
    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]
f(x, y):
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(x, y: real): real =
	(x + y) / (y + (1))
END code
\frac{x + y}{y + 1}

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 9 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?

\[\frac{x + y}{y + 1} \]
(FPCore (x y)
  :precision binary64
  :pre TRUE
  (/ (+ x y) (+ y 1.0)))
double code(double x, double y) {
	return (x + y) / (y + 1.0);
}
real(8) function code(x, y)
use fmin_fmax_functions
    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]
f(x, y):
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(x, y: real): real =
	(x + y) / (y + (1))
END code
\frac{x + y}{y + 1}

Alternative 1: 100.0% accurate, 0.8× speedup?

\[\frac{x + y}{0.5 + \left(0.5 + y\right)} \]
(FPCore (x y)
  :precision binary64
  :pre TRUE
  (/ (+ x y) (+ 0.5 (+ 0.5 y))))
double code(double x, double y) {
	return (x + y) / (0.5 + (0.5 + y));
}
real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x + y) / (0.5d0 + (0.5d0 + y))
end function
public static double code(double x, double y) {
	return (x + y) / (0.5 + (0.5 + y));
}
def code(x, y):
	return (x + y) / (0.5 + (0.5 + y))
function code(x, y)
	return Float64(Float64(x + y) / Float64(0.5 + Float64(0.5 + y)))
end
function tmp = code(x, y)
	tmp = (x + y) / (0.5 + (0.5 + y));
end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] / N[(0.5 + N[(0.5 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x, y):
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(x, y: real): real =
	(x + y) / ((5e-1) + ((5e-1) + y))
END code
\frac{x + y}{0.5 + \left(0.5 + y\right)}
Derivation
  1. Initial program 100.0%

    \[\frac{x + y}{y + 1} \]
  2. Step-by-step derivation
    1. Applied rewrites100.0%

      \[\leadsto \frac{x + y}{0.5 + \left(0.5 + y\right)} \]
    2. Add Preprocessing

    Alternative 2: 98.3% accurate, 0.6× speedup?

    \[\begin{array}{l} t_0 := \frac{x - 1}{y} - -1\\ \mathbf{if}\;y \leq -6333.314074973118:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 546.1926757848701:\\ \;\;\;\;\frac{x + y}{1}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
    (FPCore (x y)
      :precision binary64
      :pre TRUE
      (let* ((t_0 (- (/ (- x 1.0) y) -1.0)))
      (if (<= y -6333.314074973118)
        t_0
        (if (<= y 546.1926757848701) (/ (+ x y) 1.0) t_0))))
    double code(double x, double y) {
    	double t_0 = ((x - 1.0) / y) - -1.0;
    	double tmp;
    	if (y <= -6333.314074973118) {
    		tmp = t_0;
    	} else if (y <= 546.1926757848701) {
    		tmp = (x + y) / 1.0;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    real(8) function code(x, y)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8) :: t_0
        real(8) :: tmp
        t_0 = ((x - 1.0d0) / y) - (-1.0d0)
        if (y <= (-6333.314074973118d0)) then
            tmp = t_0
        else if (y <= 546.1926757848701d0) then
            tmp = (x + y) / 1.0d0
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double x, double y) {
    	double t_0 = ((x - 1.0) / y) - -1.0;
    	double tmp;
    	if (y <= -6333.314074973118) {
    		tmp = t_0;
    	} else if (y <= 546.1926757848701) {
    		tmp = (x + y) / 1.0;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(x, y):
    	t_0 = ((x - 1.0) / y) - -1.0
    	tmp = 0
    	if y <= -6333.314074973118:
    		tmp = t_0
    	elif y <= 546.1926757848701:
    		tmp = (x + y) / 1.0
    	else:
    		tmp = t_0
    	return tmp
    
    function code(x, y)
    	t_0 = Float64(Float64(Float64(x - 1.0) / y) - -1.0)
    	tmp = 0.0
    	if (y <= -6333.314074973118)
    		tmp = t_0;
    	elseif (y <= 546.1926757848701)
    		tmp = Float64(Float64(x + y) / 1.0);
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y)
    	t_0 = ((x - 1.0) / y) - -1.0;
    	tmp = 0.0;
    	if (y <= -6333.314074973118)
    		tmp = t_0;
    	elseif (y <= 546.1926757848701)
    		tmp = (x + y) / 1.0;
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[y, -6333.314074973118], t$95$0, If[LessEqual[y, 546.1926757848701], N[(N[(x + y), $MachinePrecision] / 1.0), $MachinePrecision], t$95$0]]]
    
    f(x, y):
    	x in [-inf, +inf],
    	y in [-inf, +inf]
    code: THEORY
    BEGIN
    f(x, y: real): real =
    	LET t_0 = (((x - (1)) / y) - (-1)) IN
    		LET tmp_1 = IF (y <= (54619267578487006176146678626537322998046875e-41)) THEN ((x + y) / (1)) ELSE t_0 ENDIF IN
    		LET tmp = IF (y <= (-63333140749731182950199581682682037353515625e-40)) THEN t_0 ELSE tmp_1 ENDIF IN
    	tmp
    END code
    \begin{array}{l}
    t_0 := \frac{x - 1}{y} - -1\\
    \mathbf{if}\;y \leq -6333.314074973118:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;y \leq 546.1926757848701:\\
    \;\;\;\;\frac{x + y}{1}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < -6333.3140749731183 or 546.19267578487006 < y

      1. Initial program 100.0%

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

        \[\leadsto \left(1 + \frac{x}{y}\right) - \frac{1}{y} \]
      3. Step-by-step derivation
        1. Applied rewrites51.1%

          \[\leadsto \left(1 + \frac{x}{y}\right) - \frac{1}{y} \]
        2. Step-by-step derivation
          1. Applied rewrites51.1%

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

          if -6333.3140749731183 < y < 546.19267578487006

          1. Initial program 100.0%

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

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

              \[\leadsto \frac{x + y}{1} \]
          4. Recombined 2 regimes into one program.
          5. Add Preprocessing

          Alternative 3: 98.1% accurate, 0.2× speedup?

          \[\begin{array}{l} t_0 := \frac{x + y}{y + 1}\\ t_1 := \frac{x}{1 + y}\\ \mathbf{if}\;t\_0 \leq -200:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 0.05:\\ \;\;\;\;\frac{x + y}{1}\\ \mathbf{elif}\;t\_0 \leq 2:\\ \;\;\;\;\frac{y}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
          (FPCore (x y)
            :precision binary64
            :pre TRUE
            (let* ((t_0 (/ (+ x y) (+ y 1.0))) (t_1 (/ x (+ 1.0 y))))
            (if (<= t_0 -200.0)
              t_1
              (if (<= t_0 0.05)
                (/ (+ x y) 1.0)
                (if (<= t_0 2.0) (/ y (+ y 1.0)) t_1)))))
          double code(double x, double y) {
          	double t_0 = (x + y) / (y + 1.0);
          	double t_1 = x / (1.0 + y);
          	double tmp;
          	if (t_0 <= -200.0) {
          		tmp = t_1;
          	} else if (t_0 <= 0.05) {
          		tmp = (x + y) / 1.0;
          	} else if (t_0 <= 2.0) {
          		tmp = y / (y + 1.0);
          	} else {
          		tmp = t_1;
          	}
          	return tmp;
          }
          
          real(8) function code(x, y)
          use fmin_fmax_functions
              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) / (y + 1.0d0)
              t_1 = x / (1.0d0 + y)
              if (t_0 <= (-200.0d0)) then
                  tmp = t_1
              else if (t_0 <= 0.05d0) then
                  tmp = (x + y) / 1.0d0
              else if (t_0 <= 2.0d0) then
                  tmp = y / (y + 1.0d0)
              else
                  tmp = t_1
              end if
              code = tmp
          end function
          
          public static double code(double x, double y) {
          	double t_0 = (x + y) / (y + 1.0);
          	double t_1 = x / (1.0 + y);
          	double tmp;
          	if (t_0 <= -200.0) {
          		tmp = t_1;
          	} else if (t_0 <= 0.05) {
          		tmp = (x + y) / 1.0;
          	} else if (t_0 <= 2.0) {
          		tmp = y / (y + 1.0);
          	} else {
          		tmp = t_1;
          	}
          	return tmp;
          }
          
          def code(x, y):
          	t_0 = (x + y) / (y + 1.0)
          	t_1 = x / (1.0 + y)
          	tmp = 0
          	if t_0 <= -200.0:
          		tmp = t_1
          	elif t_0 <= 0.05:
          		tmp = (x + y) / 1.0
          	elif t_0 <= 2.0:
          		tmp = y / (y + 1.0)
          	else:
          		tmp = t_1
          	return tmp
          
          function code(x, y)
          	t_0 = Float64(Float64(x + y) / Float64(y + 1.0))
          	t_1 = Float64(x / Float64(1.0 + y))
          	tmp = 0.0
          	if (t_0 <= -200.0)
          		tmp = t_1;
          	elseif (t_0 <= 0.05)
          		tmp = Float64(Float64(x + y) / 1.0);
          	elseif (t_0 <= 2.0)
          		tmp = Float64(y / Float64(y + 1.0));
          	else
          		tmp = t_1;
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y)
          	t_0 = (x + y) / (y + 1.0);
          	t_1 = x / (1.0 + y);
          	tmp = 0.0;
          	if (t_0 <= -200.0)
          		tmp = t_1;
          	elseif (t_0 <= 0.05)
          		tmp = (x + y) / 1.0;
          	elseif (t_0 <= 2.0)
          		tmp = y / (y + 1.0);
          	else
          		tmp = t_1;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -200.0], t$95$1, If[LessEqual[t$95$0, 0.05], N[(N[(x + y), $MachinePrecision] / 1.0), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
          
          f(x, y):
          	x in [-inf, +inf],
          	y in [-inf, +inf]
          code: THEORY
          BEGIN
          f(x, y: real): real =
          	LET t_0 = ((x + y) / (y + (1))) IN
          		LET t_1 = (x / ((1) + y)) IN
          			LET tmp_2 = IF (t_0 <= (2)) THEN (y / (y + (1))) ELSE t_1 ENDIF IN
          			LET tmp_1 = IF (t_0 <= (5000000000000000277555756156289135105907917022705078125e-56)) THEN ((x + y) / (1)) ELSE tmp_2 ENDIF IN
          			LET tmp = IF (t_0 <= (-200)) THEN t_1 ELSE tmp_1 ENDIF IN
          	tmp
          END code
          \begin{array}{l}
          t_0 := \frac{x + y}{y + 1}\\
          t_1 := \frac{x}{1 + y}\\
          \mathbf{if}\;t\_0 \leq -200:\\
          \;\;\;\;t\_1\\
          
          \mathbf{elif}\;t\_0 \leq 0.05:\\
          \;\;\;\;\frac{x + y}{1}\\
          
          \mathbf{elif}\;t\_0 \leq 2:\\
          \;\;\;\;\frac{y}{y + 1}\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_1\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if (/.f64 (+.f64 x y) (+.f64 y #s(literal 1 binary64))) < -200 or 2 < (/.f64 (+.f64 x y) (+.f64 y #s(literal 1 binary64)))

            1. Initial program 100.0%

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

              \[\leadsto \frac{x}{1 + y} \]
            3. Step-by-step derivation
              1. Applied rewrites50.2%

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

              if -200 < (/.f64 (+.f64 x y) (+.f64 y #s(literal 1 binary64))) < 0.050000000000000003

              1. Initial program 100.0%

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

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

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

                if 0.050000000000000003 < (/.f64 (+.f64 x y) (+.f64 y #s(literal 1 binary64))) < 2

                1. Initial program 100.0%

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

                  \[\leadsto \frac{y}{y + 1} \]
                3. Step-by-step derivation
                  1. Applied rewrites51.3%

                    \[\leadsto \frac{y}{y + 1} \]
                4. Recombined 3 regimes into one program.
                5. Add Preprocessing

                Alternative 4: 97.8% accurate, 0.7× speedup?

                \[\begin{array}{l} t_0 := \frac{x}{y} - -1\\ \mathbf{if}\;y \leq -0.02470192540250247:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 3.227028658029451:\\ \;\;\;\;\frac{x + y}{1}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
                (FPCore (x y)
                  :precision binary64
                  :pre TRUE
                  (let* ((t_0 (- (/ x y) -1.0)))
                  (if (<= y -0.02470192540250247)
                    t_0
                    (if (<= y 3.227028658029451) (/ (+ x y) 1.0) t_0))))
                double code(double x, double y) {
                	double t_0 = (x / y) - -1.0;
                	double tmp;
                	if (y <= -0.02470192540250247) {
                		tmp = t_0;
                	} else if (y <= 3.227028658029451) {
                		tmp = (x + y) / 1.0;
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                real(8) function code(x, y)
                use fmin_fmax_functions
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    real(8) :: t_0
                    real(8) :: tmp
                    t_0 = (x / y) - (-1.0d0)
                    if (y <= (-0.02470192540250247d0)) then
                        tmp = t_0
                    else if (y <= 3.227028658029451d0) then
                        tmp = (x + y) / 1.0d0
                    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 tmp;
                	if (y <= -0.02470192540250247) {
                		tmp = t_0;
                	} else if (y <= 3.227028658029451) {
                		tmp = (x + y) / 1.0;
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                def code(x, y):
                	t_0 = (x / y) - -1.0
                	tmp = 0
                	if y <= -0.02470192540250247:
                		tmp = t_0
                	elif y <= 3.227028658029451:
                		tmp = (x + y) / 1.0
                	else:
                		tmp = t_0
                	return tmp
                
                function code(x, y)
                	t_0 = Float64(Float64(x / y) - -1.0)
                	tmp = 0.0
                	if (y <= -0.02470192540250247)
                		tmp = t_0;
                	elseif (y <= 3.227028658029451)
                		tmp = Float64(Float64(x + y) / 1.0);
                	else
                		tmp = t_0;
                	end
                	return tmp
                end
                
                function tmp_2 = code(x, y)
                	t_0 = (x / y) - -1.0;
                	tmp = 0.0;
                	if (y <= -0.02470192540250247)
                		tmp = t_0;
                	elseif (y <= 3.227028658029451)
                		tmp = (x + y) / 1.0;
                	else
                		tmp = t_0;
                	end
                	tmp_2 = tmp;
                end
                
                code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[y, -0.02470192540250247], t$95$0, If[LessEqual[y, 3.227028658029451], N[(N[(x + y), $MachinePrecision] / 1.0), $MachinePrecision], t$95$0]]]
                
                f(x, y):
                	x in [-inf, +inf],
                	y in [-inf, +inf]
                code: THEORY
                BEGIN
                f(x, y: real): real =
                	LET t_0 = ((x / y) - (-1)) IN
                		LET tmp_1 = IF (y <= (322702865802945115802913278457708656787872314453125e-50)) THEN ((x + y) / (1)) ELSE t_0 ENDIF IN
                		LET tmp = IF (y <= (-24701925402502468431809035109836258925497531890869140625e-57)) THEN t_0 ELSE tmp_1 ENDIF IN
                	tmp
                END code
                \begin{array}{l}
                t_0 := \frac{x}{y} - -1\\
                \mathbf{if}\;y \leq -0.02470192540250247:\\
                \;\;\;\;t\_0\\
                
                \mathbf{elif}\;y \leq 3.227028658029451:\\
                \;\;\;\;\frac{x + y}{1}\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_0\\
                
                
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if y < -0.024701925402502468 or 3.2270286580294512 < y

                  1. Initial program 100.0%

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

                    \[\leadsto \left(1 + \frac{x}{y}\right) - \frac{1}{y} \]
                  3. Step-by-step derivation
                    1. Applied rewrites51.1%

                      \[\leadsto \left(1 + \frac{x}{y}\right) - \frac{1}{y} \]
                    2. Step-by-step derivation
                      1. Applied rewrites51.1%

                        \[\leadsto \frac{x - 1}{y} - -1 \]
                      2. Taylor expanded in x around inf

                        \[\leadsto \frac{x}{y} - -1 \]
                      3. Step-by-step derivation
                        1. Applied rewrites51.1%

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

                        if -0.024701925402502468 < y < 3.2270286580294512

                        1. Initial program 100.0%

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

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

                            \[\leadsto \frac{x + y}{1} \]
                        4. Recombined 2 regimes into one program.
                        5. Add Preprocessing

                        Alternative 5: 86.7% accurate, 0.3× speedup?

                        \[\begin{array}{l} t_0 := \frac{x + y}{y + 1}\\ t_1 := \frac{x}{1 + y}\\ \mathbf{if}\;t\_0 \leq 5 \cdot 10^{-134}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 2:\\ \;\;\;\;\frac{y}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
                        (FPCore (x y)
                          :precision binary64
                          :pre TRUE
                          (let* ((t_0 (/ (+ x y) (+ y 1.0))) (t_1 (/ x (+ 1.0 y))))
                          (if (<= t_0 5e-134) t_1 (if (<= t_0 2.0) (/ y (+ y 1.0)) t_1))))
                        double code(double x, double y) {
                        	double t_0 = (x + y) / (y + 1.0);
                        	double t_1 = x / (1.0 + y);
                        	double tmp;
                        	if (t_0 <= 5e-134) {
                        		tmp = t_1;
                        	} else if (t_0 <= 2.0) {
                        		tmp = y / (y + 1.0);
                        	} else {
                        		tmp = t_1;
                        	}
                        	return tmp;
                        }
                        
                        real(8) function code(x, y)
                        use fmin_fmax_functions
                            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) / (y + 1.0d0)
                            t_1 = x / (1.0d0 + y)
                            if (t_0 <= 5d-134) then
                                tmp = t_1
                            else if (t_0 <= 2.0d0) then
                                tmp = y / (y + 1.0d0)
                            else
                                tmp = t_1
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double x, double y) {
                        	double t_0 = (x + y) / (y + 1.0);
                        	double t_1 = x / (1.0 + y);
                        	double tmp;
                        	if (t_0 <= 5e-134) {
                        		tmp = t_1;
                        	} else if (t_0 <= 2.0) {
                        		tmp = y / (y + 1.0);
                        	} else {
                        		tmp = t_1;
                        	}
                        	return tmp;
                        }
                        
                        def code(x, y):
                        	t_0 = (x + y) / (y + 1.0)
                        	t_1 = x / (1.0 + y)
                        	tmp = 0
                        	if t_0 <= 5e-134:
                        		tmp = t_1
                        	elif t_0 <= 2.0:
                        		tmp = y / (y + 1.0)
                        	else:
                        		tmp = t_1
                        	return tmp
                        
                        function code(x, y)
                        	t_0 = Float64(Float64(x + y) / Float64(y + 1.0))
                        	t_1 = Float64(x / Float64(1.0 + y))
                        	tmp = 0.0
                        	if (t_0 <= 5e-134)
                        		tmp = t_1;
                        	elseif (t_0 <= 2.0)
                        		tmp = Float64(y / Float64(y + 1.0));
                        	else
                        		tmp = t_1;
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(x, y)
                        	t_0 = (x + y) / (y + 1.0);
                        	t_1 = x / (1.0 + y);
                        	tmp = 0.0;
                        	if (t_0 <= 5e-134)
                        		tmp = t_1;
                        	elseif (t_0 <= 2.0)
                        		tmp = y / (y + 1.0);
                        	else
                        		tmp = t_1;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-134], t$95$1, If[LessEqual[t$95$0, 2.0], N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
                        
                        f(x, y):
                        	x in [-inf, +inf],
                        	y in [-inf, +inf]
                        code: THEORY
                        BEGIN
                        f(x, y: real): real =
                        	LET t_0 = ((x + y) / (y + (1))) IN
                        		LET t_1 = (x / ((1) + y)) IN
                        			LET tmp_1 = IF (t_0 <= (2)) THEN (y / (y + (1))) ELSE t_1 ENDIF IN
                        			LET tmp = IF (t_0 <= (5000000000000000320748171325227407602265583029471801419809593512473507099237019991411223221120531020560880949660340328963055617707357760006409658941734521084366182056151828897429570144449678740321014602295052267721788818054326005599506438550205322516652098864567339603526120051278434163878998570228560286230286314809322274765879257074630004353821277618408203125e-494)) THEN t_1 ELSE tmp_1 ENDIF IN
                        	tmp
                        END code
                        \begin{array}{l}
                        t_0 := \frac{x + y}{y + 1}\\
                        t_1 := \frac{x}{1 + y}\\
                        \mathbf{if}\;t\_0 \leq 5 \cdot 10^{-134}:\\
                        \;\;\;\;t\_1\\
                        
                        \mathbf{elif}\;t\_0 \leq 2:\\
                        \;\;\;\;\frac{y}{y + 1}\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;t\_1\\
                        
                        
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if (/.f64 (+.f64 x y) (+.f64 y #s(literal 1 binary64))) < 5.0000000000000003e-134 or 2 < (/.f64 (+.f64 x y) (+.f64 y #s(literal 1 binary64)))

                          1. Initial program 100.0%

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

                            \[\leadsto \frac{x}{1 + y} \]
                          3. Step-by-step derivation
                            1. Applied rewrites50.2%

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

                            if 5.0000000000000003e-134 < (/.f64 (+.f64 x y) (+.f64 y #s(literal 1 binary64))) < 2

                            1. Initial program 100.0%

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

                              \[\leadsto \frac{y}{y + 1} \]
                            3. Step-by-step derivation
                              1. Applied rewrites51.3%

                                \[\leadsto \frac{y}{y + 1} \]
                            4. Recombined 2 regimes into one program.
                            5. Add Preprocessing

                            Alternative 6: 85.8% accurate, 0.3× speedup?

                            \[\begin{array}{l} t_0 := \frac{x + y}{y + 1}\\ t_1 := \frac{x}{1 + y}\\ \mathbf{if}\;t\_0 \leq 0.05:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 2:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
                            (FPCore (x y)
                              :precision binary64
                              :pre TRUE
                              (let* ((t_0 (/ (+ x y) (+ y 1.0))) (t_1 (/ x (+ 1.0 y))))
                              (if (<= t_0 0.05) t_1 (if (<= t_0 2.0) 1.0 t_1))))
                            double code(double x, double y) {
                            	double t_0 = (x + y) / (y + 1.0);
                            	double t_1 = x / (1.0 + y);
                            	double tmp;
                            	if (t_0 <= 0.05) {
                            		tmp = t_1;
                            	} else if (t_0 <= 2.0) {
                            		tmp = 1.0;
                            	} else {
                            		tmp = t_1;
                            	}
                            	return tmp;
                            }
                            
                            real(8) function code(x, y)
                            use fmin_fmax_functions
                                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) / (y + 1.0d0)
                                t_1 = x / (1.0d0 + y)
                                if (t_0 <= 0.05d0) then
                                    tmp = t_1
                                else if (t_0 <= 2.0d0) then
                                    tmp = 1.0d0
                                else
                                    tmp = t_1
                                end if
                                code = tmp
                            end function
                            
                            public static double code(double x, double y) {
                            	double t_0 = (x + y) / (y + 1.0);
                            	double t_1 = x / (1.0 + y);
                            	double tmp;
                            	if (t_0 <= 0.05) {
                            		tmp = t_1;
                            	} else if (t_0 <= 2.0) {
                            		tmp = 1.0;
                            	} else {
                            		tmp = t_1;
                            	}
                            	return tmp;
                            }
                            
                            def code(x, y):
                            	t_0 = (x + y) / (y + 1.0)
                            	t_1 = x / (1.0 + y)
                            	tmp = 0
                            	if t_0 <= 0.05:
                            		tmp = t_1
                            	elif t_0 <= 2.0:
                            		tmp = 1.0
                            	else:
                            		tmp = t_1
                            	return tmp
                            
                            function code(x, y)
                            	t_0 = Float64(Float64(x + y) / Float64(y + 1.0))
                            	t_1 = Float64(x / Float64(1.0 + y))
                            	tmp = 0.0
                            	if (t_0 <= 0.05)
                            		tmp = t_1;
                            	elseif (t_0 <= 2.0)
                            		tmp = 1.0;
                            	else
                            		tmp = t_1;
                            	end
                            	return tmp
                            end
                            
                            function tmp_2 = code(x, y)
                            	t_0 = (x + y) / (y + 1.0);
                            	t_1 = x / (1.0 + y);
                            	tmp = 0.0;
                            	if (t_0 <= 0.05)
                            		tmp = t_1;
                            	elseif (t_0 <= 2.0)
                            		tmp = 1.0;
                            	else
                            		tmp = t_1;
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.05], t$95$1, If[LessEqual[t$95$0, 2.0], 1.0, t$95$1]]]]
                            
                            f(x, y):
                            	x in [-inf, +inf],
                            	y in [-inf, +inf]
                            code: THEORY
                            BEGIN
                            f(x, y: real): real =
                            	LET t_0 = ((x + y) / (y + (1))) IN
                            		LET t_1 = (x / ((1) + y)) IN
                            			LET tmp_1 = IF (t_0 <= (2)) THEN (1) ELSE t_1 ENDIF IN
                            			LET tmp = IF (t_0 <= (5000000000000000277555756156289135105907917022705078125e-56)) THEN t_1 ELSE tmp_1 ENDIF IN
                            	tmp
                            END code
                            \begin{array}{l}
                            t_0 := \frac{x + y}{y + 1}\\
                            t_1 := \frac{x}{1 + y}\\
                            \mathbf{if}\;t\_0 \leq 0.05:\\
                            \;\;\;\;t\_1\\
                            
                            \mathbf{elif}\;t\_0 \leq 2:\\
                            \;\;\;\;1\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;t\_1\\
                            
                            
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if (/.f64 (+.f64 x y) (+.f64 y #s(literal 1 binary64))) < 0.050000000000000003 or 2 < (/.f64 (+.f64 x y) (+.f64 y #s(literal 1 binary64)))

                              1. Initial program 100.0%

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

                                \[\leadsto \frac{x}{1 + y} \]
                              3. Step-by-step derivation
                                1. Applied rewrites50.2%

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

                                if 0.050000000000000003 < (/.f64 (+.f64 x y) (+.f64 y #s(literal 1 binary64))) < 2

                                1. Initial program 100.0%

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

                                  \[\leadsto \left(1 + \frac{x}{y}\right) - \frac{1}{y} \]
                                3. Step-by-step derivation
                                  1. Applied rewrites51.1%

                                    \[\leadsto \left(1 + \frac{x}{y}\right) - \frac{1}{y} \]
                                  2. Step-by-step derivation
                                    1. Applied rewrites51.1%

                                      \[\leadsto \frac{x - 1}{y} - -1 \]
                                    2. Taylor expanded in x around inf

                                      \[\leadsto \frac{x}{y} - -1 \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites51.1%

                                        \[\leadsto \frac{x}{y} - -1 \]
                                      2. Taylor expanded in y around inf

                                        \[\leadsto 1 \]
                                      3. Step-by-step derivation
                                        1. Applied rewrites39.5%

                                          \[\leadsto 1 \]
                                      4. Recombined 2 regimes into one program.
                                      5. Add Preprocessing

                                      Alternative 7: 50.7% accurate, 0.6× speedup?

                                      \[\begin{array}{l} \mathbf{if}\;\frac{x + y}{y + 1} \leq 10^{-13}:\\ \;\;\;\;\frac{y}{1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
                                      (FPCore (x y)
                                        :precision binary64
                                        :pre TRUE
                                        (if (<= (/ (+ x y) (+ y 1.0)) 1e-13) (/ y 1.0) 1.0))
                                      double code(double x, double y) {
                                      	double tmp;
                                      	if (((x + y) / (y + 1.0)) <= 1e-13) {
                                      		tmp = y / 1.0;
                                      	} else {
                                      		tmp = 1.0;
                                      	}
                                      	return tmp;
                                      }
                                      
                                      real(8) function code(x, y)
                                      use fmin_fmax_functions
                                          real(8), intent (in) :: x
                                          real(8), intent (in) :: y
                                          real(8) :: tmp
                                          if (((x + y) / (y + 1.0d0)) <= 1d-13) then
                                              tmp = y / 1.0d0
                                          else
                                              tmp = 1.0d0
                                          end if
                                          code = tmp
                                      end function
                                      
                                      public static double code(double x, double y) {
                                      	double tmp;
                                      	if (((x + y) / (y + 1.0)) <= 1e-13) {
                                      		tmp = y / 1.0;
                                      	} else {
                                      		tmp = 1.0;
                                      	}
                                      	return tmp;
                                      }
                                      
                                      def code(x, y):
                                      	tmp = 0
                                      	if ((x + y) / (y + 1.0)) <= 1e-13:
                                      		tmp = y / 1.0
                                      	else:
                                      		tmp = 1.0
                                      	return tmp
                                      
                                      function code(x, y)
                                      	tmp = 0.0
                                      	if (Float64(Float64(x + y) / Float64(y + 1.0)) <= 1e-13)
                                      		tmp = Float64(y / 1.0);
                                      	else
                                      		tmp = 1.0;
                                      	end
                                      	return tmp
                                      end
                                      
                                      function tmp_2 = code(x, y)
                                      	tmp = 0.0;
                                      	if (((x + y) / (y + 1.0)) <= 1e-13)
                                      		tmp = y / 1.0;
                                      	else
                                      		tmp = 1.0;
                                      	end
                                      	tmp_2 = tmp;
                                      end
                                      
                                      code[x_, y_] := If[LessEqual[N[(N[(x + y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], 1e-13], N[(y / 1.0), $MachinePrecision], 1.0]
                                      
                                      f(x, y):
                                      	x in [-inf, +inf],
                                      	y in [-inf, +inf]
                                      code: THEORY
                                      BEGIN
                                      f(x, y: real): real =
                                      	LET tmp = IF (((x + y) / (y + (1))) <= (10000000000000000303737455634003709136034716842278413651001756079494953155517578125e-95)) THEN (y / (1)) ELSE (1) ENDIF IN
                                      	tmp
                                      END code
                                      \begin{array}{l}
                                      \mathbf{if}\;\frac{x + y}{y + 1} \leq 10^{-13}:\\
                                      \;\;\;\;\frac{y}{1}\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;1\\
                                      
                                      
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if (/.f64 (+.f64 x y) (+.f64 y #s(literal 1 binary64))) < 1e-13

                                        1. Initial program 100.0%

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

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

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

                                            \[\leadsto \frac{y}{1} \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites14.3%

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

                                            if 1e-13 < (/.f64 (+.f64 x y) (+.f64 y #s(literal 1 binary64)))

                                            1. Initial program 100.0%

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

                                              \[\leadsto \left(1 + \frac{x}{y}\right) - \frac{1}{y} \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites51.1%

                                                \[\leadsto \left(1 + \frac{x}{y}\right) - \frac{1}{y} \]
                                              2. Step-by-step derivation
                                                1. Applied rewrites51.1%

                                                  \[\leadsto \frac{x - 1}{y} - -1 \]
                                                2. Taylor expanded in x around inf

                                                  \[\leadsto \frac{x}{y} - -1 \]
                                                3. Step-by-step derivation
                                                  1. Applied rewrites51.1%

                                                    \[\leadsto \frac{x}{y} - -1 \]
                                                  2. Taylor expanded in y around inf

                                                    \[\leadsto 1 \]
                                                  3. Step-by-step derivation
                                                    1. Applied rewrites39.5%

                                                      \[\leadsto 1 \]
                                                  4. Recombined 2 regimes into one program.
                                                  5. Add Preprocessing

                                                  Alternative 8: 39.5% accurate, 10.0× speedup?

                                                  \[1 \]
                                                  (FPCore (x y)
                                                    :precision binary64
                                                    :pre TRUE
                                                    1.0)
                                                  double code(double x, double y) {
                                                  	return 1.0;
                                                  }
                                                  
                                                  real(8) function code(x, y)
                                                  use fmin_fmax_functions
                                                      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
                                                  
                                                  f(x, y):
                                                  	x in [-inf, +inf],
                                                  	y in [-inf, +inf]
                                                  code: THEORY
                                                  BEGIN
                                                  f(x, y: real): real =
                                                  	1
                                                  END code
                                                  1
                                                  
                                                  Derivation
                                                  1. Initial program 100.0%

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

                                                    \[\leadsto \left(1 + \frac{x}{y}\right) - \frac{1}{y} \]
                                                  3. Step-by-step derivation
                                                    1. Applied rewrites51.1%

                                                      \[\leadsto \left(1 + \frac{x}{y}\right) - \frac{1}{y} \]
                                                    2. Step-by-step derivation
                                                      1. Applied rewrites51.1%

                                                        \[\leadsto \frac{x - 1}{y} - -1 \]
                                                      2. Taylor expanded in x around inf

                                                        \[\leadsto \frac{x}{y} - -1 \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites51.1%

                                                          \[\leadsto \frac{x}{y} - -1 \]
                                                        2. Taylor expanded in y around inf

                                                          \[\leadsto 1 \]
                                                        3. Step-by-step derivation
                                                          1. Applied rewrites39.5%

                                                            \[\leadsto 1 \]
                                                          2. Add Preprocessing

                                                          Reproduce

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