
(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 5 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 (* 60.63794581618656 (/ x (fma 7.787037037037037 x -0.13793103448275862))) x (/ 0.019024970273483946 (fma x -7.787037037037037 0.13793103448275862))))
double code(double x) {
return fma((60.63794581618656 * (x / fma(7.787037037037037, x, -0.13793103448275862))), x, (0.019024970273483946 / fma(x, -7.787037037037037, 0.13793103448275862)));
}
function code(x) return fma(Float64(60.63794581618656 * Float64(x / fma(7.787037037037037, x, -0.13793103448275862))), x, Float64(0.019024970273483946 / fma(x, -7.787037037037037, 0.13793103448275862))) end
code[x_] := N[(N[(60.63794581618656 * N[(x / N[(7.787037037037037 * x + -0.13793103448275862), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x + N[(0.019024970273483946 / N[(x * -7.787037037037037 + 0.13793103448275862), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(60.63794581618656 \cdot \frac{x}{\mathsf{fma}\left(7.787037037037037, x, -0.13793103448275862\right)}, x, \frac{0.019024970273483946}{\mathsf{fma}\left(x, -7.787037037037037, 0.13793103448275862\right)}\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lift-/.f64N/A
sub-negN/A
lower--.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
metadata-evalN/A
metadata-eval99.9
Applied rewrites99.9%
lift--.f64N/A
flip--N/A
metadata-evalN/A
lift-*.f64N/A
lift-fma.f64N/A
div-subN/A
lift-*.f64N/A
lift-*.f64N/A
swap-sqrN/A
metadata-evalN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r/N/A
lift-/.f64N/A
sub-negN/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
frac-2negN/A
Applied rewrites99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (* x (/ 841.0 108.0))))
(if (<= t_0 -500000000000.0)
(* x 7.787037037037037)
(if (<= t_0 5e-5) 0.13793103448275862 (* x 7.787037037037037)))))
double code(double x) {
double t_0 = x * (841.0 / 108.0);
double tmp;
if (t_0 <= -500000000000.0) {
tmp = x * 7.787037037037037;
} else if (t_0 <= 5e-5) {
tmp = 0.13793103448275862;
} else {
tmp = x * 7.787037037037037;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = x * (841.0d0 / 108.0d0)
if (t_0 <= (-500000000000.0d0)) then
tmp = x * 7.787037037037037d0
else if (t_0 <= 5d-5) then
tmp = 0.13793103448275862d0
else
tmp = x * 7.787037037037037d0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = x * (841.0 / 108.0);
double tmp;
if (t_0 <= -500000000000.0) {
tmp = x * 7.787037037037037;
} else if (t_0 <= 5e-5) {
tmp = 0.13793103448275862;
} else {
tmp = x * 7.787037037037037;
}
return tmp;
}
def code(x): t_0 = x * (841.0 / 108.0) tmp = 0 if t_0 <= -500000000000.0: tmp = x * 7.787037037037037 elif t_0 <= 5e-5: tmp = 0.13793103448275862 else: tmp = x * 7.787037037037037 return tmp
function code(x) t_0 = Float64(x * Float64(841.0 / 108.0)) tmp = 0.0 if (t_0 <= -500000000000.0) tmp = Float64(x * 7.787037037037037); elseif (t_0 <= 5e-5) tmp = 0.13793103448275862; else tmp = Float64(x * 7.787037037037037); end return tmp end
function tmp_2 = code(x) t_0 = x * (841.0 / 108.0); tmp = 0.0; if (t_0 <= -500000000000.0) tmp = x * 7.787037037037037; elseif (t_0 <= 5e-5) tmp = 0.13793103448275862; else tmp = x * 7.787037037037037; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(x * N[(841.0 / 108.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -500000000000.0], N[(x * 7.787037037037037), $MachinePrecision], If[LessEqual[t$95$0, 5e-5], 0.13793103448275862, N[(x * 7.787037037037037), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{841}{108}\\
\mathbf{if}\;t\_0 \leq -500000000000:\\
\;\;\;\;x \cdot 7.787037037037037\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-5}:\\
\;\;\;\;0.13793103448275862\\
\mathbf{else}:\\
\;\;\;\;x \cdot 7.787037037037037\\
\end{array}
\end{array}
if (*.f64 (/.f64 #s(literal 841 binary64) #s(literal 108 binary64)) x) < -5e11 or 5.00000000000000024e-5 < (*.f64 (/.f64 #s(literal 841 binary64) #s(literal 108 binary64)) x) Initial program 99.8%
Taylor expanded in x around inf
lower-*.f6498.6
Applied rewrites98.6%
if -5e11 < (*.f64 (/.f64 #s(literal 841 binary64) #s(literal 108 binary64)) x) < 5.00000000000000024e-5Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites98.0%
Final simplification98.3%
(FPCore (x) :precision binary64 (- (* x 7.787037037037037) -0.13793103448275862))
double code(double x) {
return (x * 7.787037037037037) - -0.13793103448275862;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * 7.787037037037037d0) - (-0.13793103448275862d0)
end function
public static double code(double x) {
return (x * 7.787037037037037) - -0.13793103448275862;
}
def code(x): return (x * 7.787037037037037) - -0.13793103448275862
function code(x) return Float64(Float64(x * 7.787037037037037) - -0.13793103448275862) end
function tmp = code(x) tmp = (x * 7.787037037037037) - -0.13793103448275862; end
code[x_] := N[(N[(x * 7.787037037037037), $MachinePrecision] - -0.13793103448275862), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 7.787037037037037 - -0.13793103448275862
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lift-/.f64N/A
sub-negN/A
lower--.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
metadata-evalN/A
metadata-eval99.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (fma x 7.787037037037037 0.13793103448275862))
double code(double x) {
return fma(x, 7.787037037037037, 0.13793103448275862);
}
function code(x) return fma(x, 7.787037037037037, 0.13793103448275862) end
code[x_] := N[(x * 7.787037037037037 + 0.13793103448275862), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, 7.787037037037037, 0.13793103448275862\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-/.f64N/A
metadata-eval99.9
lift-/.f64N/A
metadata-eval99.9
Applied rewrites99.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
Applied rewrites49.8%
herbie shell --seed 2024221
(FPCore (x)
:name "Data.Colour.CIE:cieLABView from colour-2.3.3, A"
:precision binary64
(+ (* (/ 841.0 108.0) x) (/ 4.0 29.0)))