
(FPCore (x) :precision binary64 :pre TRUE (+ (* (/ 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)
use fmin_fmax_functions
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]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (((841) / (108)) * x) + ((4) / (29)) END code
\frac{841}{108} \cdot x + \frac{4}{29}
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 :pre TRUE (+ (* (/ 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)
use fmin_fmax_functions
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]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (((841) / (108)) * x) + ((4) / (29)) END code
\frac{841}{108} \cdot x + \frac{4}{29}
(FPCore (x) :precision binary64 :pre TRUE (fma 7.787037037037037 x 0.13793103448275862))
double code(double x) {
return fma(7.787037037037037, x, 0.13793103448275862);
}
function code(x) return fma(7.787037037037037, x, 0.13793103448275862) end
code[x_] := N[(7.787037037037037 * x + 0.13793103448275862), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = ((778703703703703720151452216668985784053802490234375e-50) * x) + (137931034482758618775477543749730102717876434326171875e-54) END code
\mathsf{fma}\left(7.787037037037037, x, 0.13793103448275862\right)
Initial program 99.9%
Applied rewrites99.9%
(FPCore (x)
:precision binary64
:pre TRUE
(let* ((t_0 (* (/ 841.0 108.0) x)))
(if (<= t_0 -100.0)
(* x 7.787037037037037)
(if (<= t_0 2e-14) 0.13793103448275862 (* x 7.787037037037037)))))double code(double x) {
double t_0 = (841.0 / 108.0) * x;
double tmp;
if (t_0 <= -100.0) {
tmp = x * 7.787037037037037;
} else if (t_0 <= 2e-14) {
tmp = 0.13793103448275862;
} else {
tmp = x * 7.787037037037037;
}
return tmp;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (841.0d0 / 108.0d0) * x
if (t_0 <= (-100.0d0)) then
tmp = x * 7.787037037037037d0
else if (t_0 <= 2d-14) then
tmp = 0.13793103448275862d0
else
tmp = x * 7.787037037037037d0
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) {
tmp = x * 7.787037037037037;
} else if (t_0 <= 2e-14) {
tmp = 0.13793103448275862;
} else {
tmp = x * 7.787037037037037;
}
return tmp;
}
def code(x): t_0 = (841.0 / 108.0) * x tmp = 0 if t_0 <= -100.0: tmp = x * 7.787037037037037 elif t_0 <= 2e-14: tmp = 0.13793103448275862 else: tmp = x * 7.787037037037037 return tmp
function code(x) t_0 = Float64(Float64(841.0 / 108.0) * x) tmp = 0.0 if (t_0 <= -100.0) tmp = Float64(x * 7.787037037037037); elseif (t_0 <= 2e-14) tmp = 0.13793103448275862; else tmp = Float64(x * 7.787037037037037); end return tmp end
function tmp_2 = code(x) t_0 = (841.0 / 108.0) * x; tmp = 0.0; if (t_0 <= -100.0) tmp = x * 7.787037037037037; elseif (t_0 <= 2e-14) tmp = 0.13793103448275862; else tmp = x * 7.787037037037037; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(841.0 / 108.0), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[t$95$0, -100.0], N[(x * 7.787037037037037), $MachinePrecision], If[LessEqual[t$95$0, 2e-14], 0.13793103448275862, N[(x * 7.787037037037037), $MachinePrecision]]]]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = LET t_0 = (((841) / (108)) * x) IN LET tmp_1 = IF (t_0 <= (1999999999999999997638618709119797394268658145832784356343836407177150249481201171875e-98)) THEN (137931034482758618775477543749730102717876434326171875e-54) ELSE (x * (778703703703703720151452216668985784053802490234375e-50)) ENDIF IN LET tmp = IF (t_0 <= (-100)) THEN (x * (778703703703703720151452216668985784053802490234375e-50)) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := \frac{841}{108} \cdot x\\
\mathbf{if}\;t\_0 \leq -100:\\
\;\;\;\;x \cdot 7.787037037037037\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-14}:\\
\;\;\;\;0.13793103448275862\\
\mathbf{else}:\\
\;\;\;\;x \cdot 7.787037037037037\\
\end{array}
if (*.f64 (/.f64 #s(literal 841 binary64) #s(literal 108 binary64)) x) < -100 or 2e-14 < (*.f64 (/.f64 #s(literal 841 binary64) #s(literal 108 binary64)) x) Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites50.8%
if -100 < (*.f64 (/.f64 #s(literal 841 binary64) #s(literal 108 binary64)) x) < 2e-14Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites50.8%
(FPCore (x) :precision binary64 :pre TRUE 0.13793103448275862)
double code(double x) {
return 0.13793103448275862;
}
real(8) function code(x)
use fmin_fmax_functions
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
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = 137931034482758618775477543749730102717876434326171875e-54 END code
0.13793103448275862
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites50.8%
herbie shell --seed 2026092
(FPCore (x)
:name "Data.Colour.CIE:cieLABView from colour-2.3.3, A"
:precision binary64
(+ (* (/ 841.0 108.0) x) (/ 4.0 29.0)))