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

Percentage Accurate: 52.1% → 90.7%
Time: 42.1s
Alternatives: 7
Speedup: 30.1×

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 7 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: 52.1% 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: 90.7% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 20:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\

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


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

    1. Initial program 56.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 20 < (exp.f64 z)

    1. Initial program 57.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(y \cdot \color{blue}{\mathsf{expm1}\left(z\right)}\right)}{t} \]
    3. Simplified57.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 57.0%

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

        \[\leadsto x - \color{blue}{\frac{e^{z} - 1}{\frac{t}{y}}} \]
      2. associate-/r/57.0%

        \[\leadsto x - \color{blue}{\frac{e^{z} - 1}{t} \cdot y} \]
      3. expm1-def57.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{z} \leq 20:\\ \;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \end{array} \]

Alternative 2: 85.0% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;z \leq 5.7 \cdot 10^{+28}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + z \cdot \left(y \cdot 0.5\right)\right)\right)}{t}\\

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


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

    1. Initial program 71.5%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(y \cdot \color{blue}{\left(e^{z} - 1\right)}\right)}{t} \]
      13. 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.7%

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

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

      \[\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.7%

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

      \[\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 79.4%

      \[\leadsto x - \frac{1}{\color{blue}{\frac{t}{\left(e^{z} - 1\right) \cdot y} + 0.5 \cdot t}} \]
    9. Step-by-step derivation
      1. +-commutative79.4%

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

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

        \[\leadsto x - \frac{1}{t \cdot 0.5 + \frac{t}{\color{blue}{\mathsf{expm1}\left(z\right)} \cdot y}} \]
      4. *-commutative79.4%

        \[\leadsto x - \frac{1}{t \cdot 0.5 + \frac{t}{\color{blue}{y \cdot \mathsf{expm1}\left(z\right)}}} \]
    10. Simplified79.4%

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

    if -2.39999999999999991 < z < 5.7000000000000003e28

    1. Initial program 49.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot z + 0.5 \cdot \left(y \cdot {z}^{2}\right)}\right)}{t} \]
    5. Step-by-step derivation
      1. *-commutative97.7%

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(z, y, 0.5 \cdot \left(y \cdot {z}^{2}\right)\right)}\right)}{t} \]
      3. *-commutative97.7%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\mathsf{fma}\left(z, y, \color{blue}{\left(y \cdot {z}^{2}\right) \cdot 0.5}\right)\right)}{t} \]
      4. *-commutative97.7%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\mathsf{fma}\left(z, y, \color{blue}{\left({z}^{2} \cdot y\right)} \cdot 0.5\right)\right)}{t} \]
      5. associate-*l*97.7%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\mathsf{fma}\left(z, y, \color{blue}{{z}^{2} \cdot \left(y \cdot 0.5\right)}\right)\right)}{t} \]
      6. unpow297.7%

        \[\leadsto x - \frac{\mathsf{log1p}\left(\mathsf{fma}\left(z, y, \color{blue}{\left(z \cdot z\right)} \cdot \left(y \cdot 0.5\right)\right)\right)}{t} \]
    6. Simplified97.7%

      \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(z, y, \left(z \cdot z\right) \cdot \left(y \cdot 0.5\right)\right)}\right)}{t} \]
    7. Step-by-step derivation
      1. expm1-log1p-u74.6%

        \[\leadsto x - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{log1p}\left(\mathsf{fma}\left(z, y, \left(z \cdot z\right) \cdot \left(y \cdot 0.5\right)\right)\right)}{t}\right)\right)} \]
      2. expm1-udef62.8%

        \[\leadsto x - \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\mathsf{log1p}\left(\mathsf{fma}\left(z, y, \left(z \cdot z\right) \cdot \left(y \cdot 0.5\right)\right)\right)}{t}\right)} - 1\right)} \]
      3. fma-udef62.8%

        \[\leadsto x - \left(e^{\mathsf{log1p}\left(\frac{\mathsf{log1p}\left(\color{blue}{z \cdot y + \left(z \cdot z\right) \cdot \left(y \cdot 0.5\right)}\right)}{t}\right)} - 1\right) \]
      4. associate-*l*62.8%

        \[\leadsto x - \left(e^{\mathsf{log1p}\left(\frac{\mathsf{log1p}\left(z \cdot y + \color{blue}{z \cdot \left(z \cdot \left(y \cdot 0.5\right)\right)}\right)}{t}\right)} - 1\right) \]
      5. distribute-lft-out62.8%

        \[\leadsto x - \left(e^{\mathsf{log1p}\left(\frac{\mathsf{log1p}\left(\color{blue}{z \cdot \left(y + z \cdot \left(y \cdot 0.5\right)\right)}\right)}{t}\right)} - 1\right) \]
    8. Applied egg-rr62.8%

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

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

        \[\leadsto x - \color{blue}{\frac{\mathsf{log1p}\left(z \cdot \left(y + z \cdot \left(y \cdot 0.5\right)\right)\right)}{t}} \]
    10. Simplified97.7%

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

    if 5.7000000000000003e28 < z

    1. Initial program 62.3%

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

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

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

        \[\leadsto x - \frac{\color{blue}{\mathsf{log1p}\left(-\left(y - y \cdot e^{z}\right)\right)}}{t} \]
      4. neg-sub062.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \color{blue}{\frac{e^{z} - 1}{\frac{t}{y}}} \]
      2. associate-/r/62.3%

        \[\leadsto x - \color{blue}{\frac{e^{z} - 1}{t} \cdot y} \]
      3. expm1-def62.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.4:\\ \;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot \mathsf{expm1}\left(z\right)}}\\ \mathbf{elif}\;z \leq 5.7 \cdot 10^{+28}:\\ \;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + z \cdot \left(y \cdot 0.5\right)\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \end{array} \]

Alternative 3: 79.1% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.05 \cdot 10^{-139}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot \mathsf{expm1}\left(z\right)}}\\

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


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

    1. Initial program 54.2%

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

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

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

        \[\leadsto x - \frac{\color{blue}{\mathsf{log1p}\left(-\left(y - y \cdot e^{z}\right)\right)}}{t} \]
      4. neg-sub074.3%

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

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

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

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

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

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

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

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

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

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

      \[\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.7%

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

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

      \[\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.7%

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

      \[\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 67.4%

      \[\leadsto x - \frac{1}{\color{blue}{\frac{t}{\left(e^{z} - 1\right) \cdot y} + 0.5 \cdot t}} \]
    9. Step-by-step derivation
      1. +-commutative67.4%

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

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

        \[\leadsto x - \frac{1}{t \cdot 0.5 + \frac{t}{\color{blue}{\mathsf{expm1}\left(z\right)} \cdot y}} \]
      4. *-commutative90.6%

        \[\leadsto x - \frac{1}{t \cdot 0.5 + \frac{t}{\color{blue}{y \cdot \mathsf{expm1}\left(z\right)}}} \]
    10. Simplified90.6%

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

    if 2.05000000000000007e-139 < z

    1. Initial program 61.9%

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

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

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

        \[\leadsto x - \frac{\color{blue}{\mathsf{log1p}\left(-\left(y - y \cdot e^{z}\right)\right)}}{t} \]
      4. neg-sub063.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(y \cdot \color{blue}{\mathsf{expm1}\left(z\right)}\right)}{t} \]
    3. Simplified76.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 62.2%

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

        \[\leadsto x - \color{blue}{\frac{e^{z} - 1}{\frac{t}{y}}} \]
      2. associate-/r/62.2%

        \[\leadsto x - \color{blue}{\frac{e^{z} - 1}{t} \cdot y} \]
      3. expm1-def70.5%

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

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

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

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

Alternative 4: 77.8% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 2 \cdot 10^{-73}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\

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


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

    1. Initial program 54.8%

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

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

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

        \[\leadsto x - \frac{\color{blue}{\mathsf{log1p}\left(-\left(y - y \cdot e^{z}\right)\right)}}{t} \]
      4. neg-sub072.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \color{blue}{\frac{e^{z} - 1}{\frac{t}{y}}} \]
      2. associate-/r/64.0%

        \[\leadsto x - \color{blue}{\frac{e^{z} - 1}{t} \cdot y} \]
      3. expm1-def85.3%

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

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

    if 1.99999999999999999e-73 < z

    1. Initial program 63.3%

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

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

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

        \[\leadsto x - \frac{\color{blue}{\mathsf{log1p}\left(-\left(y - y \cdot e^{z}\right)\right)}}{t} \]
      4. neg-sub063.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(y \cdot \color{blue}{\mathsf{expm1}\left(z\right)}\right)}{t} \]
    3. Simplified66.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 61.7%

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

        \[\leadsto x - \color{blue}{\frac{e^{z} - 1}{\frac{t}{y}}} \]
      2. associate-/r/61.7%

        \[\leadsto x - \color{blue}{\frac{e^{z} - 1}{t} \cdot y} \]
      3. expm1-def63.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 2 \cdot 10^{-73}:\\ \;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \end{array} \]

Alternative 5: 76.4% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 10^{-179}:\\
\;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\

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


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

    1. Initial program 54.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e-179 < z

    1. Initial program 60.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \color{blue}{\frac{e^{z} - 1}{\frac{t}{y}}} \]
      2. associate-/r/61.7%

        \[\leadsto x - \color{blue}{\frac{e^{z} - 1}{t} \cdot y} \]
      3. expm1-def72.4%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 10^{-179}:\\ \;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \end{array} \]

Alternative 6: 58.7% accurate, 30.1× speedup?

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

\\
x - z \cdot \frac{y}{t}
\end{array}
Derivation
  1. Initial program 56.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x - \color{blue}{\frac{y}{\frac{t}{z}}} \]
    2. associate-/r/61.6%

      \[\leadsto x - \color{blue}{\frac{y}{t} \cdot z} \]
  6. Simplified61.6%

    \[\leadsto x - \color{blue}{\frac{y}{t} \cdot z} \]
  7. Final simplification61.6%

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

Alternative 7: 65.4% accurate, 30.1× speedup?

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

\\
x - y \cdot \frac{z}{t}
\end{array}
Derivation
  1. Initial program 56.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x - \color{blue}{\frac{e^{z} - 1}{\frac{t}{y}}} \]
    2. associate-/r/63.5%

      \[\leadsto x - \color{blue}{\frac{e^{z} - 1}{t} \cdot y} \]
    3. expm1-def80.5%

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

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

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

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

Developer target: 53.8% 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 2023278 
(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)))