
(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 (if (<= x 1.4e-141) (+ t (* (- z t) (/ x y))) (+ t (/ x (/ y (- z t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 1.4e-141) {
tmp = t + ((z - t) * (x / y));
} else {
tmp = t + (x / (y / (z - 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 <= 1.4d-141) then
tmp = t + ((z - t) * (x / y))
else
tmp = t + (x / (y / (z - t)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= 1.4e-141) {
tmp = t + ((z - t) * (x / y));
} else {
tmp = t + (x / (y / (z - t)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= 1.4e-141: tmp = t + ((z - t) * (x / y)) else: tmp = t + (x / (y / (z - t))) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= 1.4e-141) tmp = Float64(t + Float64(Float64(z - t) * Float64(x / y))); else tmp = Float64(t + Float64(x / Float64(y / Float64(z - t)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= 1.4e-141) tmp = t + ((z - t) * (x / y)); else tmp = t + (x / (y / (z - t))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, 1.4e-141], N[(t + N[(N[(z - t), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t + N[(x / N[(y / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.4 \cdot 10^{-141}:\\
\;\;\;\;t + \left(z - t\right) \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;t + \frac{x}{\frac{y}{z - t}}\\
\end{array}
\end{array}
if x < 1.40000000000000006e-141Initial program 97.3%
if 1.40000000000000006e-141 < x Initial program 92.6%
associate-*l/91.3%
associate-*r/98.6%
clear-num98.6%
un-div-inv98.6%
Applied egg-rr98.6%
Final simplification97.7%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.15e-40) (not (<= t 0.00152))) (* t (- 1.0 (/ x y))) (+ t (/ x (/ y z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.15e-40) || !(t <= 0.00152)) {
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 <= (-1.15d-40)) .or. (.not. (t <= 0.00152d0))) 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 <= -1.15e-40) || !(t <= 0.00152)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = t + (x / (y / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.15e-40) or not (t <= 0.00152): 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 <= -1.15e-40) || !(t <= 0.00152)) tmp = Float64(t * Float64(1.0 - Float64(x / y))); else tmp = Float64(t + Float64(x / Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.15e-40) || ~((t <= 0.00152))) 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, -1.15e-40], N[Not[LessEqual[t, 0.00152]], $MachinePrecision]], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t + N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.15 \cdot 10^{-40} \lor \neg \left(t \leq 0.00152\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t + \frac{x}{\frac{y}{z}}\\
\end{array}
\end{array}
if t < -1.15e-40 or 0.0015200000000000001 < t Initial program 99.9%
Taylor expanded in z around 0 87.3%
mul-1-neg87.3%
*-rgt-identity87.3%
associate-/l*89.9%
distribute-rgt-neg-in89.9%
mul-1-neg89.9%
distribute-lft-in89.8%
mul-1-neg89.8%
unsub-neg89.8%
Simplified89.8%
if -1.15e-40 < t < 0.0015200000000000001Initial program 90.6%
Taylor expanded in z around inf 83.9%
associate-/l*84.6%
Simplified84.6%
clear-num84.6%
un-div-inv84.7%
Applied egg-rr84.7%
Final simplification87.6%
(FPCore (x y z t) :precision binary64 (if (or (<= t -7e-43) (not (<= t 0.0018))) (* t (- 1.0 (/ x y))) (+ t (* x (/ z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -7e-43) || !(t <= 0.0018)) {
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 <= (-7d-43)) .or. (.not. (t <= 0.0018d0))) 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 <= -7e-43) || !(t <= 0.0018)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = t + (x * (z / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -7e-43) or not (t <= 0.0018): 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 <= -7e-43) || !(t <= 0.0018)) 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 <= -7e-43) || ~((t <= 0.0018))) 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, -7e-43], N[Not[LessEqual[t, 0.0018]], $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 -7 \cdot 10^{-43} \lor \neg \left(t \leq 0.0018\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t + x \cdot \frac{z}{y}\\
\end{array}
\end{array}
if t < -6.99999999999999994e-43 or 0.0018 < t Initial program 99.9%
Taylor expanded in z around 0 87.3%
mul-1-neg87.3%
*-rgt-identity87.3%
associate-/l*89.9%
distribute-rgt-neg-in89.9%
mul-1-neg89.9%
distribute-lft-in89.8%
mul-1-neg89.8%
unsub-neg89.8%
Simplified89.8%
if -6.99999999999999994e-43 < t < 0.0018Initial program 90.6%
Taylor expanded in z around inf 83.9%
associate-/l*84.6%
Simplified84.6%
Final simplification87.6%
(FPCore (x y z t) :precision binary64 (if (<= t -1.55e-38) (* t (- 1.0 (/ x y))) (if (<= t 0.0045) (+ t (/ x (/ y z))) (- t (* t (/ x y))))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.55e-38) {
tmp = t * (1.0 - (x / y));
} else if (t <= 0.0045) {
tmp = t + (x / (y / z));
} else {
tmp = t - (t * (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 <= (-1.55d-38)) then
tmp = t * (1.0d0 - (x / y))
else if (t <= 0.0045d0) then
tmp = t + (x / (y / z))
else
tmp = t - (t * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.55e-38) {
tmp = t * (1.0 - (x / y));
} else if (t <= 0.0045) {
tmp = t + (x / (y / z));
} else {
tmp = t - (t * (x / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.55e-38: tmp = t * (1.0 - (x / y)) elif t <= 0.0045: tmp = t + (x / (y / z)) else: tmp = t - (t * (x / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.55e-38) tmp = Float64(t * Float64(1.0 - Float64(x / y))); elseif (t <= 0.0045) tmp = Float64(t + Float64(x / Float64(y / z))); else tmp = Float64(t - Float64(t * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.55e-38) tmp = t * (1.0 - (x / y)); elseif (t <= 0.0045) tmp = t + (x / (y / z)); else tmp = t - (t * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.55e-38], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 0.0045], N[(t + N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t - N[(t * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.55 \cdot 10^{-38}:\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{elif}\;t \leq 0.0045:\\
\;\;\;\;t + \frac{x}{\frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;t - t \cdot \frac{x}{y}\\
\end{array}
\end{array}
if t < -1.54999999999999991e-38Initial program 99.9%
Taylor expanded in z around 0 86.5%
mul-1-neg86.5%
*-rgt-identity86.5%
associate-/l*87.6%
distribute-rgt-neg-in87.6%
mul-1-neg87.6%
distribute-lft-in87.6%
mul-1-neg87.6%
unsub-neg87.6%
Simplified87.6%
if -1.54999999999999991e-38 < t < 0.00449999999999999966Initial program 90.6%
Taylor expanded in z around inf 83.9%
associate-/l*84.6%
Simplified84.6%
clear-num84.6%
un-div-inv84.7%
Applied egg-rr84.7%
if 0.00449999999999999966 < t Initial program 99.9%
Taylor expanded in x around 0 92.7%
associate-*r/89.7%
*-commutative89.7%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in z around 0 88.2%
mul-1-neg88.2%
associate-*r/92.6%
rem-square-sqrt56.0%
distribute-lft-neg-in56.0%
cancel-sign-sub-inv56.0%
rem-square-sqrt92.6%
Simplified92.6%
Final simplification87.6%
(FPCore (x y z t) :precision binary64 (+ t (/ (- z t) (/ y x))))
double code(double x, double y, double z, double t) {
return t + ((z - t) / (y / x));
}
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 - t) / (y / x))
end function
public static double code(double x, double y, double z, double t) {
return t + ((z - t) / (y / x));
}
def code(x, y, z, t): return t + ((z - t) / (y / x))
function code(x, y, z, t) return Float64(t + Float64(Float64(z - t) / Float64(y / x))) end
function tmp = code(x, y, z, t) tmp = t + ((z - t) / (y / x)); end
code[x_, y_, z_, t_] := N[(t + N[(N[(z - t), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
t + \frac{z - t}{\frac{y}{x}}
\end{array}
Initial program 95.8%
Taylor expanded in x around 0 95.1%
associate-*r/93.5%
*-commutative93.5%
associate-/r/96.5%
Simplified96.5%
Final simplification96.5%
(FPCore (x y z t) :precision binary64 (+ t (* (- z t) (/ x y))))
double code(double x, double y, double z, double t) {
return t + ((z - t) * (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 - t) * (x / y))
end function
public static double code(double x, double y, double z, double t) {
return t + ((z - t) * (x / y));
}
def code(x, y, z, t): return t + ((z - t) * (x / y))
function code(x, y, z, t) return Float64(t + Float64(Float64(z - t) * Float64(x / y))) end
function tmp = code(x, y, z, t) tmp = t + ((z - t) * (x / y)); end
code[x_, y_, z_, t_] := N[(t + N[(N[(z - t), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
t + \left(z - t\right) \cdot \frac{x}{y}
\end{array}
Initial program 95.8%
Final simplification95.8%
(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 95.8%
Taylor expanded in z around 0 68.7%
mul-1-neg68.7%
*-rgt-identity68.7%
associate-/l*69.8%
distribute-rgt-neg-in69.8%
mul-1-neg69.8%
distribute-lft-in69.8%
mul-1-neg69.8%
unsub-neg69.8%
Simplified69.8%
(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 95.8%
Taylor expanded in x around 0 39.2%
(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 2024137
(FPCore (x y z t)
:name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
:precision binary64
:alt
(! :herbie-platform default (if (< z 689864138640673/250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ (* (/ x y) (- z t)) t) (if (< z 581748612718609/25000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ (* x (/ (- z t) y)) t) (+ (* (/ x y) (- z t)) t))))
(+ (* (/ x y) (- z t)) t))