
(FPCore (x y) :precision binary64 :pre TRUE (- (* (+ x 1.0) y) x))
double code(double x, double y) {
return ((x + 1.0) * y) - x;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x + 1.0d0) * y) - x
end function
public static double code(double x, double y) {
return ((x + 1.0) * y) - x;
}
def code(x, y): return ((x + 1.0) * y) - x
function code(x, y) return Float64(Float64(Float64(x + 1.0) * y) - x) end
function tmp = code(x, y) tmp = ((x + 1.0) * y) - x; end
code[x_, y_] := N[(N[(N[(x + 1.0), $MachinePrecision] * y), $MachinePrecision] - x), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((x + (1)) * y) - x END code
\left(x + 1\right) \cdot y - x
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (- (* (+ x 1.0) y) x))
double code(double x, double y) {
return ((x + 1.0) * y) - x;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x + 1.0d0) * y) - x
end function
public static double code(double x, double y) {
return ((x + 1.0) * y) - x;
}
def code(x, y): return ((x + 1.0) * y) - x
function code(x, y) return Float64(Float64(Float64(x + 1.0) * y) - x) end
function tmp = code(x, y) tmp = ((x + 1.0) * y) - x; end
code[x_, y_] := N[(N[(N[(x + 1.0), $MachinePrecision] * y), $MachinePrecision] - x), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((x + (1)) * y) - x END code
\left(x + 1\right) \cdot y - x
(FPCore (x y) :precision binary64 :pre TRUE (fma x y (- y x)))
double code(double x, double y) {
return fma(x, y, (y - x));
}
function code(x, y) return fma(x, y, Float64(y - x)) end
code[x_, y_] := N[(x * y + N[(y - x), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (x * y) + (y - x) END code
\mathsf{fma}\left(x, y, y - x\right)
Initial program 100.0%
Applied rewrites100.0%
(FPCore (x y)
:precision binary64
:pre TRUE
(let* ((t_0 (* x (- y 1.0))))
(if (<= x -618.7610523406546)
t_0
(if (<= x 246929.50132633775) (- y x) t_0))))double code(double x, double y) {
double t_0 = x * (y - 1.0);
double tmp;
if (x <= -618.7610523406546) {
tmp = t_0;
} else if (x <= 246929.50132633775) {
tmp = y - x;
} else {
tmp = t_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 * (y - 1.0d0)
if (x <= (-618.7610523406546d0)) then
tmp = t_0
else if (x <= 246929.50132633775d0) then
tmp = y - x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * (y - 1.0);
double tmp;
if (x <= -618.7610523406546) {
tmp = t_0;
} else if (x <= 246929.50132633775) {
tmp = y - x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x * (y - 1.0) tmp = 0 if x <= -618.7610523406546: tmp = t_0 elif x <= 246929.50132633775: tmp = y - x else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x * Float64(y - 1.0)) tmp = 0.0 if (x <= -618.7610523406546) tmp = t_0; elseif (x <= 246929.50132633775) tmp = Float64(y - x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x * (y - 1.0); tmp = 0.0; if (x <= -618.7610523406546) tmp = t_0; elseif (x <= 246929.50132633775) tmp = y - x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(y - 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -618.7610523406546], t$95$0, If[LessEqual[x, 246929.50132633775], N[(y - x), $MachinePrecision], t$95$0]]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET t_0 = (x * (y - (1))) IN LET tmp_1 = IF (x <= (2469295013263377477414906024932861328125e-34)) THEN (y - x) ELSE t_0 ENDIF IN LET tmp = IF (x <= (-6187610523406546008118311874568462371826171875e-43)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x \cdot \left(y - 1\right)\\
\mathbf{if}\;x \leq -618.7610523406546:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 246929.50132633775:\\
\;\;\;\;y - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -618.7610523406546 or 246929.50132633775 < x Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites63.5%
if -618.7610523406546 < x < 246929.50132633775Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites74.8%
(FPCore (x y) :precision binary64 :pre TRUE (- y x))
double code(double x, double y) {
return y - x;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y - x
end function
public static double code(double x, double y) {
return y - x;
}
def code(x, y): return y - x
function code(x, y) return Float64(y - x) end
function tmp = code(x, y) tmp = y - x; end
code[x_, y_] := N[(y - x), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = y - x END code
y - x
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites74.8%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= x -3.712143610141413e-15) (- x) (if (<= x 2.394325450771144e-33) y (- x))))
double code(double x, double y) {
double tmp;
if (x <= -3.712143610141413e-15) {
tmp = -x;
} else if (x <= 2.394325450771144e-33) {
tmp = y;
} else {
tmp = -x;
}
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 (x <= (-3.712143610141413d-15)) then
tmp = -x
else if (x <= 2.394325450771144d-33) then
tmp = y
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3.712143610141413e-15) {
tmp = -x;
} else if (x <= 2.394325450771144e-33) {
tmp = y;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.712143610141413e-15: tmp = -x elif x <= 2.394325450771144e-33: tmp = y else: tmp = -x return tmp
function code(x, y) tmp = 0.0 if (x <= -3.712143610141413e-15) tmp = Float64(-x); elseif (x <= 2.394325450771144e-33) tmp = y; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3.712143610141413e-15) tmp = -x; elseif (x <= 2.394325450771144e-33) tmp = y; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.712143610141413e-15], (-x), If[LessEqual[x, 2.394325450771144e-33], y, (-x)]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp_1 = IF (x <= (23943254507711438993143429196243359042823939859644038686053973230752092945912903125516534019734393723410903476178646087646484375e-160)) THEN y ELSE (- x) ENDIF IN LET tmp = IF (x <= (-37121436101414133244504551030812255985592254710347948076787361060269176959991455078125e-100)) THEN (- x) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;x \leq -3.712143610141413 \cdot 10^{-15}:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq 2.394325450771144 \cdot 10^{-33}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
if x < -3.7121436101414133e-15 or 2.3943254507711439e-33 < x Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites39.0%
Applied rewrites39.0%
if -3.7121436101414133e-15 < x < 2.3943254507711439e-33Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites39.0%
Applied rewrites39.0%
Taylor expanded in undef-var around zero
Applied rewrites2.6%
Taylor expanded in x around 0
Applied rewrites38.0%
(FPCore (x y) :precision binary64 :pre TRUE y)
double code(double x, double y) {
return y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y
end function
public static double code(double x, double y) {
return y;
}
def code(x, y): return y
function code(x, y) return y end
function tmp = code(x, y) tmp = y; end
code[x_, y_] := y
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = y END code
y
Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites39.0%
Applied rewrites39.0%
Taylor expanded in undef-var around zero
Applied rewrites2.6%
Taylor expanded in x around 0
Applied rewrites38.0%
herbie shell --seed 2026092
(FPCore (x y)
:name "Data.Colour.SRGB:transferFunction from colour-2.3.3"
:precision binary64
(- (* (+ x 1.0) y) x))