
(FPCore (x y) :precision binary64 :pre TRUE (- (* x y) x))
double code(double x, double y) {
return (x * y) - x;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) - x
end function
public static double code(double x, double y) {
return (x * y) - x;
}
def code(x, y): return (x * y) - x
function code(x, y) return Float64(Float64(x * y) - x) end
function tmp = code(x, y) tmp = (x * y) - x; end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (x * y) - x END code
x \cdot y - x
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (- (* x y) x))
double code(double x, double y) {
return (x * y) - x;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) - x
end function
public static double code(double x, double y) {
return (x * y) - x;
}
def code(x, y): return (x * y) - x
function code(x, y) return Float64(Float64(x * y) - x) end
function tmp = code(x, y) tmp = (x * y) - x; end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (x * y) - x END code
x \cdot y - x
(FPCore (x y) :precision binary64 :pre TRUE (* x (- y 1.0)))
double code(double x, double y) {
return x * (y - 1.0);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (y - 1.0d0)
end function
public static double code(double x, double y) {
return x * (y - 1.0);
}
def code(x, y): return x * (y - 1.0)
function code(x, y) return Float64(x * Float64(y - 1.0)) end
function tmp = code(x, y) tmp = x * (y - 1.0); end
code[x_, y_] := N[(x * N[(y - 1.0), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = x * (y - (1)) END code
x \cdot \left(y - 1\right)
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= y -7.956262582700838) (* x y) (if (<= y 593.6025228697331) (- x) (* x y))))
double code(double x, double y) {
double tmp;
if (y <= -7.956262582700838) {
tmp = x * y;
} else if (y <= 593.6025228697331) {
tmp = -x;
} else {
tmp = x * 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 <= (-7.956262582700838d0)) then
tmp = x * y
else if (y <= 593.6025228697331d0) then
tmp = -x
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -7.956262582700838) {
tmp = x * y;
} else if (y <= 593.6025228697331) {
tmp = -x;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7.956262582700838: tmp = x * y elif y <= 593.6025228697331: tmp = -x else: tmp = x * y return tmp
function code(x, y) tmp = 0.0 if (y <= -7.956262582700838) tmp = Float64(x * y); elseif (y <= 593.6025228697331) tmp = Float64(-x); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -7.956262582700838) tmp = x * y; elseif (y <= 593.6025228697331) tmp = -x; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -7.956262582700838], N[(x * y), $MachinePrecision], If[LessEqual[y, 593.6025228697331], (-x), N[(x * 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 <= (59360252286973309310269542038440704345703125e-41)) THEN (- x) ELSE (x * y) ENDIF IN LET tmp = IF (y <= (-795626258270083841495079468586482107639312744140625e-50)) THEN (x * y) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;y \leq -7.956262582700838:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq 593.6025228697331:\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if y < -7.9562625827008384 or 593.60252286973309 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in y around inf
Applied rewrites51.3%
if -7.9562625827008384 < y < 593.60252286973309Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites50.7%
Applied rewrites50.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 Float64(-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 y around 0
Applied rewrites50.7%
Applied rewrites50.7%
herbie shell --seed 2026092
(FPCore (x y)
:name "Data.Histogram.Bin.LogBinD:$cbinSizeN from histogram-fill-0.8.4.1"
:precision binary64
(- (* x y) x))