
(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 60.3%
associate-+l-75.2%
sub-neg75.2%
log1p-def79.8%
neg-sub079.8%
associate-+l-79.8%
neg-sub079.8%
neg-mul-179.8%
*-commutative79.8%
distribute-rgt-out79.8%
+-commutative79.8%
metadata-eval79.8%
sub-neg79.8%
expm1-def98.2%
Simplified98.2%
Final simplification98.2%
(FPCore (x y z t) :precision binary64 (if (<= z -470.0) (+ x (/ -1.0 (+ (/ t (* y (expm1 z))) (* t 0.5)))) (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -470.0) {
tmp = x + (-1.0 / ((t / (y * expm1(z))) + (t * 0.5)));
} 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 <= -470.0) {
tmp = x + (-1.0 / ((t / (y * Math.expm1(z))) + (t * 0.5)));
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -470.0: tmp = x + (-1.0 / ((t / (y * math.expm1(z))) + (t * 0.5))) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -470.0) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t / Float64(y * expm1(z))) + Float64(t * 0.5)))); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -470.0], N[(x + N[(-1.0 / N[(N[(t / N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t * 0.5), $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 -470:\\
\;\;\;\;x + \frac{-1}{\frac{t}{y \cdot \mathsf{expm1}\left(z\right)} + t \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if z < -470Initial program 82.8%
associate-+l-82.8%
sub-neg82.8%
log1p-def99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
neg-mul-199.9%
*-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
metadata-eval99.9%
sub-neg99.9%
expm1-def99.9%
Simplified99.9%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 82.7%
expm1-def82.7%
*-commutative82.7%
Simplified82.7%
if -470 < z Initial program 52.9%
associate-+l-72.8%
sub-neg72.8%
log1p-def73.2%
neg-sub073.2%
associate-+l-73.2%
neg-sub073.2%
neg-mul-173.2%
*-commutative73.2%
distribute-rgt-out73.2%
+-commutative73.2%
metadata-eval73.2%
sub-neg73.2%
expm1-def97.7%
Simplified97.7%
Taylor expanded in z around 0 97.1%
*-commutative97.1%
Simplified97.1%
Final simplification93.5%
(FPCore (x y z t) :precision binary64 (if (<= y -6.5e+104) x (- x (* y (/ (expm1 z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -6.5e+104) {
tmp = x;
} else {
tmp = x - (y * (expm1(z) / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -6.5e+104) {
tmp = x;
} else {
tmp = x - (y * (Math.expm1(z) / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -6.5e+104: tmp = x else: tmp = x - (y * (math.expm1(z) / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -6.5e+104) tmp = x; else tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -6.5e+104], x, N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+104}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\end{array}
if y < -6.5000000000000005e104Initial program 42.7%
associate-+l-67.8%
sub-neg67.8%
log1p-def67.8%
neg-sub067.8%
associate-+l-67.8%
neg-sub067.8%
neg-mul-167.8%
*-commutative67.8%
distribute-rgt-out67.7%
+-commutative67.7%
metadata-eval67.7%
sub-neg67.7%
expm1-def99.7%
Simplified99.7%
Taylor expanded in x around inf 46.7%
if -6.5000000000000005e104 < y Initial program 63.0%
associate-+l-76.4%
sub-neg76.4%
log1p-def81.7%
neg-sub081.7%
associate-+l-81.7%
neg-sub081.7%
neg-mul-181.7%
*-commutative81.7%
distribute-rgt-out81.7%
+-commutative81.7%
metadata-eval81.7%
sub-neg81.7%
expm1-def98.0%
Simplified98.0%
Taylor expanded in y around 0 79.3%
associate-/l*78.7%
associate-/r/79.3%
expm1-def93.9%
Simplified93.9%
Final simplification87.4%
(FPCore (x y z t) :precision binary64 (if (<= z -2.2e+15) (- x (* y (/ (expm1 z) t))) (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.2e+15) {
tmp = x - (y * (expm1(z) / 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.2e+15) {
tmp = x - (y * (Math.expm1(z) / t));
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.2e+15: tmp = x - (y * (math.expm1(z) / t)) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.2e+15) tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.2e+15], N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / 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.2 \cdot 10^{+15}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if z < -2.2e15Initial program 83.2%
associate-+l-83.2%
sub-neg83.2%
log1p-def99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
neg-mul-199.9%
*-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
metadata-eval99.9%
sub-neg99.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in y around 0 71.2%
associate-/l*71.2%
associate-/r/71.2%
expm1-def71.2%
Simplified71.2%
if -2.2e15 < z Initial program 53.4%
associate-+l-72.8%
sub-neg72.8%
log1p-def73.8%
neg-sub073.8%
associate-+l-73.8%
neg-sub073.8%
neg-mul-173.8%
*-commutative73.8%
distribute-rgt-out73.8%
+-commutative73.8%
metadata-eval73.8%
sub-neg73.8%
expm1-def97.7%
Simplified97.7%
Taylor expanded in z around 0 96.3%
*-commutative96.3%
Simplified96.3%
Final simplification90.5%
(FPCore (x y z t) :precision binary64 (if (<= x -2.3e-236) x (if (<= x 1.35e-304) (/ (- y) (/ t z)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.3e-236) {
tmp = x;
} else if (x <= 1.35e-304) {
tmp = -y / (t / z);
} else {
tmp = 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 (x <= (-2.3d-236)) then
tmp = x
else if (x <= 1.35d-304) then
tmp = -y / (t / z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.3e-236) {
tmp = x;
} else if (x <= 1.35e-304) {
tmp = -y / (t / z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -2.3e-236: tmp = x elif x <= 1.35e-304: tmp = -y / (t / z) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -2.3e-236) tmp = x; elseif (x <= 1.35e-304) tmp = Float64(Float64(-y) / Float64(t / z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -2.3e-236) tmp = x; elseif (x <= 1.35e-304) tmp = -y / (t / z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -2.3e-236], x, If[LessEqual[x, 1.35e-304], N[((-y) / N[(t / z), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3 \cdot 10^{-236}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-304}:\\
\;\;\;\;\frac{-y}{\frac{t}{z}}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.30000000000000006e-236 or 1.35000000000000005e-304 < x Initial program 64.6%
associate-+l-81.1%
sub-neg81.1%
log1p-def84.2%
neg-sub084.2%
associate-+l-84.2%
neg-sub084.2%
neg-mul-184.2%
*-commutative84.2%
distribute-rgt-out84.2%
+-commutative84.2%
metadata-eval84.2%
sub-neg84.2%
expm1-def98.7%
Simplified98.7%
Taylor expanded in x around inf 75.9%
if -2.30000000000000006e-236 < x < 1.35000000000000005e-304Initial program 19.8%
associate-+l-20.5%
sub-neg20.5%
log1p-def38.7%
neg-sub038.7%
associate-+l-38.7%
neg-sub038.7%
neg-mul-138.7%
*-commutative38.7%
distribute-rgt-out38.7%
+-commutative38.7%
metadata-eval38.7%
sub-neg38.7%
expm1-def93.8%
Simplified93.8%
Taylor expanded in x around 0 9.2%
associate-*r/9.2%
log1p-def27.5%
*-commutative27.5%
expm1-def82.8%
neg-mul-182.8%
expm1-def27.5%
*-commutative27.5%
expm1-def82.8%
Simplified82.8%
Taylor expanded in z around 0 52.6%
mul-1-neg52.6%
associate-*r/54.6%
distribute-rgt-neg-in54.6%
Simplified54.6%
distribute-rgt-neg-out54.6%
add-sqr-sqrt37.4%
sqrt-unprod23.0%
clear-num23.0%
clear-num23.0%
frac-times23.0%
sqr-neg23.0%
distribute-frac-neg23.0%
distribute-frac-neg23.0%
frac-times23.0%
sqrt-unprod1.3%
add-sqr-sqrt2.8%
add-sqr-sqrt1.4%
sqrt-unprod18.9%
sqr-neg18.9%
sqrt-unprod17.4%
add-sqr-sqrt54.6%
un-div-inv54.6%
Applied egg-rr54.6%
Final simplification73.8%
(FPCore (x y z t) :precision binary64 (if (<= x -2.5e-236) x (if (<= x 1.16e-305) (* z (/ (- y) t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.5e-236) {
tmp = x;
} else if (x <= 1.16e-305) {
tmp = z * (-y / t);
} else {
tmp = 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 (x <= (-2.5d-236)) then
tmp = x
else if (x <= 1.16d-305) then
tmp = z * (-y / t)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.5e-236) {
tmp = x;
} else if (x <= 1.16e-305) {
tmp = z * (-y / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -2.5e-236: tmp = x elif x <= 1.16e-305: tmp = z * (-y / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -2.5e-236) tmp = x; elseif (x <= 1.16e-305) tmp = Float64(z * Float64(Float64(-y) / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -2.5e-236) tmp = x; elseif (x <= 1.16e-305) tmp = z * (-y / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -2.5e-236], x, If[LessEqual[x, 1.16e-305], N[(z * N[((-y) / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.5 \cdot 10^{-236}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.16 \cdot 10^{-305}:\\
\;\;\;\;z \cdot \frac{-y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.4999999999999999e-236 or 1.16e-305 < x Initial program 64.6%
associate-+l-81.1%
sub-neg81.1%
log1p-def84.2%
neg-sub084.2%
associate-+l-84.2%
neg-sub084.2%
neg-mul-184.2%
*-commutative84.2%
distribute-rgt-out84.2%
+-commutative84.2%
metadata-eval84.2%
sub-neg84.2%
expm1-def98.7%
Simplified98.7%
Taylor expanded in x around inf 75.9%
if -2.4999999999999999e-236 < x < 1.16e-305Initial program 19.8%
associate-+l-20.5%
sub-neg20.5%
log1p-def38.7%
neg-sub038.7%
associate-+l-38.7%
neg-sub038.7%
neg-mul-138.7%
*-commutative38.7%
distribute-rgt-out38.7%
+-commutative38.7%
metadata-eval38.7%
sub-neg38.7%
expm1-def93.8%
Simplified93.8%
Taylor expanded in x around 0 9.2%
associate-*r/9.2%
log1p-def27.5%
*-commutative27.5%
expm1-def82.8%
neg-mul-182.8%
expm1-def27.5%
*-commutative27.5%
expm1-def82.8%
Simplified82.8%
Taylor expanded in z around 0 52.6%
mul-1-neg52.6%
associate-*r/54.6%
distribute-rgt-neg-in54.6%
Simplified54.6%
Taylor expanded in y around 0 52.6%
mul-1-neg52.6%
associate-*l/58.4%
distribute-rgt-neg-in58.4%
Simplified58.4%
Final simplification74.2%
(FPCore (x y z t) :precision binary64 (if (<= z -26000000.0) x (- x (* z (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -26000000.0) {
tmp = x;
} else {
tmp = x - (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) :: tmp
if (z <= (-26000000.0d0)) then
tmp = x
else
tmp = x - (z * (y / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -26000000.0) {
tmp = x;
} else {
tmp = x - (z * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -26000000.0: tmp = x else: tmp = x - (z * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -26000000.0) tmp = x; else tmp = Float64(x - Float64(z * Float64(y / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -26000000.0) tmp = x; else tmp = x - (z * (y / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -26000000.0], x, N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -26000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t}\\
\end{array}
\end{array}
if z < -2.6e7Initial program 83.7%
associate-+l-83.7%
sub-neg83.7%
log1p-def99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
neg-mul-199.9%
*-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
metadata-eval99.9%
sub-neg99.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 64.8%
if -2.6e7 < z Initial program 52.9%
associate-+l-72.6%
sub-neg72.6%
log1p-def73.5%
neg-sub073.5%
associate-+l-73.5%
neg-sub073.5%
neg-mul-173.5%
*-commutative73.5%
distribute-rgt-out73.5%
+-commutative73.5%
metadata-eval73.5%
sub-neg73.5%
expm1-def97.7%
Simplified97.7%
Taylor expanded in z around 0 87.1%
associate-/l*89.2%
Simplified89.2%
associate-/r/85.4%
Applied egg-rr85.4%
Final simplification80.5%
(FPCore (x y z t) :precision binary64 (if (<= z -38000000.0) x (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -38000000.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 <= (-38000000.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 <= -38000000.0) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -38000000.0: tmp = x else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -38000000.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 <= -38000000.0) tmp = x; else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -38000000.0], x, N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -38000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -3.8e7Initial program 83.7%
associate-+l-83.7%
sub-neg83.7%
log1p-def99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
neg-mul-199.9%
*-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
metadata-eval99.9%
sub-neg99.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 64.8%
if -3.8e7 < z Initial program 52.9%
associate-+l-72.6%
sub-neg72.6%
log1p-def73.5%
neg-sub073.5%
associate-+l-73.5%
neg-sub073.5%
neg-mul-173.5%
*-commutative73.5%
distribute-rgt-out73.5%
+-commutative73.5%
metadata-eval73.5%
sub-neg73.5%
expm1-def97.7%
Simplified97.7%
Taylor expanded in z around 0 87.1%
associate-/l*89.2%
Simplified89.2%
Final simplification83.3%
(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 60.3%
associate-+l-75.2%
sub-neg75.2%
log1p-def79.8%
neg-sub079.8%
associate-+l-79.8%
neg-sub079.8%
neg-mul-179.8%
*-commutative79.8%
distribute-rgt-out79.8%
+-commutative79.8%
metadata-eval79.8%
sub-neg79.8%
expm1-def98.2%
Simplified98.2%
Taylor expanded in x around inf 70.0%
Final simplification70.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 2023185
(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)))