Data.Colour.SRGB:transferFunction from colour-2.3.3

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

    \[\left(x + 1\right) \cdot y - x \]
  2. Add Preprocessing
  3. Final simplification100.0%

    \[\leadsto y \cdot \left(x + 1\right) - x \]
  4. Add Preprocessing

Alternative 2: 61.9% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.85 \cdot 10^{+244}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -6.6 \cdot 10^{+152}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq -1:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{-78}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 1.46 \cdot 10^{+113} \lor \neg \left(y \leq 2.9 \cdot 10^{+200}\right) \land y \leq 5.4 \cdot 10^{+262}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -1.85e+244)
   (* x y)
   (if (<= y -6.6e+152)
     y
     (if (<= y -1.0)
       (* x y)
       (if (<= y 4.3e-78)
         (- x)
         (if (or (<= y 1.46e+113) (and (not (<= y 2.9e+200)) (<= y 5.4e+262)))
           y
           (* x y)))))))
double code(double x, double y) {
	double tmp;
	if (y <= -1.85e+244) {
		tmp = x * y;
	} else if (y <= -6.6e+152) {
		tmp = y;
	} else if (y <= -1.0) {
		tmp = x * y;
	} else if (y <= 4.3e-78) {
		tmp = -x;
	} else if ((y <= 1.46e+113) || (!(y <= 2.9e+200) && (y <= 5.4e+262))) {
		tmp = y;
	} else {
		tmp = x * y;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-1.85d+244)) then
        tmp = x * y
    else if (y <= (-6.6d+152)) then
        tmp = y
    else if (y <= (-1.0d0)) then
        tmp = x * y
    else if (y <= 4.3d-78) then
        tmp = -x
    else if ((y <= 1.46d+113) .or. (.not. (y <= 2.9d+200)) .and. (y <= 5.4d+262)) then
        tmp = y
    else
        tmp = x * y
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -1.85e+244) {
		tmp = x * y;
	} else if (y <= -6.6e+152) {
		tmp = y;
	} else if (y <= -1.0) {
		tmp = x * y;
	} else if (y <= 4.3e-78) {
		tmp = -x;
	} else if ((y <= 1.46e+113) || (!(y <= 2.9e+200) && (y <= 5.4e+262))) {
		tmp = y;
	} else {
		tmp = x * y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -1.85e+244:
		tmp = x * y
	elif y <= -6.6e+152:
		tmp = y
	elif y <= -1.0:
		tmp = x * y
	elif y <= 4.3e-78:
		tmp = -x
	elif (y <= 1.46e+113) or (not (y <= 2.9e+200) and (y <= 5.4e+262)):
		tmp = y
	else:
		tmp = x * y
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -1.85e+244)
		tmp = Float64(x * y);
	elseif (y <= -6.6e+152)
		tmp = y;
	elseif (y <= -1.0)
		tmp = Float64(x * y);
	elseif (y <= 4.3e-78)
		tmp = Float64(-x);
	elseif ((y <= 1.46e+113) || (!(y <= 2.9e+200) && (y <= 5.4e+262)))
		tmp = y;
	else
		tmp = Float64(x * y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -1.85e+244)
		tmp = x * y;
	elseif (y <= -6.6e+152)
		tmp = y;
	elseif (y <= -1.0)
		tmp = x * y;
	elseif (y <= 4.3e-78)
		tmp = -x;
	elseif ((y <= 1.46e+113) || (~((y <= 2.9e+200)) && (y <= 5.4e+262)))
		tmp = y;
	else
		tmp = x * y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -1.85e+244], N[(x * y), $MachinePrecision], If[LessEqual[y, -6.6e+152], y, If[LessEqual[y, -1.0], N[(x * y), $MachinePrecision], If[LessEqual[y, 4.3e-78], (-x), If[Or[LessEqual[y, 1.46e+113], And[N[Not[LessEqual[y, 2.9e+200]], $MachinePrecision], LessEqual[y, 5.4e+262]]], y, N[(x * y), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{+244}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;y \leq -6.6 \cdot 10^{+152}:\\
\;\;\;\;y\\

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

\mathbf{elif}\;y \leq 4.3 \cdot 10^{-78}:\\
\;\;\;\;-x\\

\mathbf{elif}\;y \leq 1.46 \cdot 10^{+113} \lor \neg \left(y \leq 2.9 \cdot 10^{+200}\right) \land y \leq 5.4 \cdot 10^{+262}:\\
\;\;\;\;y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.8500000000000001e244 or -6.6000000000000003e152 < y < -1 or 1.46e113 < y < 2.8999999999999999e200 or 5.4000000000000002e262 < y

    1. Initial program 100.0%

      \[\left(x + 1\right) \cdot y - x \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 74.1%

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

        \[\leadsto \color{blue}{y \cdot x} - x \]
    5. Simplified74.1%

      \[\leadsto \color{blue}{y \cdot x} - x \]
    6. Taylor expanded in y around inf 70.0%

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

    if -1.8500000000000001e244 < y < -6.6000000000000003e152 or 4.29999999999999994e-78 < y < 1.46e113 or 2.8999999999999999e200 < y < 5.4000000000000002e262

    1. Initial program 100.0%

      \[\left(x + 1\right) \cdot y - x \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 64.8%

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

    if -1 < y < 4.29999999999999994e-78

    1. Initial program 100.0%

      \[\left(x + 1\right) \cdot y - x \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 85.2%

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

        \[\leadsto \color{blue}{-x} \]
    5. Simplified85.2%

      \[\leadsto \color{blue}{-x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification75.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.85 \cdot 10^{+244}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -6.6 \cdot 10^{+152}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq -1:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{-78}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 1.46 \cdot 10^{+113} \lor \neg \left(y \leq 2.9 \cdot 10^{+200}\right) \land y \leq 5.4 \cdot 10^{+262}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-70} \lor \neg \left(x \leq 1.4 \cdot 10^{-122} \lor \neg \left(x \leq 7.8 \cdot 10^{-104}\right) \land x \leq 3.6 \cdot 10^{-19}\right):\\ \;\;\;\;x \cdot \left(y + -1\right)\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -2.7e-70)
         (not (or (<= x 1.4e-122) (and (not (<= x 7.8e-104)) (<= x 3.6e-19)))))
   (* x (+ y -1.0))
   y))
double code(double x, double y) {
	double tmp;
	if ((x <= -2.7e-70) || !((x <= 1.4e-122) || (!(x <= 7.8e-104) && (x <= 3.6e-19)))) {
		tmp = x * (y + -1.0);
	} else {
		tmp = y;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x <= (-2.7d-70)) .or. (.not. (x <= 1.4d-122) .or. (.not. (x <= 7.8d-104)) .and. (x <= 3.6d-19))) then
        tmp = x * (y + (-1.0d0))
    else
        tmp = y
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x <= -2.7e-70) || !((x <= 1.4e-122) || (!(x <= 7.8e-104) && (x <= 3.6e-19)))) {
		tmp = x * (y + -1.0);
	} else {
		tmp = y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -2.7e-70) or not ((x <= 1.4e-122) or (not (x <= 7.8e-104) and (x <= 3.6e-19))):
		tmp = x * (y + -1.0)
	else:
		tmp = y
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -2.7e-70) || !((x <= 1.4e-122) || (!(x <= 7.8e-104) && (x <= 3.6e-19))))
		tmp = Float64(x * Float64(y + -1.0));
	else
		tmp = y;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= -2.7e-70) || ~(((x <= 1.4e-122) || (~((x <= 7.8e-104)) && (x <= 3.6e-19)))))
		tmp = x * (y + -1.0);
	else
		tmp = y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, -2.7e-70], N[Not[Or[LessEqual[x, 1.4e-122], And[N[Not[LessEqual[x, 7.8e-104]], $MachinePrecision], LessEqual[x, 3.6e-19]]]], $MachinePrecision]], N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], y]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-70} \lor \neg \left(x \leq 1.4 \cdot 10^{-122} \lor \neg \left(x \leq 7.8 \cdot 10^{-104}\right) \land x \leq 3.6 \cdot 10^{-19}\right):\\
\;\;\;\;x \cdot \left(y + -1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.7000000000000001e-70 or 1.3999999999999999e-122 < x < 7.8000000000000004e-104 or 3.6000000000000001e-19 < x

    1. Initial program 100.0%

      \[\left(x + 1\right) \cdot y - x \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 96.4%

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

    if -2.7000000000000001e-70 < x < 1.3999999999999999e-122 or 7.8000000000000004e-104 < x < 3.6000000000000001e-19

    1. Initial program 100.0%

      \[\left(x + 1\right) \cdot y - x \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 85.3%

      \[\leadsto \color{blue}{y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-70} \lor \neg \left(x \leq 1.4 \cdot 10^{-122} \lor \neg \left(x \leq 7.8 \cdot 10^{-104}\right) \land x \leq 3.6 \cdot 10^{-19}\right):\\ \;\;\;\;x \cdot \left(y + -1\right)\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 86.4% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -41000 \lor \neg \left(y \leq 4.3 \cdot 10^{-78}\right):\\
\;\;\;\;y \cdot \left(x + 1\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(y + -1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -41000 or 4.29999999999999994e-78 < y

    1. Initial program 100.0%

      \[\left(x + 1\right) \cdot y - x \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 93.3%

      \[\leadsto \color{blue}{y \cdot \left(1 + x\right)} \]

    if -41000 < y < 4.29999999999999994e-78

    1. Initial program 100.0%

      \[\left(x + 1\right) \cdot y - x \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 87.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -41000 \lor \neg \left(y \leq 4.3 \cdot 10^{-78}\right):\\ \;\;\;\;y \cdot \left(x + 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y + -1\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 86.4% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -44000 \lor \neg \left(y \leq 4.3 \cdot 10^{-78}\right):\\
\;\;\;\;y \cdot \left(x + 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -44000 or 4.29999999999999994e-78 < y

    1. Initial program 100.0%

      \[\left(x + 1\right) \cdot y - x \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 93.3%

      \[\leadsto \color{blue}{y \cdot \left(1 + x\right)} \]

    if -44000 < y < 4.29999999999999994e-78

    1. Initial program 100.0%

      \[\left(x + 1\right) \cdot y - x \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 87.0%

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

        \[\leadsto \color{blue}{y \cdot x} - x \]
    5. Simplified87.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -44000 \lor \neg \left(y \leq 4.3 \cdot 10^{-78}\right):\\ \;\;\;\;y \cdot \left(x + 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y - x\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 61.7% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;y \leq 4.3 \cdot 10^{-78}:\\
\;\;\;\;-x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -41000 or 4.29999999999999994e-78 < y

    1. Initial program 100.0%

      \[\left(x + 1\right) \cdot y - x \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 49.1%

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

    if -41000 < y < 4.29999999999999994e-78

    1. Initial program 100.0%

      \[\left(x + 1\right) \cdot y - x \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 82.7%

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

        \[\leadsto \color{blue}{-x} \]
    5. Simplified82.7%

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

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

Alternative 7: 38.5% accurate, 7.0× speedup?

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

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

    \[\left(x + 1\right) \cdot y - x \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0 33.6%

    \[\leadsto \color{blue}{y} \]
  4. Final simplification33.6%

    \[\leadsto y \]
  5. Add Preprocessing

Reproduce

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