
(FPCore (x y z t) :precision binary64 :pre TRUE (+ x (/ (* (- y x) z) t)))
double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + (((y - x) * z) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
def code(x, y, z, t): return x + (((y - x) * z) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(Float64(y - x) * z) / t)) end
function tmp = code(x, y, z, t) tmp = x + (((y - x) * z) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = x + (((y - x) * z) / t) END code
x + \frac{\left(y - x\right) \cdot z}{t}
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 :pre TRUE (+ x (/ (* (- y x) z) t)))
double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + (((y - x) * z) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
def code(x, y, z, t): return x + (((y - x) * z) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(Float64(y - x) * z) / t)) end
function tmp = code(x, y, z, t) tmp = x + (((y - x) * z) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = x + (((y - x) * z) / t) END code
x + \frac{\left(y - x\right) \cdot z}{t}
(FPCore (x y z t) :precision binary64 :pre TRUE (fma (- y x) (/ z t) x))
double code(double x, double y, double z, double t) {
return fma((y - x), (z / t), x);
}
function code(x, y, z, t) return fma(Float64(y - x), Float64(z / t), x) end
code[x_, y_, z_, t_] := N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision] + x), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = ((y - x) * (z / t)) + x END code
\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)
Initial program 92.6%
Applied rewrites97.7%
(FPCore (x y z t)
:precision binary64
:pre TRUE
(let* ((t_1 (fma z (/ (- y x) t) x)))
(if (<= z -4.728533899018201e-139)
t_1
(if (<= z 6.252784341431828e-144) (+ x (/ (* y z) t)) t_1))))double code(double x, double y, double z, double t) {
double t_1 = fma(z, ((y - x) / t), x);
double tmp;
if (z <= -4.728533899018201e-139) {
tmp = t_1;
} else if (z <= 6.252784341431828e-144) {
tmp = x + ((y * z) / t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(z, Float64(Float64(y - x) / t), x) tmp = 0.0 if (z <= -4.728533899018201e-139) tmp = t_1; elseif (z <= 6.252784341431828e-144) tmp = Float64(x + Float64(Float64(y * z) / t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -4.728533899018201e-139], t$95$1, If[LessEqual[z, 6.252784341431828e-144], N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = LET t_1 = ((z * ((y - x) / t)) + x) IN LET tmp_1 = IF (z <= (62527843414318284319719186882294129945665249758899645478466771126279286229732234053854960031919877088596234922290488433363746527256442759741628772655174069142188068917128278829357567423586008842545337851794968377781359039242519844761653512788956608172266090888065588382911232572899901562758371090199375151908011040129850746210936354266374617195956009396695662871934473514556884765625e-526)) THEN (x + ((y * z) / t)) ELSE t_1 ENDIF IN LET tmp = IF (z <= (-4728533899018200774641182461610982058121710058363072129266127018695922885542054899446073763047811518160217172628469730287682553638056889081744717244442655850490171087568147235982100242987047427902356625302140388120547202609837905052830333942549129578531123285954401523057544004834867761435383436144458441063639988092998275693600355139289970196614376618526875972747802734375e-511)) THEN t_1 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, \frac{y - x}{t}, x\right)\\
\mathbf{if}\;z \leq -4.728533899018201 \cdot 10^{-139}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 6.252784341431828 \cdot 10^{-144}:\\
\;\;\;\;x + \frac{y \cdot z}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if z < -4.7285338990182008e-139 or 6.2527843414318284e-144 < z Initial program 92.6%
Applied rewrites92.4%
if -4.7285338990182008e-139 < z < 6.2527843414318284e-144Initial program 92.6%
Taylor expanded in x around 0
Applied rewrites73.0%
(FPCore (x y z t) :precision binary64 :pre TRUE (fma y (/ z t) x))
double code(double x, double y, double z, double t) {
return fma(y, (z / t), x);
}
function code(x, y, z, t) return fma(y, Float64(z / t), x) end
code[x_, y_, z_, t_] := N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = (y * (z / t)) + x END code
\mathsf{fma}\left(y, \frac{z}{t}, x\right)
Initial program 92.6%
Taylor expanded in x around 0
Applied rewrites73.0%
Applied rewrites76.4%
(FPCore (x y z t) :precision binary64 :pre TRUE (fma z (/ y t) x))
double code(double x, double y, double z, double t) {
return fma(z, (y / t), x);
}
function code(x, y, z, t) return fma(z, Float64(y / t), x) end
code[x_, y_, z_, t_] := N[(z * N[(y / t), $MachinePrecision] + x), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = (z * (y / t)) + x END code
\mathsf{fma}\left(z, \frac{y}{t}, x\right)
Initial program 92.6%
Taylor expanded in x around 0
Applied rewrites73.0%
Applied rewrites72.8%
herbie shell --seed 2026092
(FPCore (x y z t)
:name "Numeric.Histogram:binBounds from Chart-1.5.3"
:precision binary64
(+ x (/ (* (- y x) z) t)))