
(FPCore (x y) :precision binary64 :pre TRUE (+ x (/ y 500.0)))
double code(double x, double y) {
return x + (y / 500.0);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (y / 500.0d0)
end function
public static double code(double x, double y) {
return x + (y / 500.0);
}
def code(x, y): return x + (y / 500.0)
function code(x, y) return Float64(x + Float64(y / 500.0)) end
function tmp = code(x, y) tmp = x + (y / 500.0); end
code[x_, y_] := N[(x + N[(y / 500.0), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = x + (y / (500)) END code
x + \frac{y}{500}
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (+ x (/ y 500.0)))
double code(double x, double y) {
return x + (y / 500.0);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (y / 500.0d0)
end function
public static double code(double x, double y) {
return x + (y / 500.0);
}
def code(x, y): return x + (y / 500.0)
function code(x, y) return Float64(x + Float64(y / 500.0)) end
function tmp = code(x, y) tmp = x + (y / 500.0); end
code[x_, y_] := N[(x + N[(y / 500.0), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = x + (y / (500)) END code
x + \frac{y}{500}
(FPCore (x y) :precision binary64 :pre TRUE (fma 0.002 y x))
double code(double x, double y) {
return fma(0.002, y, x);
}
function code(x, y) return fma(0.002, y, x) end
code[x_, y_] := N[(0.002 * y + x), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((200000000000000004163336342344337026588618755340576171875e-59) * y) + x END code
\mathsf{fma}\left(0.002, y, x\right)
Initial program 100.0%
Applied rewrites99.9%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= (/ y 500.0) -5e+30) (/ y 500.0) (if (<= (/ y 500.0) 5e+37) x (/ y 500.0))))
double code(double x, double y) {
double tmp;
if ((y / 500.0) <= -5e+30) {
tmp = y / 500.0;
} else if ((y / 500.0) <= 5e+37) {
tmp = x;
} else {
tmp = y / 500.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) :: tmp
if ((y / 500.0d0) <= (-5d+30)) then
tmp = y / 500.0d0
else if ((y / 500.0d0) <= 5d+37) then
tmp = x
else
tmp = y / 500.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y / 500.0) <= -5e+30) {
tmp = y / 500.0;
} else if ((y / 500.0) <= 5e+37) {
tmp = x;
} else {
tmp = y / 500.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y / 500.0) <= -5e+30: tmp = y / 500.0 elif (y / 500.0) <= 5e+37: tmp = x else: tmp = y / 500.0 return tmp
function code(x, y) tmp = 0.0 if (Float64(y / 500.0) <= -5e+30) tmp = Float64(y / 500.0); elseif (Float64(y / 500.0) <= 5e+37) tmp = x; else tmp = Float64(y / 500.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y / 500.0) <= -5e+30) tmp = y / 500.0; elseif ((y / 500.0) <= 5e+37) tmp = x; else tmp = y / 500.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(y / 500.0), $MachinePrecision], -5e+30], N[(y / 500.0), $MachinePrecision], If[LessEqual[N[(y / 500.0), $MachinePrecision], 5e+37], x, N[(y / 500.0), $MachinePrecision]]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp_1 = IF ((y / (500)) <= (49999999999999998874404911728017014784)) THEN x ELSE (y / (500)) ENDIF IN LET tmp = IF ((y / (500)) <= (-4999999999999999817948147482624)) THEN (y / (500)) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\frac{y}{500} \leq -5 \cdot 10^{+30}:\\
\;\;\;\;\frac{y}{500}\\
\mathbf{elif}\;\frac{y}{500} \leq 5 \cdot 10^{+37}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{500}\\
\end{array}
if (/.f64 y #s(literal 500 binary64)) < -4.9999999999999998e30 or 4.9999999999999999e37 < (/.f64 y #s(literal 500 binary64)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites49.7%
Applied rewrites49.8%
if -4.9999999999999998e30 < (/.f64 y #s(literal 500 binary64)) < 4.9999999999999999e37Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites49.7%
Applied rewrites49.8%
Taylor expanded in x around inf
Applied rewrites51.7%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= (/ y 500.0) -5e+30) (* 0.002 y) (if (<= (/ y 500.0) 5e+37) x (* 0.002 y))))
double code(double x, double y) {
double tmp;
if ((y / 500.0) <= -5e+30) {
tmp = 0.002 * y;
} else if ((y / 500.0) <= 5e+37) {
tmp = x;
} else {
tmp = 0.002 * 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) :: tmp
if ((y / 500.0d0) <= (-5d+30)) then
tmp = 0.002d0 * y
else if ((y / 500.0d0) <= 5d+37) then
tmp = x
else
tmp = 0.002d0 * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y / 500.0) <= -5e+30) {
tmp = 0.002 * y;
} else if ((y / 500.0) <= 5e+37) {
tmp = x;
} else {
tmp = 0.002 * y;
}
return tmp;
}
def code(x, y): tmp = 0 if (y / 500.0) <= -5e+30: tmp = 0.002 * y elif (y / 500.0) <= 5e+37: tmp = x else: tmp = 0.002 * y return tmp
function code(x, y) tmp = 0.0 if (Float64(y / 500.0) <= -5e+30) tmp = Float64(0.002 * y); elseif (Float64(y / 500.0) <= 5e+37) tmp = x; else tmp = Float64(0.002 * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y / 500.0) <= -5e+30) tmp = 0.002 * y; elseif ((y / 500.0) <= 5e+37) tmp = x; else tmp = 0.002 * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(y / 500.0), $MachinePrecision], -5e+30], N[(0.002 * y), $MachinePrecision], If[LessEqual[N[(y / 500.0), $MachinePrecision], 5e+37], x, N[(0.002 * y), $MachinePrecision]]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp_1 = IF ((y / (500)) <= (49999999999999998874404911728017014784)) THEN x ELSE ((200000000000000004163336342344337026588618755340576171875e-59) * y) ENDIF IN LET tmp = IF ((y / (500)) <= (-4999999999999999817948147482624)) THEN ((200000000000000004163336342344337026588618755340576171875e-59) * y) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\frac{y}{500} \leq -5 \cdot 10^{+30}:\\
\;\;\;\;0.002 \cdot y\\
\mathbf{elif}\;\frac{y}{500} \leq 5 \cdot 10^{+37}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;0.002 \cdot y\\
\end{array}
if (/.f64 y #s(literal 500 binary64)) < -4.9999999999999998e30 or 4.9999999999999999e37 < (/.f64 y #s(literal 500 binary64)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites49.7%
if -4.9999999999999998e30 < (/.f64 y #s(literal 500 binary64)) < 4.9999999999999999e37Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites49.7%
Applied rewrites49.8%
Taylor expanded in x around inf
Applied rewrites51.7%
(FPCore (x y) :precision binary64 :pre TRUE x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = x END code
x
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites49.7%
Applied rewrites49.8%
Taylor expanded in x around inf
Applied rewrites51.7%
herbie shell --seed 2026092
(FPCore (x y)
:name "Data.Colour.CIE:cieLAB from colour-2.3.3, C"
:precision binary64
(+ x (/ y 500.0)))