
(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 11 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 97.5%
fma-define97.5%
Simplified97.5%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -10000000.0) (not (<= (/ x y) 20000000000000.0))) (* (/ x y) (- t)) t))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -10000000.0) || !((x / y) <= 20000000000000.0)) {
tmp = (x / y) * -t;
} 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) <= (-10000000.0d0)) .or. (.not. ((x / y) <= 20000000000000.0d0))) then
tmp = (x / y) * -t
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) <= -10000000.0) || !((x / y) <= 20000000000000.0)) {
tmp = (x / y) * -t;
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -10000000.0) or not ((x / y) <= 20000000000000.0): tmp = (x / y) * -t else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -10000000.0) || !(Float64(x / y) <= 20000000000000.0)) tmp = Float64(Float64(x / y) * Float64(-t)); else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x / y) <= -10000000.0) || ~(((x / y) <= 20000000000000.0))) tmp = (x / y) * -t; else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -10000000.0], N[Not[LessEqual[N[(x / y), $MachinePrecision], 20000000000000.0]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] * (-t)), $MachinePrecision], t]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -10000000 \lor \neg \left(\frac{x}{y} \leq 20000000000000\right):\\
\;\;\;\;\frac{x}{y} \cdot \left(-t\right)\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if (/.f64 x y) < -1e7 or 2e13 < (/.f64 x y) Initial program 96.1%
Taylor expanded in z around 0 58.5%
mul-1-neg58.5%
*-commutative58.5%
associate-*l/61.4%
*-lft-identity61.4%
distribute-lft-neg-in61.4%
mul-1-neg61.4%
distribute-rgt-in61.4%
mul-1-neg61.4%
unsub-neg61.4%
Simplified61.4%
Taylor expanded in x around inf 61.2%
associate-*r/61.2%
neg-mul-161.2%
Simplified61.2%
if -1e7 < (/.f64 x y) < 2e13Initial program 98.8%
Taylor expanded in x around 0 78.0%
Final simplification69.7%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -10000000.0) (not (<= (/ x y) 4e+15))) (* x (/ t (- y))) t))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -10000000.0) || !((x / y) <= 4e+15)) {
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 / y) <= (-10000000.0d0)) .or. (.not. ((x / y) <= 4d+15))) 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 / y) <= -10000000.0) || !((x / y) <= 4e+15)) {
tmp = x * (t / -y);
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -10000000.0) or not ((x / y) <= 4e+15): tmp = x * (t / -y) else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -10000000.0) || !(Float64(x / y) <= 4e+15)) 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 / y) <= -10000000.0) || ~(((x / y) <= 4e+15))) tmp = x * (t / -y); else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -10000000.0], N[Not[LessEqual[N[(x / y), $MachinePrecision], 4e+15]], $MachinePrecision]], N[(x * N[(t / (-y)), $MachinePrecision]), $MachinePrecision], t]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -10000000 \lor \neg \left(\frac{x}{y} \leq 4 \cdot 10^{+15}\right):\\
\;\;\;\;x \cdot \frac{t}{-y}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if (/.f64 x y) < -1e7 or 4e15 < (/.f64 x y) Initial program 96.1%
Taylor expanded in z around 0 58.6%
mul-1-neg58.6%
*-commutative58.6%
associate-*l/61.6%
*-lft-identity61.6%
distribute-lft-neg-in61.6%
mul-1-neg61.6%
distribute-rgt-in61.6%
mul-1-neg61.6%
unsub-neg61.6%
Simplified61.6%
Taylor expanded in x around inf 61.5%
associate-*r/61.5%
neg-mul-161.5%
Simplified61.5%
*-commutative61.5%
add-sqr-sqrt35.7%
sqrt-unprod38.1%
sqr-neg38.1%
sqrt-unprod5.4%
add-sqr-sqrt10.9%
add-sqr-sqrt3.9%
sqrt-unprod25.3%
sqr-neg25.3%
sqrt-unprod25.9%
add-sqr-sqrt61.5%
/-rgt-identity61.5%
clear-num61.4%
div-inv61.5%
associate-/r*60.0%
frac-2neg60.0%
un-div-inv60.0%
distribute-neg-frac60.0%
frac-2neg60.0%
un-div-inv58.5%
clear-num58.5%
distribute-lft-neg-in58.5%
Applied egg-rr58.5%
if -1e7 < (/.f64 x y) < 4e15Initial program 98.8%
Taylor expanded in x around 0 76.9%
Final simplification68.0%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) -10000000.0) (* (/ x y) (- t)) (if (<= (/ x y) 20000000000000.0) t (/ (* t (- x)) y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -10000000.0) {
tmp = (x / y) * -t;
} else if ((x / y) <= 20000000000000.0) {
tmp = t;
} else {
tmp = (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 ((x / y) <= (-10000000.0d0)) then
tmp = (x / y) * -t
else if ((x / y) <= 20000000000000.0d0) then
tmp = t
else
tmp = (t * -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) <= -10000000.0) {
tmp = (x / y) * -t;
} else if ((x / y) <= 20000000000000.0) {
tmp = t;
} else {
tmp = (t * -x) / y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -10000000.0: tmp = (x / y) * -t elif (x / y) <= 20000000000000.0: tmp = t else: tmp = (t * -x) / y return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -10000000.0) tmp = Float64(Float64(x / y) * Float64(-t)); elseif (Float64(x / y) <= 20000000000000.0) tmp = t; else tmp = Float64(Float64(t * Float64(-x)) / y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x / y) <= -10000000.0) tmp = (x / y) * -t; elseif ((x / y) <= 20000000000000.0) tmp = t; else tmp = (t * -x) / y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -10000000.0], N[(N[(x / y), $MachinePrecision] * (-t)), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 20000000000000.0], t, N[(N[(t * (-x)), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -10000000:\\
\;\;\;\;\frac{x}{y} \cdot \left(-t\right)\\
\mathbf{elif}\;\frac{x}{y} \leq 20000000000000:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;\frac{t \cdot \left(-x\right)}{y}\\
\end{array}
\end{array}
if (/.f64 x y) < -1e7Initial program 97.1%
Taylor expanded in z around 0 54.9%
mul-1-neg54.9%
*-commutative54.9%
associate-*l/61.7%
*-lft-identity61.7%
distribute-lft-neg-in61.7%
mul-1-neg61.7%
distribute-rgt-in61.7%
mul-1-neg61.7%
unsub-neg61.7%
Simplified61.7%
Taylor expanded in x around inf 61.5%
associate-*r/61.5%
neg-mul-161.5%
Simplified61.5%
if -1e7 < (/.f64 x y) < 2e13Initial program 98.8%
Taylor expanded in x around 0 78.0%
if 2e13 < (/.f64 x y) Initial program 95.0%
Taylor expanded in z around 0 62.7%
mul-1-neg62.7%
*-commutative62.7%
associate-*l/61.1%
*-lft-identity61.1%
distribute-lft-neg-in61.1%
mul-1-neg61.1%
distribute-rgt-in61.1%
mul-1-neg61.1%
unsub-neg61.1%
Simplified61.1%
Taylor expanded in x around inf 60.9%
associate-*r/60.9%
neg-mul-160.9%
Simplified60.9%
*-commutative60.9%
add-sqr-sqrt36.5%
sqrt-unprod40.6%
sqr-neg40.6%
sqrt-unprod4.2%
add-sqr-sqrt10.0%
add-sqr-sqrt2.7%
sqrt-unprod18.4%
sqr-neg18.4%
sqrt-unprod19.1%
add-sqr-sqrt60.9%
/-rgt-identity60.9%
clear-num60.8%
div-inv60.9%
associate-/r*60.1%
frac-2neg60.1%
un-div-inv60.0%
distribute-neg-frac60.0%
frac-2neg60.0%
un-div-inv56.3%
clear-num56.3%
distribute-lft-neg-in56.3%
associate-*r/62.4%
distribute-neg-frac262.4%
Applied egg-rr62.4%
Final simplification70.1%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -1.7e+295) (not (<= (/ x y) 0.36))) (* (/ x y) t) t))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -1.7e+295) || !((x / y) <= 0.36)) {
tmp = (x / y) * t;
} 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) <= (-1.7d+295)) .or. (.not. ((x / y) <= 0.36d0))) then
tmp = (x / y) * t
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) <= -1.7e+295) || !((x / y) <= 0.36)) {
tmp = (x / y) * t;
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -1.7e+295) or not ((x / y) <= 0.36): tmp = (x / y) * t else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -1.7e+295) || !(Float64(x / y) <= 0.36)) tmp = Float64(Float64(x / y) * t); else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x / y) <= -1.7e+295) || ~(((x / y) <= 0.36))) tmp = (x / y) * t; else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -1.7e+295], N[Not[LessEqual[N[(x / y), $MachinePrecision], 0.36]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] * t), $MachinePrecision], t]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -1.7 \cdot 10^{+295} \lor \neg \left(\frac{x}{y} \leq 0.36\right):\\
\;\;\;\;\frac{x}{y} \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if (/.f64 x y) < -1.70000000000000001e295 or 0.35999999999999999 < (/.f64 x y) Initial program 93.8%
Taylor expanded in z around 0 59.5%
mul-1-neg59.5%
*-commutative59.5%
associate-*l/58.3%
*-lft-identity58.3%
distribute-lft-neg-in58.3%
mul-1-neg58.3%
distribute-rgt-in58.3%
mul-1-neg58.3%
unsub-neg58.3%
Simplified58.3%
Taylor expanded in x around inf 58.1%
associate-*r/58.1%
neg-mul-158.1%
Simplified58.1%
div-inv58.1%
add-sqr-sqrt37.4%
sqrt-unprod45.6%
sqr-neg45.6%
sqrt-unprod8.3%
add-sqr-sqrt16.6%
Applied egg-rr16.6%
associate-*r/16.6%
*-rgt-identity16.6%
Simplified16.6%
if -1.70000000000000001e295 < (/.f64 x y) < 0.35999999999999999Initial program 99.1%
Taylor expanded in x around 0 58.3%
Final simplification45.6%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) (- INFINITY)) (* (/ x y) t) (if (<= (/ x y) 5e-8) t (/ t (/ y x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -((double) INFINITY)) {
tmp = (x / y) * t;
} else if ((x / y) <= 5e-8) {
tmp = t;
} else {
tmp = t / (y / x);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -Double.POSITIVE_INFINITY) {
tmp = (x / y) * t;
} else if ((x / y) <= 5e-8) {
tmp = t;
} else {
tmp = t / (y / x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -math.inf: tmp = (x / y) * t elif (x / y) <= 5e-8: tmp = t else: tmp = t / (y / x) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= Float64(-Inf)) tmp = Float64(Float64(x / y) * t); elseif (Float64(x / y) <= 5e-8) tmp = t; else tmp = Float64(t / Float64(y / x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x / y) <= -Inf) tmp = (x / y) * t; elseif ((x / y) <= 5e-8) tmp = t; else tmp = t / (y / x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], (-Infinity)], N[(N[(x / y), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 5e-8], t, N[(t / N[(y / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -\infty:\\
\;\;\;\;\frac{x}{y} \cdot t\\
\mathbf{elif}\;\frac{x}{y} \leq 5 \cdot 10^{-8}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;\frac{t}{\frac{y}{x}}\\
\end{array}
\end{array}
if (/.f64 x y) < -inf.0Initial program 90.0%
Taylor expanded in z around 0 52.8%
mul-1-neg52.8%
*-commutative52.8%
associate-*l/52.7%
*-lft-identity52.7%
distribute-lft-neg-in52.7%
mul-1-neg52.7%
distribute-rgt-in52.7%
mul-1-neg52.7%
unsub-neg52.7%
Simplified52.7%
Taylor expanded in x around inf 52.7%
associate-*r/52.7%
neg-mul-152.7%
Simplified52.7%
div-inv52.7%
add-sqr-sqrt42.1%
sqrt-unprod63.4%
sqr-neg63.4%
sqrt-unprod21.3%
add-sqr-sqrt37.3%
Applied egg-rr37.3%
associate-*r/37.3%
*-rgt-identity37.3%
Simplified37.3%
if -inf.0 < (/.f64 x y) < 4.9999999999999998e-8Initial program 99.1%
Taylor expanded in x around 0 58.3%
if 4.9999999999999998e-8 < (/.f64 x y) Initial program 95.1%
Taylor expanded in z around 0 61.7%
mul-1-neg61.7%
*-commutative61.7%
associate-*l/60.1%
*-lft-identity60.1%
distribute-lft-neg-in60.1%
mul-1-neg60.1%
distribute-rgt-in60.1%
mul-1-neg60.1%
unsub-neg60.1%
Simplified60.1%
Taylor expanded in x around inf 59.9%
associate-*r/59.9%
neg-mul-159.9%
Simplified59.9%
clear-num59.8%
un-div-inv60.4%
add-sqr-sqrt36.0%
sqrt-unprod39.9%
sqr-neg39.9%
sqrt-unprod4.2%
add-sqr-sqrt9.9%
Applied egg-rr9.9%
Final simplification45.6%
(FPCore (x y z t) :precision binary64 (if (or (<= z -9.6e-37) (not (<= z 1.5e-43))) (+ t (* (/ x y) z)) (* t (- 1.0 (/ x y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -9.6e-37) || !(z <= 1.5e-43)) {
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 ((z <= (-9.6d-37)) .or. (.not. (z <= 1.5d-43))) 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 ((z <= -9.6e-37) || !(z <= 1.5e-43)) {
tmp = t + ((x / y) * z);
} else {
tmp = t * (1.0 - (x / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -9.6e-37) or not (z <= 1.5e-43): tmp = t + ((x / y) * z) else: tmp = t * (1.0 - (x / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -9.6e-37) || !(z <= 1.5e-43)) 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 ((z <= -9.6e-37) || ~((z <= 1.5e-43))) tmp = t + ((x / y) * z); else tmp = t * (1.0 - (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -9.6e-37], N[Not[LessEqual[z, 1.5e-43]], $MachinePrecision]], 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}\;z \leq -9.6 \cdot 10^{-37} \lor \neg \left(z \leq 1.5 \cdot 10^{-43}\right):\\
\;\;\;\;t + \frac{x}{y} \cdot z\\
\mathbf{else}:\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -9.59999999999999963e-37 or 1.50000000000000002e-43 < z Initial program 98.9%
Taylor expanded in z around inf 92.8%
if -9.59999999999999963e-37 < z < 1.50000000000000002e-43Initial program 95.8%
Taylor expanded in z around 0 85.8%
mul-1-neg85.8%
*-commutative85.8%
associate-*l/89.0%
*-lft-identity89.0%
distribute-lft-neg-in89.0%
mul-1-neg89.0%
distribute-rgt-in89.0%
mul-1-neg89.0%
unsub-neg89.0%
Simplified89.0%
Final simplification91.1%
(FPCore (x y z t) :precision binary64 (if (or (<= z -6.2e-37) (not (<= z 2.9e-50))) (+ t (* x (/ z y))) (* t (- 1.0 (/ x y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -6.2e-37) || !(z <= 2.9e-50)) {
tmp = t + (x * (z / y));
} 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 ((z <= (-6.2d-37)) .or. (.not. (z <= 2.9d-50))) then
tmp = t + (x * (z / y))
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 ((z <= -6.2e-37) || !(z <= 2.9e-50)) {
tmp = t + (x * (z / y));
} else {
tmp = t * (1.0 - (x / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -6.2e-37) or not (z <= 2.9e-50): tmp = t + (x * (z / y)) else: tmp = t * (1.0 - (x / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -6.2e-37) || !(z <= 2.9e-50)) tmp = Float64(t + Float64(x * Float64(z / y))); 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 ((z <= -6.2e-37) || ~((z <= 2.9e-50))) tmp = t + (x * (z / y)); else tmp = t * (1.0 - (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -6.2e-37], N[Not[LessEqual[z, 2.9e-50]], $MachinePrecision]], N[(t + N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{-37} \lor \neg \left(z \leq 2.9 \cdot 10^{-50}\right):\\
\;\;\;\;t + x \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -6.19999999999999987e-37 or 2.90000000000000008e-50 < z Initial program 98.9%
Taylor expanded in z around inf 88.0%
associate-/l*87.1%
Simplified87.1%
if -6.19999999999999987e-37 < z < 2.90000000000000008e-50Initial program 95.8%
Taylor expanded in z around 0 85.8%
mul-1-neg85.8%
*-commutative85.8%
associate-*l/89.0%
*-lft-identity89.0%
distribute-lft-neg-in89.0%
mul-1-neg89.0%
distribute-rgt-in89.0%
mul-1-neg89.0%
unsub-neg89.0%
Simplified89.0%
Final simplification88.0%
(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 97.5%
Final simplification97.5%
(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 97.5%
Taylor expanded in z around 0 66.9%
mul-1-neg66.9%
*-commutative66.9%
associate-*l/70.2%
*-lft-identity70.2%
distribute-lft-neg-in70.2%
mul-1-neg70.2%
distribute-rgt-in70.2%
mul-1-neg70.2%
unsub-neg70.2%
Simplified70.2%
(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 97.5%
Taylor expanded in x around 0 41.1%
(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 2024185
(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))