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

Percentage Accurate: 61.8% → 98.4%
Time: 17.0s
Alternatives: 10
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 10 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.8% 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.4% 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 65.3%

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

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

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

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

      \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
    5. neg-mul-165.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 92.5% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -20000000:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\

\mathbf{elif}\;y \leq 5 \cdot 10^{-5}:\\
\;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\

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


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

    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. remove-double-neg56.6%

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-156.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x - \frac{1}{\color{blue}{0.5 \cdot t + \frac{t}{y \cdot z}}} \]

    if -2e7 < y < 5.00000000000000024e-5

    1. Initial program 79.6%

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

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-179.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000024e-5 < y

    1. Initial program 7.5%

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

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-17.5%

        \[\leadsto x - \color{blue}{\left(-\left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)\right)} \]
      6. remove-double-neg7.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
      16. 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. Add Preprocessing
    5. Taylor expanded in z around 0 98.1%

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

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

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

      \[\leadsto x - \color{blue}{\frac{1}{t} \cdot \mathsf{log1p}\left(y \cdot z\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification94.6%

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

Alternative 3: 93.6% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 79.6%

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

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-179.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
      16. 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. Add Preprocessing
    5. 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}} \]
    6. Applied egg-rr99.9%

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

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

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

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

      \[\leadsto x - \frac{\frac{1}{t}}{\color{blue}{0.5 + \frac{1}{y \cdot \left(e^{z} - 1\right)}}} \]
    10. Step-by-step derivation
      1. associate-/r*88.1%

        \[\leadsto x - \frac{\frac{1}{t}}{0.5 + \color{blue}{\frac{\frac{1}{y}}{e^{z} - 1}}} \]
      2. expm1-def88.1%

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

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

    if -0.024500000000000001 < z

    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. remove-double-neg58.9%

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-158.9%

        \[\leadsto x - \color{blue}{\left(-\left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)\right)} \]
      6. remove-double-neg58.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.0245:\\ \;\;\;\;x + \frac{\frac{-1}{t}}{0.5 + \frac{\frac{1}{y}}{\mathsf{expm1}\left(z\right)}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{-1}{\frac{t}{\mathsf{log1p}\left(y \cdot z\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 92.5% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3300000:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\

\mathbf{elif}\;y \leq 5 \cdot 10^{-5}:\\
\;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -3.3e6

    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. remove-double-neg56.6%

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-156.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x - \frac{1}{\color{blue}{0.5 \cdot t + \frac{t}{y \cdot z}}} \]

    if -3.3e6 < y < 5.00000000000000024e-5

    1. Initial program 79.6%

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

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-179.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000024e-5 < y

    1. Initial program 7.5%

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

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-17.5%

        \[\leadsto x - \color{blue}{\left(-\left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)\right)} \]
      6. remove-double-neg7.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
      16. 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. Add Preprocessing
    5. Taylor expanded in z around 0 98.1%

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

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

Alternative 5: 89.3% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3300000:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\

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


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

    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. remove-double-neg56.6%

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-156.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x - \frac{1}{\color{blue}{0.5 \cdot t + \frac{t}{y \cdot z}}} \]

    if -3.3e6 < y

    1. Initial program 67.6%

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

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-167.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
      16. 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. Add Preprocessing
    5. Taylor expanded in y around 0 83.3%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3300000:\\ \;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 83.0% accurate, 11.7× speedup?

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

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

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


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

    1. Initial program 81.2%

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

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-181.2%

        \[\leadsto x - \color{blue}{\left(-\left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)\right)} \]
      6. remove-double-neg81.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
      16. 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. Add Preprocessing
    5. Taylor expanded in x around inf 68.1%

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

    if -1.4500000000000001e53 < z

    1. Initial program 59.8%

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

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-159.8%

        \[\leadsto x - \color{blue}{\left(-\left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)\right)} \]
      6. remove-double-neg59.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.45 \cdot 10^{+53}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 84.4% accurate, 12.4× speedup?

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

\\
x + \frac{\frac{-1}{t}}{0.5 + \left(\frac{1}{y \cdot z} - \frac{0.5}{y}\right)}
\end{array}
Derivation
  1. Initial program 65.3%

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

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

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

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

      \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
    5. neg-mul-165.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto x - \frac{\frac{1}{t}}{\color{blue}{0.5 + \frac{1}{y \cdot \left(e^{z} - 1\right)}}} \]
  10. Step-by-step derivation
    1. associate-/r*78.5%

      \[\leadsto x - \frac{\frac{1}{t}}{0.5 + \color{blue}{\frac{\frac{1}{y}}{e^{z} - 1}}} \]
    2. expm1-def89.9%

      \[\leadsto x - \frac{\frac{1}{t}}{0.5 + \frac{\frac{1}{y}}{\color{blue}{\mathsf{expm1}\left(z\right)}}} \]
  11. Simplified89.9%

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

    \[\leadsto x - \frac{\frac{1}{t}}{0.5 + \color{blue}{\left(\frac{1}{y \cdot z} - 0.5 \cdot \frac{1}{y}\right)}} \]
  13. Step-by-step derivation
    1. associate-*r/84.6%

      \[\leadsto x - \frac{\frac{1}{t}}{0.5 + \left(\frac{1}{y \cdot z} - \color{blue}{\frac{0.5 \cdot 1}{y}}\right)} \]
    2. metadata-eval84.6%

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

    \[\leadsto x - \frac{\frac{1}{t}}{0.5 + \color{blue}{\left(\frac{1}{y \cdot z} - \frac{0.5}{y}\right)}} \]
  15. Final simplification84.6%

    \[\leadsto x + \frac{\frac{-1}{t}}{0.5 + \left(\frac{1}{y \cdot z} - \frac{0.5}{y}\right)} \]
  16. Add Preprocessing

Alternative 8: 81.9% accurate, 17.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-21}:\\
\;\;\;\;x\\

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


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

    1. Initial program 78.5%

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

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-178.5%

        \[\leadsto x - \color{blue}{\left(-\left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)\right)} \]
      6. remove-double-neg78.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
      16. 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. Add Preprocessing
    5. Taylor expanded in x around inf 66.1%

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

    if -4.99999999999999973e-21 < z

    1. Initial program 58.8%

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

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-158.8%

        \[\leadsto x - \color{blue}{\left(-\left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)\right)} \]
      6. remove-double-neg58.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{-21}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 81.8% accurate, 17.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{-25}:\\
\;\;\;\;x\\

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


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

    1. Initial program 78.5%

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

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-178.5%

        \[\leadsto x - \color{blue}{\left(-\left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)\right)} \]
      6. remove-double-neg78.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \frac{\mathsf{log1p}\left(\color{blue}{y \cdot \left(e^{z} - 1\right)}\right)}{t} \]
      16. 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. Add Preprocessing
    5. Taylor expanded in x around inf 66.1%

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

    if -8.49999999999999981e-25 < z

    1. Initial program 58.8%

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

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

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

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

        \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
      5. neg-mul-158.8%

        \[\leadsto x - \color{blue}{\left(-\left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)\right)} \]
      6. remove-double-neg58.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \color{blue}{\frac{y}{\frac{t}{z}}} \]
    7. Simplified91.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8.5 \cdot 10^{-25}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{z}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 71.6% 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 65.3%

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

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

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

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

      \[\leadsto x - \color{blue}{-1 \cdot \left(-\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\right)} \]
    5. neg-mul-165.3%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{x} \]
  6. Final simplification71.3%

    \[\leadsto x \]
  7. Add Preprocessing

Developer target: 74.6% 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 2024036 
(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)))