?

Average Error: 25.3 → 9.8
Time: 1.1min
Precision: binary64
Cost: 13960

?

\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -6.2 \cdot 10^{+23}:\\ \;\;\;\;x - \frac{\left(e^{z} - 1\right) \cdot y}{t}\\ \mathbf{elif}\;z \leq -1.05 \cdot 10^{-130}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + 0.5 \cdot {z}^{2}\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \left(0.5 \cdot \frac{{z}^{2}}{t} + \frac{z}{t}\right) \cdot \left(-y\right)\\ \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 (<= z -6.2e+23)
   (- x (/ (* (- (exp z) 1.0) y) t))
   (if (<= z -1.05e-130)
     (- x (/ (log (+ 1.0 (* y (+ z (* 0.5 (pow z 2.0)))))) t))
     (+ x (* (+ (* 0.5 (/ (pow z 2.0) t)) (/ z t)) (- y))))))
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 (z <= -6.2e+23) {
		tmp = x - (((exp(z) - 1.0) * y) / t);
	} else if (z <= -1.05e-130) {
		tmp = x - (log((1.0 + (y * (z + (0.5 * pow(z, 2.0)))))) / t);
	} else {
		tmp = x + (((0.5 * (pow(z, 2.0) / t)) + (z / t)) * -y);
	}
	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) :: tmp
    if (z <= (-6.2d+23)) then
        tmp = x - (((exp(z) - 1.0d0) * y) / t)
    else if (z <= (-1.05d-130)) then
        tmp = x - (log((1.0d0 + (y * (z + (0.5d0 * (z ** 2.0d0)))))) / t)
    else
        tmp = x + (((0.5d0 * ((z ** 2.0d0) / t)) + (z / t)) * -y)
    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 tmp;
	if (z <= -6.2e+23) {
		tmp = x - (((Math.exp(z) - 1.0) * y) / t);
	} else if (z <= -1.05e-130) {
		tmp = x - (Math.log((1.0 + (y * (z + (0.5 * Math.pow(z, 2.0)))))) / t);
	} else {
		tmp = x + (((0.5 * (Math.pow(z, 2.0) / t)) + (z / t)) * -y);
	}
	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 z <= -6.2e+23:
		tmp = x - (((math.exp(z) - 1.0) * y) / t)
	elif z <= -1.05e-130:
		tmp = x - (math.log((1.0 + (y * (z + (0.5 * math.pow(z, 2.0)))))) / t)
	else:
		tmp = x + (((0.5 * (math.pow(z, 2.0) / t)) + (z / t)) * -y)
	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 (z <= -6.2e+23)
		tmp = Float64(x - Float64(Float64(Float64(exp(z) - 1.0) * y) / t));
	elseif (z <= -1.05e-130)
		tmp = Float64(x - Float64(log(Float64(1.0 + Float64(y * Float64(z + Float64(0.5 * (z ^ 2.0)))))) / t));
	else
		tmp = Float64(x + Float64(Float64(Float64(0.5 * Float64((z ^ 2.0) / t)) + Float64(z / t)) * Float64(-y)));
	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)
	tmp = 0.0;
	if (z <= -6.2e+23)
		tmp = x - (((exp(z) - 1.0) * y) / t);
	elseif (z <= -1.05e-130)
		tmp = x - (log((1.0 + (y * (z + (0.5 * (z ^ 2.0)))))) / t);
	else
		tmp = x + (((0.5 * ((z ^ 2.0) / t)) + (z / t)) * -y);
	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_] := If[LessEqual[z, -6.2e+23], N[(x - N[(N[(N[(N[Exp[z], $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -1.05e-130], 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], N[(x + N[(N[(N[(0.5 * N[(N[Power[z, 2.0], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] + N[(z / t), $MachinePrecision]), $MachinePrecision] * (-y)), $MachinePrecision]), $MachinePrecision]]]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{+23}:\\
\;\;\;\;x - \frac{\left(e^{z} - 1\right) \cdot y}{t}\\

\mathbf{elif}\;z \leq -1.05 \cdot 10^{-130}:\\
\;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + 0.5 \cdot {z}^{2}\right)\right)}{t}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original25.3
Target16.3
Herbie9.8
\[\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 3 regimes
  2. if z < -6.19999999999999941e23

    1. Initial program 11.8

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

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

    if -6.19999999999999941e23 < z < -1.05000000000000001e-130

    1. Initial program 25.9

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

      \[\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. Simplified14.2

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

      [Start]14.2

      \[ 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 [=>]14.2

      \[ 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 [=>]14.2

      \[ 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 [=>]14.2

      \[ 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-51 [=>]14.2

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

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

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

    if -1.05000000000000001e-130 < z

    1. Initial program 31.6

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

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

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

      [Start]14.7

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

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

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

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

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

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

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

      rational.json-simplify-1 [=>]14.7

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

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

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

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

      \[ x - \frac{z \cdot y + \left(y + \color{blue}{\left(-{y}^{2}\right)}\right) \cdot \left(0.5 \cdot {z}^{2}\right)}{t} \]
    4. Taylor expanded in y around 0 6.0

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

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

      [Start]6.0

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

      rational.json-simplify-1 [=>]6.0

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6.2 \cdot 10^{+23}:\\ \;\;\;\;x - \frac{\left(e^{z} - 1\right) \cdot y}{t}\\ \mathbf{elif}\;z \leq -1.05 \cdot 10^{-130}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + 0.5 \cdot {z}^{2}\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \left(0.5 \cdot \frac{{z}^{2}}{t} + \frac{z}{t}\right) \cdot \left(-y\right)\\ \end{array} \]

Alternatives

Alternative 1
Error9.5
Cost7624
\[\begin{array}{l} \mathbf{if}\;z \leq -6.5 \cdot 10^{+23}:\\ \;\;\;\;x - \frac{\left(e^{z} - 1\right) \cdot y}{t}\\ \mathbf{elif}\;z \leq -2.8 \cdot 10^{-130}:\\ \;\;\;\;x - \frac{\log \left(y \cdot z + 1\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \left(0.5 \cdot \frac{{z}^{2}}{t} + \frac{z}{t}\right) \cdot \left(-y\right)\\ \end{array} \]
Alternative 2
Error9.5
Cost7432
\[\begin{array}{l} \mathbf{if}\;z \leq -6.2 \cdot 10^{+23}:\\ \;\;\;\;x - \frac{\left(e^{z} - 1\right) \cdot y}{t}\\ \mathbf{elif}\;z \leq -2.8 \cdot 10^{-130}:\\ \;\;\;\;x - \frac{\log \left(y \cdot z + 1\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z + 0.5 \cdot {z}^{2}}{t}\\ \end{array} \]
Alternative 3
Error11.8
Cost7240
\[\begin{array}{l} \mathbf{if}\;z \leq -1.22 \cdot 10^{+53}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2.8 \cdot 10^{-130}:\\ \;\;\;\;x - \frac{\log \left(y \cdot z + 1\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{z}}\\ \end{array} \]
Alternative 4
Error9.5
Cost7240
\[\begin{array}{l} \mathbf{if}\;z \leq -3.6 \cdot 10^{+24}:\\ \;\;\;\;x - \frac{\left(e^{z} - 1\right) \cdot y}{t}\\ \mathbf{elif}\;z \leq -1.35 \cdot 10^{-130}:\\ \;\;\;\;x - \frac{\log \left(y \cdot z + 1\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{z}}\\ \end{array} \]
Alternative 5
Error19.1
Cost648
\[\begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{-197}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -8.6 \cdot 10^{-285}:\\ \;\;\;\;\frac{y}{t} \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error14.8
Cost580
\[\begin{array}{l} \mathbf{if}\;z \leq -1.8 \cdot 10^{-71}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot \frac{y}{t}\\ \end{array} \]
Alternative 7
Error12.2
Cost580
\[\begin{array}{l} \mathbf{if}\;z \leq -5.2 \cdot 10^{+43}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{z}}\\ \end{array} \]
Alternative 8
Error18.6
Cost64
\[x \]

Error

Reproduce?

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