
(FPCore (x) :precision binary64 :pre TRUE (/ (+ x 16.0) 116.0))
double code(double x) {
return (x + 16.0) / 116.0;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (x + 16.0d0) / 116.0d0
end function
public static double code(double x) {
return (x + 16.0) / 116.0;
}
def code(x): return (x + 16.0) / 116.0
function code(x) return Float64(Float64(x + 16.0) / 116.0) end
function tmp = code(x) tmp = (x + 16.0) / 116.0; end
code[x_] := N[(N[(x + 16.0), $MachinePrecision] / 116.0), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (x + (16)) / (116) END code
\frac{x + 16}{116}
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 :pre TRUE (/ (+ x 16.0) 116.0))
double code(double x) {
return (x + 16.0) / 116.0;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (x + 16.0d0) / 116.0d0
end function
public static double code(double x) {
return (x + 16.0) / 116.0;
}
def code(x): return (x + 16.0) / 116.0
function code(x) return Float64(Float64(x + 16.0) / 116.0) end
function tmp = code(x) tmp = (x + 16.0) / 116.0; end
code[x_] := N[(N[(x + 16.0), $MachinePrecision] / 116.0), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (x + (16)) / (116) END code
\frac{x + 16}{116}
(FPCore (x) :precision binary64 :pre TRUE (fma 0.008620689655172414 x 0.13793103448275862))
double code(double x) {
return fma(0.008620689655172414, x, 0.13793103448275862);
}
function code(x) return fma(0.008620689655172414, x, 0.13793103448275862) end
code[x_] := N[(0.008620689655172414 * x + 0.13793103448275862), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = ((86206896551724136734673464843581314198672771453857421875e-58) * x) + (137931034482758618775477543749730102717876434326171875e-54) END code
\mathsf{fma}\left(0.008620689655172414, x, 0.13793103448275862\right)
Initial program 100.0%
Applied rewrites99.9%
(FPCore (x) :precision binary64 :pre TRUE (if (<= (+ x 16.0) -0.5) (/ x 116.0) (if (<= (+ x 16.0) 20.0) 0.13793103448275862 (/ x 116.0))))
double code(double x) {
double tmp;
if ((x + 16.0) <= -0.5) {
tmp = x / 116.0;
} else if ((x + 16.0) <= 20.0) {
tmp = 0.13793103448275862;
} else {
tmp = x / 116.0;
}
return tmp;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if ((x + 16.0d0) <= (-0.5d0)) then
tmp = x / 116.0d0
else if ((x + 16.0d0) <= 20.0d0) then
tmp = 0.13793103448275862d0
else
tmp = x / 116.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x + 16.0) <= -0.5) {
tmp = x / 116.0;
} else if ((x + 16.0) <= 20.0) {
tmp = 0.13793103448275862;
} else {
tmp = x / 116.0;
}
return tmp;
}
def code(x): tmp = 0 if (x + 16.0) <= -0.5: tmp = x / 116.0 elif (x + 16.0) <= 20.0: tmp = 0.13793103448275862 else: tmp = x / 116.0 return tmp
function code(x) tmp = 0.0 if (Float64(x + 16.0) <= -0.5) tmp = Float64(x / 116.0); elseif (Float64(x + 16.0) <= 20.0) tmp = 0.13793103448275862; else tmp = Float64(x / 116.0); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x + 16.0) <= -0.5) tmp = x / 116.0; elseif ((x + 16.0) <= 20.0) tmp = 0.13793103448275862; else tmp = x / 116.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(x + 16.0), $MachinePrecision], -0.5], N[(x / 116.0), $MachinePrecision], If[LessEqual[N[(x + 16.0), $MachinePrecision], 20.0], 0.13793103448275862, N[(x / 116.0), $MachinePrecision]]]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = LET tmp_1 = IF ((x + (16)) <= (20)) THEN (137931034482758618775477543749730102717876434326171875e-54) ELSE (x / (116)) ENDIF IN LET tmp = IF ((x + (16)) <= (-5e-1)) THEN (x / (116)) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;x + 16 \leq -0.5:\\
\;\;\;\;\frac{x}{116}\\
\mathbf{elif}\;x + 16 \leq 20:\\
\;\;\;\;0.13793103448275862\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{116}\\
\end{array}
if (+.f64 x #s(literal 16 binary64)) < -0.5 or 20 < (+.f64 x #s(literal 16 binary64)) Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites50.4%
Applied rewrites50.4%
if -0.5 < (+.f64 x #s(literal 16 binary64)) < 20Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites51.2%
(FPCore (x)
:precision binary64
:pre TRUE
(if (<= (+ x 16.0) -0.5)
(* 0.008620689655172414 x)
(if (<= (+ x 16.0) 20.0)
0.13793103448275862
(* 0.008620689655172414 x))))double code(double x) {
double tmp;
if ((x + 16.0) <= -0.5) {
tmp = 0.008620689655172414 * x;
} else if ((x + 16.0) <= 20.0) {
tmp = 0.13793103448275862;
} else {
tmp = 0.008620689655172414 * x;
}
return tmp;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if ((x + 16.0d0) <= (-0.5d0)) then
tmp = 0.008620689655172414d0 * x
else if ((x + 16.0d0) <= 20.0d0) then
tmp = 0.13793103448275862d0
else
tmp = 0.008620689655172414d0 * x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x + 16.0) <= -0.5) {
tmp = 0.008620689655172414 * x;
} else if ((x + 16.0) <= 20.0) {
tmp = 0.13793103448275862;
} else {
tmp = 0.008620689655172414 * x;
}
return tmp;
}
def code(x): tmp = 0 if (x + 16.0) <= -0.5: tmp = 0.008620689655172414 * x elif (x + 16.0) <= 20.0: tmp = 0.13793103448275862 else: tmp = 0.008620689655172414 * x return tmp
function code(x) tmp = 0.0 if (Float64(x + 16.0) <= -0.5) tmp = Float64(0.008620689655172414 * x); elseif (Float64(x + 16.0) <= 20.0) tmp = 0.13793103448275862; else tmp = Float64(0.008620689655172414 * x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x + 16.0) <= -0.5) tmp = 0.008620689655172414 * x; elseif ((x + 16.0) <= 20.0) tmp = 0.13793103448275862; else tmp = 0.008620689655172414 * x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(x + 16.0), $MachinePrecision], -0.5], N[(0.008620689655172414 * x), $MachinePrecision], If[LessEqual[N[(x + 16.0), $MachinePrecision], 20.0], 0.13793103448275862, N[(0.008620689655172414 * x), $MachinePrecision]]]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = LET tmp_1 = IF ((x + (16)) <= (20)) THEN (137931034482758618775477543749730102717876434326171875e-54) ELSE ((86206896551724136734673464843581314198672771453857421875e-58) * x) ENDIF IN LET tmp = IF ((x + (16)) <= (-5e-1)) THEN ((86206896551724136734673464843581314198672771453857421875e-58) * x) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;x + 16 \leq -0.5:\\
\;\;\;\;0.008620689655172414 \cdot x\\
\mathbf{elif}\;x + 16 \leq 20:\\
\;\;\;\;0.13793103448275862\\
\mathbf{else}:\\
\;\;\;\;0.008620689655172414 \cdot x\\
\end{array}
if (+.f64 x #s(literal 16 binary64)) < -0.5 or 20 < (+.f64 x #s(literal 16 binary64)) Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites50.4%
if -0.5 < (+.f64 x #s(literal 16 binary64)) < 20Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites51.2%
(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 100.0%
Taylor expanded in x around 0
Applied rewrites51.2%
herbie shell --seed 2026092
(FPCore (x)
:name "Data.Colour.CIE:cieLAB from colour-2.3.3, B"
:precision binary64
(/ (+ x 16.0) 116.0))