
(FPCore (x) :precision binary64 :pre TRUE (- (* x 116.0) 16.0))
double code(double x) {
return (x * 116.0) - 16.0;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (x * 116.0d0) - 16.0d0
end function
public static double code(double x) {
return (x * 116.0) - 16.0;
}
def code(x): return (x * 116.0) - 16.0
function code(x) return Float64(Float64(x * 116.0) - 16.0) end
function tmp = code(x) tmp = (x * 116.0) - 16.0; end
code[x_] := N[(N[(x * 116.0), $MachinePrecision] - 16.0), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (x * (116)) - (16) END code
x \cdot 116 - 16
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 :pre TRUE (- (* x 116.0) 16.0))
double code(double x) {
return (x * 116.0) - 16.0;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (x * 116.0d0) - 16.0d0
end function
public static double code(double x) {
return (x * 116.0) - 16.0;
}
def code(x): return (x * 116.0) - 16.0
function code(x) return Float64(Float64(x * 116.0) - 16.0) end
function tmp = code(x) tmp = (x * 116.0) - 16.0; end
code[x_] := N[(N[(x * 116.0), $MachinePrecision] - 16.0), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (x * (116)) - (16) END code
x \cdot 116 - 16
(FPCore (x) :precision binary64 :pre TRUE (fma 116.0 x -16.0))
double code(double x) {
return fma(116.0, x, -16.0);
}
function code(x) return fma(116.0, x, -16.0) end
code[x_] := N[(116.0 * x + -16.0), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = ((116) * x) + (-16) END code
\mathsf{fma}\left(116, x, -16\right)
Initial program 100.0%
Applied rewrites100.0%
(FPCore (x) :precision binary64 :pre TRUE (if (<= (* x 116.0) -1000.0) (* 116.0 x) (if (<= (* x 116.0) 5e-13) -16.0 (* 116.0 x))))
double code(double x) {
double tmp;
if ((x * 116.0) <= -1000.0) {
tmp = 116.0 * x;
} else if ((x * 116.0) <= 5e-13) {
tmp = -16.0;
} else {
tmp = 116.0 * x;
}
return tmp;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if ((x * 116.0d0) <= (-1000.0d0)) then
tmp = 116.0d0 * x
else if ((x * 116.0d0) <= 5d-13) then
tmp = -16.0d0
else
tmp = 116.0d0 * x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x * 116.0) <= -1000.0) {
tmp = 116.0 * x;
} else if ((x * 116.0) <= 5e-13) {
tmp = -16.0;
} else {
tmp = 116.0 * x;
}
return tmp;
}
def code(x): tmp = 0 if (x * 116.0) <= -1000.0: tmp = 116.0 * x elif (x * 116.0) <= 5e-13: tmp = -16.0 else: tmp = 116.0 * x return tmp
function code(x) tmp = 0.0 if (Float64(x * 116.0) <= -1000.0) tmp = Float64(116.0 * x); elseif (Float64(x * 116.0) <= 5e-13) tmp = -16.0; else tmp = Float64(116.0 * x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x * 116.0) <= -1000.0) tmp = 116.0 * x; elseif ((x * 116.0) <= 5e-13) tmp = -16.0; else tmp = 116.0 * x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(x * 116.0), $MachinePrecision], -1000.0], N[(116.0 * x), $MachinePrecision], If[LessEqual[N[(x * 116.0), $MachinePrecision], 5e-13], -16.0, N[(116.0 * x), $MachinePrecision]]]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = LET tmp_1 = IF ((x * (116)) <= (499999999999999989943323814627807683626421753064761333007481880486011505126953125e-93)) THEN (-16) ELSE ((116) * x) ENDIF IN LET tmp = IF ((x * (116)) <= (-1000)) THEN ((116) * x) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;x \cdot 116 \leq -1000:\\
\;\;\;\;116 \cdot x\\
\mathbf{elif}\;x \cdot 116 \leq 5 \cdot 10^{-13}:\\
\;\;\;\;-16\\
\mathbf{else}:\\
\;\;\;\;116 \cdot x\\
\end{array}
if (*.f64 x #s(literal 116 binary64)) < -1e3 or 4.9999999999999999e-13 < (*.f64 x #s(literal 116 binary64)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites50.8%
Taylor expanded in x around inf
Applied rewrites50.7%
if -1e3 < (*.f64 x #s(literal 116 binary64)) < 4.9999999999999999e-13Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites50.8%
(FPCore (x) :precision binary64 :pre TRUE -16.0)
double code(double x) {
return -16.0;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = -16.0d0
end function
public static double code(double x) {
return -16.0;
}
def code(x): return -16.0
function code(x) return -16.0 end
function tmp = code(x) tmp = -16.0; end
code[x_] := -16.0
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = -16 END code
-16
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites50.8%
herbie shell --seed 2026092
(FPCore (x)
:name "Data.Colour.CIE:lightness from colour-2.3.3"
:precision binary64
(- (* x 116.0) 16.0))