
(FPCore (x y) :precision binary64 :pre TRUE (* (* (- x (/ 16.0 116.0)) 3.0) y))
double code(double x, double y) {
return ((x - (16.0 / 116.0)) * 3.0) * y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x - (16.0d0 / 116.0d0)) * 3.0d0) * y
end function
public static double code(double x, double y) {
return ((x - (16.0 / 116.0)) * 3.0) * y;
}
def code(x, y): return ((x - (16.0 / 116.0)) * 3.0) * y
function code(x, y) return Float64(Float64(Float64(x - Float64(16.0 / 116.0)) * 3.0) * y) end
function tmp = code(x, y) tmp = ((x - (16.0 / 116.0)) * 3.0) * y; end
code[x_, y_] := N[(N[(N[(x - N[(16.0 / 116.0), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision] * y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((x - ((16) / (116))) * (3)) * y END code
\left(\left(x - \frac{16}{116}\right) \cdot 3\right) \cdot y
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (* (* (- x (/ 16.0 116.0)) 3.0) y))
double code(double x, double y) {
return ((x - (16.0 / 116.0)) * 3.0) * y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x - (16.0d0 / 116.0d0)) * 3.0d0) * y
end function
public static double code(double x, double y) {
return ((x - (16.0 / 116.0)) * 3.0) * y;
}
def code(x, y): return ((x - (16.0 / 116.0)) * 3.0) * y
function code(x, y) return Float64(Float64(Float64(x - Float64(16.0 / 116.0)) * 3.0) * y) end
function tmp = code(x, y) tmp = ((x - (16.0 / 116.0)) * 3.0) * y; end
code[x_, y_] := N[(N[(N[(x - N[(16.0 / 116.0), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision] * y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((x - ((16) / (116))) * (3)) * y END code
\left(\left(x - \frac{16}{116}\right) \cdot 3\right) \cdot y
(FPCore (x y) :precision binary64 :pre TRUE (* (fma 3.0 x -0.41379310344827586) y))
double code(double x, double y) {
return fma(3.0, x, -0.41379310344827586) * y;
}
function code(x, y) return Float64(fma(3.0, x, -0.41379310344827586) * y) end
code[x_, y_] := N[(N[(3.0 * x + -0.41379310344827586), $MachinePrecision] * y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (((3) * x) + (-413793103448275856326432631249190308153629302978515625e-54)) * y END code
\mathsf{fma}\left(3, x, -0.41379310344827586\right) \cdot y
Initial program 99.7%
Applied rewrites99.7%
(FPCore (x y)
:precision binary64
:pre TRUE
(let* ((t_0 (- x (/ 16.0 116.0))))
(if (<= t_0 -500.0)
(* 3.0 (* x y))
(if (<= t_0 -0.1) (* -0.41379310344827586 y) (* (* 3.0 x) y)))))double code(double x, double y) {
double t_0 = x - (16.0 / 116.0);
double tmp;
if (t_0 <= -500.0) {
tmp = 3.0 * (x * y);
} else if (t_0 <= -0.1) {
tmp = -0.41379310344827586 * y;
} else {
tmp = (3.0 * x) * y;
}
return tmp;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x - (16.0d0 / 116.0d0)
if (t_0 <= (-500.0d0)) then
tmp = 3.0d0 * (x * y)
else if (t_0 <= (-0.1d0)) then
tmp = (-0.41379310344827586d0) * y
else
tmp = (3.0d0 * x) * y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x - (16.0 / 116.0);
double tmp;
if (t_0 <= -500.0) {
tmp = 3.0 * (x * y);
} else if (t_0 <= -0.1) {
tmp = -0.41379310344827586 * y;
} else {
tmp = (3.0 * x) * y;
}
return tmp;
}
def code(x, y): t_0 = x - (16.0 / 116.0) tmp = 0 if t_0 <= -500.0: tmp = 3.0 * (x * y) elif t_0 <= -0.1: tmp = -0.41379310344827586 * y else: tmp = (3.0 * x) * y return tmp
function code(x, y) t_0 = Float64(x - Float64(16.0 / 116.0)) tmp = 0.0 if (t_0 <= -500.0) tmp = Float64(3.0 * Float64(x * y)); elseif (t_0 <= -0.1) tmp = Float64(-0.41379310344827586 * y); else tmp = Float64(Float64(3.0 * x) * y); end return tmp end
function tmp_2 = code(x, y) t_0 = x - (16.0 / 116.0); tmp = 0.0; if (t_0 <= -500.0) tmp = 3.0 * (x * y); elseif (t_0 <= -0.1) tmp = -0.41379310344827586 * y; else tmp = (3.0 * x) * y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x - N[(16.0 / 116.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -500.0], N[(3.0 * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.1], N[(-0.41379310344827586 * y), $MachinePrecision], N[(N[(3.0 * x), $MachinePrecision] * y), $MachinePrecision]]]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET t_0 = (x - ((16) / (116))) IN LET tmp_1 = IF (t_0 <= (-1000000000000000055511151231257827021181583404541015625e-55)) THEN ((-413793103448275856326432631249190308153629302978515625e-54) * y) ELSE (((3) * x) * y) ENDIF IN LET tmp = IF (t_0 <= (-500)) THEN ((3) * (x * y)) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x - \frac{16}{116}\\
\mathbf{if}\;t\_0 \leq -500:\\
\;\;\;\;3 \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;t\_0 \leq -0.1:\\
\;\;\;\;-0.41379310344827586 \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(3 \cdot x\right) \cdot y\\
\end{array}
if (-.f64 x (/.f64 #s(literal 16 binary64) #s(literal 116 binary64))) < -500Initial program 99.7%
Taylor expanded in x around inf
Applied rewrites51.2%
if -500 < (-.f64 x (/.f64 #s(literal 16 binary64) #s(literal 116 binary64))) < -0.10000000000000001Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites50.6%
if -0.10000000000000001 < (-.f64 x (/.f64 #s(literal 16 binary64) #s(literal 116 binary64))) Initial program 99.7%
Taylor expanded in x around inf
Applied rewrites51.2%
(FPCore (x y)
:precision binary64
:pre TRUE
(let* ((t_0 (- x (/ 16.0 116.0))))
(if (<= t_0 -500.0)
(* 3.0 (* x y))
(if (<= t_0 -0.1) (* -0.41379310344827586 y) (* x (* y 3.0))))))double code(double x, double y) {
double t_0 = x - (16.0 / 116.0);
double tmp;
if (t_0 <= -500.0) {
tmp = 3.0 * (x * y);
} else if (t_0 <= -0.1) {
tmp = -0.41379310344827586 * y;
} else {
tmp = x * (y * 3.0);
}
return tmp;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x - (16.0d0 / 116.0d0)
if (t_0 <= (-500.0d0)) then
tmp = 3.0d0 * (x * y)
else if (t_0 <= (-0.1d0)) then
tmp = (-0.41379310344827586d0) * y
else
tmp = x * (y * 3.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x - (16.0 / 116.0);
double tmp;
if (t_0 <= -500.0) {
tmp = 3.0 * (x * y);
} else if (t_0 <= -0.1) {
tmp = -0.41379310344827586 * y;
} else {
tmp = x * (y * 3.0);
}
return tmp;
}
def code(x, y): t_0 = x - (16.0 / 116.0) tmp = 0 if t_0 <= -500.0: tmp = 3.0 * (x * y) elif t_0 <= -0.1: tmp = -0.41379310344827586 * y else: tmp = x * (y * 3.0) return tmp
function code(x, y) t_0 = Float64(x - Float64(16.0 / 116.0)) tmp = 0.0 if (t_0 <= -500.0) tmp = Float64(3.0 * Float64(x * y)); elseif (t_0 <= -0.1) tmp = Float64(-0.41379310344827586 * y); else tmp = Float64(x * Float64(y * 3.0)); end return tmp end
function tmp_2 = code(x, y) t_0 = x - (16.0 / 116.0); tmp = 0.0; if (t_0 <= -500.0) tmp = 3.0 * (x * y); elseif (t_0 <= -0.1) tmp = -0.41379310344827586 * y; else tmp = x * (y * 3.0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x - N[(16.0 / 116.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -500.0], N[(3.0 * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.1], N[(-0.41379310344827586 * y), $MachinePrecision], N[(x * N[(y * 3.0), $MachinePrecision]), $MachinePrecision]]]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET t_0 = (x - ((16) / (116))) IN LET tmp_1 = IF (t_0 <= (-1000000000000000055511151231257827021181583404541015625e-55)) THEN ((-413793103448275856326432631249190308153629302978515625e-54) * y) ELSE (x * (y * (3))) ENDIF IN LET tmp = IF (t_0 <= (-500)) THEN ((3) * (x * y)) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x - \frac{16}{116}\\
\mathbf{if}\;t\_0 \leq -500:\\
\;\;\;\;3 \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;t\_0 \leq -0.1:\\
\;\;\;\;-0.41379310344827586 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot 3\right)\\
\end{array}
if (-.f64 x (/.f64 #s(literal 16 binary64) #s(literal 116 binary64))) < -500Initial program 99.7%
Taylor expanded in x around inf
Applied rewrites51.2%
if -500 < (-.f64 x (/.f64 #s(literal 16 binary64) #s(literal 116 binary64))) < -0.10000000000000001Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites50.6%
if -0.10000000000000001 < (-.f64 x (/.f64 #s(literal 16 binary64) #s(literal 116 binary64))) Initial program 99.7%
Taylor expanded in x around inf
Applied rewrites51.2%
Applied rewrites51.2%
(FPCore (x y)
:precision binary64
:pre TRUE
(let* ((t_0 (- x (/ 16.0 116.0))) (t_1 (* 3.0 (* x y))))
(if (<= t_0 -500.0)
t_1
(if (<= t_0 -0.1) (* -0.41379310344827586 y) t_1))))double code(double x, double y) {
double t_0 = x - (16.0 / 116.0);
double t_1 = 3.0 * (x * y);
double tmp;
if (t_0 <= -500.0) {
tmp = t_1;
} else if (t_0 <= -0.1) {
tmp = -0.41379310344827586 * y;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x - (16.0d0 / 116.0d0)
t_1 = 3.0d0 * (x * y)
if (t_0 <= (-500.0d0)) then
tmp = t_1
else if (t_0 <= (-0.1d0)) then
tmp = (-0.41379310344827586d0) * y
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x - (16.0 / 116.0);
double t_1 = 3.0 * (x * y);
double tmp;
if (t_0 <= -500.0) {
tmp = t_1;
} else if (t_0 <= -0.1) {
tmp = -0.41379310344827586 * y;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = x - (16.0 / 116.0) t_1 = 3.0 * (x * y) tmp = 0 if t_0 <= -500.0: tmp = t_1 elif t_0 <= -0.1: tmp = -0.41379310344827586 * y else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(x - Float64(16.0 / 116.0)) t_1 = Float64(3.0 * Float64(x * y)) tmp = 0.0 if (t_0 <= -500.0) tmp = t_1; elseif (t_0 <= -0.1) tmp = Float64(-0.41379310344827586 * y); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = x - (16.0 / 116.0); t_1 = 3.0 * (x * y); tmp = 0.0; if (t_0 <= -500.0) tmp = t_1; elseif (t_0 <= -0.1) tmp = -0.41379310344827586 * y; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x - N[(16.0 / 116.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(3.0 * N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -500.0], t$95$1, If[LessEqual[t$95$0, -0.1], N[(-0.41379310344827586 * y), $MachinePrecision], t$95$1]]]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET t_0 = (x - ((16) / (116))) IN LET t_1 = ((3) * (x * y)) IN LET tmp_1 = IF (t_0 <= (-1000000000000000055511151231257827021181583404541015625e-55)) THEN ((-413793103448275856326432631249190308153629302978515625e-54) * y) ELSE t_1 ENDIF IN LET tmp = IF (t_0 <= (-500)) THEN t_1 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x - \frac{16}{116}\\
t_1 := 3 \cdot \left(x \cdot y\right)\\
\mathbf{if}\;t\_0 \leq -500:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq -0.1:\\
\;\;\;\;-0.41379310344827586 \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (-.f64 x (/.f64 #s(literal 16 binary64) #s(literal 116 binary64))) < -500 or -0.10000000000000001 < (-.f64 x (/.f64 #s(literal 16 binary64) #s(literal 116 binary64))) Initial program 99.7%
Taylor expanded in x around inf
Applied rewrites51.2%
if -500 < (-.f64 x (/.f64 #s(literal 16 binary64) #s(literal 116 binary64))) < -0.10000000000000001Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites50.6%
(FPCore (x y) :precision binary64 :pre TRUE (* -0.41379310344827586 y))
double code(double x, double y) {
return -0.41379310344827586 * y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (-0.41379310344827586d0) * y
end function
public static double code(double x, double y) {
return -0.41379310344827586 * y;
}
def code(x, y): return -0.41379310344827586 * y
function code(x, y) return Float64(-0.41379310344827586 * y) end
function tmp = code(x, y) tmp = -0.41379310344827586 * y; end
code[x_, y_] := N[(-0.41379310344827586 * y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (-413793103448275856326432631249190308153629302978515625e-54) * y END code
-0.41379310344827586 \cdot y
Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites50.6%
herbie shell --seed 2026092
(FPCore (x y)
:name "Data.Colour.CIE:cieLAB from colour-2.3.3, A"
:precision binary64
(* (* (- x (/ 16.0 116.0)) 3.0) y))