
(FPCore (x y z t) :precision binary64 :pre TRUE (+ (* (/ x y) (- z t)) t))
double code(double x, double y, double z, double t) {
return ((x / y) * (z - t)) + 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) * (z - t)) + t
end function
public static double code(double x, double y, double z, double t) {
return ((x / y) * (z - t)) + t;
}
def code(x, y, z, t): return ((x / y) * (z - t)) + t
function code(x, y, z, t) return Float64(Float64(Float64(x / y) * Float64(z - t)) + t) end
function tmp = code(x, y, z, t) tmp = ((x / y) * (z - t)) + t; end
code[x_, y_, z_, t_] := N[(N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] + t), $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) * (z - t)) + t END code
\frac{x}{y} \cdot \left(z - t\right) + t
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 :pre TRUE (+ (* (/ x y) (- z t)) t))
double code(double x, double y, double z, double t) {
return ((x / y) * (z - t)) + 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) * (z - t)) + t
end function
public static double code(double x, double y, double z, double t) {
return ((x / y) * (z - t)) + t;
}
def code(x, y, z, t): return ((x / y) * (z - t)) + t
function code(x, y, z, t) return Float64(Float64(Float64(x / y) * Float64(z - t)) + t) end
function tmp = code(x, y, z, t) tmp = ((x / y) * (z - t)) + t; end
code[x_, y_, z_, t_] := N[(N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] + t), $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) * (z - t)) + t END code
\frac{x}{y} \cdot \left(z - t\right) + t
(FPCore (x y z t) :precision binary64 :pre TRUE (fma (- z t) (/ x y) t))
double code(double x, double y, double z, double t) {
return fma((z - t), (x / y), t);
}
function code(x, y, z, t) return fma(Float64(z - t), Float64(x / y), t) end
code[x_, y_, z_, t_] := N[(N[(z - t), $MachinePrecision] * N[(x / y), $MachinePrecision] + t), $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 - t) * (x / y)) + t END code
\mathsf{fma}\left(z - t, \frac{x}{y}, t\right)
Initial program 97.7%
Applied rewrites97.7%
(FPCore (x y z t)
:precision binary64
:pre TRUE
(let* ((t_1 (/ (* x (- z t)) y)))
(if (<= (/ x y) -2000000000000.0)
t_1
(if (<= (/ x y) 500000000000.0) (+ (* z (/ x y)) t) t_1))))double code(double x, double y, double z, double t) {
double t_1 = (x * (z - t)) / y;
double tmp;
if ((x / y) <= -2000000000000.0) {
tmp = t_1;
} else if ((x / y) <= 500000000000.0) {
tmp = (z * (x / y)) + t;
} else {
tmp = t_1;
}
return tmp;
}
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
real(8) :: t_1
real(8) :: tmp
t_1 = (x * (z - t)) / y
if ((x / y) <= (-2000000000000.0d0)) then
tmp = t_1
else if ((x / y) <= 500000000000.0d0) then
tmp = (z * (x / y)) + t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (x * (z - t)) / y;
double tmp;
if ((x / y) <= -2000000000000.0) {
tmp = t_1;
} else if ((x / y) <= 500000000000.0) {
tmp = (z * (x / y)) + t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * (z - t)) / y tmp = 0 if (x / y) <= -2000000000000.0: tmp = t_1 elif (x / y) <= 500000000000.0: tmp = (z * (x / y)) + t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * Float64(z - t)) / y) tmp = 0.0 if (Float64(x / y) <= -2000000000000.0) tmp = t_1; elseif (Float64(x / y) <= 500000000000.0) tmp = Float64(Float64(z * Float64(x / y)) + t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * (z - t)) / y; tmp = 0.0; if ((x / y) <= -2000000000000.0) tmp = t_1; elseif ((x / y) <= 500000000000.0) tmp = (z * (x / y)) + t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[(z - t), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -2000000000000.0], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 500000000000.0], N[(N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision] + t), $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 = ((x * (z - t)) / y) IN LET tmp_1 = IF ((x / y) <= (5e11)) THEN ((z * (x / y)) + t) ELSE t_1 ENDIF IN LET tmp = IF ((x / y) <= (-2e12)) THEN t_1 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_1 := \frac{x \cdot \left(z - t\right)}{y}\\
\mathbf{if}\;\frac{x}{y} \leq -2000000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{x}{y} \leq 500000000000:\\
\;\;\;\;z \cdot \frac{x}{y} + t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (/.f64 x y) < -2e12 or 5e11 < (/.f64 x y) Initial program 97.7%
Applied rewrites84.5%
Taylor expanded in x around 0
Applied rewrites28.7%
Taylor expanded in x around inf
Applied rewrites58.6%
if -2e12 < (/.f64 x y) < 5e11Initial program 97.7%
Taylor expanded in z around inf
Applied rewrites72.1%
Applied rewrites75.7%
(FPCore (x y z t)
:precision binary64
:pre TRUE
(let* ((t_1 (/ (* x (- z t)) y)))
(if (<= (/ x y) -2e-6)
t_1
(if (<= (/ x y) 5e-6) (fma x (/ z y) t) t_1))))double code(double x, double y, double z, double t) {
double t_1 = (x * (z - t)) / y;
double tmp;
if ((x / y) <= -2e-6) {
tmp = t_1;
} else if ((x / y) <= 5e-6) {
tmp = fma(x, (z / y), t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x * Float64(z - t)) / y) tmp = 0.0 if (Float64(x / y) <= -2e-6) tmp = t_1; elseif (Float64(x / y) <= 5e-6) tmp = fma(x, Float64(z / y), t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[(z - t), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -2e-6], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 5e-6], N[(x * N[(z / y), $MachinePrecision] + t), $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 = ((x * (z - t)) / y) IN LET tmp_1 = IF ((x / y) <= (50000000000000004090152695701565477293115691281855106353759765625e-70)) THEN ((x * (z / y)) + t) ELSE t_1 ENDIF IN LET tmp = IF ((x / y) <= (-199999999999999990949622365177251737122787744738161563873291015625e-71)) THEN t_1 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_1 := \frac{x \cdot \left(z - t\right)}{y}\\
\mathbf{if}\;\frac{x}{y} \leq -2 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{x}{y} \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{z}{y}, t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (/.f64 x y) < -1.9999999999999999e-6 or 5.0000000000000004e-6 < (/.f64 x y) Initial program 97.7%
Applied rewrites84.5%
Taylor expanded in x around 0
Applied rewrites28.7%
Taylor expanded in x around inf
Applied rewrites58.6%
if -1.9999999999999999e-6 < (/.f64 x y) < 5.0000000000000004e-6Initial program 97.7%
Applied rewrites92.6%
Taylor expanded in z around inf
Applied rewrites72.3%
(FPCore (x y z t) :precision binary64 :pre TRUE (fma x (/ z y) t))
double code(double x, double y, double z, double t) {
return fma(x, (z / y), t);
}
function code(x, y, z, t) return fma(x, Float64(z / y), t) end
code[x_, y_, z_, t_] := N[(x * N[(z / y), $MachinePrecision] + t), $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 * (z / y)) + t END code
\mathsf{fma}\left(x, \frac{z}{y}, t\right)
Initial program 97.7%
Applied rewrites92.6%
Taylor expanded in z around inf
Applied rewrites72.3%
(FPCore (x y z t) :precision binary64 :pre TRUE (let* ((t_1 (/ (* x z) y))) (if (<= (/ x y) -5e-11) t_1 (if (<= (/ x y) 1e-28) t t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (x * z) / y;
double tmp;
if ((x / y) <= -5e-11) {
tmp = t_1;
} else if ((x / y) <= 1e-28) {
tmp = t;
} else {
tmp = t_1;
}
return tmp;
}
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
real(8) :: t_1
real(8) :: tmp
t_1 = (x * z) / y
if ((x / y) <= (-5d-11)) then
tmp = t_1
else if ((x / y) <= 1d-28) then
tmp = t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (x * z) / y;
double tmp;
if ((x / y) <= -5e-11) {
tmp = t_1;
} else if ((x / y) <= 1e-28) {
tmp = t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * z) / y tmp = 0 if (x / y) <= -5e-11: tmp = t_1 elif (x / y) <= 1e-28: tmp = t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * z) / y) tmp = 0.0 if (Float64(x / y) <= -5e-11) tmp = t_1; elseif (Float64(x / y) <= 1e-28) tmp = t; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * z) / y; tmp = 0.0; if ((x / y) <= -5e-11) tmp = t_1; elseif ((x / y) <= 1e-28) tmp = t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -5e-11], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 1e-28], t, 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 = ((x * z) / y) IN LET tmp_1 = IF ((x / y) <= (9999999999999999712325434616006196770329693636753639999435544334276007748447435974359365218333550728857517242431640625e-146)) THEN t ELSE t_1 ENDIF IN LET tmp = IF ((x / y) <= (-50000000000000001821609865774887078958277353279981980449520051479339599609375e-87)) THEN t_1 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_1 := \frac{x \cdot z}{y}\\
\mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{-11}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{x}{y} \leq 10^{-28}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (/.f64 x y) < -5.0000000000000002e-11 or 9.9999999999999997e-29 < (/.f64 x y) Initial program 97.7%
Applied rewrites84.5%
Taylor expanded in x around 0
Applied rewrites28.7%
Taylor expanded in z around inf
Applied rewrites37.2%
if -5.0000000000000002e-11 < (/.f64 x y) < 9.9999999999999997e-29Initial program 97.7%
Taylor expanded in x around 0
Applied rewrites37.8%
(FPCore (x y z t) :precision binary64 :pre TRUE t)
double code(double x, double y, double z, double t) {
return 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 = t
end function
public static double code(double x, double y, double z, double t) {
return t;
}
def code(x, y, z, t): return t
function code(x, y, z, t) return t end
function tmp = code(x, y, z, t) tmp = t; end
code[x_, y_, z_, t_] := t
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 = t END code
t
Initial program 97.7%
Taylor expanded in x around 0
Applied rewrites37.8%
herbie shell --seed 2026092
(FPCore (x y z t)
:name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
:precision binary64
(+ (* (/ x y) (- z t)) t))