Average Error: 24.9 → 0.9
Time: 29.4s
Precision: binary64
Cost: 13248
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
\[x - \frac{\mathsf{log1p}\left(\mathsf{expm1}\left(z\right) \cdot y\right)}{t} \]
(FPCore (x y z t)
 :precision binary64
 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
(FPCore (x y z t) :precision binary64 (- x (/ (log1p (* (expm1 z) y)) t)))
double code(double x, double y, double z, double t) {
	return x - (log(((1.0 - y) + (y * exp(z)))) / t);
}
double code(double x, double y, double z, double t) {
	return x - (log1p((expm1(z) * y)) / t);
}
public static double code(double x, double y, double z, double t) {
	return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
public static double code(double x, double y, double z, double t) {
	return x - (Math.log1p((Math.expm1(z) * y)) / t);
}
def code(x, y, z, t):
	return x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
def code(x, y, z, t):
	return x - (math.log1p((math.expm1(z) * y)) / t)
function code(x, y, z, t)
	return Float64(x - Float64(log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) / t))
end
function code(x, y, z, t)
	return Float64(x - Float64(log1p(Float64(expm1(z) * y)) / 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]
code[x_, y_, z_, t_] := N[(x - N[(N[Log[1 + N[(N[(Exp[z] - 1), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
x - \frac{\mathsf{log1p}\left(\mathsf{expm1}\left(z\right) \cdot y\right)}{t}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original24.9
Target15.9
Herbie0.9
\[\begin{array}{l} \mathbf{if}\;z < -2.8874623088207947 \cdot 10^{+119}:\\ \;\;\;\;\left(x - \frac{\frac{-0.5}{y \cdot t}}{z \cdot z}\right) - \frac{-0.5}{y \cdot t} \cdot \frac{\frac{2}{z}}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + z \cdot y\right)}{t}\\ \end{array} \]

Derivation

  1. Initial program 24.9

    \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
  2. Simplified10.9

    \[\leadsto \color{blue}{x - \frac{\mathsf{log1p}\left(\mathsf{fma}\left(e^{z}, y, -y\right)\right)}{t}} \]
    Proof
  3. Applied egg-rr0.9

    \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(z\right) \cdot y}\right)}{t} \]

Alternatives

Alternative 1
Error7.8
Cost6980
\[\begin{array}{l} \mathbf{if}\;z \leq -2.85 \cdot 10^{+57}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\ \end{array} \]
Alternative 2
Error18.9
Cost6916
\[\begin{array}{l} \mathbf{if}\;y \leq 3.05 \cdot 10^{+81}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(y \cdot z\right)}{-t}\\ \end{array} \]
Alternative 3
Error17.9
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2023010 
(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)))