Average Error: 24.8 → 0.5
Time: 20.6s
Precision: binary64
Cost: 13513
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{-155} \lor \neg \left(y \leq 9.6 \cdot 10^{-53}\right):\\ \;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\ \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
(FPCore (x y z t)
 :precision binary64
 (if (or (<= y -5e-155) (not (<= y 9.6e-53)))
   (- x (/ (log1p (* y (expm1 z))) t))
   (- x (* 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) {
	double tmp;
	if ((y <= -5e-155) || !(y <= 9.6e-53)) {
		tmp = x - (log1p((y * expm1(z))) / t);
	} else {
		tmp = x - (y * (expm1(z) / t));
	}
	return tmp;
}
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) {
	double tmp;
	if ((y <= -5e-155) || !(y <= 9.6e-53)) {
		tmp = x - (Math.log1p((y * Math.expm1(z))) / t);
	} else {
		tmp = x - (y * (Math.expm1(z) / t));
	}
	return tmp;
}
def code(x, y, z, t):
	return x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
def code(x, y, z, t):
	tmp = 0
	if (y <= -5e-155) or not (y <= 9.6e-53):
		tmp = x - (math.log1p((y * math.expm1(z))) / t)
	else:
		tmp = x - (y * (math.expm1(z) / t))
	return tmp
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)
	tmp = 0.0
	if ((y <= -5e-155) || !(y <= 9.6e-53))
		tmp = Float64(x - Float64(log1p(Float64(y * expm1(z))) / t));
	else
		tmp = Float64(x - Float64(y * Float64(expm1(z) / t)));
	end
	return tmp
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_] := If[Or[LessEqual[y, -5e-155], N[Not[LessEqual[y, 9.6e-53]], $MachinePrecision]], N[(x - N[(N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-155} \lor \neg \left(y \leq 9.6 \cdot 10^{-53}\right):\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\

\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original24.8
Target16.0
Herbie0.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. Split input into 2 regimes
  2. if y < -4.9999999999999999e-155 or 9.6000000000000003e-53 < y

    1. Initial program 35.5

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

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

      [Start]35.5

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

      *-lft-identity [<=]35.5

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

      distribute-lft-out-- [<=]35.5

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

      *-lft-identity [=>]35.5

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

      *-commutative [<=]35.5

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

      *-rgt-identity [=>]35.5

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

    if -4.9999999999999999e-155 < y < 9.6000000000000003e-53

    1. Initial program 8.7

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

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

      [Start]8.7

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

      *-lft-identity [<=]8.7

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

      distribute-lft-out-- [<=]8.7

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

      *-lft-identity [=>]8.7

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

      *-commutative [<=]8.7

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

      *-rgt-identity [=>]8.7

      \[ x - \color{blue}{\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}} \]
    3. Taylor expanded in y around 0 3.9

      \[\leadsto x - \color{blue}{\frac{\left(e^{z} - 1\right) \cdot y}{t}} \]
    4. Simplified0.3

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

      [Start]3.9

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

      associate-*l/ [<=]4.0

      \[ x - \color{blue}{\frac{e^{z} - 1}{t} \cdot y} \]

      expm1-def [=>]0.3

      \[ x - \frac{\color{blue}{\mathsf{expm1}\left(z\right)}}{t} \cdot y \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{-155} \lor \neg \left(y \leq 9.6 \cdot 10^{-53}\right):\\ \;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\ \end{array} \]

Alternatives

Alternative 1
Error4.2
Cost7364
\[\begin{array}{l} \mathbf{if}\;z \leq -8.6 \cdot 10^{+28}:\\ \;\;\;\;x + \frac{-1}{t \cdot \left(0.5 + \frac{1}{y \cdot \mathsf{expm1}\left(z\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\ \end{array} \]
Alternative 2
Error4.2
Cost7364
\[\begin{array}{l} \mathbf{if}\;z \leq -8.6 \cdot 10^{+28}:\\ \;\;\;\;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 3
Error5.1
Cost7113
\[\begin{array}{l} \mathbf{if}\;y \leq -2.9 \cdot 10^{+66} \lor \neg \left(y \leq 400000\right):\\ \;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\ \end{array} \]
Alternative 4
Error7.2
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq -380000000000:\\ \;\;\;\;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 5
Error9.5
Cost1220
\[\begin{array}{l} t_1 := \frac{\frac{t}{z}}{y}\\ \mathbf{if}\;z \leq -8.6 \cdot 10^{+28}:\\ \;\;\;\;x + \frac{-1}{t_1 + 0.5 \cdot \left(t - \frac{t}{y}\right)}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{-1}{t \cdot 0.5 + t_1}\\ \end{array} \]
Alternative 6
Error19.0
Cost913
\[\begin{array}{l} \mathbf{if}\;t \leq -2.4 \cdot 10^{-160}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -1.05 \cdot 10^{-211} \lor \neg \left(t \leq -4 \cdot 10^{-252}\right) \land t \leq 1.8 \cdot 10^{-271}:\\ \;\;\;\;y \cdot \frac{-z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error19.1
Cost913
\[\begin{array}{l} \mathbf{if}\;t \leq -8 \cdot 10^{-159}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -1.15 \cdot 10^{-211} \lor \neg \left(t \leq -2.1 \cdot 10^{-257}\right) \land t \leq 10^{-271}:\\ \;\;\;\;\frac{-y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error11.7
Cost832
\[x + \frac{-1}{t \cdot 0.5 + \frac{\frac{t}{z}}{y}} \]
Alternative 9
Error18.9
Cost648
\[\begin{array}{l} \mathbf{if}\;t \leq -2.35 \cdot 10^{-160}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -1.2 \cdot 10^{-211}:\\ \;\;\;\;z \cdot \frac{-y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error14.0
Cost580
\[\begin{array}{l} \mathbf{if}\;z \leq -1.32 \cdot 10^{+40}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot \frac{y}{t}\\ \end{array} \]
Alternative 11
Error11.7
Cost580
\[\begin{array}{l} \mathbf{if}\;z \leq -6.7 \cdot 10^{+39}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 12
Error11.7
Cost580
\[\begin{array}{l} \mathbf{if}\;z \leq -1.3 \cdot 10^{+40}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{z}}\\ \end{array} \]
Alternative 13
Error18.2
Cost64
\[x \]

Error

Reproduce

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