Data.Colour.CIE:cieLAB from colour-2.3.3, C

Percentage Accurate: 100.0% → 100.0%
Time: 3.7s
Alternatives: 5
Speedup: 1.0×

Specification

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

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 2: 75.2% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{y}{500} \leq -2 \cdot 10^{+54}:\\
\;\;\;\;\frac{y}{500}\\

\mathbf{elif}\;\frac{y}{500} \leq 2.5 \cdot 10^{-27}:\\
\;\;\;\;x\\

\mathbf{elif}\;\frac{y}{500} \leq 20:\\
\;\;\;\;\frac{y}{500}\\

\mathbf{elif}\;\frac{y}{500} \leq 10^{+28}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 y 500) < -2.0000000000000002e54 or 2.5000000000000001e-27 < (/.f64 y 500) < 20 or 9.99999999999999958e27 < (/.f64 y 500)

    1. Initial program 100.0%

      \[x + \frac{y}{500} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto x + \frac{\color{blue}{1 \cdot y}}{500} \]
      2. metadata-eval100.0%

        \[\leadsto x + \frac{\color{blue}{\left(--1\right)} \cdot y}{500} \]
      3. associate-/l*99.7%

        \[\leadsto x + \color{blue}{\frac{--1}{\frac{500}{y}}} \]
      4. distribute-neg-frac99.7%

        \[\leadsto x + \color{blue}{\left(-\frac{-1}{\frac{500}{y}}\right)} \]
      5. associate-/r/99.8%

        \[\leadsto x + \left(-\color{blue}{\frac{-1}{500} \cdot y}\right) \]
      6. distribute-lft-neg-in99.8%

        \[\leadsto x + \color{blue}{\left(-\frac{-1}{500}\right) \cdot y} \]
      7. *-commutative99.8%

        \[\leadsto x + \color{blue}{y \cdot \left(-\frac{-1}{500}\right)} \]
      8. metadata-eval99.8%

        \[\leadsto x + y \cdot \left(-\color{blue}{-0.002}\right) \]
      9. metadata-eval99.8%

        \[\leadsto x + y \cdot \color{blue}{0.002} \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{x + y \cdot 0.002} \]
    4. Step-by-step derivation
      1. +-commutative99.8%

        \[\leadsto \color{blue}{y \cdot 0.002 + x} \]
      2. flip-+42.4%

        \[\leadsto \color{blue}{\frac{\left(y \cdot 0.002\right) \cdot \left(y \cdot 0.002\right) - x \cdot x}{y \cdot 0.002 - x}} \]
      3. swap-sqr42.1%

        \[\leadsto \frac{\color{blue}{\left(y \cdot y\right) \cdot \left(0.002 \cdot 0.002\right)} - x \cdot x}{y \cdot 0.002 - x} \]
      4. metadata-eval42.1%

        \[\leadsto \frac{\left(y \cdot y\right) \cdot \color{blue}{4 \cdot 10^{-6}} - x \cdot x}{y \cdot 0.002 - x} \]
    5. Applied egg-rr42.1%

      \[\leadsto \color{blue}{\frac{\left(y \cdot y\right) \cdot 4 \cdot 10^{-6} - x \cdot x}{y \cdot 0.002 - x}} \]
    6. Taylor expanded in y around inf 39.8%

      \[\leadsto \frac{\color{blue}{4 \cdot 10^{-6} \cdot {y}^{2}}}{y \cdot 0.002 - x} \]
    7. Step-by-step derivation
      1. unpow239.8%

        \[\leadsto \frac{4 \cdot 10^{-6} \cdot \color{blue}{\left(y \cdot y\right)}}{y \cdot 0.002 - x} \]
      2. *-commutative39.8%

        \[\leadsto \frac{\color{blue}{\left(y \cdot y\right) \cdot 4 \cdot 10^{-6}}}{y \cdot 0.002 - x} \]
      3. associate-*r*39.9%

        \[\leadsto \frac{\color{blue}{y \cdot \left(y \cdot 4 \cdot 10^{-6}\right)}}{y \cdot 0.002 - x} \]
    8. Simplified39.9%

      \[\leadsto \frac{\color{blue}{y \cdot \left(y \cdot 4 \cdot 10^{-6}\right)}}{y \cdot 0.002 - x} \]
    9. Taylor expanded in y around inf 86.1%

      \[\leadsto \color{blue}{0.002 \cdot y} \]
    10. Step-by-step derivation
      1. *-commutative86.1%

        \[\leadsto \color{blue}{y \cdot 0.002} \]
    11. Simplified86.1%

      \[\leadsto \color{blue}{y \cdot 0.002} \]
    12. Step-by-step derivation
      1. metadata-eval86.1%

        \[\leadsto y \cdot \color{blue}{\frac{1}{500}} \]
      2. div-inv86.2%

        \[\leadsto \color{blue}{\frac{y}{500}} \]
    13. Applied egg-rr86.2%

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

    if -2.0000000000000002e54 < (/.f64 y 500) < 2.5000000000000001e-27 or 20 < (/.f64 y 500) < 9.99999999999999958e27

    1. Initial program 100.0%

      \[x + \frac{y}{500} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto x + \frac{\color{blue}{1 \cdot y}}{500} \]
      2. metadata-eval100.0%

        \[\leadsto x + \frac{\color{blue}{\left(--1\right)} \cdot y}{500} \]
      3. associate-/l*99.8%

        \[\leadsto x + \color{blue}{\frac{--1}{\frac{500}{y}}} \]
      4. distribute-neg-frac99.8%

        \[\leadsto x + \color{blue}{\left(-\frac{-1}{\frac{500}{y}}\right)} \]
      5. associate-/r/100.0%

        \[\leadsto x + \left(-\color{blue}{\frac{-1}{500} \cdot y}\right) \]
      6. distribute-lft-neg-in100.0%

        \[\leadsto x + \color{blue}{\left(-\frac{-1}{500}\right) \cdot y} \]
      7. *-commutative100.0%

        \[\leadsto x + \color{blue}{y \cdot \left(-\frac{-1}{500}\right)} \]
      8. metadata-eval100.0%

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

        \[\leadsto x + y \cdot \color{blue}{0.002} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{x + y \cdot 0.002} \]
    4. Taylor expanded in x around inf 78.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{500} \leq -2 \cdot 10^{+54}:\\ \;\;\;\;\frac{y}{500}\\ \mathbf{elif}\;\frac{y}{500} \leq 2.5 \cdot 10^{-27}:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{y}{500} \leq 20:\\ \;\;\;\;\frac{y}{500}\\ \mathbf{elif}\;\frac{y}{500} \leq 10^{+28}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{500}\\ \end{array} \]

Alternative 3: 75.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{+56}:\\ \;\;\;\;y \cdot 0.002\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-24}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4100000000:\\ \;\;\;\;y \cdot 0.002\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{+30}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.002\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -9.2e+56)
   (* y 0.002)
   (if (<= y 1.3e-24)
     x
     (if (<= y 4100000000.0) (* y 0.002) (if (<= y 4.5e+30) x (* y 0.002))))))
double code(double x, double y) {
	double tmp;
	if (y <= -9.2e+56) {
		tmp = y * 0.002;
	} else if (y <= 1.3e-24) {
		tmp = x;
	} else if (y <= 4100000000.0) {
		tmp = y * 0.002;
	} else if (y <= 4.5e+30) {
		tmp = x;
	} else {
		tmp = y * 0.002;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-9.2d+56)) then
        tmp = y * 0.002d0
    else if (y <= 1.3d-24) then
        tmp = x
    else if (y <= 4100000000.0d0) then
        tmp = y * 0.002d0
    else if (y <= 4.5d+30) then
        tmp = x
    else
        tmp = y * 0.002d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -9.2e+56) {
		tmp = y * 0.002;
	} else if (y <= 1.3e-24) {
		tmp = x;
	} else if (y <= 4100000000.0) {
		tmp = y * 0.002;
	} else if (y <= 4.5e+30) {
		tmp = x;
	} else {
		tmp = y * 0.002;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -9.2e+56:
		tmp = y * 0.002
	elif y <= 1.3e-24:
		tmp = x
	elif y <= 4100000000.0:
		tmp = y * 0.002
	elif y <= 4.5e+30:
		tmp = x
	else:
		tmp = y * 0.002
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -9.2e+56)
		tmp = Float64(y * 0.002);
	elseif (y <= 1.3e-24)
		tmp = x;
	elseif (y <= 4100000000.0)
		tmp = Float64(y * 0.002);
	elseif (y <= 4.5e+30)
		tmp = x;
	else
		tmp = Float64(y * 0.002);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -9.2e+56)
		tmp = y * 0.002;
	elseif (y <= 1.3e-24)
		tmp = x;
	elseif (y <= 4100000000.0)
		tmp = y * 0.002;
	elseif (y <= 4.5e+30)
		tmp = x;
	else
		tmp = y * 0.002;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -9.2e+56], N[(y * 0.002), $MachinePrecision], If[LessEqual[y, 1.3e-24], x, If[LessEqual[y, 4100000000.0], N[(y * 0.002), $MachinePrecision], If[LessEqual[y, 4.5e+30], x, N[(y * 0.002), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+56}:\\
\;\;\;\;y \cdot 0.002\\

\mathbf{elif}\;y \leq 1.3 \cdot 10^{-24}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 4100000000:\\
\;\;\;\;y \cdot 0.002\\

\mathbf{elif}\;y \leq 4.5 \cdot 10^{+30}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -9.20000000000000058e56 or 1.3e-24 < y < 4.1e9 or 4.49999999999999995e30 < y

    1. Initial program 100.0%

      \[x + \frac{y}{500} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto x + \frac{\color{blue}{1 \cdot y}}{500} \]
      2. metadata-eval100.0%

        \[\leadsto x + \frac{\color{blue}{\left(--1\right)} \cdot y}{500} \]
      3. associate-/l*99.7%

        \[\leadsto x + \color{blue}{\frac{--1}{\frac{500}{y}}} \]
      4. distribute-neg-frac99.7%

        \[\leadsto x + \color{blue}{\left(-\frac{-1}{\frac{500}{y}}\right)} \]
      5. associate-/r/99.8%

        \[\leadsto x + \left(-\color{blue}{\frac{-1}{500} \cdot y}\right) \]
      6. distribute-lft-neg-in99.8%

        \[\leadsto x + \color{blue}{\left(-\frac{-1}{500}\right) \cdot y} \]
      7. *-commutative99.8%

        \[\leadsto x + \color{blue}{y \cdot \left(-\frac{-1}{500}\right)} \]
      8. metadata-eval99.8%

        \[\leadsto x + y \cdot \left(-\color{blue}{-0.002}\right) \]
      9. metadata-eval99.8%

        \[\leadsto x + y \cdot \color{blue}{0.002} \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{x + y \cdot 0.002} \]
    4. Step-by-step derivation
      1. +-commutative99.8%

        \[\leadsto \color{blue}{y \cdot 0.002 + x} \]
      2. flip-+42.4%

        \[\leadsto \color{blue}{\frac{\left(y \cdot 0.002\right) \cdot \left(y \cdot 0.002\right) - x \cdot x}{y \cdot 0.002 - x}} \]
      3. swap-sqr42.1%

        \[\leadsto \frac{\color{blue}{\left(y \cdot y\right) \cdot \left(0.002 \cdot 0.002\right)} - x \cdot x}{y \cdot 0.002 - x} \]
      4. metadata-eval42.1%

        \[\leadsto \frac{\left(y \cdot y\right) \cdot \color{blue}{4 \cdot 10^{-6}} - x \cdot x}{y \cdot 0.002 - x} \]
    5. Applied egg-rr42.1%

      \[\leadsto \color{blue}{\frac{\left(y \cdot y\right) \cdot 4 \cdot 10^{-6} - x \cdot x}{y \cdot 0.002 - x}} \]
    6. Taylor expanded in y around inf 39.8%

      \[\leadsto \frac{\color{blue}{4 \cdot 10^{-6} \cdot {y}^{2}}}{y \cdot 0.002 - x} \]
    7. Step-by-step derivation
      1. unpow239.8%

        \[\leadsto \frac{4 \cdot 10^{-6} \cdot \color{blue}{\left(y \cdot y\right)}}{y \cdot 0.002 - x} \]
      2. *-commutative39.8%

        \[\leadsto \frac{\color{blue}{\left(y \cdot y\right) \cdot 4 \cdot 10^{-6}}}{y \cdot 0.002 - x} \]
      3. associate-*r*39.9%

        \[\leadsto \frac{\color{blue}{y \cdot \left(y \cdot 4 \cdot 10^{-6}\right)}}{y \cdot 0.002 - x} \]
    8. Simplified39.9%

      \[\leadsto \frac{\color{blue}{y \cdot \left(y \cdot 4 \cdot 10^{-6}\right)}}{y \cdot 0.002 - x} \]
    9. Taylor expanded in y around inf 86.1%

      \[\leadsto \color{blue}{0.002 \cdot y} \]
    10. Step-by-step derivation
      1. *-commutative86.1%

        \[\leadsto \color{blue}{y \cdot 0.002} \]
    11. Simplified86.1%

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

    if -9.20000000000000058e56 < y < 1.3e-24 or 4.1e9 < y < 4.49999999999999995e30

    1. Initial program 100.0%

      \[x + \frac{y}{500} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto x + \frac{\color{blue}{1 \cdot y}}{500} \]
      2. metadata-eval100.0%

        \[\leadsto x + \frac{\color{blue}{\left(--1\right)} \cdot y}{500} \]
      3. associate-/l*99.8%

        \[\leadsto x + \color{blue}{\frac{--1}{\frac{500}{y}}} \]
      4. distribute-neg-frac99.8%

        \[\leadsto x + \color{blue}{\left(-\frac{-1}{\frac{500}{y}}\right)} \]
      5. associate-/r/100.0%

        \[\leadsto x + \left(-\color{blue}{\frac{-1}{500} \cdot y}\right) \]
      6. distribute-lft-neg-in100.0%

        \[\leadsto x + \color{blue}{\left(-\frac{-1}{500}\right) \cdot y} \]
      7. *-commutative100.0%

        \[\leadsto x + \color{blue}{y \cdot \left(-\frac{-1}{500}\right)} \]
      8. metadata-eval100.0%

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

        \[\leadsto x + y \cdot \color{blue}{0.002} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{x + y \cdot 0.002} \]
    4. Taylor expanded in x around inf 78.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{+56}:\\ \;\;\;\;y \cdot 0.002\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-24}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4100000000:\\ \;\;\;\;y \cdot 0.002\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{+30}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.002\\ \end{array} \]

Alternative 4: 99.9% accurate, 1.0× speedup?

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

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

    \[x + \frac{y}{500} \]
  2. Step-by-step derivation
    1. *-lft-identity100.0%

      \[\leadsto x + \frac{\color{blue}{1 \cdot y}}{500} \]
    2. metadata-eval100.0%

      \[\leadsto x + \frac{\color{blue}{\left(--1\right)} \cdot y}{500} \]
    3. associate-/l*99.8%

      \[\leadsto x + \color{blue}{\frac{--1}{\frac{500}{y}}} \]
    4. distribute-neg-frac99.8%

      \[\leadsto x + \color{blue}{\left(-\frac{-1}{\frac{500}{y}}\right)} \]
    5. associate-/r/99.9%

      \[\leadsto x + \left(-\color{blue}{\frac{-1}{500} \cdot y}\right) \]
    6. distribute-lft-neg-in99.9%

      \[\leadsto x + \color{blue}{\left(-\frac{-1}{500}\right) \cdot y} \]
    7. *-commutative99.9%

      \[\leadsto x + \color{blue}{y \cdot \left(-\frac{-1}{500}\right)} \]
    8. metadata-eval99.9%

      \[\leadsto x + y \cdot \left(-\color{blue}{-0.002}\right) \]
    9. metadata-eval99.9%

      \[\leadsto x + y \cdot \color{blue}{0.002} \]
  3. Simplified99.9%

    \[\leadsto \color{blue}{x + y \cdot 0.002} \]
  4. Final simplification99.9%

    \[\leadsto x + y \cdot 0.002 \]

Alternative 5: 52.1% accurate, 5.0× speedup?

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

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

    \[x + \frac{y}{500} \]
  2. Step-by-step derivation
    1. *-lft-identity100.0%

      \[\leadsto x + \frac{\color{blue}{1 \cdot y}}{500} \]
    2. metadata-eval100.0%

      \[\leadsto x + \frac{\color{blue}{\left(--1\right)} \cdot y}{500} \]
    3. associate-/l*99.8%

      \[\leadsto x + \color{blue}{\frac{--1}{\frac{500}{y}}} \]
    4. distribute-neg-frac99.8%

      \[\leadsto x + \color{blue}{\left(-\frac{-1}{\frac{500}{y}}\right)} \]
    5. associate-/r/99.9%

      \[\leadsto x + \left(-\color{blue}{\frac{-1}{500} \cdot y}\right) \]
    6. distribute-lft-neg-in99.9%

      \[\leadsto x + \color{blue}{\left(-\frac{-1}{500}\right) \cdot y} \]
    7. *-commutative99.9%

      \[\leadsto x + \color{blue}{y \cdot \left(-\frac{-1}{500}\right)} \]
    8. metadata-eval99.9%

      \[\leadsto x + y \cdot \left(-\color{blue}{-0.002}\right) \]
    9. metadata-eval99.9%

      \[\leadsto x + y \cdot \color{blue}{0.002} \]
  3. Simplified99.9%

    \[\leadsto \color{blue}{x + y \cdot 0.002} \]
  4. Taylor expanded in x around inf 48.0%

    \[\leadsto \color{blue}{x} \]
  5. Final simplification48.0%

    \[\leadsto x \]

Reproduce

?
herbie shell --seed 2023293 
(FPCore (x y)
  :name "Data.Colour.CIE:cieLAB from colour-2.3.3, C"
  :precision binary64
  (+ x (/ y 500.0)))