System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2

Percentage Accurate: 61.4% → 98.6%
Time: 14.6s
Alternatives: 6
Speedup: 211.0×

Specification

?
\[\begin{array}{l} \\ x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
double code(double x, double y, double z, double t) {
	return x - (log(((1.0 - y) + (y * exp(z)))) / t);
}
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
public static double code(double x, double y, double z, double t) {
	return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
def code(x, y, z, t):
	return x - (math.log(((1.0 - y) + (y * math.exp(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 tmp = code(x, y, z, t)
	tmp = x - (log(((1.0 - y) + (y * exp(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]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 61.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
double code(double x, double y, double z, double t) {
	return x - (log(((1.0 - y) + (y * exp(z)))) / t);
}
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
public static double code(double x, double y, double z, double t) {
	return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
def code(x, y, z, t):
	return x - (math.log(((1.0 - y) + (y * math.exp(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 tmp = code(x, y, z, t)
	tmp = x - (log(((1.0 - y) + (y * exp(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]
\begin{array}{l}

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

Alternative 1: 98.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t} \end{array} \]
(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 - (log1p((y * expm1(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.log1p((y * math.expm1(z))) / t)
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[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}
\end{array}
Derivation
  1. Initial program 58.9%

    \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
  2. Step-by-step derivation
    1. sub-neg58.9%

      \[\leadsto x - \frac{\log \left(\color{blue}{\left(1 + \left(-y\right)\right)} + y \cdot e^{z}\right)}{t} \]
    2. associate-+l+76.2%

      \[\leadsto x - \frac{\log \color{blue}{\left(1 + \left(\left(-y\right) + y \cdot e^{z}\right)\right)}}{t} \]
    3. cancel-sign-sub76.2%

      \[\leadsto x - \frac{\log \left(1 + \color{blue}{\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}\right)}{t} \]
    4. log1p-def81.7%

      \[\leadsto x - \frac{\color{blue}{\mathsf{log1p}\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}}{t} \]
    5. cancel-sign-sub81.7%

      \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{\left(-y\right) + y \cdot e^{z}}\right)}{t} \]
    6. +-commutative81.7%

      \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot e^{z} + \left(-y\right)}\right)}{t} \]
    7. unsub-neg81.7%

      \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot e^{z} - y}\right)}{t} \]
    8. *-rgt-identity81.7%

      \[\leadsto x - \frac{\mathsf{log1p}\left(y \cdot e^{z} - \color{blue}{y \cdot 1}\right)}{t} \]
    9. distribute-lft-out--81.7%

      \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
    10. expm1-def98.6%

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

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

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

Alternative 2: 87.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{z} \leq 0:\\ \;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot \left(e^{z} + -1\right)}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot \left(z + 0.5 \cdot {z}^{2}\right)}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (exp z) 0.0)
   (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y (+ (exp z) -1.0))))))
   (- x (/ (* y (+ z (* 0.5 (pow z 2.0)))) t))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (exp(z) <= 0.0) {
		tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (exp(z) + -1.0)))));
	} else {
		tmp = x - ((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
    real(8) :: tmp
    if (exp(z) <= 0.0d0) then
        tmp = x + ((-1.0d0) / ((t * 0.5d0) + (t / (y * (exp(z) + (-1.0d0))))))
    else
        tmp = x - ((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) {
	double tmp;
	if (Math.exp(z) <= 0.0) {
		tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (Math.exp(z) + -1.0)))));
	} else {
		tmp = x - ((y * (z + (0.5 * Math.pow(z, 2.0)))) / t);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if math.exp(z) <= 0.0:
		tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (math.exp(z) + -1.0)))))
	else:
		tmp = x - ((y * (z + (0.5 * math.pow(z, 2.0)))) / t)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (exp(z) <= 0.0)
		tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * Float64(exp(z) + -1.0))))));
	else
		tmp = Float64(x - Float64(Float64(y * Float64(z + Float64(0.5 * (z ^ 2.0)))) / t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (exp(z) <= 0.0)
		tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (exp(z) + -1.0)))));
	else
		tmp = x - ((y * (z + (0.5 * (z ^ 2.0)))) / t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[N[Exp[z], $MachinePrecision], 0.0], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * N[(N[Exp[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(y * N[(z + N[(0.5 * N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 0:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot \left(e^{z} + -1\right)}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (exp.f64 z) < 0.0

    1. Initial program 81.1%

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
    2. Step-by-step derivation
      1. sub-neg81.1%

        \[\leadsto x - \frac{\log \left(\color{blue}{\left(1 + \left(-y\right)\right)} + y \cdot e^{z}\right)}{t} \]
      2. associate-+l+81.1%

        \[\leadsto x - \frac{\log \color{blue}{\left(1 + \left(\left(-y\right) + y \cdot e^{z}\right)\right)}}{t} \]
      3. cancel-sign-sub81.1%

        \[\leadsto x - \frac{\log \left(1 + \color{blue}{\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}\right)}{t} \]
      4. log1p-def100.0%

        \[\leadsto x - \frac{\color{blue}{\mathsf{log1p}\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}}{t} \]
      5. cancel-sign-sub100.0%

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot e^{z} - y}\right)}{t} \]
      8. *-rgt-identity100.0%

        \[\leadsto x - \frac{\mathsf{log1p}\left(y \cdot e^{z} - \color{blue}{y \cdot 1}\right)}{t} \]
      9. distribute-lft-out--100.0%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
      10. expm1-def100.0%

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

      \[\leadsto \color{blue}{x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}} \]
    4. Step-by-step derivation
      1. clear-num99.9%

        \[\leadsto x - \color{blue}{\frac{1}{\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}}} \]
      2. inv-pow99.9%

        \[\leadsto x - \color{blue}{{\left(\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}\right)}^{-1}} \]
    5. Applied egg-rr99.9%

      \[\leadsto x - \color{blue}{{\left(\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}\right)}^{-1}} \]
    6. Step-by-step derivation
      1. unpow-199.9%

        \[\leadsto x - \color{blue}{\frac{1}{\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}}} \]
    7. Applied egg-rr99.9%

      \[\leadsto x - \color{blue}{\frac{1}{\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}}} \]
    8. Taylor expanded in y around 0 84.0%

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

    if 0.0 < (exp.f64 z)

    1. Initial program 49.7%

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
    2. Step-by-step derivation
      1. sub-neg49.7%

        \[\leadsto x - \frac{\log \left(\color{blue}{\left(1 + \left(-y\right)\right)} + y \cdot e^{z}\right)}{t} \]
      2. associate-+l+74.1%

        \[\leadsto x - \frac{\log \color{blue}{\left(1 + \left(\left(-y\right) + y \cdot e^{z}\right)\right)}}{t} \]
      3. cancel-sign-sub74.1%

        \[\leadsto x - \frac{\log \left(1 + \color{blue}{\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}\right)}{t} \]
      4. log1p-def74.1%

        \[\leadsto x - \frac{\color{blue}{\mathsf{log1p}\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}}{t} \]
      5. cancel-sign-sub74.1%

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot e^{z} - y}\right)}{t} \]
      8. *-rgt-identity74.1%

        \[\leadsto x - \frac{\mathsf{log1p}\left(y \cdot e^{z} - \color{blue}{y \cdot 1}\right)}{t} \]
      9. distribute-lft-out--74.1%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
      10. expm1-def98.0%

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

      \[\leadsto \color{blue}{x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}} \]
    4. Taylor expanded in y around 0 73.3%

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

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

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

Alternative 3: 87.1% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{+102}:\\ \;\;\;\;x + \frac{-1}{\left(\frac{t}{y} \cdot -0.5 + \frac{t}{y \cdot z}\right) - z \cdot \left(-0.25 \cdot \frac{t}{y} + \frac{t}{y} \cdot 0.16666666666666666\right)}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= y -3.5e+102)
   (+
    x
    (/
     -1.0
     (-
      (+ (* (/ t y) -0.5) (/ t (* y z)))
      (* z (+ (* -0.25 (/ t y)) (* (/ t y) 0.16666666666666666))))))
   (- x (* y (/ (expm1 z) t)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -3.5e+102) {
		tmp = x + (-1.0 / ((((t / y) * -0.5) + (t / (y * z))) - (z * ((-0.25 * (t / y)) + ((t / y) * 0.16666666666666666)))));
	} else {
		tmp = x - (y * (expm1(z) / t));
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -3.5e+102) {
		tmp = x + (-1.0 / ((((t / y) * -0.5) + (t / (y * z))) - (z * ((-0.25 * (t / y)) + ((t / y) * 0.16666666666666666)))));
	} else {
		tmp = x - (y * (Math.expm1(z) / t));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if y <= -3.5e+102:
		tmp = x + (-1.0 / ((((t / y) * -0.5) + (t / (y * z))) - (z * ((-0.25 * (t / y)) + ((t / y) * 0.16666666666666666)))))
	else:
		tmp = x - (y * (math.expm1(z) / t))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (y <= -3.5e+102)
		tmp = Float64(x + Float64(-1.0 / Float64(Float64(Float64(Float64(t / y) * -0.5) + Float64(t / Float64(y * z))) - Float64(z * Float64(Float64(-0.25 * Float64(t / y)) + Float64(Float64(t / y) * 0.16666666666666666))))));
	else
		tmp = Float64(x - Float64(y * Float64(expm1(z) / t)));
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.5e+102], N[(x + N[(-1.0 / N[(N[(N[(N[(t / y), $MachinePrecision] * -0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z * N[(N[(-0.25 * N[(t / y), $MachinePrecision]), $MachinePrecision] + N[(N[(t / y), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{+102}:\\
\;\;\;\;x + \frac{-1}{\left(\frac{t}{y} \cdot -0.5 + \frac{t}{y \cdot z}\right) - z \cdot \left(-0.25 \cdot \frac{t}{y} + \frac{t}{y} \cdot 0.16666666666666666\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.50000000000000011e102

    1. Initial program 37.9%

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
    2. Step-by-step derivation
      1. sub-neg37.9%

        \[\leadsto x - \frac{\log \left(\color{blue}{\left(1 + \left(-y\right)\right)} + y \cdot e^{z}\right)}{t} \]
      2. associate-+l+73.1%

        \[\leadsto x - \frac{\log \color{blue}{\left(1 + \left(\left(-y\right) + y \cdot e^{z}\right)\right)}}{t} \]
      3. cancel-sign-sub73.1%

        \[\leadsto x - \frac{\log \left(1 + \color{blue}{\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}\right)}{t} \]
      4. log1p-def73.1%

        \[\leadsto x - \frac{\color{blue}{\mathsf{log1p}\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}}{t} \]
      5. cancel-sign-sub73.1%

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot e^{z} - y}\right)}{t} \]
      8. *-rgt-identity73.1%

        \[\leadsto x - \frac{\mathsf{log1p}\left(y \cdot e^{z} - \color{blue}{y \cdot 1}\right)}{t} \]
      9. distribute-lft-out--73.1%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
      10. expm1-def99.8%

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

      \[\leadsto \color{blue}{x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}} \]
    4. Taylor expanded in y around 0 43.1%

      \[\leadsto x - \color{blue}{\frac{y \cdot \left(e^{z} - 1\right)}{t}} \]
    5. Step-by-step derivation
      1. clear-num43.1%

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

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

        \[\leadsto x - {\left(\frac{t}{y \cdot \color{blue}{\mathsf{expm1}\left(z\right)}}\right)}^{-1} \]
    6. Applied egg-rr55.2%

      \[\leadsto x - \color{blue}{{\left(\frac{t}{y \cdot \mathsf{expm1}\left(z\right)}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-155.2%

        \[\leadsto x - \color{blue}{\frac{1}{\frac{t}{y \cdot \mathsf{expm1}\left(z\right)}}} \]
    8. Simplified55.2%

      \[\leadsto x - \color{blue}{\frac{1}{\frac{t}{y \cdot \mathsf{expm1}\left(z\right)}}} \]
    9. Taylor expanded in z around 0 65.3%

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

    if -3.50000000000000011e102 < y

    1. Initial program 64.9%

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
    2. Step-by-step derivation
      1. sub-neg64.9%

        \[\leadsto x - \frac{\log \left(\color{blue}{\left(1 + \left(-y\right)\right)} + y \cdot e^{z}\right)}{t} \]
      2. associate-+l+77.1%

        \[\leadsto x - \frac{\log \color{blue}{\left(1 + \left(\left(-y\right) + y \cdot e^{z}\right)\right)}}{t} \]
      3. cancel-sign-sub77.1%

        \[\leadsto x - \frac{\log \left(1 + \color{blue}{\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}\right)}{t} \]
      4. log1p-def84.2%

        \[\leadsto x - \frac{\color{blue}{\mathsf{log1p}\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}}{t} \]
      5. cancel-sign-sub84.2%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{\left(-y\right) + y \cdot e^{z}}\right)}{t} \]
      6. +-commutative84.2%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot e^{z} + \left(-y\right)}\right)}{t} \]
      7. unsub-neg84.2%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot e^{z} - y}\right)}{t} \]
      8. *-rgt-identity84.2%

        \[\leadsto x - \frac{\mathsf{log1p}\left(y \cdot e^{z} - \color{blue}{y \cdot 1}\right)}{t} \]
      9. distribute-lft-out--84.1%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
      10. expm1-def98.2%

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

      \[\leadsto \color{blue}{x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}} \]
    4. Step-by-step derivation
      1. clear-num98.2%

        \[\leadsto x - \color{blue}{\frac{1}{\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}}} \]
      2. inv-pow98.2%

        \[\leadsto x - \color{blue}{{\left(\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}\right)}^{-1}} \]
    5. Applied egg-rr98.2%

      \[\leadsto x - \color{blue}{{\left(\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}\right)}^{-1}} \]
    6. Taylor expanded in y around 0 81.4%

      \[\leadsto x - \color{blue}{\frac{y \cdot \left(e^{z} - 1\right)}{t}} \]
    7. Step-by-step derivation
      1. expm1-def90.7%

        \[\leadsto x - \frac{y \cdot \color{blue}{\mathsf{expm1}\left(z\right)}}{t} \]
      2. associate-*r/91.9%

        \[\leadsto x - \color{blue}{y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}} \]
    8. Simplified91.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{+102}:\\ \;\;\;\;x + \frac{-1}{\left(\frac{t}{y} \cdot -0.5 + \frac{t}{y \cdot z}\right) - z \cdot \left(-0.25 \cdot \frac{t}{y} + \frac{t}{y} \cdot 0.16666666666666666\right)}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\ \end{array} \]

Alternative 4: 82.6% accurate, 23.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.9 \cdot 10^{+14}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= z -1.9e+14) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -1.9e+14) {
		tmp = x;
	} else {
		tmp = x - (y * (z / 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
    real(8) :: tmp
    if (z <= (-1.9d+14)) then
        tmp = x
    else
        tmp = x - (y * (z / t))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -1.9e+14) {
		tmp = x;
	} else {
		tmp = x - (y * (z / t));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if z <= -1.9e+14:
		tmp = x
	else:
		tmp = x - (y * (z / t))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -1.9e+14)
		tmp = x;
	else
		tmp = Float64(x - Float64(y * Float64(z / t)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= -1.9e+14)
		tmp = x;
	else
		tmp = x - (y * (z / t));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.9e+14], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+14}:\\
\;\;\;\;x\\

\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.9e14

    1. Initial program 81.7%

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
    2. Step-by-step derivation
      1. sub-neg81.7%

        \[\leadsto x - \frac{\log \left(\color{blue}{\left(1 + \left(-y\right)\right)} + y \cdot e^{z}\right)}{t} \]
      2. associate-+l+81.7%

        \[\leadsto x - \frac{\log \color{blue}{\left(1 + \left(\left(-y\right) + y \cdot e^{z}\right)\right)}}{t} \]
      3. cancel-sign-sub81.7%

        \[\leadsto x - \frac{\log \left(1 + \color{blue}{\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}\right)}{t} \]
      4. log1p-def100.0%

        \[\leadsto x - \frac{\color{blue}{\mathsf{log1p}\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}}{t} \]
      5. cancel-sign-sub100.0%

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot e^{z} - y}\right)}{t} \]
      8. *-rgt-identity100.0%

        \[\leadsto x - \frac{\mathsf{log1p}\left(y \cdot e^{z} - \color{blue}{y \cdot 1}\right)}{t} \]
      9. distribute-lft-out--100.0%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
      10. expm1-def100.0%

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

      \[\leadsto \color{blue}{x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}} \]
    4. Step-by-step derivation
      1. clear-num99.9%

        \[\leadsto x - \color{blue}{\frac{1}{\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}}} \]
      2. inv-pow99.9%

        \[\leadsto x - \color{blue}{{\left(\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}\right)}^{-1}} \]
    5. Applied egg-rr99.9%

      \[\leadsto x - \color{blue}{{\left(\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}\right)}^{-1}} \]
    6. Taylor expanded in z around 0 33.0%

      \[\leadsto x - \color{blue}{\frac{y \cdot z}{t}} \]
    7. Step-by-step derivation
      1. associate-*r/33.1%

        \[\leadsto x - \color{blue}{y \cdot \frac{z}{t}} \]
    8. Simplified33.1%

      \[\leadsto x - \color{blue}{y \cdot \frac{z}{t}} \]
    9. Step-by-step derivation
      1. associate-*r/33.0%

        \[\leadsto x - \color{blue}{\frac{y \cdot z}{t}} \]
      2. frac-2neg33.0%

        \[\leadsto x - \color{blue}{\frac{-y \cdot z}{-t}} \]
      3. neg-mul-133.0%

        \[\leadsto x - \frac{-y \cdot z}{\color{blue}{-1 \cdot t}} \]
      4. associate-/r*33.0%

        \[\leadsto x - \color{blue}{\frac{\frac{-y \cdot z}{-1}}{t}} \]
      5. distribute-lft-neg-in33.0%

        \[\leadsto x - \frac{\frac{\color{blue}{\left(-y\right) \cdot z}}{-1}}{t} \]
      6. add-sqr-sqrt17.7%

        \[\leadsto x - \frac{\frac{\color{blue}{\left(\sqrt{-y} \cdot \sqrt{-y}\right)} \cdot z}{-1}}{t} \]
      7. sqrt-unprod39.0%

        \[\leadsto x - \frac{\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}} \cdot z}{-1}}{t} \]
      8. sqr-neg39.0%

        \[\leadsto x - \frac{\frac{\sqrt{\color{blue}{y \cdot y}} \cdot z}{-1}}{t} \]
      9. sqrt-unprod15.1%

        \[\leadsto x - \frac{\frac{\color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot z}{-1}}{t} \]
      10. add-sqr-sqrt31.0%

        \[\leadsto x - \frac{\frac{\color{blue}{y} \cdot z}{-1}}{t} \]
    10. Applied egg-rr31.0%

      \[\leadsto x - \color{blue}{\frac{\frac{y \cdot z}{-1}}{t}} \]
    11. Step-by-step derivation
      1. associate-/l/31.0%

        \[\leadsto x - \color{blue}{\frac{y \cdot z}{t \cdot -1}} \]
      2. *-commutative31.0%

        \[\leadsto x - \frac{\color{blue}{z \cdot y}}{t \cdot -1} \]
      3. associate-/l*35.0%

        \[\leadsto x - \color{blue}{\frac{z}{\frac{t \cdot -1}{y}}} \]
    12. Simplified35.0%

      \[\leadsto x - \color{blue}{\frac{z}{\frac{t \cdot -1}{y}}} \]
    13. Taylor expanded in x around inf 63.5%

      \[\leadsto \color{blue}{x} \]

    if -1.9e14 < z

    1. Initial program 50.0%

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
    2. Step-by-step derivation
      1. sub-neg50.0%

        \[\leadsto x - \frac{\log \left(\color{blue}{\left(1 + \left(-y\right)\right)} + y \cdot e^{z}\right)}{t} \]
      2. associate-+l+74.0%

        \[\leadsto x - \frac{\log \color{blue}{\left(1 + \left(\left(-y\right) + y \cdot e^{z}\right)\right)}}{t} \]
      3. cancel-sign-sub74.0%

        \[\leadsto x - \frac{\log \left(1 + \color{blue}{\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}\right)}{t} \]
      4. log1p-def74.6%

        \[\leadsto x - \frac{\color{blue}{\mathsf{log1p}\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}}{t} \]
      5. cancel-sign-sub74.6%

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot e^{z} + \left(-y\right)}\right)}{t} \]
      7. unsub-neg74.6%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot e^{z} - y}\right)}{t} \]
      8. *-rgt-identity74.6%

        \[\leadsto x - \frac{\mathsf{log1p}\left(y \cdot e^{z} - \color{blue}{y \cdot 1}\right)}{t} \]
      9. distribute-lft-out--74.5%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
      10. expm1-def98.1%

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

      \[\leadsto \color{blue}{x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}} \]
    4. Step-by-step derivation
      1. clear-num98.0%

        \[\leadsto x - \color{blue}{\frac{1}{\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}}} \]
      2. inv-pow98.0%

        \[\leadsto x - \color{blue}{{\left(\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}\right)}^{-1}} \]
    5. Applied egg-rr98.0%

      \[\leadsto x - \color{blue}{{\left(\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}\right)}^{-1}} \]
    6. Taylor expanded in z around 0 86.6%

      \[\leadsto x - \color{blue}{\frac{y \cdot z}{t}} \]
    7. Step-by-step derivation
      1. associate-*r/86.3%

        \[\leadsto x - \color{blue}{y \cdot \frac{z}{t}} \]
    8. Simplified86.3%

      \[\leadsto x - \color{blue}{y \cdot \frac{z}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification79.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.9 \cdot 10^{+14}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \end{array} \]

Alternative 5: 81.8% accurate, 23.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2 \cdot 10^{+15}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot z}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t) :precision binary64 (if (<= z -2e+15) x (- x (/ (* y z) t))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -2e+15) {
		tmp = x;
	} else {
		tmp = x - ((y * z) / 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
    real(8) :: tmp
    if (z <= (-2d+15)) then
        tmp = x
    else
        tmp = x - ((y * z) / t)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -2e+15) {
		tmp = x;
	} else {
		tmp = x - ((y * z) / t);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if z <= -2e+15:
		tmp = x
	else:
		tmp = x - ((y * z) / t)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -2e+15)
		tmp = x;
	else
		tmp = Float64(x - Float64(Float64(y * z) / t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= -2e+15)
		tmp = x;
	else
		tmp = x - ((y * z) / t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[z, -2e+15], x, N[(x - N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+15}:\\
\;\;\;\;x\\

\mathbf{else}:\\
\;\;\;\;x - \frac{y \cdot z}{t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2e15

    1. Initial program 81.7%

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
    2. Step-by-step derivation
      1. sub-neg81.7%

        \[\leadsto x - \frac{\log \left(\color{blue}{\left(1 + \left(-y\right)\right)} + y \cdot e^{z}\right)}{t} \]
      2. associate-+l+81.7%

        \[\leadsto x - \frac{\log \color{blue}{\left(1 + \left(\left(-y\right) + y \cdot e^{z}\right)\right)}}{t} \]
      3. cancel-sign-sub81.7%

        \[\leadsto x - \frac{\log \left(1 + \color{blue}{\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}\right)}{t} \]
      4. log1p-def100.0%

        \[\leadsto x - \frac{\color{blue}{\mathsf{log1p}\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}}{t} \]
      5. cancel-sign-sub100.0%

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot e^{z} - y}\right)}{t} \]
      8. *-rgt-identity100.0%

        \[\leadsto x - \frac{\mathsf{log1p}\left(y \cdot e^{z} - \color{blue}{y \cdot 1}\right)}{t} \]
      9. distribute-lft-out--100.0%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
      10. expm1-def100.0%

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

      \[\leadsto \color{blue}{x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}} \]
    4. Step-by-step derivation
      1. clear-num99.9%

        \[\leadsto x - \color{blue}{\frac{1}{\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}}} \]
      2. inv-pow99.9%

        \[\leadsto x - \color{blue}{{\left(\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}\right)}^{-1}} \]
    5. Applied egg-rr99.9%

      \[\leadsto x - \color{blue}{{\left(\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}\right)}^{-1}} \]
    6. Taylor expanded in z around 0 33.0%

      \[\leadsto x - \color{blue}{\frac{y \cdot z}{t}} \]
    7. Step-by-step derivation
      1. associate-*r/33.1%

        \[\leadsto x - \color{blue}{y \cdot \frac{z}{t}} \]
    8. Simplified33.1%

      \[\leadsto x - \color{blue}{y \cdot \frac{z}{t}} \]
    9. Step-by-step derivation
      1. associate-*r/33.0%

        \[\leadsto x - \color{blue}{\frac{y \cdot z}{t}} \]
      2. frac-2neg33.0%

        \[\leadsto x - \color{blue}{\frac{-y \cdot z}{-t}} \]
      3. neg-mul-133.0%

        \[\leadsto x - \frac{-y \cdot z}{\color{blue}{-1 \cdot t}} \]
      4. associate-/r*33.0%

        \[\leadsto x - \color{blue}{\frac{\frac{-y \cdot z}{-1}}{t}} \]
      5. distribute-lft-neg-in33.0%

        \[\leadsto x - \frac{\frac{\color{blue}{\left(-y\right) \cdot z}}{-1}}{t} \]
      6. add-sqr-sqrt17.7%

        \[\leadsto x - \frac{\frac{\color{blue}{\left(\sqrt{-y} \cdot \sqrt{-y}\right)} \cdot z}{-1}}{t} \]
      7. sqrt-unprod39.0%

        \[\leadsto x - \frac{\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}} \cdot z}{-1}}{t} \]
      8. sqr-neg39.0%

        \[\leadsto x - \frac{\frac{\sqrt{\color{blue}{y \cdot y}} \cdot z}{-1}}{t} \]
      9. sqrt-unprod15.1%

        \[\leadsto x - \frac{\frac{\color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot z}{-1}}{t} \]
      10. add-sqr-sqrt31.0%

        \[\leadsto x - \frac{\frac{\color{blue}{y} \cdot z}{-1}}{t} \]
    10. Applied egg-rr31.0%

      \[\leadsto x - \color{blue}{\frac{\frac{y \cdot z}{-1}}{t}} \]
    11. Step-by-step derivation
      1. associate-/l/31.0%

        \[\leadsto x - \color{blue}{\frac{y \cdot z}{t \cdot -1}} \]
      2. *-commutative31.0%

        \[\leadsto x - \frac{\color{blue}{z \cdot y}}{t \cdot -1} \]
      3. associate-/l*35.0%

        \[\leadsto x - \color{blue}{\frac{z}{\frac{t \cdot -1}{y}}} \]
    12. Simplified35.0%

      \[\leadsto x - \color{blue}{\frac{z}{\frac{t \cdot -1}{y}}} \]
    13. Taylor expanded in x around inf 63.5%

      \[\leadsto \color{blue}{x} \]

    if -2e15 < z

    1. Initial program 50.0%

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
    2. Step-by-step derivation
      1. sub-neg50.0%

        \[\leadsto x - \frac{\log \left(\color{blue}{\left(1 + \left(-y\right)\right)} + y \cdot e^{z}\right)}{t} \]
      2. associate-+l+74.0%

        \[\leadsto x - \frac{\log \color{blue}{\left(1 + \left(\left(-y\right) + y \cdot e^{z}\right)\right)}}{t} \]
      3. cancel-sign-sub74.0%

        \[\leadsto x - \frac{\log \left(1 + \color{blue}{\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}\right)}{t} \]
      4. log1p-def74.6%

        \[\leadsto x - \frac{\color{blue}{\mathsf{log1p}\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}}{t} \]
      5. cancel-sign-sub74.6%

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot e^{z} + \left(-y\right)}\right)}{t} \]
      7. unsub-neg74.6%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot e^{z} - y}\right)}{t} \]
      8. *-rgt-identity74.6%

        \[\leadsto x - \frac{\mathsf{log1p}\left(y \cdot e^{z} - \color{blue}{y \cdot 1}\right)}{t} \]
      9. distribute-lft-out--74.5%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
      10. expm1-def98.1%

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

      \[\leadsto \color{blue}{x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}} \]
    4. Taylor expanded in z around 0 86.6%

      \[\leadsto x - \color{blue}{\frac{y \cdot z}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2 \cdot 10^{+15}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot z}{t}\\ \end{array} \]

Alternative 6: 71.9% accurate, 211.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
	return x;
}
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
end function
public static double code(double x, double y, double z, double t) {
	return x;
}
def code(x, y, z, t):
	return x
function code(x, y, z, t)
	return x
end
function tmp = code(x, y, z, t)
	tmp = x;
end
code[x_, y_, z_, t_] := x
\begin{array}{l}

\\
x
\end{array}
Derivation
  1. Initial program 58.9%

    \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \]
  2. Step-by-step derivation
    1. sub-neg58.9%

      \[\leadsto x - \frac{\log \left(\color{blue}{\left(1 + \left(-y\right)\right)} + y \cdot e^{z}\right)}{t} \]
    2. associate-+l+76.2%

      \[\leadsto x - \frac{\log \color{blue}{\left(1 + \left(\left(-y\right) + y \cdot e^{z}\right)\right)}}{t} \]
    3. cancel-sign-sub76.2%

      \[\leadsto x - \frac{\log \left(1 + \color{blue}{\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}\right)}{t} \]
    4. log1p-def81.7%

      \[\leadsto x - \frac{\color{blue}{\mathsf{log1p}\left(\left(-y\right) - \left(-y\right) \cdot e^{z}\right)}}{t} \]
    5. cancel-sign-sub81.7%

      \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{\left(-y\right) + y \cdot e^{z}}\right)}{t} \]
    6. +-commutative81.7%

      \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot e^{z} + \left(-y\right)}\right)}{t} \]
    7. unsub-neg81.7%

      \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot e^{z} - y}\right)}{t} \]
    8. *-rgt-identity81.7%

      \[\leadsto x - \frac{\mathsf{log1p}\left(y \cdot e^{z} - \color{blue}{y \cdot 1}\right)}{t} \]
    9. distribute-lft-out--81.7%

      \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
    10. expm1-def98.6%

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

    \[\leadsto \color{blue}{x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}} \]
  4. Step-by-step derivation
    1. clear-num98.5%

      \[\leadsto x - \color{blue}{\frac{1}{\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}}} \]
    2. inv-pow98.5%

      \[\leadsto x - \color{blue}{{\left(\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}\right)}^{-1}} \]
  5. Applied egg-rr98.5%

    \[\leadsto x - \color{blue}{{\left(\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}\right)}^{-1}} \]
  6. Taylor expanded in z around 0 71.5%

    \[\leadsto x - \color{blue}{\frac{y \cdot z}{t}} \]
  7. Step-by-step derivation
    1. associate-*r/71.4%

      \[\leadsto x - \color{blue}{y \cdot \frac{z}{t}} \]
  8. Simplified71.4%

    \[\leadsto x - \color{blue}{y \cdot \frac{z}{t}} \]
  9. Step-by-step derivation
    1. associate-*r/71.5%

      \[\leadsto x - \color{blue}{\frac{y \cdot z}{t}} \]
    2. frac-2neg71.5%

      \[\leadsto x - \color{blue}{\frac{-y \cdot z}{-t}} \]
    3. neg-mul-171.5%

      \[\leadsto x - \frac{-y \cdot z}{\color{blue}{-1 \cdot t}} \]
    4. associate-/r*71.5%

      \[\leadsto x - \color{blue}{\frac{\frac{-y \cdot z}{-1}}{t}} \]
    5. distribute-lft-neg-in71.5%

      \[\leadsto x - \frac{\frac{\color{blue}{\left(-y\right) \cdot z}}{-1}}{t} \]
    6. add-sqr-sqrt34.7%

      \[\leadsto x - \frac{\frac{\color{blue}{\left(\sqrt{-y} \cdot \sqrt{-y}\right)} \cdot z}{-1}}{t} \]
    7. sqrt-unprod59.7%

      \[\leadsto x - \frac{\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}} \cdot z}{-1}}{t} \]
    8. sqr-neg59.7%

      \[\leadsto x - \frac{\frac{\sqrt{\color{blue}{y \cdot y}} \cdot z}{-1}}{t} \]
    9. sqrt-unprod31.6%

      \[\leadsto x - \frac{\frac{\color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot z}{-1}}{t} \]
    10. add-sqr-sqrt59.2%

      \[\leadsto x - \frac{\frac{\color{blue}{y} \cdot z}{-1}}{t} \]
  10. Applied egg-rr59.2%

    \[\leadsto x - \color{blue}{\frac{\frac{y \cdot z}{-1}}{t}} \]
  11. Step-by-step derivation
    1. associate-/l/59.2%

      \[\leadsto x - \color{blue}{\frac{y \cdot z}{t \cdot -1}} \]
    2. *-commutative59.2%

      \[\leadsto x - \frac{\color{blue}{z \cdot y}}{t \cdot -1} \]
    3. associate-/l*59.2%

      \[\leadsto x - \color{blue}{\frac{z}{\frac{t \cdot -1}{y}}} \]
  12. Simplified59.2%

    \[\leadsto x - \color{blue}{\frac{z}{\frac{t \cdot -1}{y}}} \]
  13. Taylor expanded in x around inf 70.1%

    \[\leadsto \color{blue}{x} \]
  14. Final simplification70.1%

    \[\leadsto x \]

Developer target: 75.0% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{-0.5}{y \cdot t}\\ \mathbf{if}\;z < -2.8874623088207947 \cdot 10^{+119}:\\ \;\;\;\;\left(x - \frac{t_1}{z \cdot z}\right) - t_1 \cdot \frac{\frac{2}{z}}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + z \cdot y\right)}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ (- 0.5) (* y t))))
   (if (< z -2.8874623088207947e+119)
     (- (- x (/ t_1 (* z z))) (* t_1 (/ (/ 2.0 z) (* z z))))
     (- x (/ (log (+ 1.0 (* z y))) t)))))
double code(double x, double y, double z, double t) {
	double t_1 = -0.5 / (y * t);
	double tmp;
	if (z < -2.8874623088207947e+119) {
		tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z)));
	} else {
		tmp = x - (log((1.0 + (z * y))) / 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
    real(8) :: t_1
    real(8) :: tmp
    t_1 = -0.5d0 / (y * t)
    if (z < (-2.8874623088207947d+119)) then
        tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0d0 / z) / (z * z)))
    else
        tmp = x - (log((1.0d0 + (z * y))) / t)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = -0.5 / (y * t);
	double tmp;
	if (z < -2.8874623088207947e+119) {
		tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z)));
	} else {
		tmp = x - (Math.log((1.0 + (z * y))) / t);
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = -0.5 / (y * t)
	tmp = 0
	if z < -2.8874623088207947e+119:
		tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z)))
	else:
		tmp = x - (math.log((1.0 + (z * y))) / t)
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(-0.5) / Float64(y * t))
	tmp = 0.0
	if (z < -2.8874623088207947e+119)
		tmp = Float64(Float64(x - Float64(t_1 / Float64(z * z))) - Float64(t_1 * Float64(Float64(2.0 / z) / Float64(z * z))));
	else
		tmp = Float64(x - Float64(log(Float64(1.0 + Float64(z * y))) / t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = -0.5 / (y * t);
	tmp = 0.0;
	if (z < -2.8874623088207947e+119)
		tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z)));
	else
		tmp = x - (log((1.0 + (z * y))) / t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-0.5) / N[(y * t), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -2.8874623088207947e+119], N[(N[(x - N[(t$95$1 / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[(N[(2.0 / z), $MachinePrecision] / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{-0.5}{y \cdot t}\\
\mathbf{if}\;z < -2.8874623088207947 \cdot 10^{+119}:\\
\;\;\;\;\left(x - \frac{t_1}{z \cdot z}\right) - t_1 \cdot \frac{\frac{2}{z}}{z \cdot z}\\

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


\end{array}
\end{array}

Reproduce

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