
(FPCore (x y z t) :precision binary64 (+ (* (/ 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)
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]
\begin{array}{l}
\\
\frac{x}{y} \cdot \left(z - t\right) + 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 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)
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]
\begin{array}{l}
\\
\frac{x}{y} \cdot \left(z - t\right) + t
\end{array}
(FPCore (x y z t) :precision binary64 (fma (/ x y) (- z t) t))
double code(double x, double y, double z, double t) {
return fma((x / y), (z - t), t);
}
function code(x, y, z, t) return fma(Float64(x / y), Float64(z - t), t) end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{x}{y}, z - t, t\right)
\end{array}
Initial program 98.0%
fma-define98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x y z t) :precision binary64 (if (or (<= t -280000000000.0) (not (<= t 5500000000000.0))) (* t (- 1.0 (/ x y))) (+ t (* x (/ z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -280000000000.0) || !(t <= 5500000000000.0)) {
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 ((t <= (-280000000000.0d0)) .or. (.not. (t <= 5500000000000.0d0))) 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 ((t <= -280000000000.0) || !(t <= 5500000000000.0)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = t + (x * (z / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -280000000000.0) or not (t <= 5500000000000.0): tmp = t * (1.0 - (x / y)) else: tmp = t + (x * (z / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -280000000000.0) || !(t <= 5500000000000.0)) 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 ((t <= -280000000000.0) || ~((t <= 5500000000000.0))) 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[t, -280000000000.0], N[Not[LessEqual[t, 5500000000000.0]], $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}\;t \leq -280000000000 \lor \neg \left(t \leq 5500000000000\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t + x \cdot \frac{z}{y}\\
\end{array}
\end{array}
if t < -2.8e11 or 5.5e12 < t Initial program 99.9%
associate-*l/90.8%
associate-/l*91.6%
fma-define91.6%
Simplified91.6%
Taylor expanded in z around 0 79.0%
mul-1-neg79.0%
*-rgt-identity79.0%
associate-/l*84.3%
distribute-rgt-neg-in84.3%
mul-1-neg84.3%
distribute-lft-in84.2%
mul-1-neg84.2%
unsub-neg84.2%
Simplified84.2%
if -2.8e11 < t < 5.5e12Initial program 96.3%
Taylor expanded in z around inf 87.7%
associate-/l*83.2%
Simplified83.2%
Final simplification83.7%
(FPCore (x y z t) :precision binary64 (if (or (<= t -4.1e+186) (not (<= t 5000000000000.0))) (* t (- 1.0 (/ x y))) (+ t (* (/ x y) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -4.1e+186) || !(t <= 5000000000000.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 ((t <= (-4.1d+186)) .or. (.not. (t <= 5000000000000.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 ((t <= -4.1e+186) || !(t <= 5000000000000.0)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = t + ((x / y) * z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -4.1e+186) or not (t <= 5000000000000.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 ((t <= -4.1e+186) || !(t <= 5000000000000.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 ((t <= -4.1e+186) || ~((t <= 5000000000000.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[t, -4.1e+186], N[Not[LessEqual[t, 5000000000000.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}\;t \leq -4.1 \cdot 10^{+186} \lor \neg \left(t \leq 5000000000000\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t + \frac{x}{y} \cdot z\\
\end{array}
\end{array}
if t < -4.1e186 or 5e12 < t Initial program 99.9%
associate-*l/92.9%
associate-/l*90.9%
fma-define90.9%
Simplified90.9%
Taylor expanded in z around 0 84.5%
mul-1-neg84.5%
*-rgt-identity84.5%
associate-/l*89.5%
distribute-rgt-neg-in89.5%
mul-1-neg89.5%
distribute-lft-in89.5%
mul-1-neg89.5%
unsub-neg89.5%
Simplified89.5%
if -4.1e186 < t < 5e12Initial program 96.9%
Taylor expanded in x around 0 92.9%
associate-/l*90.5%
*-commutative90.5%
associate-/r/96.5%
Simplified96.5%
Taylor expanded in z around inf 81.7%
associate-*l/86.2%
*-commutative86.2%
Simplified86.2%
Final simplification87.4%
(FPCore (x y z t) :precision binary64 (if (<= t -4.1e+186) (- t (* (/ x y) t)) (if (<= t 5000000000000.0) (+ t (* (/ x y) z)) (* t (- 1.0 (/ x y))))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -4.1e+186) {
tmp = t - ((x / y) * t);
} else if (t <= 5000000000000.0) {
tmp = t + ((x / y) * z);
} else {
tmp = t * (1.0 - (x / 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 (t <= (-4.1d+186)) then
tmp = t - ((x / y) * t)
else if (t <= 5000000000000.0d0) then
tmp = t + ((x / y) * z)
else
tmp = t * (1.0d0 - (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -4.1e+186) {
tmp = t - ((x / y) * t);
} else if (t <= 5000000000000.0) {
tmp = t + ((x / y) * z);
} else {
tmp = t * (1.0 - (x / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -4.1e+186: tmp = t - ((x / y) * t) elif t <= 5000000000000.0: tmp = t + ((x / y) * z) else: tmp = t * (1.0 - (x / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -4.1e+186) tmp = Float64(t - Float64(Float64(x / y) * t)); elseif (t <= 5000000000000.0) tmp = Float64(t + Float64(Float64(x / y) * z)); else tmp = Float64(t * Float64(1.0 - Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -4.1e+186) tmp = t - ((x / y) * t); elseif (t <= 5000000000000.0) tmp = t + ((x / y) * z); else tmp = t * (1.0 - (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -4.1e+186], N[(t - N[(N[(x / y), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 5000000000000.0], N[(t + N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.1 \cdot 10^{+186}:\\
\;\;\;\;t - \frac{x}{y} \cdot t\\
\mathbf{elif}\;t \leq 5000000000000:\\
\;\;\;\;t + \frac{x}{y} \cdot z\\
\mathbf{else}:\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\end{array}
\end{array}
if t < -4.1e186Initial program 100.0%
Taylor expanded in z around 0 88.6%
associate-*r/88.6%
mul-1-neg88.6%
*-commutative88.6%
distribute-rgt-neg-out88.6%
associate-/l*84.6%
Simplified84.6%
Taylor expanded in x around 0 88.6%
mul-1-neg88.6%
associate-/l*100.0%
distribute-lft-neg-in100.0%
cancel-sign-sub-inv100.0%
Simplified100.0%
if -4.1e186 < t < 5e12Initial program 96.9%
Taylor expanded in x around 0 92.9%
associate-/l*90.5%
*-commutative90.5%
associate-/r/96.5%
Simplified96.5%
Taylor expanded in z around inf 81.7%
associate-*l/86.2%
*-commutative86.2%
Simplified86.2%
if 5e12 < t Initial program 99.9%
associate-*l/94.4%
associate-/l*93.2%
fma-define93.2%
Simplified93.2%
Taylor expanded in z around 0 83.0%
mul-1-neg83.0%
*-rgt-identity83.0%
associate-/l*85.7%
distribute-rgt-neg-in85.7%
mul-1-neg85.7%
distribute-lft-in85.7%
mul-1-neg85.7%
unsub-neg85.7%
Simplified85.7%
Final simplification87.4%
(FPCore (x y z t) :precision binary64 (if (or (<= x -9.4e+33) (not (<= x 7e+21))) (* x (/ t (- y))) t))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -9.4e+33) || !(x <= 7e+21)) {
tmp = x * (t / -y);
} 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 ((x <= (-9.4d+33)) .or. (.not. (x <= 7d+21))) then
tmp = x * (t / -y)
else
tmp = t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -9.4e+33) || !(x <= 7e+21)) {
tmp = x * (t / -y);
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -9.4e+33) or not (x <= 7e+21): tmp = x * (t / -y) else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -9.4e+33) || !(x <= 7e+21)) tmp = Float64(x * Float64(t / Float64(-y))); else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -9.4e+33) || ~((x <= 7e+21))) tmp = x * (t / -y); else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -9.4e+33], N[Not[LessEqual[x, 7e+21]], $MachinePrecision]], N[(x * N[(t / (-y)), $MachinePrecision]), $MachinePrecision], t]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.4 \cdot 10^{+33} \lor \neg \left(x \leq 7 \cdot 10^{+21}\right):\\
\;\;\;\;x \cdot \frac{t}{-y}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if x < -9.3999999999999996e33 or 7e21 < x Initial program 97.6%
Taylor expanded in z around 0 51.7%
associate-*r/51.7%
mul-1-neg51.7%
*-commutative51.7%
distribute-rgt-neg-out51.7%
associate-/l*57.1%
Simplified57.1%
*-commutative57.1%
distribute-frac-neg57.1%
distribute-frac-neg257.1%
associate-*l/51.7%
Applied egg-rr51.7%
+-commutative51.7%
distribute-frac-neg251.7%
associate-*r/57.9%
sub-neg57.9%
associate-*r/51.7%
*-commutative51.7%
associate-/l*57.1%
Applied egg-rr57.1%
Taylor expanded in x around inf 46.3%
mul-1-neg46.3%
associate-*l/47.7%
*-commutative47.7%
distribute-rgt-neg-out47.7%
distribute-frac-neg247.7%
Simplified47.7%
if -9.3999999999999996e33 < x < 7e21Initial program 98.5%
associate-*l/98.5%
associate-/l*85.8%
fma-define85.8%
Simplified85.8%
Taylor expanded in x around 0 51.7%
Final simplification49.8%
(FPCore (x y z t) :precision binary64 (+ t (* (/ x y) (- z t))))
double code(double x, double y, double z, double t) {
return t + ((x / y) * (z - 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 + ((x / y) * (z - t))
end function
public static double code(double x, double y, double z, double t) {
return t + ((x / y) * (z - t));
}
def code(x, y, z, t): return t + ((x / y) * (z - t))
function code(x, y, z, t) return Float64(t + Float64(Float64(x / y) * Float64(z - t))) end
function tmp = code(x, y, z, t) tmp = t + ((x / y) * (z - t)); end
code[x_, y_, z_, t_] := N[(t + N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
t + \frac{x}{y} \cdot \left(z - t\right)
\end{array}
Initial program 98.0%
Final simplification98.0%
(FPCore (x y z t) :precision binary64 (* t (- 1.0 (/ x y))))
double code(double x, double y, double z, double t) {
return t * (1.0 - (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 * (1.0d0 - (x / y))
end function
public static double code(double x, double y, double z, double t) {
return t * (1.0 - (x / y));
}
def code(x, y, z, t): return t * (1.0 - (x / y))
function code(x, y, z, t) return Float64(t * Float64(1.0 - Float64(x / y))) end
function tmp = code(x, y, z, t) tmp = t * (1.0 - (x / y)); end
code[x_, y_, z_, t_] := N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
t \cdot \left(1 - \frac{x}{y}\right)
\end{array}
Initial program 98.0%
associate-*l/92.9%
associate-/l*90.7%
fma-define90.7%
Simplified90.7%
Taylor expanded in z around 0 57.5%
mul-1-neg57.5%
*-rgt-identity57.5%
associate-/l*60.5%
distribute-rgt-neg-in60.5%
mul-1-neg60.5%
distribute-lft-in60.5%
mul-1-neg60.5%
unsub-neg60.5%
Simplified60.5%
Final simplification60.5%
(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.0%
associate-*l/92.9%
associate-/l*90.7%
fma-define90.7%
Simplified90.7%
Taylor expanded in x around 0 32.9%
Final simplification32.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ (* (/ x y) (- z t)) t)))
(if (< z 2.759456554562692e-282)
t_1
(if (< z 2.326994450874436e-110) (+ (* x (/ (- z t) y)) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = ((x / y) * (z - t)) + t;
double tmp;
if (z < 2.759456554562692e-282) {
tmp = t_1;
} else if (z < 2.326994450874436e-110) {
tmp = (x * ((z - t) / y)) + t;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = ((x / y) * (z - t)) + t
if (z < 2.759456554562692d-282) then
tmp = t_1
else if (z < 2.326994450874436d-110) then
tmp = (x * ((z - t) / 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 / y) * (z - t)) + t;
double tmp;
if (z < 2.759456554562692e-282) {
tmp = t_1;
} else if (z < 2.326994450874436e-110) {
tmp = (x * ((z - t) / y)) + t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = ((x / y) * (z - t)) + t tmp = 0 if z < 2.759456554562692e-282: tmp = t_1 elif z < 2.326994450874436e-110: tmp = (x * ((z - t) / y)) + t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(Float64(x / y) * Float64(z - t)) + t) tmp = 0.0 if (z < 2.759456554562692e-282) tmp = t_1; elseif (z < 2.326994450874436e-110) tmp = Float64(Float64(x * Float64(Float64(z - t) / y)) + t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = ((x / y) * (z - t)) + t; tmp = 0.0; if (z < 2.759456554562692e-282) tmp = t_1; elseif (z < 2.326994450874436e-110) tmp = (x * ((z - t) / y)) + t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]}, If[Less[z, 2.759456554562692e-282], t$95$1, If[Less[z, 2.326994450874436e-110], N[(N[(x * N[(N[(z - t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{y} \cdot \left(z - t\right) + t\\
\mathbf{if}\;z < 2.759456554562692 \cdot 10^{-282}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z < 2.326994450874436 \cdot 10^{-110}:\\
\;\;\;\;x \cdot \frac{z - t}{y} + t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024079
(FPCore (x y z t)
:name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
:precision binary64
:alt
(if (< z 2.759456554562692e-282) (+ (* (/ x y) (- z t)) t) (if (< z 2.326994450874436e-110) (+ (* x (/ (- z t) y)) t) (+ (* (/ x y) (- z t)) t)))
(+ (* (/ x y) (- z t)) t))