
(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 (* x (+ 7.787037037037037 (/ 0.13793103448275862 x))))
double code(double x) {
return x * (7.787037037037037 + (0.13793103448275862 / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (7.787037037037037d0 + (0.13793103448275862d0 / x))
end function
public static double code(double x) {
return x * (7.787037037037037 + (0.13793103448275862 / x));
}
def code(x): return x * (7.787037037037037 + (0.13793103448275862 / x))
function code(x) return Float64(x * Float64(7.787037037037037 + Float64(0.13793103448275862 / x))) end
function tmp = code(x) tmp = x * (7.787037037037037 + (0.13793103448275862 / x)); end
code[x_] := N[(x * N[(7.787037037037037 + N[(0.13793103448275862 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(7.787037037037037 + \frac{0.13793103448275862}{x}\right)
\end{array}
Initial program 99.9%
+-lowering-+.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
metadata-eval99.9%
Simplified99.9%
flip-+N/A
clear-numN/A
associate-/r/N/A
flip3--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
Applied egg-rr74.2%
Taylor expanded in x around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6426.4%
Simplified26.4%
clear-numN/A
associate-/r/N/A
associate-/r/N/A
metadata-evalN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
div-invN/A
associate-*l*N/A
*-commutativeN/A
associate-*r/N/A
*-commutativeN/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr51.2%
Taylor expanded in x around inf
+-lowering-+.f64N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f6499.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (if (<= x -0.018) (* 7.787037037037037 x) (if (<= x 0.0175) 0.13793103448275862 (* 7.787037037037037 x))))
double code(double x) {
double tmp;
if (x <= -0.018) {
tmp = 7.787037037037037 * x;
} else if (x <= 0.0175) {
tmp = 0.13793103448275862;
} else {
tmp = 7.787037037037037 * x;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-0.018d0)) then
tmp = 7.787037037037037d0 * x
else if (x <= 0.0175d0) then
tmp = 0.13793103448275862d0
else
tmp = 7.787037037037037d0 * x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -0.018) {
tmp = 7.787037037037037 * x;
} else if (x <= 0.0175) {
tmp = 0.13793103448275862;
} else {
tmp = 7.787037037037037 * x;
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.018: tmp = 7.787037037037037 * x elif x <= 0.0175: tmp = 0.13793103448275862 else: tmp = 7.787037037037037 * x return tmp
function code(x) tmp = 0.0 if (x <= -0.018) tmp = Float64(7.787037037037037 * x); elseif (x <= 0.0175) tmp = 0.13793103448275862; else tmp = Float64(7.787037037037037 * x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -0.018) tmp = 7.787037037037037 * x; elseif (x <= 0.0175) tmp = 0.13793103448275862; else tmp = 7.787037037037037 * x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -0.018], N[(7.787037037037037 * x), $MachinePrecision], If[LessEqual[x, 0.0175], 0.13793103448275862, N[(7.787037037037037 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.018:\\
\;\;\;\;7.787037037037037 \cdot x\\
\mathbf{elif}\;x \leq 0.0175:\\
\;\;\;\;0.13793103448275862\\
\mathbf{else}:\\
\;\;\;\;7.787037037037037 \cdot x\\
\end{array}
\end{array}
if x < -0.0179999999999999986 or 0.017500000000000002 < x Initial program 99.8%
+-lowering-+.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around inf
*-lowering-*.f6498.3%
Simplified98.3%
if -0.0179999999999999986 < x < 0.017500000000000002Initial program 100.0%
+-lowering-+.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0
Simplified99.0%
(FPCore (x) :precision binary64 (+ 0.13793103448275862 (* 7.787037037037037 x)))
double code(double x) {
return 0.13793103448275862 + (7.787037037037037 * x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.13793103448275862d0 + (7.787037037037037d0 * x)
end function
public static double code(double x) {
return 0.13793103448275862 + (7.787037037037037 * x);
}
def code(x): return 0.13793103448275862 + (7.787037037037037 * x)
function code(x) return Float64(0.13793103448275862 + Float64(7.787037037037037 * x)) end
function tmp = code(x) tmp = 0.13793103448275862 + (7.787037037037037 * x); end
code[x_] := N[(0.13793103448275862 + N[(7.787037037037037 * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.13793103448275862 + 7.787037037037037 \cdot x
\end{array}
Initial program 99.9%
+-lowering-+.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
metadata-eval99.9%
Simplified99.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%
+-lowering-+.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0
Simplified50.7%
herbie shell --seed 2024161
(FPCore (x)
:name "Data.Colour.CIE:cieLABView from colour-2.3.3, A"
:precision binary64
(+ (* (/ 841.0 108.0) x) (/ 4.0 29.0)))