Average Error: 25.2 → 0.9
Time: 22.8s
Precision: binary64
Cost: 13248
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
\[x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\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 (* y (expm1 z))) 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((y * expm1(z))) / 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((y * Math.expm1(z))) / 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((y * math.expm1(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 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[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[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original25.2
Target16.5
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 25.2

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

    \[\leadsto \color{blue}{x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}} \]
    Proof
    (-.f64 x (/.f64 (log1p.f64 (*.f64 y (expm1.f64 z))) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 x (/.f64 (log1p.f64 (*.f64 y (Rewrite<= expm1-def_binary64 (-.f64 (exp.f64 z) 1)))) t)): 38 points increase in error, 0 points decrease in error
    (-.f64 x (/.f64 (log1p.f64 (*.f64 y (Rewrite=> sub-neg_binary64 (+.f64 (exp.f64 z) (neg.f64 1))))) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 x (/.f64 (log1p.f64 (*.f64 y (+.f64 (exp.f64 z) (Rewrite=> metadata-eval -1)))) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 x (/.f64 (log1p.f64 (*.f64 y (Rewrite<= +-commutative_binary64 (+.f64 -1 (exp.f64 z))))) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 x (/.f64 (log1p.f64 (Rewrite<= distribute-lft-out_binary64 (+.f64 (*.f64 y -1) (*.f64 y (exp.f64 z))))) t)): 1 points increase in error, 0 points decrease in error
    (-.f64 x (/.f64 (log1p.f64 (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 -1 y)) (*.f64 y (exp.f64 z)))) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 x (/.f64 (log1p.f64 (+.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 y)) (*.f64 y (exp.f64 z)))) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 x (/.f64 (log1p.f64 (+.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 y)) (*.f64 y (exp.f64 z)))) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 x (/.f64 (log1p.f64 (Rewrite=> associate-+l-_binary64 (-.f64 0 (-.f64 y (*.f64 y (exp.f64 z)))))) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 x (/.f64 (log1p.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 (-.f64 y (*.f64 y (exp.f64 z)))))) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 x (/.f64 (Rewrite<= log1p-def_binary64 (log.f64 (+.f64 1 (neg.f64 (-.f64 y (*.f64 y (exp.f64 z))))))) t)): 18 points increase in error, 0 points decrease in error
    (-.f64 x (/.f64 (log.f64 (Rewrite<= sub-neg_binary64 (-.f64 1 (-.f64 y (*.f64 y (exp.f64 z)))))) t)): 0 points increase in error, 0 points decrease in error
    (-.f64 x (/.f64 (log.f64 (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z))))) t)): 83 points increase in error, 0 points decrease in error
  3. Final simplification0.9

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

Alternatives

Alternative 1
Error3.9
Cost13892
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 10^{-10}:\\ \;\;\;\;x - \frac{1}{\frac{t}{y \cdot \left(e^{z} + -1\right)} + t \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + y \cdot \left(z \cdot 0.5\right)\right)\right)}{t}\\ \end{array} \]
Alternative 2
Error5.1
Cost7496
\[\begin{array}{l} \mathbf{if}\;y \leq -43081170.212476544:\\ \;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\ \mathbf{elif}\;y \leq 4.064265715160281 \cdot 10^{-12}:\\ \;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + y \cdot \left(z \cdot 0.5\right)\right)\right)}{t}\\ \end{array} \]
Alternative 3
Error5.8
Cost7112
\[\begin{array}{l} t_1 := x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\ \mathbf{if}\;y \leq -43081170.212476544:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.36794657830425 \cdot 10^{-7}:\\ \;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error5.2
Cost7112
\[\begin{array}{l} t_1 := x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\ \mathbf{if}\;y \leq -43081170.212476544:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.36794657830425 \cdot 10^{-7}:\\ \;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error7.8
Cost6980
\[\begin{array}{l} \mathbf{if}\;z \leq -1.45 \cdot 10^{+16}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\ \end{array} \]
Alternative 6
Error18.8
Cost648
\[\begin{array}{l} \mathbf{if}\;x \leq -5.444136328967944 \cdot 10^{-212}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.73443205492674 \cdot 10^{-279}:\\ \;\;\;\;\frac{y \cdot \left(-z\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error18.4
Cost648
\[\begin{array}{l} \mathbf{if}\;t \leq -9.810798911517797 \cdot 10^{-284}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 4.3857165798153556 \cdot 10^{-247}:\\ \;\;\;\;y \cdot \frac{-z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error11.6
Cost580
\[\begin{array}{l} \mathbf{if}\;z \leq -2.5 \cdot 10^{+16}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 9
Error12.0
Cost580
\[\begin{array}{l} \mathbf{if}\;z \leq -2.5 \cdot 10^{+16}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot z}{t}\\ \end{array} \]
Alternative 10
Error18.6
Cost64
\[x \]

Error

Reproduce

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