
(FPCore (x) :precision binary64 (+ (* (/ 841.0 108.0) x) (/ 4.0 29.0)))
double code(double x) {
return ((841.0 / 108.0) * x) + (4.0 / 29.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((841.0d0 / 108.0d0) * x) + (4.0d0 / 29.0d0)
end function
public static double code(double x) {
return ((841.0 / 108.0) * x) + (4.0 / 29.0);
}
def code(x): return ((841.0 / 108.0) * x) + (4.0 / 29.0)
function code(x) return Float64(Float64(Float64(841.0 / 108.0) * x) + Float64(4.0 / 29.0)) end
function tmp = code(x) tmp = ((841.0 / 108.0) * x) + (4.0 / 29.0); end
code[x_] := N[(N[(N[(841.0 / 108.0), $MachinePrecision] * x), $MachinePrecision] + N[(4.0 / 29.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{841}{108} \cdot x + \frac{4}{29}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (+ (* (/ 841.0 108.0) x) (/ 4.0 29.0)))
double code(double x) {
return ((841.0 / 108.0) * x) + (4.0 / 29.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((841.0d0 / 108.0d0) * x) + (4.0d0 / 29.0d0)
end function
public static double code(double x) {
return ((841.0 / 108.0) * x) + (4.0 / 29.0);
}
def code(x): return ((841.0 / 108.0) * x) + (4.0 / 29.0)
function code(x) return Float64(Float64(Float64(841.0 / 108.0) * x) + Float64(4.0 / 29.0)) end
function tmp = code(x) tmp = ((841.0 / 108.0) * x) + (4.0 / 29.0); end
code[x_] := N[(N[(N[(841.0 / 108.0), $MachinePrecision] * x), $MachinePrecision] + N[(4.0 / 29.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{841}{108} \cdot x + \frac{4}{29}
\end{array}
(FPCore (x) :precision binary64 (fma (/ 0.13793103448275862 x) x (* x 7.787037037037037)))
double code(double x) {
return fma((0.13793103448275862 / x), x, (x * 7.787037037037037));
}
function code(x) return fma(Float64(0.13793103448275862 / x), x, Float64(x * 7.787037037037037)) end
code[x_] := N[(N[(0.13793103448275862 / x), $MachinePrecision] * x + N[(x * 7.787037037037037), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{0.13793103448275862}{x}, x, x \cdot 7.787037037037037\right)
\end{array}
Initial program 99.9%
Taylor expanded in x around inf 99.8%
expm1-log1p-u72.5%
expm1-undefine71.9%
un-div-inv71.9%
Applied egg-rr71.9%
sub-neg71.9%
metadata-eval71.9%
+-commutative71.9%
log1p-undefine71.9%
rem-exp-log99.2%
associate-+r+99.2%
metadata-eval99.5%
Simplified99.5%
associate-+r+99.5%
metadata-eval99.8%
+-commutative99.8%
distribute-rgt-in99.9%
fma-define99.9%
*-commutative99.9%
Applied egg-rr99.9%
(FPCore (x)
:precision binary64
(if (or (<= (* x 7.787037037037037) -20.0)
(not (<= (* x 7.787037037037037) 1e-7)))
(* x 7.787037037037037)
0.13793103448275862))
double code(double x) {
double tmp;
if (((x * 7.787037037037037) <= -20.0) || !((x * 7.787037037037037) <= 1e-7)) {
tmp = x * 7.787037037037037;
} else {
tmp = 0.13793103448275862;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((x * 7.787037037037037d0) <= (-20.0d0)) .or. (.not. ((x * 7.787037037037037d0) <= 1d-7))) then
tmp = x * 7.787037037037037d0
else
tmp = 0.13793103448275862d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((x * 7.787037037037037) <= -20.0) || !((x * 7.787037037037037) <= 1e-7)) {
tmp = x * 7.787037037037037;
} else {
tmp = 0.13793103448275862;
}
return tmp;
}
def code(x): tmp = 0 if ((x * 7.787037037037037) <= -20.0) or not ((x * 7.787037037037037) <= 1e-7): tmp = x * 7.787037037037037 else: tmp = 0.13793103448275862 return tmp
function code(x) tmp = 0.0 if ((Float64(x * 7.787037037037037) <= -20.0) || !(Float64(x * 7.787037037037037) <= 1e-7)) tmp = Float64(x * 7.787037037037037); else tmp = 0.13793103448275862; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((x * 7.787037037037037) <= -20.0) || ~(((x * 7.787037037037037) <= 1e-7))) tmp = x * 7.787037037037037; else tmp = 0.13793103448275862; end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[N[(x * 7.787037037037037), $MachinePrecision], -20.0], N[Not[LessEqual[N[(x * 7.787037037037037), $MachinePrecision], 1e-7]], $MachinePrecision]], N[(x * 7.787037037037037), $MachinePrecision], 0.13793103448275862]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot 7.787037037037037 \leq -20 \lor \neg \left(x \cdot 7.787037037037037 \leq 10^{-7}\right):\\
\;\;\;\;x \cdot 7.787037037037037\\
\mathbf{else}:\\
\;\;\;\;0.13793103448275862\\
\end{array}
\end{array}
if (*.f64 (/.f64 #s(literal 841 binary64) #s(literal 108 binary64)) x) < -20 or 9.9999999999999995e-8 < (*.f64 (/.f64 #s(literal 841 binary64) #s(literal 108 binary64)) x) Initial program 99.8%
fma-define99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-define99.8%
metadata-eval99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 97.2%
if -20 < (*.f64 (/.f64 #s(literal 841 binary64) #s(literal 108 binary64)) x) < 9.9999999999999995e-8Initial program 100.0%
Taylor expanded in x around 0 98.0%
Final simplification97.6%
(FPCore (x) :precision binary64 (+ 0.13793103448275862 (* x 7.787037037037037)))
double code(double x) {
return 0.13793103448275862 + (x * 7.787037037037037);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.13793103448275862d0 + (x * 7.787037037037037d0)
end function
public static double code(double x) {
return 0.13793103448275862 + (x * 7.787037037037037);
}
def code(x): return 0.13793103448275862 + (x * 7.787037037037037)
function code(x) return Float64(0.13793103448275862 + Float64(x * 7.787037037037037)) end
function tmp = code(x) tmp = 0.13793103448275862 + (x * 7.787037037037037); end
code[x_] := N[(0.13793103448275862 + N[(x * 7.787037037037037), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.13793103448275862 + x \cdot 7.787037037037037
\end{array}
Initial program 99.9%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
metadata-eval99.9%
metadata-eval99.9%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.9%
(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 99.9%
Taylor expanded in x around 0 48.1%
herbie shell --seed 2024191
(FPCore (x)
:name "Data.Colour.CIE:cieLABView from colour-2.3.3, A"
:precision binary64
(+ (* (/ 841.0 108.0) x) (/ 4.0 29.0)))