
(FPCore (x y) :precision binary64 :pre TRUE (* 200.0 (- x y)))
double code(double x, double y) {
return 200.0 * (x - y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 200.0d0 * (x - y)
end function
public static double code(double x, double y) {
return 200.0 * (x - y);
}
def code(x, y): return 200.0 * (x - y)
function code(x, y) return Float64(200.0 * Float64(x - y)) end
function tmp = code(x, y) tmp = 200.0 * (x - y); end
code[x_, y_] := N[(200.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 = (200) * (x - y) END code
200 \cdot \left(x - y\right)
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (* 200.0 (- x y)))
double code(double x, double y) {
return 200.0 * (x - y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 200.0d0 * (x - y)
end function
public static double code(double x, double y) {
return 200.0 * (x - y);
}
def code(x, y): return 200.0 * (x - y)
function code(x, y) return Float64(200.0 * Float64(x - y)) end
function tmp = code(x, y) tmp = 200.0 * (x - y); end
code[x_, y_] := N[(200.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 = (200) * (x - y) END code
200 \cdot \left(x - y\right)
(FPCore (x y) :precision binary64 :pre TRUE (fma -200.0 y (* 200.0 x)))
double code(double x, double y) {
return fma(-200.0, y, (200.0 * x));
}
function code(x, y) return fma(-200.0, y, Float64(200.0 * x)) end
code[x_, y_] := N[(-200.0 * y + N[(200.0 * x), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((-200) * y) + ((200) * x) END code
\mathsf{fma}\left(-200, y, 200 \cdot x\right)
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= y -4.155509726251822e+46) (* -200.0 y) (if (<= y 2.426229654520916e+48) (* 200.0 x) (* -200.0 y))))
double code(double x, double y) {
double tmp;
if (y <= -4.155509726251822e+46) {
tmp = -200.0 * y;
} else if (y <= 2.426229654520916e+48) {
tmp = 200.0 * x;
} else {
tmp = -200.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 = (-200.0d0) * y
else if (y <= 2.426229654520916d+48) then
tmp = 200.0d0 * x
else
tmp = (-200.0d0) * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -4.155509726251822e+46) {
tmp = -200.0 * y;
} else if (y <= 2.426229654520916e+48) {
tmp = 200.0 * x;
} else {
tmp = -200.0 * y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.155509726251822e+46: tmp = -200.0 * y elif y <= 2.426229654520916e+48: tmp = 200.0 * x else: tmp = -200.0 * y return tmp
function code(x, y) tmp = 0.0 if (y <= -4.155509726251822e+46) tmp = Float64(-200.0 * y); elseif (y <= 2.426229654520916e+48) tmp = Float64(200.0 * x); else tmp = Float64(-200.0 * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -4.155509726251822e+46) tmp = -200.0 * y; elseif (y <= 2.426229654520916e+48) tmp = 200.0 * x; else tmp = -200.0 * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -4.155509726251822e+46], N[(-200.0 * y), $MachinePrecision], If[LessEqual[y, 2.426229654520916e+48], N[(200.0 * x), $MachinePrecision], N[(-200.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 ((200) * x) ELSE ((-200) * y) ENDIF IN LET tmp = IF (y <= (-41555097262518219140230899091581622926874509312)) THEN ((-200) * y) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;y \leq -4.155509726251822 \cdot 10^{+46}:\\
\;\;\;\;-200 \cdot y\\
\mathbf{elif}\;y \leq 2.426229654520916 \cdot 10^{+48}:\\
\;\;\;\;200 \cdot x\\
\mathbf{else}:\\
\;\;\;\;-200 \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 (* -200.0 y))
double code(double x, double y) {
return -200.0 * y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (-200.0d0) * y
end function
public static double code(double x, double y) {
return -200.0 * y;
}
def code(x, y): return -200.0 * y
function code(x, y) return Float64(-200.0 * y) end
function tmp = code(x, y) tmp = -200.0 * y; end
code[x_, y_] := N[(-200.0 * y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (-200) * y END code
-200 \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, C"
:precision binary64
(* 200.0 (- x y)))