
(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 10 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 y) -40000.0)
(/ (* x (- z t)) y)
(if (<= (/ x y) 2e-10)
(+ t (/ z (/ y x)))
(if (<= (/ x y) 2000000000000.0)
(* t (- 1.0 (/ x y)))
(if (<= (/ x y) 2e+69) (* (/ x y) (- z t)) (* x (/ (- z t) y)))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -40000.0) {
tmp = (x * (z - t)) / y;
} else if ((x / y) <= 2e-10) {
tmp = t + (z / (y / x));
} else if ((x / y) <= 2000000000000.0) {
tmp = t * (1.0 - (x / y));
} else if ((x / y) <= 2e+69) {
tmp = (x / y) * (z - t);
} else {
tmp = x * ((z - t) / 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 ((x / y) <= (-40000.0d0)) then
tmp = (x * (z - t)) / y
else if ((x / y) <= 2d-10) then
tmp = t + (z / (y / x))
else if ((x / y) <= 2000000000000.0d0) then
tmp = t * (1.0d0 - (x / y))
else if ((x / y) <= 2d+69) then
tmp = (x / y) * (z - t)
else
tmp = x * ((z - t) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -40000.0) {
tmp = (x * (z - t)) / y;
} else if ((x / y) <= 2e-10) {
tmp = t + (z / (y / x));
} else if ((x / y) <= 2000000000000.0) {
tmp = t * (1.0 - (x / y));
} else if ((x / y) <= 2e+69) {
tmp = (x / y) * (z - t);
} else {
tmp = x * ((z - t) / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -40000.0: tmp = (x * (z - t)) / y elif (x / y) <= 2e-10: tmp = t + (z / (y / x)) elif (x / y) <= 2000000000000.0: tmp = t * (1.0 - (x / y)) elif (x / y) <= 2e+69: tmp = (x / y) * (z - t) else: tmp = x * ((z - t) / y) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -40000.0) tmp = Float64(Float64(x * Float64(z - t)) / y); elseif (Float64(x / y) <= 2e-10) tmp = Float64(t + Float64(z / Float64(y / x))); elseif (Float64(x / y) <= 2000000000000.0) tmp = Float64(t * Float64(1.0 - Float64(x / y))); elseif (Float64(x / y) <= 2e+69) tmp = Float64(Float64(x / y) * Float64(z - t)); else tmp = Float64(x * Float64(Float64(z - t) / y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x / y) <= -40000.0) tmp = (x * (z - t)) / y; elseif ((x / y) <= 2e-10) tmp = t + (z / (y / x)); elseif ((x / y) <= 2000000000000.0) tmp = t * (1.0 - (x / y)); elseif ((x / y) <= 2e+69) tmp = (x / y) * (z - t); else tmp = x * ((z - t) / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -40000.0], N[(N[(x * N[(z - t), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 2e-10], N[(t + N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 2000000000000.0], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 2e+69], N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(z - t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -40000:\\
\;\;\;\;\frac{x \cdot \left(z - t\right)}{y}\\
\mathbf{elif}\;\frac{x}{y} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;t + \frac{z}{\frac{y}{x}}\\
\mathbf{elif}\;\frac{x}{y} \leq 2000000000000:\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{elif}\;\frac{x}{y} \leq 2 \cdot 10^{+69}:\\
\;\;\;\;\frac{x}{y} \cdot \left(z - t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{z - t}{y}\\
\end{array}
\end{array}
if (/.f64 x y) < -4e4Initial program 95.5%
Taylor expanded in x around 0 95.5%
Taylor expanded in x around -inf 94.6%
if -4e4 < (/.f64 x y) < 2.00000000000000007e-10Initial program 99.9%
Taylor expanded in z around inf 93.6%
associate-/l*98.9%
Simplified98.9%
if 2.00000000000000007e-10 < (/.f64 x y) < 2e12Initial program 99.6%
Taylor expanded in x around 0 78.1%
Taylor expanded in z around 0 78.1%
associate-*r/99.6%
neg-mul-199.6%
distribute-lft-neg-in99.6%
cancel-sign-sub-inv99.6%
*-rgt-identity99.6%
distribute-lft-out--99.6%
Simplified99.6%
if 2e12 < (/.f64 x y) < 2.0000000000000001e69Initial program 99.7%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around -inf 99.7%
Taylor expanded in z around 0 99.7%
associate-*r/99.7%
associate-*r/99.7%
neg-mul-199.7%
distribute-lft-neg-in99.7%
distribute-rgt-in99.7%
sub-neg99.7%
Simplified99.7%
if 2.0000000000000001e69 < (/.f64 x y) Initial program 96.5%
Taylor expanded in x around inf 96.2%
Taylor expanded in z around 0 96.2%
mul-1-neg96.2%
distribute-frac-neg96.2%
+-commutative96.2%
distribute-frac-neg96.2%
sub-neg96.2%
div-sub99.9%
Simplified99.9%
Final simplification98.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (/ x y) (- z t))))
(if (<= (/ x y) -40000.0)
t_1
(if (<= (/ x y) 2e-10)
(+ t (/ z (/ y x)))
(if (<= (/ x y) 2000000000000.0)
(* t (- 1.0 (/ x y)))
(if (<= (/ x y) 2e+69) t_1 (* x (/ (- z t) y))))))))
double code(double x, double y, double z, double t) {
double t_1 = (x / y) * (z - t);
double tmp;
if ((x / y) <= -40000.0) {
tmp = t_1;
} else if ((x / y) <= 2e-10) {
tmp = t + (z / (y / x));
} else if ((x / y) <= 2000000000000.0) {
tmp = t * (1.0 - (x / y));
} else if ((x / y) <= 2e+69) {
tmp = t_1;
} else {
tmp = x * ((z - t) / 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) :: t_1
real(8) :: tmp
t_1 = (x / y) * (z - t)
if ((x / y) <= (-40000.0d0)) then
tmp = t_1
else if ((x / y) <= 2d-10) then
tmp = t + (z / (y / x))
else if ((x / y) <= 2000000000000.0d0) then
tmp = t * (1.0d0 - (x / y))
else if ((x / y) <= 2d+69) then
tmp = t_1
else
tmp = x * ((z - t) / y)
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);
double tmp;
if ((x / y) <= -40000.0) {
tmp = t_1;
} else if ((x / y) <= 2e-10) {
tmp = t + (z / (y / x));
} else if ((x / y) <= 2000000000000.0) {
tmp = t * (1.0 - (x / y));
} else if ((x / y) <= 2e+69) {
tmp = t_1;
} else {
tmp = x * ((z - t) / y);
}
return tmp;
}
def code(x, y, z, t): t_1 = (x / y) * (z - t) tmp = 0 if (x / y) <= -40000.0: tmp = t_1 elif (x / y) <= 2e-10: tmp = t + (z / (y / x)) elif (x / y) <= 2000000000000.0: tmp = t * (1.0 - (x / y)) elif (x / y) <= 2e+69: tmp = t_1 else: tmp = x * ((z - t) / y) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x / y) * Float64(z - t)) tmp = 0.0 if (Float64(x / y) <= -40000.0) tmp = t_1; elseif (Float64(x / y) <= 2e-10) tmp = Float64(t + Float64(z / Float64(y / x))); elseif (Float64(x / y) <= 2000000000000.0) tmp = Float64(t * Float64(1.0 - Float64(x / y))); elseif (Float64(x / y) <= 2e+69) tmp = t_1; else tmp = Float64(x * Float64(Float64(z - t) / y)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x / y) * (z - t); tmp = 0.0; if ((x / y) <= -40000.0) tmp = t_1; elseif ((x / y) <= 2e-10) tmp = t + (z / (y / x)); elseif ((x / y) <= 2000000000000.0) tmp = t * (1.0 - (x / y)); elseif ((x / y) <= 2e+69) tmp = t_1; else tmp = x * ((z - t) / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -40000.0], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 2e-10], N[(t + N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 2000000000000.0], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 2e+69], t$95$1, N[(x * N[(N[(z - t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{y} \cdot \left(z - t\right)\\
\mathbf{if}\;\frac{x}{y} \leq -40000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{x}{y} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;t + \frac{z}{\frac{y}{x}}\\
\mathbf{elif}\;\frac{x}{y} \leq 2000000000000:\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{elif}\;\frac{x}{y} \leq 2 \cdot 10^{+69}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{z - t}{y}\\
\end{array}
\end{array}
if (/.f64 x y) < -4e4 or 2e12 < (/.f64 x y) < 2.0000000000000001e69Initial program 95.8%
Taylor expanded in x around 0 95.8%
Taylor expanded in x around -inf 95.0%
Taylor expanded in z around 0 83.2%
associate-*r/74.8%
associate-*r/76.6%
neg-mul-176.6%
distribute-lft-neg-in76.6%
distribute-rgt-in94.3%
sub-neg94.3%
Simplified94.3%
if -4e4 < (/.f64 x y) < 2.00000000000000007e-10Initial program 99.9%
Taylor expanded in z around inf 93.6%
associate-/l*98.9%
Simplified98.9%
if 2.00000000000000007e-10 < (/.f64 x y) < 2e12Initial program 99.6%
Taylor expanded in x around 0 78.1%
Taylor expanded in z around 0 78.1%
associate-*r/99.6%
neg-mul-199.6%
distribute-lft-neg-in99.6%
cancel-sign-sub-inv99.6%
*-rgt-identity99.6%
distribute-lft-out--99.6%
Simplified99.6%
if 2.0000000000000001e69 < (/.f64 x y) Initial program 96.5%
Taylor expanded in x around inf 96.2%
Taylor expanded in z around 0 96.2%
mul-1-neg96.2%
distribute-frac-neg96.2%
+-commutative96.2%
distribute-frac-neg96.2%
sub-neg96.2%
div-sub99.9%
Simplified99.9%
Final simplification97.9%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) -1e+81) (* t (/ x (- y))) (if (or (<= (/ x y) -5e-155) (not (<= (/ x y) 2e-20))) (* (/ x y) z) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -1e+81) {
tmp = t * (x / -y);
} else if (((x / y) <= -5e-155) || !((x / y) <= 2e-20)) {
tmp = (x / y) * 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 ((x / y) <= (-1d+81)) then
tmp = t * (x / -y)
else if (((x / y) <= (-5d-155)) .or. (.not. ((x / y) <= 2d-20))) then
tmp = (x / y) * 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 ((x / y) <= -1e+81) {
tmp = t * (x / -y);
} else if (((x / y) <= -5e-155) || !((x / y) <= 2e-20)) {
tmp = (x / y) * z;
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -1e+81: tmp = t * (x / -y) elif ((x / y) <= -5e-155) or not ((x / y) <= 2e-20): tmp = (x / y) * z else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -1e+81) tmp = Float64(t * Float64(x / Float64(-y))); elseif ((Float64(x / y) <= -5e-155) || !(Float64(x / y) <= 2e-20)) tmp = Float64(Float64(x / y) * z); else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x / y) <= -1e+81) tmp = t * (x / -y); elseif (((x / y) <= -5e-155) || ~(((x / y) <= 2e-20))) tmp = (x / y) * z; else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -1e+81], N[(t * N[(x / (-y)), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(x / y), $MachinePrecision], -5e-155], N[Not[LessEqual[N[(x / y), $MachinePrecision], 2e-20]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -1 \cdot 10^{+81}:\\
\;\;\;\;t \cdot \frac{x}{-y}\\
\mathbf{elif}\;\frac{x}{y} \leq -5 \cdot 10^{-155} \lor \neg \left(\frac{x}{y} \leq 2 \cdot 10^{-20}\right):\\
\;\;\;\;\frac{x}{y} \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if (/.f64 x y) < -9.99999999999999921e80Initial program 94.4%
Taylor expanded in x around inf 94.1%
Taylor expanded in z around 0 67.1%
mul-1-neg67.1%
distribute-frac-neg67.1%
Simplified67.1%
*-commutative67.1%
frac-2neg67.1%
remove-double-neg67.1%
associate-*r/67.1%
Applied egg-rr67.1%
associate-/l*67.1%
associate-/r/69.1%
Simplified69.1%
if -9.99999999999999921e80 < (/.f64 x y) < -4.9999999999999999e-155 or 1.99999999999999989e-20 < (/.f64 x y) Initial program 98.2%
Taylor expanded in x around inf 72.6%
Taylor expanded in z around inf 48.2%
*-commutative48.2%
clear-num47.9%
un-div-inv47.9%
Applied egg-rr47.9%
associate-/r/53.6%
Applied egg-rr53.6%
if -4.9999999999999999e-155 < (/.f64 x y) < 1.99999999999999989e-20Initial program 99.9%
Taylor expanded in x around 0 82.3%
Final simplification67.2%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -5e-155) (not (<= (/ x y) 2000000000000.0))) (* (/ x y) (- z t)) (* t (- 1.0 (/ x y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -5e-155) || !((x / y) <= 2000000000000.0)) {
tmp = (x / y) * (z - t);
} 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 (((x / y) <= (-5d-155)) .or. (.not. ((x / y) <= 2000000000000.0d0))) then
tmp = (x / y) * (z - t)
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 (((x / y) <= -5e-155) || !((x / y) <= 2000000000000.0)) {
tmp = (x / y) * (z - t);
} else {
tmp = t * (1.0 - (x / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -5e-155) or not ((x / y) <= 2000000000000.0): tmp = (x / y) * (z - t) else: tmp = t * (1.0 - (x / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -5e-155) || !(Float64(x / y) <= 2000000000000.0)) tmp = Float64(Float64(x / y) * Float64(z - t)); 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 (((x / y) <= -5e-155) || ~(((x / y) <= 2000000000000.0))) tmp = (x / y) * (z - t); else tmp = t * (1.0 - (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -5e-155], N[Not[LessEqual[N[(x / y), $MachinePrecision], 2000000000000.0]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{-155} \lor \neg \left(\frac{x}{y} \leq 2000000000000\right):\\
\;\;\;\;\frac{x}{y} \cdot \left(z - t\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\end{array}
\end{array}
if (/.f64 x y) < -4.9999999999999999e-155 or 2e12 < (/.f64 x y) Initial program 96.8%
Taylor expanded in x around 0 93.8%
Taylor expanded in x around -inf 87.0%
Taylor expanded in z around 0 76.2%
associate-*r/71.1%
associate-*r/73.8%
neg-mul-173.8%
distribute-lft-neg-in73.8%
distribute-rgt-in87.8%
sub-neg87.8%
Simplified87.8%
if -4.9999999999999999e-155 < (/.f64 x y) < 2e12Initial program 99.8%
Taylor expanded in x around 0 90.1%
Taylor expanded in z around 0 76.0%
associate-*r/81.3%
neg-mul-181.3%
distribute-lft-neg-in81.3%
cancel-sign-sub-inv81.3%
*-rgt-identity81.3%
distribute-lft-out--81.3%
Simplified81.3%
Final simplification85.2%
(FPCore (x y z t)
:precision binary64
(if (<= (/ x y) -5e-155)
(* (/ x y) (- z t))
(if (<= (/ x y) 2000000000000.0)
(* t (- 1.0 (/ x y)))
(* x (/ (- z t) y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -5e-155) {
tmp = (x / y) * (z - t);
} else if ((x / y) <= 2000000000000.0) {
tmp = t * (1.0 - (x / y));
} else {
tmp = x * ((z - t) / 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 ((x / y) <= (-5d-155)) then
tmp = (x / y) * (z - t)
else if ((x / y) <= 2000000000000.0d0) then
tmp = t * (1.0d0 - (x / y))
else
tmp = x * ((z - t) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -5e-155) {
tmp = (x / y) * (z - t);
} else if ((x / y) <= 2000000000000.0) {
tmp = t * (1.0 - (x / y));
} else {
tmp = x * ((z - t) / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -5e-155: tmp = (x / y) * (z - t) elif (x / y) <= 2000000000000.0: tmp = t * (1.0 - (x / y)) else: tmp = x * ((z - t) / y) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -5e-155) tmp = Float64(Float64(x / y) * Float64(z - t)); elseif (Float64(x / y) <= 2000000000000.0) tmp = Float64(t * Float64(1.0 - Float64(x / y))); else tmp = Float64(x * Float64(Float64(z - t) / y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x / y) <= -5e-155) tmp = (x / y) * (z - t); elseif ((x / y) <= 2000000000000.0) tmp = t * (1.0 - (x / y)); else tmp = x * ((z - t) / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -5e-155], N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 2000000000000.0], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(z - t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{-155}:\\
\;\;\;\;\frac{x}{y} \cdot \left(z - t\right)\\
\mathbf{elif}\;\frac{x}{y} \leq 2000000000000:\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{z - t}{y}\\
\end{array}
\end{array}
if (/.f64 x y) < -4.9999999999999999e-155Initial program 96.8%
Taylor expanded in x around 0 92.8%
Taylor expanded in x around -inf 81.5%
Taylor expanded in z around 0 72.6%
associate-*r/67.4%
associate-*r/68.8%
neg-mul-168.8%
distribute-lft-neg-in68.8%
distribute-rgt-in82.0%
sub-neg82.0%
Simplified82.0%
if -4.9999999999999999e-155 < (/.f64 x y) < 2e12Initial program 99.8%
Taylor expanded in x around 0 90.1%
Taylor expanded in z around 0 76.0%
associate-*r/81.3%
neg-mul-181.3%
distribute-lft-neg-in81.3%
cancel-sign-sub-inv81.3%
*-rgt-identity81.3%
distribute-lft-out--81.3%
Simplified81.3%
if 2e12 < (/.f64 x y) Initial program 96.7%
Taylor expanded in x around inf 93.4%
Taylor expanded in z around 0 93.4%
mul-1-neg93.4%
distribute-frac-neg93.4%
+-commutative93.4%
distribute-frac-neg93.4%
sub-neg93.4%
div-sub96.8%
Simplified96.8%
Final simplification85.2%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -5e-155) (not (<= (/ x y) 2e-20))) (* (/ x y) z) t))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -5e-155) || !((x / y) <= 2e-20)) {
tmp = (x / y) * 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 (((x / y) <= (-5d-155)) .or. (.not. ((x / y) <= 2d-20))) then
tmp = (x / y) * 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 (((x / y) <= -5e-155) || !((x / y) <= 2e-20)) {
tmp = (x / y) * z;
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -5e-155) or not ((x / y) <= 2e-20): tmp = (x / y) * z else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -5e-155) || !(Float64(x / y) <= 2e-20)) tmp = Float64(Float64(x / y) * z); else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x / y) <= -5e-155) || ~(((x / y) <= 2e-20))) tmp = (x / y) * z; else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -5e-155], N[Not[LessEqual[N[(x / y), $MachinePrecision], 2e-20]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision], t]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{-155} \lor \neg \left(\frac{x}{y} \leq 2 \cdot 10^{-20}\right):\\
\;\;\;\;\frac{x}{y} \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if (/.f64 x y) < -4.9999999999999999e-155 or 1.99999999999999989e-20 < (/.f64 x y) Initial program 97.0%
Taylor expanded in x around inf 79.4%
Taylor expanded in z around inf 46.7%
*-commutative46.7%
clear-num46.5%
un-div-inv46.6%
Applied egg-rr46.6%
associate-/r/50.8%
Applied egg-rr50.8%
if -4.9999999999999999e-155 < (/.f64 x y) < 1.99999999999999989e-20Initial program 99.9%
Taylor expanded in x around 0 82.3%
Final simplification62.4%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) -5e-155) (/ z (/ y x)) (if (<= (/ x y) 2e-20) t (* (/ x y) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -5e-155) {
tmp = z / (y / x);
} else if ((x / y) <= 2e-20) {
tmp = t;
} else {
tmp = (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 ((x / y) <= (-5d-155)) then
tmp = z / (y / x)
else if ((x / y) <= 2d-20) then
tmp = t
else
tmp = (x / y) * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -5e-155) {
tmp = z / (y / x);
} else if ((x / y) <= 2e-20) {
tmp = t;
} else {
tmp = (x / y) * z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -5e-155: tmp = z / (y / x) elif (x / y) <= 2e-20: tmp = t else: tmp = (x / y) * z return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -5e-155) tmp = Float64(z / Float64(y / x)); elseif (Float64(x / y) <= 2e-20) tmp = t; else tmp = Float64(Float64(x / y) * z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x / y) <= -5e-155) tmp = z / (y / x); elseif ((x / y) <= 2e-20) tmp = t; else tmp = (x / y) * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -5e-155], N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 2e-20], t, N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{-155}:\\
\;\;\;\;\frac{z}{\frac{y}{x}}\\
\mathbf{elif}\;\frac{x}{y} \leq 2 \cdot 10^{-20}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot z\\
\end{array}
\end{array}
if (/.f64 x y) < -4.9999999999999999e-155Initial program 96.8%
Taylor expanded in x around inf 75.3%
Taylor expanded in z around inf 43.0%
associate-*l/46.1%
associate-/l*48.8%
Applied egg-rr48.8%
if -4.9999999999999999e-155 < (/.f64 x y) < 1.99999999999999989e-20Initial program 99.9%
Taylor expanded in x around 0 82.3%
if 1.99999999999999989e-20 < (/.f64 x y) Initial program 97.2%
Taylor expanded in x around inf 84.8%
Taylor expanded in z around inf 51.6%
*-commutative51.6%
clear-num51.5%
un-div-inv51.6%
Applied egg-rr51.6%
associate-/r/54.8%
Applied egg-rr54.8%
Final simplification62.8%
(FPCore (x y z t) :precision binary64 (if (or (<= t -8.5e-46) (not (<= t 1.85e-49))) (* t (- 1.0 (/ x y))) (/ z (/ y x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -8.5e-46) || !(t <= 1.85e-49)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = z / (y / x);
}
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 <= (-8.5d-46)) .or. (.not. (t <= 1.85d-49))) then
tmp = t * (1.0d0 - (x / y))
else
tmp = z / (y / x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -8.5e-46) || !(t <= 1.85e-49)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = z / (y / x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -8.5e-46) or not (t <= 1.85e-49): tmp = t * (1.0 - (x / y)) else: tmp = z / (y / x) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -8.5e-46) || !(t <= 1.85e-49)) tmp = Float64(t * Float64(1.0 - Float64(x / y))); else tmp = Float64(z / Float64(y / x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -8.5e-46) || ~((t <= 1.85e-49))) tmp = t * (1.0 - (x / y)); else tmp = z / (y / x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -8.5e-46], N[Not[LessEqual[t, 1.85e-49]], $MachinePrecision]], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -8.5 \cdot 10^{-46} \lor \neg \left(t \leq 1.85 \cdot 10^{-49}\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{y}{x}}\\
\end{array}
\end{array}
if t < -8.5000000000000001e-46 or 1.85e-49 < t Initial program 99.9%
Taylor expanded in x around 0 91.1%
Taylor expanded in z around 0 79.0%
associate-*r/86.0%
neg-mul-186.0%
distribute-lft-neg-in86.0%
cancel-sign-sub-inv86.0%
*-rgt-identity86.0%
distribute-lft-out--86.0%
Simplified86.0%
if -8.5000000000000001e-46 < t < 1.85e-49Initial program 95.3%
Taylor expanded in x around inf 70.3%
Taylor expanded in z around inf 60.2%
associate-*l/61.9%
associate-/l*65.5%
Applied egg-rr65.5%
Final simplification77.5%
(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)
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%
Taylor expanded in x around 0 37.3%
Final simplification37.3%
(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 2023274
(FPCore (x y z t)
:name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
:precision binary64
:herbie-target
(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))