
(FPCore (x) :precision binary64 (- (* x 116.0) 16.0))
double code(double x) {
return (x * 116.0) - 16.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * 116.0d0) - 16.0d0
end function
public static double code(double x) {
return (x * 116.0) - 16.0;
}
def code(x): return (x * 116.0) - 16.0
function code(x) return Float64(Float64(x * 116.0) - 16.0) end
function tmp = code(x) tmp = (x * 116.0) - 16.0; end
code[x_] := N[(N[(x * 116.0), $MachinePrecision] - 16.0), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 116 - 16
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (* x 116.0) 16.0))
double code(double x) {
return (x * 116.0) - 16.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * 116.0d0) - 16.0d0
end function
public static double code(double x) {
return (x * 116.0) - 16.0;
}
def code(x): return (x * 116.0) - 16.0
function code(x) return Float64(Float64(x * 116.0) - 16.0) end
function tmp = code(x) tmp = (x * 116.0) - 16.0; end
code[x_] := N[(N[(x * 116.0), $MachinePrecision] - 16.0), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 116 - 16
\end{array}
(FPCore (x) :precision binary64 (fma x 116.0 -16.0))
double code(double x) {
return fma(x, 116.0, -16.0);
}
function code(x) return fma(x, 116.0, -16.0) end
code[x_] := N[(x * 116.0 + -16.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, 116, -16\right)
\end{array}
Initial program 100.0%
fma-neg100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (if (or (<= x -0.14) (not (<= x 0.135))) (* x 116.0) -16.0))
double code(double x) {
double tmp;
if ((x <= -0.14) || !(x <= 0.135)) {
tmp = x * 116.0;
} else {
tmp = -16.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-0.14d0)) .or. (.not. (x <= 0.135d0))) then
tmp = x * 116.0d0
else
tmp = -16.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -0.14) || !(x <= 0.135)) {
tmp = x * 116.0;
} else {
tmp = -16.0;
}
return tmp;
}
def code(x): tmp = 0 if (x <= -0.14) or not (x <= 0.135): tmp = x * 116.0 else: tmp = -16.0 return tmp
function code(x) tmp = 0.0 if ((x <= -0.14) || !(x <= 0.135)) tmp = Float64(x * 116.0); else tmp = -16.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -0.14) || ~((x <= 0.135))) tmp = x * 116.0; else tmp = -16.0; end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -0.14], N[Not[LessEqual[x, 0.135]], $MachinePrecision]], N[(x * 116.0), $MachinePrecision], -16.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.14 \lor \neg \left(x \leq 0.135\right):\\
\;\;\;\;x \cdot 116\\
\mathbf{else}:\\
\;\;\;\;-16\\
\end{array}
\end{array}
if x < -0.14000000000000001 or 0.13500000000000001 < x Initial program 100.0%
Taylor expanded in x around inf 98.3%
if -0.14000000000000001 < x < 0.13500000000000001Initial program 100.0%
Taylor expanded in x around 0 98.0%
Final simplification98.2%
(FPCore (x) :precision binary64 (- (* x 116.0) 16.0))
double code(double x) {
return (x * 116.0) - 16.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * 116.0d0) - 16.0d0
end function
public static double code(double x) {
return (x * 116.0) - 16.0;
}
def code(x): return (x * 116.0) - 16.0
function code(x) return Float64(Float64(x * 116.0) - 16.0) end
function tmp = code(x) tmp = (x * 116.0) - 16.0; end
code[x_] := N[(N[(x * 116.0), $MachinePrecision] - 16.0), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 116 - 16
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 -16.0)
double code(double x) {
return -16.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -16.0d0
end function
public static double code(double x) {
return -16.0;
}
def code(x): return -16.0
function code(x) return -16.0 end
function tmp = code(x) tmp = -16.0; end
code[x_] := -16.0
\begin{array}{l}
\\
-16
\end{array}
Initial program 100.0%
Taylor expanded in x around 0 48.7%
Final simplification48.7%
herbie shell --seed 2023311
(FPCore (x)
:name "Data.Colour.CIE:lightness from colour-2.3.3"
:precision binary64
(- (* x 116.0) 16.0))