
(FPCore (x y z t) :precision binary64 (* (/ (- x y) (- z y)) t))
double code(double x, double y, double z, double t) {
return ((x - y) / (z - y)) * t;
}
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
public static double code(double x, double y, double z, double t) {
return ((x - y) / (z - y)) * t;
}
def code(x, y, z, t): return ((x - y) / (z - y)) * t
function code(x, y, z, t) return Float64(Float64(Float64(x - y) / Float64(z - y)) * t) end
function tmp = code(x, y, z, t) tmp = ((x - y) / (z - y)) * t; end
code[x_, y_, z_, t_] := N[(N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - y} \cdot t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (* (/ (- x y) (- z y)) t))
double code(double x, double y, double z, double t) {
return ((x - y) / (z - y)) * t;
}
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
public static double code(double x, double y, double z, double t) {
return ((x - y) / (z - y)) * t;
}
def code(x, y, z, t): return ((x - y) / (z - y)) * t
function code(x, y, z, t) return Float64(Float64(Float64(x - y) / Float64(z - y)) * t) end
function tmp = code(x, y, z, t) tmp = ((x - y) / (z - y)) * t; end
code[x_, y_, z_, t_] := N[(N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - y} \cdot t
\end{array}
(FPCore (x y z t) :precision binary64 (* (/ (- x y) (- z y)) t))
double code(double x, double y, double z, double t) {
return ((x - y) / (z - y)) * t;
}
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
public static double code(double x, double y, double z, double t) {
return ((x - y) / (z - y)) * t;
}
def code(x, y, z, t): return ((x - y) / (z - y)) * t
function code(x, y, z, t) return Float64(Float64(Float64(x - y) / Float64(z - y)) * t) end
function tmp = code(x, y, z, t) tmp = ((x - y) / (z - y)) * t; end
code[x_, y_, z_, t_] := N[(N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - y} \cdot t
\end{array}
Initial program 98.7%
Final simplification98.7%
(FPCore (x y z t) :precision binary64 (if (or (<= y -6.2e+211) (not (<= y 4.9e+129))) (* t (- 1.0 (/ x y))) (* (- x y) (/ t (- z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -6.2e+211) || !(y <= 4.9e+129)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = (x - y) * (t / (z - y));
}
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
real(8) :: tmp
if ((y <= (-6.2d+211)) .or. (.not. (y <= 4.9d+129))) then
tmp = t * (1.0d0 - (x / y))
else
tmp = (x - y) * (t / (z - y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -6.2e+211) || !(y <= 4.9e+129)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = (x - y) * (t / (z - y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -6.2e+211) or not (y <= 4.9e+129): tmp = t * (1.0 - (x / y)) else: tmp = (x - y) * (t / (z - y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -6.2e+211) || !(y <= 4.9e+129)) tmp = Float64(t * Float64(1.0 - Float64(x / y))); else tmp = Float64(Float64(x - y) * Float64(t / Float64(z - y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -6.2e+211) || ~((y <= 4.9e+129))) tmp = t * (1.0 - (x / y)); else tmp = (x - y) * (t / (z - y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -6.2e+211], N[Not[LessEqual[y, 4.9e+129]], $MachinePrecision]], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(t / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+211} \lor \neg \left(y \leq 4.9 \cdot 10^{+129}\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{t}{z - y}\\
\end{array}
\end{array}
if y < -6.2000000000000003e211 or 4.9e129 < y Initial program 100.0%
Taylor expanded in z around 0 93.6%
mul-1-neg93.6%
Simplified93.6%
Taylor expanded in x around 0 77.9%
*-rgt-identity77.9%
mul-1-neg77.9%
associate-/l*93.6%
distribute-rgt-neg-in93.6%
distribute-lft-in93.6%
sub-neg93.6%
Simplified93.6%
if -6.2000000000000003e211 < y < 4.9e129Initial program 98.2%
associate-*l/88.1%
associate-/l*93.9%
Simplified93.9%
Final simplification93.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y -3.3e-83) (not (<= y 0.00032))) (* t (- 1.0 (/ x y))) (* t (/ x z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.3e-83) || !(y <= 0.00032)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = t * (x / z);
}
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
real(8) :: tmp
if ((y <= (-3.3d-83)) .or. (.not. (y <= 0.00032d0))) then
tmp = t * (1.0d0 - (x / y))
else
tmp = t * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.3e-83) || !(y <= 0.00032)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = t * (x / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -3.3e-83) or not (y <= 0.00032): tmp = t * (1.0 - (x / y)) else: tmp = t * (x / z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -3.3e-83) || !(y <= 0.00032)) tmp = Float64(t * Float64(1.0 - Float64(x / y))); else tmp = Float64(t * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -3.3e-83) || ~((y <= 0.00032))) tmp = t * (1.0 - (x / y)); else tmp = t * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -3.3e-83], N[Not[LessEqual[y, 0.00032]], $MachinePrecision]], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.3 \cdot 10^{-83} \lor \neg \left(y \leq 0.00032\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -3.2999999999999999e-83 or 3.20000000000000026e-4 < y Initial program 99.9%
Taylor expanded in z around 0 81.2%
mul-1-neg81.2%
Simplified81.2%
Taylor expanded in x around 0 71.1%
*-rgt-identity71.1%
mul-1-neg71.1%
associate-/l*81.1%
distribute-rgt-neg-in81.1%
distribute-lft-in81.2%
sub-neg81.2%
Simplified81.2%
if -3.2999999999999999e-83 < y < 3.20000000000000026e-4Initial program 97.1%
associate-*l/92.6%
associate-/l*93.7%
Simplified93.7%
Taylor expanded in y around 0 60.9%
*-commutative60.9%
associate-/l*61.6%
Simplified61.6%
Taylor expanded in x around 0 60.9%
associate-*r/65.0%
Simplified65.0%
Final simplification74.3%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.95e-83) (not (<= y 380.0))) (* t (- 1.0 (/ x y))) (* (- x y) (/ t z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.95e-83) || !(y <= 380.0)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = (x - y) * (t / z);
}
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
real(8) :: tmp
if ((y <= (-1.95d-83)) .or. (.not. (y <= 380.0d0))) then
tmp = t * (1.0d0 - (x / y))
else
tmp = (x - y) * (t / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.95e-83) || !(y <= 380.0)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = (x - y) * (t / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.95e-83) or not (y <= 380.0): tmp = t * (1.0 - (x / y)) else: tmp = (x - y) * (t / z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.95e-83) || !(y <= 380.0)) tmp = Float64(t * Float64(1.0 - Float64(x / y))); else tmp = Float64(Float64(x - y) * Float64(t / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.95e-83) || ~((y <= 380.0))) tmp = t * (1.0 - (x / y)); else tmp = (x - y) * (t / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.95e-83], N[Not[LessEqual[y, 380.0]], $MachinePrecision]], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(t / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \cdot 10^{-83} \lor \neg \left(y \leq 380\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\
\end{array}
\end{array}
if y < -1.95e-83 or 380 < y Initial program 99.9%
Taylor expanded in z around 0 82.2%
mul-1-neg82.2%
Simplified82.2%
Taylor expanded in x around 0 72.1%
*-rgt-identity72.1%
mul-1-neg72.1%
associate-/l*82.2%
distribute-rgt-neg-in82.2%
distribute-lft-in82.2%
sub-neg82.2%
Simplified82.2%
if -1.95e-83 < y < 380Initial program 97.1%
associate-*l/92.7%
associate-/l*93.8%
Simplified93.8%
Taylor expanded in z around inf 74.9%
*-commutative74.9%
associate-/l*74.8%
Simplified74.8%
Final simplification79.0%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2.7e-8) (not (<= y 4e+38))) (* t (- 1.0 (/ x y))) (* t (/ x (- z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.7e-8) || !(y <= 4e+38)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = t * (x / (z - y));
}
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
real(8) :: tmp
if ((y <= (-2.7d-8)) .or. (.not. (y <= 4d+38))) then
tmp = t * (1.0d0 - (x / y))
else
tmp = t * (x / (z - y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.7e-8) || !(y <= 4e+38)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = t * (x / (z - y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2.7e-8) or not (y <= 4e+38): tmp = t * (1.0 - (x / y)) else: tmp = t * (x / (z - y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2.7e-8) || !(y <= 4e+38)) tmp = Float64(t * Float64(1.0 - Float64(x / y))); else tmp = Float64(t * Float64(x / Float64(z - y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -2.7e-8) || ~((y <= 4e+38))) tmp = t * (1.0 - (x / y)); else tmp = t * (x / (z - y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.7e-8], N[Not[LessEqual[y, 4e+38]], $MachinePrecision]], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t * N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{-8} \lor \neg \left(y \leq 4 \cdot 10^{+38}\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \frac{x}{z - y}\\
\end{array}
\end{array}
if y < -2.70000000000000002e-8 or 3.99999999999999991e38 < y Initial program 99.9%
Taylor expanded in z around 0 86.4%
mul-1-neg86.4%
Simplified86.4%
Taylor expanded in x around 0 74.6%
*-rgt-identity74.6%
mul-1-neg74.6%
associate-/l*86.4%
distribute-rgt-neg-in86.4%
distribute-lft-in86.4%
sub-neg86.4%
Simplified86.4%
if -2.70000000000000002e-8 < y < 3.99999999999999991e38Initial program 97.5%
Taylor expanded in x around inf 74.3%
Final simplification80.2%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2.45e-83) (not (<= y 26.0))) (* t (- 1.0 (/ x y))) (* t (/ (- x y) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.45e-83) || !(y <= 26.0)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = t * ((x - y) / z);
}
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
real(8) :: tmp
if ((y <= (-2.45d-83)) .or. (.not. (y <= 26.0d0))) then
tmp = t * (1.0d0 - (x / y))
else
tmp = t * ((x - y) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.45e-83) || !(y <= 26.0)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = t * ((x - y) / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2.45e-83) or not (y <= 26.0): tmp = t * (1.0 - (x / y)) else: tmp = t * ((x - y) / z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2.45e-83) || !(y <= 26.0)) tmp = Float64(t * Float64(1.0 - Float64(x / y))); else tmp = Float64(t * Float64(Float64(x - y) / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -2.45e-83) || ~((y <= 26.0))) tmp = t * (1.0 - (x / y)); else tmp = t * ((x - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.45e-83], N[Not[LessEqual[y, 26.0]], $MachinePrecision]], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.45 \cdot 10^{-83} \lor \neg \left(y \leq 26\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if y < -2.45e-83 or 26 < y Initial program 99.9%
Taylor expanded in z around 0 82.2%
mul-1-neg82.2%
Simplified82.2%
Taylor expanded in x around 0 72.1%
*-rgt-identity72.1%
mul-1-neg72.1%
associate-/l*82.2%
distribute-rgt-neg-in82.2%
distribute-lft-in82.2%
sub-neg82.2%
Simplified82.2%
if -2.45e-83 < y < 26Initial program 97.1%
Taylor expanded in z around inf 78.1%
Final simplification80.4%
(FPCore (x y z t) :precision binary64 (if (<= y -1.8e-7) t (if (<= y 1.02e+40) (* t (/ x z)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.8e-7) {
tmp = t;
} else if (y <= 1.02e+40) {
tmp = t * (x / z);
} else {
tmp = t;
}
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
real(8) :: tmp
if (y <= (-1.8d-7)) then
tmp = t
else if (y <= 1.02d+40) then
tmp = t * (x / z)
else
tmp = t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.8e-7) {
tmp = t;
} else if (y <= 1.02e+40) {
tmp = t * (x / z);
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.8e-7: tmp = t elif y <= 1.02e+40: tmp = t * (x / z) else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.8e-7) tmp = t; elseif (y <= 1.02e+40) tmp = Float64(t * Float64(x / z)); else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.8e-7) tmp = t; elseif (y <= 1.02e+40) tmp = t * (x / z); else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.8e-7], t, If[LessEqual[y, 1.02e+40], N[(t * N[(x / z), $MachinePrecision]), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.8 \cdot 10^{-7}:\\
\;\;\;\;t\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+40}:\\
\;\;\;\;t \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if y < -1.79999999999999997e-7 or 1.02e40 < y Initial program 99.9%
associate-*l/64.5%
associate-/l*81.1%
Simplified81.1%
Taylor expanded in y around inf 69.5%
if -1.79999999999999997e-7 < y < 1.02e40Initial program 97.5%
associate-*l/93.7%
associate-/l*93.8%
Simplified93.8%
Taylor expanded in y around 0 55.6%
*-commutative55.6%
associate-/l*55.9%
Simplified55.9%
Taylor expanded in x around 0 55.6%
associate-*r/59.0%
Simplified59.0%
Final simplification64.1%
(FPCore (x y z t) :precision binary64 t)
double code(double x, double y, double z, double t) {
return t;
}
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 = 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
\begin{array}{l}
\\
t
\end{array}
Initial program 98.7%
associate-*l/79.5%
associate-/l*87.6%
Simplified87.6%
Taylor expanded in y around inf 40.3%
Final simplification40.3%
(FPCore (x y z t) :precision binary64 (/ t (/ (- z y) (- x y))))
double code(double x, double y, double z, double t) {
return t / ((z - y) / (x - y));
}
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 = t / ((z - y) / (x - y))
end function
public static double code(double x, double y, double z, double t) {
return t / ((z - y) / (x - y));
}
def code(x, y, z, t): return t / ((z - y) / (x - y))
function code(x, y, z, t) return Float64(t / Float64(Float64(z - y) / Float64(x - y))) end
function tmp = code(x, y, z, t) tmp = t / ((z - y) / (x - y)); end
code[x_, y_, z_, t_] := N[(t / N[(N[(z - y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{t}{\frac{z - y}{x - y}}
\end{array}
herbie shell --seed 2024075
(FPCore (x y z t)
:name "Numeric.Signal.Multichannel:$cput from hsignal-0.2.7.1"
:precision binary64
:alt
(/ t (/ (- z y) (- x y)))
(* (/ (- x y) (- z y)) t))