?

Average Error: 25.3 → 8.2
Time: 36.6s
Precision: binary64
Cost: 14224

?

\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
\[\begin{array}{l} t_1 := x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\\ \mathbf{if}\;z \leq -1.75 \cdot 10^{+36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -380000000000:\\ \;\;\;\;x - \frac{\left(e^{z} - 1\right) \cdot y}{t}\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{-81}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + 0.5 \cdot {z}^{2}\right)\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
 (let* ((t_1 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t))))
   (if (<= z -1.75e+36)
     t_1
     (if (<= z -380000000000.0)
       (- x (/ (* (- (exp z) 1.0) y) t))
       (if (<= z -5e-5)
         t_1
         (if (<= z 1.95e-81)
           (- x (* y (/ z t)))
           (- x (/ (log (+ 1.0 (* y (+ z (* 0.5 (pow z 2.0)))))) 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 t_1 = x - (log(((1.0 - y) + (y * exp(z)))) / t);
	double tmp;
	if (z <= -1.75e+36) {
		tmp = t_1;
	} else if (z <= -380000000000.0) {
		tmp = x - (((exp(z) - 1.0) * y) / t);
	} else if (z <= -5e-5) {
		tmp = t_1;
	} else if (z <= 1.95e-81) {
		tmp = x - (y * (z / t));
	} else {
		tmp = x - (log((1.0 + (y * (z + (0.5 * pow(z, 2.0)))))) / 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
    code = x - (log(((1.0d0 - y) + (y * exp(z)))) / t)
end function
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 = x - (log(((1.0d0 - y) + (y * exp(z)))) / t)
    if (z <= (-1.75d+36)) then
        tmp = t_1
    else if (z <= (-380000000000.0d0)) then
        tmp = x - (((exp(z) - 1.0d0) * y) / t)
    else if (z <= (-5d-5)) then
        tmp = t_1
    else if (z <= 1.95d-81) then
        tmp = x - (y * (z / t))
    else
        tmp = x - (log((1.0d0 + (y * (z + (0.5d0 * (z ** 2.0d0)))))) / t)
    end if
    code = tmp
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);
}
public static double code(double x, double y, double z, double t) {
	double t_1 = x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
	double tmp;
	if (z <= -1.75e+36) {
		tmp = t_1;
	} else if (z <= -380000000000.0) {
		tmp = x - (((Math.exp(z) - 1.0) * y) / t);
	} else if (z <= -5e-5) {
		tmp = t_1;
	} else if (z <= 1.95e-81) {
		tmp = x - (y * (z / t));
	} else {
		tmp = x - (Math.log((1.0 + (y * (z + (0.5 * Math.pow(z, 2.0)))))) / 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):
	t_1 = x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
	tmp = 0
	if z <= -1.75e+36:
		tmp = t_1
	elif z <= -380000000000.0:
		tmp = x - (((math.exp(z) - 1.0) * y) / t)
	elif z <= -5e-5:
		tmp = t_1
	elif z <= 1.95e-81:
		tmp = x - (y * (z / t))
	else:
		tmp = x - (math.log((1.0 + (y * (z + (0.5 * math.pow(z, 2.0)))))) / 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)
	t_1 = Float64(x - Float64(log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) / t))
	tmp = 0.0
	if (z <= -1.75e+36)
		tmp = t_1;
	elseif (z <= -380000000000.0)
		tmp = Float64(x - Float64(Float64(Float64(exp(z) - 1.0) * y) / t));
	elseif (z <= -5e-5)
		tmp = t_1;
	elseif (z <= 1.95e-81)
		tmp = Float64(x - Float64(y * Float64(z / t)));
	else
		tmp = Float64(x - Float64(log(Float64(1.0 + Float64(y * Float64(z + Float64(0.5 * (z ^ 2.0)))))) / t));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = x - (log(((1.0 - y) + (y * exp(z)))) / t);
end
function tmp_2 = code(x, y, z, t)
	t_1 = x - (log(((1.0 - y) + (y * exp(z)))) / t);
	tmp = 0.0;
	if (z <= -1.75e+36)
		tmp = t_1;
	elseif (z <= -380000000000.0)
		tmp = x - (((exp(z) - 1.0) * y) / t);
	elseif (z <= -5e-5)
		tmp = t_1;
	elseif (z <= 1.95e-81)
		tmp = x - (y * (z / t));
	else
		tmp = x - (log((1.0 + (y * (z + (0.5 * (z ^ 2.0)))))) / t);
	end
	tmp_2 = 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_] := Block[{t$95$1 = N[(x - N[(N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.75e+36], t$95$1, If[LessEqual[z, -380000000000.0], N[(x - N[(N[(N[(N[Exp[z], $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -5e-5], t$95$1, If[LessEqual[z, 1.95e-81], N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[N[(1.0 + N[(y * N[(z + N[(0.5 * N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]]]]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
t_1 := x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\\
\mathbf{if}\;z \leq -1.75 \cdot 10^{+36}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq -380000000000:\\
\;\;\;\;x - \frac{\left(e^{z} - 1\right) \cdot y}{t}\\

\mathbf{elif}\;z \leq -5 \cdot 10^{-5}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 1.95 \cdot 10^{-81}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\

\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + 0.5 \cdot {z}^{2}\right)\right)}{t}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original25.3
Target16.4
Herbie8.2
\[\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 4 regimes
  2. if z < -1.7499999999999999e36 or -3.8e11 < z < -5.00000000000000024e-5

    1. Initial program 12.2

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

    if -1.7499999999999999e36 < z < -3.8e11

    1. Initial program 13.4

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

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

    if -5.00000000000000024e-5 < z < 1.94999999999999992e-81

    1. Initial program 31.4

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

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

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

      \[\leadsto y \cdot \color{blue}{\left(-1 \cdot \frac{z}{t}\right)} + x \]
    5. Simplified5.3

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

      [Start]5.3

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

      rational.json-simplify-2 [=>]5.3

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

      rational.json-simplify-9 [=>]5.3

      \[ y \cdot \color{blue}{\left(-\frac{z}{t}\right)} + x \]
    6. Applied egg-rr5.3

      \[\leadsto \color{blue}{y \cdot \left(-\frac{z}{t}\right) - \left(-x\right)} \]
    7. Simplified5.3

      \[\leadsto \color{blue}{x - y \cdot \frac{z}{t}} \]
      Proof

      [Start]5.3

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

      rational.json-simplify-8 [=>]5.3

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

      rational.json-simplify-43 [<=]5.3

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

      rational.json-simplify-8 [=>]5.3

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

      rational.json-simplify-48 [=>]5.3

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

      rational.json-simplify-2 [=>]5.3

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

      rational.json-simplify-9 [=>]5.3

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

      rational.json-simplify-12 [=>]5.3

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

      rational.json-simplify-44 [=>]5.3

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

      rational.json-simplify-5 [=>]5.3

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

    if 1.94999999999999992e-81 < z

    1. Initial program 29.3

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

      \[\leadsto x - \frac{\log \color{blue}{\left(y \cdot z + \left(1 + 0.5 \cdot \left(y \cdot {z}^{2}\right)\right)\right)}}{t} \]
    3. Simplified13.8

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

      [Start]13.8

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

      rational.json-simplify-41 [=>]13.8

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

      rational.json-simplify-43 [=>]13.8

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

      rational.json-simplify-2 [=>]13.8

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

      rational.json-simplify-47 [=>]13.8

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

      rational.json-simplify-2 [=>]13.8

      \[ x - \frac{\log \left(1 + y \cdot \left(z + \color{blue}{0.5 \cdot {z}^{2}}\right)\right)}{t} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{+36}:\\ \;\;\;\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\\ \mathbf{elif}\;z \leq -380000000000:\\ \;\;\;\;x - \frac{\left(e^{z} - 1\right) \cdot y}{t}\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-5}:\\ \;\;\;\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{-81}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + 0.5 \cdot {z}^{2}\right)\right)}{t}\\ \end{array} \]

Alternatives

Alternative 1
Error8.2
Cost13900
\[\begin{array}{l} t_1 := x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\\ \mathbf{if}\;z \leq -6.6 \cdot 10^{+36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -700000000000:\\ \;\;\;\;x - \frac{\left(e^{z} - 1\right) \cdot y}{t}\\ \mathbf{elif}\;z \leq -5.2 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{-81}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(y \cdot z + 1\right)}{t}\\ \end{array} \]
Alternative 2
Error8.8
Cost13508
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 0.998:\\ \;\;\;\;y \cdot \frac{1 - e^{z}}{t} + x\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 3
Error8.9
Cost7240
\[\begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{-5}:\\ \;\;\;\;y \cdot \frac{1 - e^{z}}{t} + x\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{-81}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(y \cdot z + 1\right)}{t}\\ \end{array} \]
Alternative 4
Error8.9
Cost7240
\[\begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{-5}:\\ \;\;\;\;x - \frac{\left(e^{z} - 1\right) \cdot y}{t}\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{-81}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(y \cdot z + 1\right)}{t}\\ \end{array} \]
Alternative 5
Error19.1
Cost648
\[\begin{array}{l} \mathbf{if}\;t \leq -7 \cdot 10^{-105}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -8.8 \cdot 10^{-154}:\\ \;\;\;\;-\frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error11.4
Cost580
\[\begin{array}{l} \mathbf{if}\;z \leq -1.05:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 7
Error18.3
Cost64
\[x \]

Error

Reproduce?

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