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