
(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 (- 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.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
lift-*.f64N/A
lower--.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-eval99.8
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (/ 841.0 108.0) x)))
(if (or (<= t_0 -100.0) (not (<= t_0 0.0001)))
(* 7.787037037037037 x)
0.13793103448275862)))
double code(double x) {
double t_0 = (841.0 / 108.0) * x;
double tmp;
if ((t_0 <= -100.0) || !(t_0 <= 0.0001)) {
tmp = 7.787037037037037 * x;
} else {
tmp = 0.13793103448275862;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (841.0d0 / 108.0d0) * x
if ((t_0 <= (-100.0d0)) .or. (.not. (t_0 <= 0.0001d0))) then
tmp = 7.787037037037037d0 * x
else
tmp = 0.13793103448275862d0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (841.0 / 108.0) * x;
double tmp;
if ((t_0 <= -100.0) || !(t_0 <= 0.0001)) {
tmp = 7.787037037037037 * x;
} else {
tmp = 0.13793103448275862;
}
return tmp;
}
def code(x): t_0 = (841.0 / 108.0) * x tmp = 0 if (t_0 <= -100.0) or not (t_0 <= 0.0001): tmp = 7.787037037037037 * x else: tmp = 0.13793103448275862 return tmp
function code(x) t_0 = Float64(Float64(841.0 / 108.0) * x) tmp = 0.0 if ((t_0 <= -100.0) || !(t_0 <= 0.0001)) tmp = Float64(7.787037037037037 * x); else tmp = 0.13793103448275862; end return tmp end
function tmp_2 = code(x) t_0 = (841.0 / 108.0) * x; tmp = 0.0; if ((t_0 <= -100.0) || ~((t_0 <= 0.0001))) tmp = 7.787037037037037 * x; else tmp = 0.13793103448275862; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(841.0 / 108.0), $MachinePrecision] * x), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -100.0], N[Not[LessEqual[t$95$0, 0.0001]], $MachinePrecision]], N[(7.787037037037037 * x), $MachinePrecision], 0.13793103448275862]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{841}{108} \cdot x\\
\mathbf{if}\;t\_0 \leq -100 \lor \neg \left(t\_0 \leq 0.0001\right):\\
\;\;\;\;7.787037037037037 \cdot x\\
\mathbf{else}:\\
\;\;\;\;0.13793103448275862\\
\end{array}
\end{array}
if (*.f64 (/.f64 #s(literal 841 binary64) #s(literal 108 binary64)) x) < -100 or 1.00000000000000005e-4 < (*.f64 (/.f64 #s(literal 841 binary64) #s(literal 108 binary64)) x) Initial program 99.7%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lower-sqrt.f6424.5
lift-/.f64N/A
metadata-eval24.5
lift-/.f64N/A
metadata-eval24.5
Applied rewrites24.5%
Taylor expanded in x around inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f6496.5
Applied rewrites96.5%
if -100 < (*.f64 (/.f64 #s(literal 841 binary64) #s(literal 108 binary64)) x) < 1.00000000000000005e-4Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites96.5%
Final simplification96.5%
(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.8%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
lift-/.f64N/A
metadata-eval99.8
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
(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.8%
Taylor expanded in x around 0
Applied rewrites51.7%
herbie shell --seed 2024326
(FPCore (x)
:name "Data.Colour.CIE:cieLABView from colour-2.3.3, A"
:precision binary64
(+ (* (/ 841.0 108.0) x) (/ 4.0 29.0)))