
(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 9 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 62.9%
sub-neg62.9%
neg-mul-162.9%
*-commutative62.9%
cancel-sign-sub62.9%
*-commutative62.9%
mul-1-neg62.9%
remove-double-neg62.9%
Simplified98.9%
Final simplification98.9%
(FPCore (x y z t) :precision binary64 (if (or (<= y -3.8e+19) (not (<= y 8.2e-22))) (+ x (/ (/ -1.0 t) (+ 0.5 (/ (/ 1.0 z) y)))) (- x (* (expm1 z) (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.8e+19) || !(y <= 8.2e-22)) {
tmp = x + ((-1.0 / t) / (0.5 + ((1.0 / z) / y)));
} else {
tmp = x - (expm1(z) * (y / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.8e+19) || !(y <= 8.2e-22)) {
tmp = x + ((-1.0 / t) / (0.5 + ((1.0 / z) / y)));
} else {
tmp = x - (Math.expm1(z) * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -3.8e+19) or not (y <= 8.2e-22): tmp = x + ((-1.0 / t) / (0.5 + ((1.0 / z) / y))) else: tmp = x - (math.expm1(z) * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -3.8e+19) || !(y <= 8.2e-22)) tmp = Float64(x + Float64(Float64(-1.0 / t) / Float64(0.5 + Float64(Float64(1.0 / z) / y)))); else tmp = Float64(x - Float64(expm1(z) * Float64(y / t))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -3.8e+19], N[Not[LessEqual[y, 8.2e-22]], $MachinePrecision]], N[(x + N[(N[(-1.0 / t), $MachinePrecision] / N[(0.5 + N[(N[(1.0 / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(Exp[z] - 1), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{+19} \lor \neg \left(y \leq 8.2 \cdot 10^{-22}\right):\\
\;\;\;\;x + \frac{\frac{-1}{t}}{0.5 + \frac{\frac{1}{z}}{y}}\\
\mathbf{else}:\\
\;\;\;\;x - \mathsf{expm1}\left(z\right) \cdot \frac{y}{t}\\
\end{array}
\end{array}
if y < -3.8e19 or 8.1999999999999999e-22 < y Initial program 29.1%
sub-neg29.1%
neg-mul-129.1%
*-commutative29.1%
cancel-sign-sub29.1%
*-commutative29.1%
mul-1-neg29.1%
remove-double-neg29.1%
Simplified99.8%
div-inv99.8%
*-commutative99.8%
Applied egg-rr99.8%
associate-/r/99.7%
div-inv99.7%
associate-/r*99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 58.7%
expm1-def75.3%
Simplified75.3%
Taylor expanded in z around 0 75.3%
*-commutative75.3%
associate-/r*75.3%
Simplified75.3%
if -3.8e19 < y < 8.1999999999999999e-22Initial program 84.3%
sub-neg84.3%
neg-mul-184.3%
*-commutative84.3%
cancel-sign-sub84.3%
*-commutative84.3%
mul-1-neg84.3%
remove-double-neg84.3%
Simplified98.4%
Taylor expanded in y around 0 92.3%
associate-/l*92.3%
associate-/r/92.3%
expm1-def99.4%
Simplified99.4%
Final simplification90.0%
(FPCore (x y z t) :precision binary64 (if (<= y -70000000.0) (+ x (/ (/ -1.0 t) (+ 0.5 (- (/ 1.0 (* y z)) (/ 0.5 y))))) (+ x (/ (/ -1.0 t) (/ (/ 1.0 y) (expm1 z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -70000000.0) {
tmp = x + ((-1.0 / t) / (0.5 + ((1.0 / (y * z)) - (0.5 / y))));
} else {
tmp = x + ((-1.0 / t) / ((1.0 / y) / expm1(z)));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -70000000.0) {
tmp = x + ((-1.0 / t) / (0.5 + ((1.0 / (y * z)) - (0.5 / y))));
} else {
tmp = x + ((-1.0 / t) / ((1.0 / y) / Math.expm1(z)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -70000000.0: tmp = x + ((-1.0 / t) / (0.5 + ((1.0 / (y * z)) - (0.5 / y)))) else: tmp = x + ((-1.0 / t) / ((1.0 / y) / math.expm1(z))) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -70000000.0) tmp = Float64(x + Float64(Float64(-1.0 / t) / Float64(0.5 + Float64(Float64(1.0 / Float64(y * z)) - Float64(0.5 / y))))); else tmp = Float64(x + Float64(Float64(-1.0 / t) / Float64(Float64(1.0 / y) / expm1(z)))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -70000000.0], N[(x + N[(N[(-1.0 / t), $MachinePrecision] / N[(0.5 + N[(N[(1.0 / N[(y * z), $MachinePrecision]), $MachinePrecision] - N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(-1.0 / t), $MachinePrecision] / N[(N[(1.0 / y), $MachinePrecision] / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -70000000:\\
\;\;\;\;x + \frac{\frac{-1}{t}}{0.5 + \left(\frac{1}{y \cdot z} - \frac{0.5}{y}\right)}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\frac{-1}{t}}{\frac{\frac{1}{y}}{\mathsf{expm1}\left(z\right)}}\\
\end{array}
\end{array}
if y < -7e7Initial program 37.5%
sub-neg37.5%
neg-mul-137.5%
*-commutative37.5%
cancel-sign-sub37.5%
*-commutative37.5%
mul-1-neg37.5%
remove-double-neg37.5%
Simplified99.9%
div-inv99.8%
*-commutative99.8%
Applied egg-rr99.8%
associate-/r/99.7%
div-inv99.7%
associate-/r*99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 63.4%
expm1-def72.1%
Simplified72.1%
Taylor expanded in z around 0 72.1%
associate-*r/72.1%
metadata-eval72.1%
Simplified72.1%
if -7e7 < y Initial program 71.2%
sub-neg71.2%
neg-mul-171.2%
*-commutative71.2%
cancel-sign-sub71.2%
*-commutative71.2%
mul-1-neg71.2%
remove-double-neg71.2%
Simplified98.6%
div-inv98.6%
*-commutative98.6%
Applied egg-rr98.6%
associate-/r/98.5%
div-inv98.4%
associate-/r*98.4%
Applied egg-rr98.4%
Taylor expanded in y around 0 84.4%
associate-/r*84.4%
expm1-def94.0%
Simplified94.0%
Final simplification88.6%
(FPCore (x y z t) :precision binary64 (+ x (/ (/ -1.0 t) (+ 0.5 (/ 1.0 (* y (expm1 z)))))))
double code(double x, double y, double z, double t) {
return x + ((-1.0 / t) / (0.5 + (1.0 / (y * expm1(z)))));
}
public static double code(double x, double y, double z, double t) {
return x + ((-1.0 / t) / (0.5 + (1.0 / (y * Math.expm1(z)))));
}
def code(x, y, z, t): return x + ((-1.0 / t) / (0.5 + (1.0 / (y * math.expm1(z)))))
function code(x, y, z, t) return Float64(x + Float64(Float64(-1.0 / t) / Float64(0.5 + Float64(1.0 / Float64(y * expm1(z)))))) end
code[x_, y_, z_, t_] := 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]
\begin{array}{l}
\\
x + \frac{\frac{-1}{t}}{0.5 + \frac{1}{y \cdot \mathsf{expm1}\left(z\right)}}
\end{array}
Initial program 62.9%
sub-neg62.9%
neg-mul-162.9%
*-commutative62.9%
cancel-sign-sub62.9%
*-commutative62.9%
mul-1-neg62.9%
remove-double-neg62.9%
Simplified98.9%
div-inv98.9%
*-commutative98.9%
Applied egg-rr98.9%
associate-/r/98.8%
div-inv98.7%
associate-/r*98.8%
Applied egg-rr98.8%
Taylor expanded in y around 0 79.3%
expm1-def89.3%
Simplified89.3%
Final simplification89.3%
(FPCore (x y z t) :precision binary64 (if (<= z -1.8e+62) x (+ x (/ (/ -1.0 t) (+ 0.5 (/ (/ 1.0 z) y))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.8e+62) {
tmp = x;
} else {
tmp = x + ((-1.0 / t) / (0.5 + ((1.0 / 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 (z <= (-1.8d+62)) then
tmp = x
else
tmp = x + (((-1.0d0) / t) / (0.5d0 + ((1.0d0 / z) / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.8e+62) {
tmp = x;
} else {
tmp = x + ((-1.0 / t) / (0.5 + ((1.0 / z) / y)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.8e+62: tmp = x else: tmp = x + ((-1.0 / t) / (0.5 + ((1.0 / z) / y))) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.8e+62) tmp = x; else tmp = Float64(x + Float64(Float64(-1.0 / t) / Float64(0.5 + Float64(Float64(1.0 / z) / y)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.8e+62) tmp = x; else tmp = x + ((-1.0 / t) / (0.5 + ((1.0 / z) / y))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.8e+62], x, N[(x + N[(N[(-1.0 / t), $MachinePrecision] / N[(0.5 + N[(N[(1.0 / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{+62}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\frac{-1}{t}}{0.5 + \frac{\frac{1}{z}}{y}}\\
\end{array}
\end{array}
if z < -1.8e62Initial program 83.2%
sub-neg83.2%
neg-mul-183.2%
*-commutative83.2%
cancel-sign-sub83.2%
*-commutative83.2%
mul-1-neg83.2%
remove-double-neg83.2%
Simplified99.9%
Taylor expanded in x around inf 70.2%
if -1.8e62 < z Initial program 56.9%
sub-neg56.9%
neg-mul-156.9%
*-commutative56.9%
cancel-sign-sub56.9%
*-commutative56.9%
mul-1-neg56.9%
remove-double-neg56.9%
Simplified98.6%
div-inv98.6%
*-commutative98.6%
Applied egg-rr98.6%
associate-/r/98.6%
div-inv98.4%
associate-/r*98.5%
Applied egg-rr98.5%
Taylor expanded in y around 0 76.6%
expm1-def89.7%
Simplified89.7%
Taylor expanded in z around 0 88.9%
*-commutative88.9%
associate-/r*88.9%
Simplified88.9%
Final simplification84.6%
(FPCore (x y z t) :precision binary64 (+ x (/ (/ -1.0 t) (+ 0.5 (- (/ 1.0 (* y z)) (/ 0.5 y))))))
double code(double x, double y, double z, double t) {
return x + ((-1.0 / t) / (0.5 + ((1.0 / (y * z)) - (0.5 / 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 = x + (((-1.0d0) / t) / (0.5d0 + ((1.0d0 / (y * z)) - (0.5d0 / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((-1.0 / t) / (0.5 + ((1.0 / (y * z)) - (0.5 / y))));
}
def code(x, y, z, t): return x + ((-1.0 / t) / (0.5 + ((1.0 / (y * z)) - (0.5 / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(-1.0 / t) / Float64(0.5 + Float64(Float64(1.0 / Float64(y * z)) - Float64(0.5 / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((-1.0 / t) / (0.5 + ((1.0 / (y * z)) - (0.5 / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(-1.0 / t), $MachinePrecision] / N[(0.5 + N[(N[(1.0 / N[(y * z), $MachinePrecision]), $MachinePrecision] - N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\frac{-1}{t}}{0.5 + \left(\frac{1}{y \cdot z} - \frac{0.5}{y}\right)}
\end{array}
Initial program 62.9%
sub-neg62.9%
neg-mul-162.9%
*-commutative62.9%
cancel-sign-sub62.9%
*-commutative62.9%
mul-1-neg62.9%
remove-double-neg62.9%
Simplified98.9%
div-inv98.9%
*-commutative98.9%
Applied egg-rr98.9%
associate-/r/98.8%
div-inv98.7%
associate-/r*98.8%
Applied egg-rr98.8%
Taylor expanded in y around 0 79.3%
expm1-def89.3%
Simplified89.3%
Taylor expanded in z around 0 85.6%
associate-*r/85.6%
metadata-eval85.6%
Simplified85.6%
Final simplification85.6%
(FPCore (x y z t) :precision binary64 (if (<= z -3200000.0) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3200000.0) {
tmp = x;
} else {
tmp = 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 (z <= (-3200000.0d0)) then
tmp = x
else
tmp = 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 (z <= -3200000.0) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3200000.0: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3200000.0) tmp = x; else tmp = Float64(x - Float64(y * Float64(z / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3200000.0) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3200000.0], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3200000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -3.2e6Initial program 84.5%
sub-neg84.5%
neg-mul-184.5%
*-commutative84.5%
cancel-sign-sub84.5%
*-commutative84.5%
mul-1-neg84.5%
remove-double-neg84.5%
Simplified99.9%
Taylor expanded in x around inf 72.1%
if -3.2e6 < z Initial program 54.8%
sub-neg54.8%
neg-mul-154.8%
*-commutative54.8%
cancel-sign-sub54.8%
*-commutative54.8%
mul-1-neg54.8%
remove-double-neg54.8%
Simplified98.6%
div-inv98.5%
*-commutative98.5%
Applied egg-rr98.5%
associate-/r/98.5%
div-inv98.3%
associate-/r*98.4%
Applied egg-rr98.4%
Taylor expanded in y around 0 75.7%
expm1-def89.5%
Simplified89.5%
Taylor expanded in z around 0 87.4%
associate-*r/88.7%
Simplified88.7%
Final simplification84.2%
(FPCore (x y z t) :precision binary64 (if (<= z -900000.0) x (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -900000.0) {
tmp = x;
} 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 <= (-900000.0d0)) then
tmp = x
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 <= -900000.0) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -900000.0: tmp = x else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -900000.0) tmp = x; 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 <= -900000.0) tmp = x; else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -900000.0], x, N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -900000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -9e5Initial program 84.5%
sub-neg84.5%
neg-mul-184.5%
*-commutative84.5%
cancel-sign-sub84.5%
*-commutative84.5%
mul-1-neg84.5%
remove-double-neg84.5%
Simplified99.9%
Taylor expanded in x around inf 72.1%
if -9e5 < z Initial program 54.8%
sub-neg54.8%
neg-mul-154.8%
*-commutative54.8%
cancel-sign-sub54.8%
*-commutative54.8%
mul-1-neg54.8%
remove-double-neg54.8%
Simplified98.6%
Taylor expanded in z around 0 87.4%
associate-/l*88.8%
Simplified88.8%
Final simplification84.2%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return 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 = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 62.9%
sub-neg62.9%
neg-mul-162.9%
*-commutative62.9%
cancel-sign-sub62.9%
*-commutative62.9%
mul-1-neg62.9%
remove-double-neg62.9%
Simplified98.9%
Taylor expanded in x around inf 74.3%
Final simplification74.3%
(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 2023336
(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)))