?

Average Accuracy: 61.4% → 98.5%
Time: 21.7s
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

Original61.4%
Target75.8%
Herbie98.5%
\[\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 61.4%

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

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

    [Start]61.4

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

    associate-+l- [=>]77.6

    \[ x - \frac{\log \color{blue}{\left(1 - \left(y - y \cdot e^{z}\right)\right)}}{t} \]

    sub-neg [=>]77.6

    \[ x - \frac{\log \color{blue}{\left(1 + \left(-\left(y - y \cdot e^{z}\right)\right)\right)}}{t} \]

    log1p-def [=>]83.4

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

    neg-sub0 [=>]83.4

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

    associate-+l- [<=]83.4

    \[ x - \frac{\mathsf{log1p}\left(\color{blue}{\left(0 - y\right) + y \cdot e^{z}}\right)}{t} \]

    neg-sub0 [<=]83.4

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

    neg-mul-1 [=>]83.4

    \[ x - \frac{\mathsf{log1p}\left(\color{blue}{-1 \cdot y} + y \cdot e^{z}\right)}{t} \]

    *-commutative [=>]83.4

    \[ x - \frac{\mathsf{log1p}\left(-1 \cdot y + \color{blue}{e^{z} \cdot y}\right)}{t} \]

    distribute-rgt-out [=>]83.4

    \[ x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(-1 + e^{z}\right)}\right)}{t} \]

    +-commutative [=>]83.4

    \[ x - \frac{\mathsf{log1p}\left(y \cdot \color{blue}{\left(e^{z} + -1\right)}\right)}{t} \]

    metadata-eval [<=]83.4

    \[ x - \frac{\mathsf{log1p}\left(y \cdot \left(e^{z} + \color{blue}{\left(-1\right)}\right)\right)}{t} \]

    sub-neg [<=]83.4

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

    expm1-def [=>]98.5

    \[ x - \frac{\mathsf{log1p}\left(y \cdot \color{blue}{\mathsf{expm1}\left(z\right)}\right)}{t} \]
  3. Final simplification98.5%

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

Alternatives

Alternative 1
Accuracy94.0%
Cost13764
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 0.999999999999999:\\ \;\;\;\;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} \]
Alternative 2
Accuracy92.9%
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq -1.65:\\ \;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{\frac{t}{z}}{y}}\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+30}:\\ \;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\ \end{array} \]
Alternative 3
Accuracy89.1%
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq -14.5:\\ \;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{\frac{t}{z}}{y}}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\ \end{array} \]
Alternative 4
Accuracy89.2%
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq -1.65:\\ \;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{\frac{t}{z}}{y}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\ \end{array} \]
Alternative 5
Accuracy85.5%
Cost1348
\[\begin{array}{l} \mathbf{if}\;z \leq -3.2 \cdot 10^{-16}:\\ \;\;\;\;x + \frac{-1}{\left(t \cdot 0.5 + \frac{t}{y \cdot z}\right) - 0.5 \cdot \frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{\frac{t}{z}}{y}}\\ \end{array} \]
Alternative 6
Accuracy84.4%
Cost964
\[\begin{array}{l} \mathbf{if}\;y \leq -2:\\ \;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{\frac{t}{z}}{y}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{z} + t \cdot -0.5}\\ \end{array} \]
Alternative 7
Accuracy70.1%
Cost913
\[\begin{array}{l} \mathbf{if}\;t \leq -1.7 \cdot 10^{-140}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -1.2 \cdot 10^{-225} \lor \neg \left(t \leq -4.4 \cdot 10^{-290}\right) \land t \leq 2 \cdot 10^{-286}:\\ \;\;\;\;\frac{y \cdot z}{-t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Accuracy82.4%
Cost836
\[\begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{+143}:\\ \;\;\;\;x - \frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{z} + t \cdot -0.5}\\ \end{array} \]
Alternative 9
Accuracy71.7%
Cost648
\[\begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{-184}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.7 \cdot 10^{-281}:\\ \;\;\;\;\frac{z}{t} \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Accuracy71.6%
Cost648
\[\begin{array}{l} \mathbf{if}\;x \leq -3.7 \cdot 10^{-188}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{-280}:\\ \;\;\;\;-\frac{y}{t} \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Accuracy81.7%
Cost580
\[\begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{+34}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 12
Accuracy72.3%
Cost64
\[x \]

Error

Reproduce?

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