
(FPCore (x y) :precision binary64 :pre TRUE (* 500.0 (- x y)))
double code(double x, double y) {
return 500.0 * (x - y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 500.0d0 * (x - y)
end function
public static double code(double x, double y) {
return 500.0 * (x - y);
}
def code(x, y): return 500.0 * (x - y)
function code(x, y) return Float64(500.0 * Float64(x - y)) end
function tmp = code(x, y) tmp = 500.0 * (x - y); end
code[x_, y_] := N[(500.0 * N[(x - y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (500) * (x - y) END code
500 \cdot \left(x - y\right)
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (* 500.0 (- x y)))
double code(double x, double y) {
return 500.0 * (x - y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 500.0d0 * (x - y)
end function
public static double code(double x, double y) {
return 500.0 * (x - y);
}
def code(x, y): return 500.0 * (x - y)
function code(x, y) return Float64(500.0 * Float64(x - y)) end
function tmp = code(x, y) tmp = 500.0 * (x - y); end
code[x_, y_] := N[(500.0 * N[(x - y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (500) * (x - y) END code
500 \cdot \left(x - y\right)
(FPCore (x y) :precision binary64 :pre TRUE (fma 500.0 x (* -500.0 y)))
double code(double x, double y) {
return fma(500.0, x, (-500.0 * y));
}
function code(x, y) return fma(500.0, x, Float64(-500.0 * y)) end
code[x_, y_] := N[(500.0 * x + N[(-500.0 * y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((500) * x) + ((-500) * y) END code
\mathsf{fma}\left(500, x, -500 \cdot y\right)
Initial program 100.0%
Applied rewrites100.0%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= y -4.155509726251822e+46) (* -500.0 y) (if (<= y 2.426229654520916e+48) (* 500.0 x) (* -500.0 y))))
double code(double x, double y) {
double tmp;
if (y <= -4.155509726251822e+46) {
tmp = -500.0 * y;
} else if (y <= 2.426229654520916e+48) {
tmp = 500.0 * x;
} else {
tmp = -500.0 * 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 <= (-4.155509726251822d+46)) then
tmp = (-500.0d0) * y
else if (y <= 2.426229654520916d+48) then
tmp = 500.0d0 * x
else
tmp = (-500.0d0) * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -4.155509726251822e+46) {
tmp = -500.0 * y;
} else if (y <= 2.426229654520916e+48) {
tmp = 500.0 * x;
} else {
tmp = -500.0 * y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.155509726251822e+46: tmp = -500.0 * y elif y <= 2.426229654520916e+48: tmp = 500.0 * x else: tmp = -500.0 * y return tmp
function code(x, y) tmp = 0.0 if (y <= -4.155509726251822e+46) tmp = Float64(-500.0 * y); elseif (y <= 2.426229654520916e+48) tmp = Float64(500.0 * x); else tmp = Float64(-500.0 * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -4.155509726251822e+46) tmp = -500.0 * y; elseif (y <= 2.426229654520916e+48) tmp = 500.0 * x; else tmp = -500.0 * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -4.155509726251822e+46], N[(-500.0 * y), $MachinePrecision], If[LessEqual[y, 2.426229654520916e+48], N[(500.0 * x), $MachinePrecision], N[(-500.0 * 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 <= (2426229654520915891643607200729785382101422440448)) THEN ((500) * x) ELSE ((-500) * y) ENDIF IN LET tmp = IF (y <= (-41555097262518219140230899091581622926874509312)) THEN ((-500) * y) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;y \leq -4.155509726251822 \cdot 10^{+46}:\\
\;\;\;\;-500 \cdot y\\
\mathbf{elif}\;y \leq 2.426229654520916 \cdot 10^{+48}:\\
\;\;\;\;500 \cdot x\\
\mathbf{else}:\\
\;\;\;\;-500 \cdot y\\
\end{array}
if y < -4.1555097262518219e46 or 2.4262296545209159e48 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites50.2%
if -4.1555097262518219e46 < y < 2.4262296545209159e48Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites51.2%
(FPCore (x y) :precision binary64 :pre TRUE (* -500.0 y))
double code(double x, double y) {
return -500.0 * y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (-500.0d0) * y
end function
public static double code(double x, double y) {
return -500.0 * y;
}
def code(x, y): return -500.0 * y
function code(x, y) return Float64(-500.0 * y) end
function tmp = code(x, y) tmp = -500.0 * y; end
code[x_, y_] := N[(-500.0 * y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (-500) * y END code
-500 \cdot y
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites50.2%
herbie shell --seed 2026092
(FPCore (x y)
:name "Data.Colour.CIE:cieLABView from colour-2.3.3, B"
:precision binary64
(* 500.0 (- x y)))