
(FPCore (x) :precision binary64 (/ (+ x 16.0) 116.0))
double code(double x) {
return (x + 16.0) / 116.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x + 16.0d0) / 116.0d0
end function
public static double code(double x) {
return (x + 16.0) / 116.0;
}
def code(x): return (x + 16.0) / 116.0
function code(x) return Float64(Float64(x + 16.0) / 116.0) end
function tmp = code(x) tmp = (x + 16.0) / 116.0; end
code[x_] := N[(N[(x + 16.0), $MachinePrecision] / 116.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + 16}{116}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (/ (+ x 16.0) 116.0))
double code(double x) {
return (x + 16.0) / 116.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x + 16.0d0) / 116.0d0
end function
public static double code(double x) {
return (x + 16.0) / 116.0;
}
def code(x): return (x + 16.0) / 116.0
function code(x) return Float64(Float64(x + 16.0) / 116.0) end
function tmp = code(x) tmp = (x + 16.0) / 116.0; end
code[x_] := N[(N[(x + 16.0), $MachinePrecision] / 116.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + 16}{116}
\end{array}
(FPCore (x) :precision binary64 (/ (+ x 16.0) 116.0))
double code(double x) {
return (x + 16.0) / 116.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x + 16.0d0) / 116.0d0
end function
public static double code(double x) {
return (x + 16.0) / 116.0;
}
def code(x): return (x + 16.0) / 116.0
function code(x) return Float64(Float64(x + 16.0) / 116.0) end
function tmp = code(x) tmp = (x + 16.0) / 116.0; end
code[x_] := N[(N[(x + 16.0), $MachinePrecision] / 116.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + 16}{116}
\end{array}
Initial program 100.0%
(FPCore (x) :precision binary64 (if (<= x -16.0) (/ x 116.0) (if (<= x 16.0) 0.13793103448275862 (/ x 116.0))))
double code(double x) {
double tmp;
if (x <= -16.0) {
tmp = x / 116.0;
} else if (x <= 16.0) {
tmp = 0.13793103448275862;
} else {
tmp = x / 116.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-16.0d0)) then
tmp = x / 116.0d0
else if (x <= 16.0d0) then
tmp = 0.13793103448275862d0
else
tmp = x / 116.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -16.0) {
tmp = x / 116.0;
} else if (x <= 16.0) {
tmp = 0.13793103448275862;
} else {
tmp = x / 116.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -16.0: tmp = x / 116.0 elif x <= 16.0: tmp = 0.13793103448275862 else: tmp = x / 116.0 return tmp
function code(x) tmp = 0.0 if (x <= -16.0) tmp = Float64(x / 116.0); elseif (x <= 16.0) tmp = 0.13793103448275862; else tmp = Float64(x / 116.0); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -16.0) tmp = x / 116.0; elseif (x <= 16.0) tmp = 0.13793103448275862; else tmp = x / 116.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -16.0], N[(x / 116.0), $MachinePrecision], If[LessEqual[x, 16.0], 0.13793103448275862, N[(x / 116.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -16:\\
\;\;\;\;\frac{x}{116}\\
\mathbf{elif}\;x \leq 16:\\
\;\;\;\;0.13793103448275862\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{116}\\
\end{array}
\end{array}
if x < -16 or 16 < x Initial program 100.0%
Taylor expanded in x around inf
Simplified98.3%
if -16 < x < 16Initial program 100.0%
Taylor expanded in x around 0
Simplified99.0%
(FPCore (x) :precision binary64 0.13793103448275862)
double code(double x) {
return 0.13793103448275862;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.13793103448275862d0
end function
public static double code(double x) {
return 0.13793103448275862;
}
def code(x): return 0.13793103448275862
function code(x) return 0.13793103448275862 end
function tmp = code(x) tmp = 0.13793103448275862; end
code[x_] := 0.13793103448275862
\begin{array}{l}
\\
0.13793103448275862
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Simplified53.0%
herbie shell --seed 2024145
(FPCore (x)
:name "Data.Colour.CIE:cieLAB from colour-2.3.3, B"
:precision binary64
(/ (+ x 16.0) 116.0))