
(FPCore (x y z t) :precision binary64 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
double code(double x, double y, double z, double t) {
return x - (log(((1.0 - y) + (y * exp(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 = x - (log(((1.0d0 - y) + (y * exp(z)))) / t)
end function
public static double code(double x, double y, double z, double t) {
return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
def code(x, y, z, t): return x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
function code(x, y, z, t) return Float64(x - Float64(log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) / t)) end
function tmp = code(x, y, z, t) tmp = x - (log(((1.0 - y) + (y * exp(z)))) / t); end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
double code(double x, double y, double z, double t) {
return x - (log(((1.0 - y) + (y * exp(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 = x - (log(((1.0d0 - y) + (y * exp(z)))) / t)
end function
public static double code(double x, double y, double z, double t) {
return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
def code(x, y, z, t): return x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
function code(x, y, z, t) return Float64(x - Float64(log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) / t)) end
function tmp = code(x, y, z, t) tmp = x - (log(((1.0 - y) + (y * exp(z)))) / t); end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (- x (/ (log1p (* y (expm1 z))) t)))
double code(double x, double y, double z, double t) {
return x - (log1p((y * expm1(z))) / t);
}
public static double code(double x, double y, double z, double t) {
return x - (Math.log1p((y * Math.expm1(z))) / t);
}
def code(x, y, z, t): return x - (math.log1p((y * math.expm1(z))) / t)
function code(x, y, z, t) return Float64(x - Float64(log1p(Float64(y * expm1(z))) / t)) end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}
\end{array}
Initial program 63.0%
remove-double-neg63.0%
neg-mul-163.0%
*-commutative63.0%
*-commutative63.0%
neg-mul-163.0%
remove-double-neg63.0%
sub-neg63.0%
associate-+l+77.4%
cancel-sign-sub77.4%
log1p-def84.8%
cancel-sign-sub84.8%
+-commutative84.8%
unsub-neg84.8%
*-rgt-identity84.8%
distribute-lft-out--84.8%
expm1-def99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x y z t) :precision binary64 (if (<= (exp z) 0.0) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y (+ (exp z) -1.0)))))) (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (exp(z) <= 0.0) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (exp(z) + -1.0)))));
} else {
tmp = x - (log1p((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (Math.exp(z) <= 0.0) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (Math.exp(z) + -1.0)))));
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if math.exp(z) <= 0.0: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (math.exp(z) + -1.0))))) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (exp(z) <= 0.0) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * Float64(exp(z) + -1.0)))))); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Exp[z], $MachinePrecision], 0.0], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * N[(N[Exp[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(y * z), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 0:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot \left(e^{z} + -1\right)}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if (exp.f64 z) < 0.0Initial program 75.7%
remove-double-neg75.7%
neg-mul-175.7%
*-commutative75.7%
*-commutative75.7%
neg-mul-175.7%
remove-double-neg75.7%
sub-neg75.7%
associate-+l+75.7%
cancel-sign-sub75.7%
log1p-def99.9%
cancel-sign-sub99.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-def99.9%
Simplified99.9%
clear-num99.8%
associate-/r/99.8%
Applied egg-rr99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 85.7%
if 0.0 < (exp.f64 z) Initial program 57.4%
remove-double-neg57.4%
neg-mul-157.4%
*-commutative57.4%
*-commutative57.4%
neg-mul-157.4%
remove-double-neg57.4%
sub-neg57.4%
associate-+l+78.1%
cancel-sign-sub78.1%
log1p-def78.1%
cancel-sign-sub78.1%
+-commutative78.1%
unsub-neg78.1%
*-rgt-identity78.1%
distribute-lft-out--78.1%
expm1-def98.8%
Simplified98.8%
Taylor expanded in z around 0 98.2%
Final simplification94.4%
(FPCore (x y z t) :precision binary64 (if (<= z -25.0) (+ x (/ (/ -1.0 t) (+ 0.5 (/ 1.0 (* y (expm1 z)))))) (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -25.0) {
tmp = x + ((-1.0 / t) / (0.5 + (1.0 / (y * expm1(z)))));
} else {
tmp = x - (log1p((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -25.0) {
tmp = x + ((-1.0 / t) / (0.5 + (1.0 / (y * Math.expm1(z)))));
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -25.0: tmp = x + ((-1.0 / t) / (0.5 + (1.0 / (y * math.expm1(z))))) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -25.0) tmp = Float64(x + Float64(Float64(-1.0 / t) / Float64(0.5 + Float64(1.0 / Float64(y * expm1(z)))))); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -25.0], N[(x + N[(N[(-1.0 / t), $MachinePrecision] / N[(0.5 + N[(1.0 / N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(y * z), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -25:\\
\;\;\;\;x + \frac{\frac{-1}{t}}{0.5 + \frac{1}{y \cdot \mathsf{expm1}\left(z\right)}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if z < -25Initial program 75.7%
remove-double-neg75.7%
neg-mul-175.7%
*-commutative75.7%
*-commutative75.7%
neg-mul-175.7%
remove-double-neg75.7%
sub-neg75.7%
associate-+l+75.7%
cancel-sign-sub75.7%
log1p-def99.9%
cancel-sign-sub99.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-def99.9%
Simplified99.9%
clear-num99.8%
associate-/r/99.8%
Applied egg-rr99.8%
associate-/r/99.8%
div-inv99.7%
associate-/r*99.6%
Applied egg-rr99.6%
Taylor expanded in y around 0 85.6%
expm1-def85.6%
Simplified85.6%
if -25 < z Initial program 57.4%
remove-double-neg57.4%
neg-mul-157.4%
*-commutative57.4%
*-commutative57.4%
neg-mul-157.4%
remove-double-neg57.4%
sub-neg57.4%
associate-+l+78.1%
cancel-sign-sub78.1%
log1p-def78.1%
cancel-sign-sub78.1%
+-commutative78.1%
unsub-neg78.1%
*-rgt-identity78.1%
distribute-lft-out--78.1%
expm1-def98.8%
Simplified98.8%
Taylor expanded in z around 0 98.2%
Final simplification94.4%
(FPCore (x y z t) :precision binary64 (if (<= z -1.75e-207) (- x (* (expm1 z) (/ y t))) (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.75e-207) {
tmp = x - (expm1(z) * (y / t));
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.75e-207) {
tmp = x - (Math.expm1(z) * (y / t));
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.75e-207: tmp = x - (math.expm1(z) * (y / t)) else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.75e-207) tmp = Float64(x - Float64(expm1(z) * Float64(y / t))); else tmp = Float64(x - Float64(y * Float64(z / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.75e-207], N[(x - N[(N[(Exp[z] - 1), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.75 \cdot 10^{-207}:\\
\;\;\;\;x - \mathsf{expm1}\left(z\right) \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -1.7500000000000001e-207Initial program 65.5%
remove-double-neg65.5%
neg-mul-165.5%
*-commutative65.5%
*-commutative65.5%
neg-mul-165.5%
remove-double-neg65.5%
sub-neg65.5%
associate-+l+75.5%
cancel-sign-sub75.5%
log1p-def90.0%
cancel-sign-sub90.0%
+-commutative90.0%
unsub-neg90.0%
*-rgt-identity90.0%
distribute-lft-out--90.0%
expm1-def99.9%
Simplified99.9%
Taylor expanded in y around 0 77.0%
associate-/l*77.0%
associate-/r/76.9%
expm1-def84.5%
Simplified84.5%
if -1.7500000000000001e-207 < z Initial program 60.4%
remove-double-neg60.4%
neg-mul-160.4%
*-commutative60.4%
*-commutative60.4%
neg-mul-160.4%
remove-double-neg60.4%
sub-neg60.4%
associate-+l+79.4%
cancel-sign-sub79.4%
log1p-def79.4%
cancel-sign-sub79.4%
+-commutative79.4%
unsub-neg79.4%
*-rgt-identity79.4%
distribute-lft-out--79.4%
expm1-def98.4%
Simplified98.4%
Taylor expanded in z around 0 93.8%
associate-/l*94.6%
Simplified94.6%
clear-num94.5%
associate-/r/94.5%
clear-num94.6%
Applied egg-rr94.6%
Final simplification89.4%
(FPCore (x y z t) :precision binary64 (if (<= z -2.25e+23) (- x (* (expm1 z) (/ y t))) (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.25e+23) {
tmp = x - (expm1(z) * (y / t));
} else {
tmp = x - (log1p((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.25e+23) {
tmp = x - (Math.expm1(z) * (y / t));
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.25e+23: tmp = x - (math.expm1(z) * (y / t)) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.25e+23) tmp = Float64(x - Float64(expm1(z) * Float64(y / t))); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.25e+23], N[(x - N[(N[(Exp[z] - 1), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(y * z), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.25 \cdot 10^{+23}:\\
\;\;\;\;x - \mathsf{expm1}\left(z\right) \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if z < -2.2499999999999999e23Initial program 75.8%
remove-double-neg75.8%
neg-mul-175.8%
*-commutative75.8%
*-commutative75.8%
neg-mul-175.8%
remove-double-neg75.8%
sub-neg75.8%
associate-+l+75.8%
cancel-sign-sub75.8%
log1p-def99.9%
cancel-sign-sub99.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in y around 0 81.7%
associate-/l*81.7%
associate-/r/81.7%
expm1-def81.7%
Simplified81.7%
if -2.2499999999999999e23 < z Initial program 57.8%
remove-double-neg57.8%
neg-mul-157.8%
*-commutative57.8%
*-commutative57.8%
neg-mul-157.8%
remove-double-neg57.8%
sub-neg57.8%
associate-+l+78.0%
cancel-sign-sub78.0%
log1p-def78.6%
cancel-sign-sub78.6%
+-commutative78.6%
unsub-neg78.6%
*-rgt-identity78.6%
distribute-lft-out--78.6%
expm1-def98.8%
Simplified98.8%
Taylor expanded in z around 0 97.3%
Final simplification92.8%
(FPCore (x y z t) :precision binary64 (- x (* y (/ (expm1 z) t))))
double code(double x, double y, double z, double t) {
return x - (y * (expm1(z) / t));
}
public static double code(double x, double y, double z, double t) {
return x - (y * (Math.expm1(z) / t));
}
def code(x, y, z, t): return x - (y * (math.expm1(z) / t))
function code(x, y, z, t) return Float64(x - Float64(y * Float64(expm1(z) / t))) end
code[x_, y_, z_, t_] := N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}
\end{array}
Initial program 63.0%
remove-double-neg63.0%
neg-mul-163.0%
*-commutative63.0%
*-commutative63.0%
neg-mul-163.0%
remove-double-neg63.0%
sub-neg63.0%
associate-+l+77.4%
cancel-sign-sub77.4%
log1p-def84.8%
cancel-sign-sub84.8%
+-commutative84.8%
unsub-neg84.8%
*-rgt-identity84.8%
distribute-lft-out--84.8%
expm1-def99.2%
Simplified99.2%
Taylor expanded in y around 0 77.8%
associate-/l*77.8%
associate-/r/77.3%
expm1-def86.2%
Simplified86.2%
*-commutative86.2%
clear-num86.2%
un-div-inv87.0%
Applied egg-rr87.0%
associate-/r/89.4%
Applied egg-rr89.4%
Final simplification89.4%
(FPCore (x y z t) :precision binary64 (if (<= z -1.8e+71) (+ x (* (/ 1.0 t) (+ -1.0 (- 1.0 (* y z))))) (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.8e+71) {
tmp = x + ((1.0 / t) * (-1.0 + (1.0 - (y * z))));
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-1.8d+71)) then
tmp = x + ((1.0d0 / t) * ((-1.0d0) + (1.0d0 - (y * z))))
else
tmp = x - (y / (t / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.8e+71) {
tmp = x + ((1.0 / t) * (-1.0 + (1.0 - (y * z))));
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.8e+71: tmp = x + ((1.0 / t) * (-1.0 + (1.0 - (y * z)))) else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.8e+71) tmp = Float64(x + Float64(Float64(1.0 / t) * Float64(-1.0 + Float64(1.0 - Float64(y * z))))); else tmp = Float64(x - Float64(y / Float64(t / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.8e+71) tmp = x + ((1.0 / t) * (-1.0 + (1.0 - (y * z)))); else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.8e+71], N[(x + N[(N[(1.0 / t), $MachinePrecision] * N[(-1.0 + N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{+71}:\\
\;\;\;\;x + \frac{1}{t} \cdot \left(-1 + \left(1 - y \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -1.8e71Initial program 77.7%
remove-double-neg77.7%
neg-mul-177.7%
*-commutative77.7%
*-commutative77.7%
neg-mul-177.7%
remove-double-neg77.7%
sub-neg77.7%
associate-+l+77.7%
cancel-sign-sub77.7%
log1p-def99.9%
cancel-sign-sub99.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in z around 0 30.7%
associate-/l*25.9%
Simplified25.9%
*-un-lft-identity25.9%
div-inv25.9%
times-frac30.7%
Applied egg-rr30.7%
associate-/r/30.7%
/-rgt-identity30.7%
expm1-log1p-u24.4%
expm1-udef31.9%
log1p-udef31.9%
rem-exp-log38.2%
Applied egg-rr38.2%
associate--l+38.2%
Simplified38.2%
if -1.8e71 < z Initial program 58.2%
remove-double-neg58.2%
neg-mul-158.2%
*-commutative58.2%
*-commutative58.2%
neg-mul-158.2%
remove-double-neg58.2%
sub-neg58.2%
associate-+l+77.3%
cancel-sign-sub77.3%
log1p-def79.8%
cancel-sign-sub79.8%
+-commutative79.8%
unsub-neg79.8%
*-rgt-identity79.8%
distribute-lft-out--79.8%
expm1-def98.9%
Simplified98.9%
Taylor expanded in z around 0 88.1%
associate-/l*88.6%
Simplified88.6%
Final simplification76.2%
(FPCore (x y z t) :precision binary64 (- x (* z (/ y t))))
double code(double x, double y, double z, double t) {
return x - (z * (y / t));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x - (z * (y / t))
end function
public static double code(double x, double y, double z, double t) {
return x - (z * (y / t));
}
def code(x, y, z, t): return x - (z * (y / t))
function code(x, y, z, t) return Float64(x - Float64(z * Float64(y / t))) end
function tmp = code(x, y, z, t) tmp = x - (z * (y / t)); end
code[x_, y_, z_, t_] := N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - z \cdot \frac{y}{t}
\end{array}
Initial program 63.0%
remove-double-neg63.0%
neg-mul-163.0%
*-commutative63.0%
*-commutative63.0%
neg-mul-163.0%
remove-double-neg63.0%
sub-neg63.0%
associate-+l+77.4%
cancel-sign-sub77.4%
log1p-def84.8%
cancel-sign-sub84.8%
+-commutative84.8%
unsub-neg84.8%
*-rgt-identity84.8%
distribute-lft-out--84.8%
expm1-def99.2%
Simplified99.2%
Taylor expanded in z around 0 74.0%
associate-/l*73.2%
Simplified73.2%
associate-/r/71.5%
Applied egg-rr71.5%
Final simplification71.5%
(FPCore (x y z t) :precision binary64 (- x (* y (/ z t))))
double code(double x, double y, double z, double t) {
return 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 = x - (y * (z / t))
end function
public static double code(double x, double y, double z, double t) {
return x - (y * (z / t));
}
def code(x, y, z, t): return x - (y * (z / t))
function code(x, y, z, t) return Float64(x - Float64(y * Float64(z / t))) end
function tmp = code(x, y, z, t) tmp = x - (y * (z / t)); end
code[x_, y_, z_, t_] := N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - y \cdot \frac{z}{t}
\end{array}
Initial program 63.0%
remove-double-neg63.0%
neg-mul-163.0%
*-commutative63.0%
*-commutative63.0%
neg-mul-163.0%
remove-double-neg63.0%
sub-neg63.0%
associate-+l+77.4%
cancel-sign-sub77.4%
log1p-def84.8%
cancel-sign-sub84.8%
+-commutative84.8%
unsub-neg84.8%
*-rgt-identity84.8%
distribute-lft-out--84.8%
expm1-def99.2%
Simplified99.2%
Taylor expanded in z around 0 74.0%
associate-/l*73.2%
Simplified73.2%
clear-num73.2%
associate-/r/72.8%
clear-num72.8%
Applied egg-rr72.8%
Final simplification72.8%
(FPCore (x y z t) :precision binary64 (- x (/ y (/ t z))))
double code(double x, double y, double z, double t) {
return x - (y / (t / z));
}
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 / (t / z))
end function
public static double code(double x, double y, double z, double t) {
return x - (y / (t / z));
}
def code(x, y, z, t): return x - (y / (t / z))
function code(x, y, z, t) return Float64(x - Float64(y / Float64(t / z))) end
function tmp = code(x, y, z, t) tmp = x - (y / (t / z)); end
code[x_, y_, z_, t_] := N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y}{\frac{t}{z}}
\end{array}
Initial program 63.0%
remove-double-neg63.0%
neg-mul-163.0%
*-commutative63.0%
*-commutative63.0%
neg-mul-163.0%
remove-double-neg63.0%
sub-neg63.0%
associate-+l+77.4%
cancel-sign-sub77.4%
log1p-def84.8%
cancel-sign-sub84.8%
+-commutative84.8%
unsub-neg84.8%
*-rgt-identity84.8%
distribute-lft-out--84.8%
expm1-def99.2%
Simplified99.2%
Taylor expanded in z around 0 74.0%
associate-/l*73.2%
Simplified73.2%
Final simplification73.2%
(FPCore (x y z t) :precision binary64 (- x (/ (* y z) t)))
double code(double x, double y, double z, double t) {
return 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 = x - ((y * z) / t)
end function
public static double code(double x, double y, double z, double t) {
return x - ((y * z) / t);
}
def code(x, y, z, t): return x - ((y * z) / t)
function code(x, y, z, t) return Float64(x - Float64(Float64(y * z) / t)) end
function tmp = code(x, y, z, t) tmp = x - ((y * z) / t); end
code[x_, y_, z_, t_] := N[(x - N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y \cdot z}{t}
\end{array}
Initial program 63.0%
remove-double-neg63.0%
neg-mul-163.0%
*-commutative63.0%
*-commutative63.0%
neg-mul-163.0%
remove-double-neg63.0%
sub-neg63.0%
associate-+l+77.4%
cancel-sign-sub77.4%
log1p-def84.8%
cancel-sign-sub84.8%
+-commutative84.8%
unsub-neg84.8%
*-rgt-identity84.8%
distribute-lft-out--84.8%
expm1-def99.2%
Simplified99.2%
Taylor expanded in z around 0 74.0%
Final simplification74.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (- 0.5) (* y t))))
(if (< z -2.8874623088207947e+119)
(- (- x (/ t_1 (* z z))) (* t_1 (/ (/ 2.0 z) (* z z))))
(- x (/ (log (+ 1.0 (* z y))) t)))))
double code(double x, double y, double z, double t) {
double t_1 = -0.5 / (y * t);
double tmp;
if (z < -2.8874623088207947e+119) {
tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z)));
} else {
tmp = x - (log((1.0 + (z * y))) / 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) :: t_1
real(8) :: tmp
t_1 = -0.5d0 / (y * t)
if (z < (-2.8874623088207947d+119)) then
tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0d0 / z) / (z * z)))
else
tmp = x - (log((1.0d0 + (z * y))) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = -0.5 / (y * t);
double tmp;
if (z < -2.8874623088207947e+119) {
tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z)));
} else {
tmp = x - (Math.log((1.0 + (z * y))) / t);
}
return tmp;
}
def code(x, y, z, t): t_1 = -0.5 / (y * t) tmp = 0 if z < -2.8874623088207947e+119: tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z))) else: tmp = x - (math.log((1.0 + (z * y))) / t) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(-0.5) / Float64(y * t)) tmp = 0.0 if (z < -2.8874623088207947e+119) tmp = Float64(Float64(x - Float64(t_1 / Float64(z * z))) - Float64(t_1 * Float64(Float64(2.0 / z) / Float64(z * z)))); else tmp = Float64(x - Float64(log(Float64(1.0 + Float64(z * y))) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -0.5 / (y * t); tmp = 0.0; if (z < -2.8874623088207947e+119) tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z))); else tmp = x - (log((1.0 + (z * y))) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-0.5) / N[(y * t), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -2.8874623088207947e+119], N[(N[(x - N[(t$95$1 / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[(N[(2.0 / z), $MachinePrecision] / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{-0.5}{y \cdot t}\\
\mathbf{if}\;z < -2.8874623088207947 \cdot 10^{+119}:\\
\;\;\;\;\left(x - \frac{t\_1}{z \cdot z}\right) - t\_1 \cdot \frac{\frac{2}{z}}{z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1 + z \cdot y\right)}{t}\\
\end{array}
\end{array}
herbie shell --seed 2024027
(FPCore (x y z t)
:name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
:precision binary64
:herbie-target
(if (< z -2.8874623088207947e+119) (- (- x (/ (/ (- 0.5) (* y t)) (* z z))) (* (/ (- 0.5) (* y t)) (/ (/ 2.0 z) (* z z)))) (- x (/ (log (+ 1.0 (* z y))) t)))
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))