(FPCore (x y z t) :precision binary64 (* (/ (- x y) (- z y)) t))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ t (- z y))) (t_2 (/ (- x y) (- z y))))
(if (<= y -1e-260)
(/ t (pow t_2 -1.0))
(if (<= y 4.860029108699026e-62) (- (* x t_1) (* y t_1)) (* t t_2)))))double code(double x, double y, double z, double t) {
return ((x - y) / (z - y)) * t;
}
double code(double x, double y, double z, double t) {
double t_1 = t / (z - y);
double t_2 = (x - y) / (z - y);
double tmp;
if (y <= -1e-260) {
tmp = t / pow(t_2, -1.0);
} else if (y <= 4.860029108699026e-62) {
tmp = (x * t_1) - (y * t_1);
} else {
tmp = t * t_2;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x - y) / (z - y)) * t
end function
real(8) function code(x, y, z, t)
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) :: t_2
real(8) :: tmp
t_1 = t / (z - y)
t_2 = (x - y) / (z - y)
if (y <= (-1d-260)) then
tmp = t / (t_2 ** (-1.0d0))
else if (y <= 4.860029108699026d-62) then
tmp = (x * t_1) - (y * t_1)
else
tmp = t * t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return ((x - y) / (z - y)) * t;
}
public static double code(double x, double y, double z, double t) {
double t_1 = t / (z - y);
double t_2 = (x - y) / (z - y);
double tmp;
if (y <= -1e-260) {
tmp = t / Math.pow(t_2, -1.0);
} else if (y <= 4.860029108699026e-62) {
tmp = (x * t_1) - (y * t_1);
} else {
tmp = t * t_2;
}
return tmp;
}
def code(x, y, z, t): return ((x - y) / (z - y)) * t
def code(x, y, z, t): t_1 = t / (z - y) t_2 = (x - y) / (z - y) tmp = 0 if y <= -1e-260: tmp = t / math.pow(t_2, -1.0) elif y <= 4.860029108699026e-62: tmp = (x * t_1) - (y * t_1) else: tmp = t * t_2 return tmp
function code(x, y, z, t) return Float64(Float64(Float64(x - y) / Float64(z - y)) * t) end
function code(x, y, z, t) t_1 = Float64(t / Float64(z - y)) t_2 = Float64(Float64(x - y) / Float64(z - y)) tmp = 0.0 if (y <= -1e-260) tmp = Float64(t / (t_2 ^ -1.0)); elseif (y <= 4.860029108699026e-62) tmp = Float64(Float64(x * t_1) - Float64(y * t_1)); else tmp = Float64(t * t_2); end return tmp end
function tmp = code(x, y, z, t) tmp = ((x - y) / (z - y)) * t; end
function tmp_2 = code(x, y, z, t) t_1 = t / (z - y); t_2 = (x - y) / (z - y); tmp = 0.0; if (y <= -1e-260) tmp = t / (t_2 ^ -1.0); elseif (y <= 4.860029108699026e-62) tmp = (x * t_1) - (y * t_1); else tmp = t * t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t / N[(z - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1e-260], N[(t / N[Power[t$95$2, -1.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.860029108699026e-62], N[(N[(x * t$95$1), $MachinePrecision] - N[(y * t$95$1), $MachinePrecision]), $MachinePrecision], N[(t * t$95$2), $MachinePrecision]]]]]
\frac{x - y}{z - y} \cdot t
\begin{array}{l}
t_1 := \frac{t}{z - y}\\
t_2 := \frac{x - y}{z - y}\\
\mathbf{if}\;y \leq -1 \cdot 10^{-260}:\\
\;\;\;\;\frac{t}{{t_2}^{-1}}\\
\mathbf{elif}\;y \leq 4.860029108699026 \cdot 10^{-62}:\\
\;\;\;\;x \cdot t_1 - y \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t \cdot t_2\\
\end{array}
Results
| Original | 2.2 |
|---|---|
| Target | 2.2 |
| Herbie | 2.4 |
if y < -9.99999999999999961e-261Initial program 1.9
Applied egg-rr1.9
Applied egg-rr2.1
if -9.99999999999999961e-261 < y < 4.86002910869902591e-62Initial program 5.6
Applied egg-rr5.6
Applied egg-rr6.2
if 4.86002910869902591e-62 < y Initial program 0.3
Final simplification2.4
herbie shell --seed 2022210
(FPCore (x y z t)
:name "Numeric.Signal.Multichannel:$cput from hsignal-0.2.7.1"
:precision binary64
:herbie-target
(/ t (/ (- z y) (- x y)))
(* (/ (- x y) (- z y)) t))