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

Percentage Accurate: 60.2% → 98.1%
Time: 21.3s
Alternatives: 11
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 11 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: 60.2% 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.1% 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 57.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 91.1% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 76.2%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-4 < (exp.f64 z)

    1. Initial program 48.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 88.1% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.1 \cdot 10^{+213} \lor \neg \left(y \leq 1.3 \cdot 10^{+113}\right):\\ \;\;\;\;x - \frac{\log \left(y \cdot z + 1\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= y -2.1e+213) (not (<= y 1.3e+113)))
   (- x (/ (log (+ (* y z) 1.0)) t))
   (- x (/ y (/ t (expm1 z))))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -2.1e+213) || !(y <= 1.3e+113)) {
		tmp = x - (log(((y * z) + 1.0)) / t);
	} 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 <= -2.1e+213) || !(y <= 1.3e+113)) {
		tmp = x - (Math.log(((y * z) + 1.0)) / t);
	} else {
		tmp = x - (y / (t / Math.expm1(z)));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (y <= -2.1e+213) or not (y <= 1.3e+113):
		tmp = x - (math.log(((y * z) + 1.0)) / t)
	else:
		tmp = x - (y / (t / math.expm1(z)))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((y <= -2.1e+213) || !(y <= 1.3e+113))
		tmp = Float64(x - Float64(log(Float64(Float64(y * z) + 1.0)) / t));
	else
		tmp = Float64(x - Float64(y / Float64(t / expm1(z))));
	end
	return tmp
end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.1e+213], N[Not[LessEqual[y, 1.3e+113]], $MachinePrecision]], N[(x - N[(N[Log[N[(N[(y * z), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] / t), $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 -2.1 \cdot 10^{+213} \lor \neg \left(y \leq 1.3 \cdot 10^{+113}\right):\\
\;\;\;\;x - \frac{\log \left(y \cdot z + 1\right)}{t}\\

\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 < -2.1000000000000001e213 or 1.3e113 < y

    1. Initial program 15.2%

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

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

    if -2.1000000000000001e213 < y < 1.3e113

    1. Initial program 66.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.1 \cdot 10^{+213} \lor \neg \left(y \leq 1.3 \cdot 10^{+113}\right):\\ \;\;\;\;x - \frac{\log \left(y \cdot z + 1\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 78.1% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_1 := x + \frac{-1}{\frac{-0.5 \cdot \frac{z \cdot t}{y} + \frac{t}{y}}{z}}\\
\mathbf{if}\;z \leq -9.2 \cdot 10^{+254}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;z \leq -5 \cdot 10^{-211}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -9.19999999999999994e254 or -3.6999999999999998e198 < z < -5.0000000000000002e-211

    1. Initial program 63.1%

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

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

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

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

      \[\leadsto x - \color{blue}{y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}} \]
    6. Step-by-step derivation
      1. associate-*r/84.2%

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

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

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

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

    if -9.19999999999999994e254 < z < -3.6999999999999998e198

    1. Initial program 51.8%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-y \cdot \mathsf{expm1}\left(z\right)}}{t} \]
      4. distribute-rgt-neg-in60.0%

        \[\leadsto \frac{\color{blue}{y \cdot \left(-\mathsf{expm1}\left(z\right)\right)}}{t} \]
      5. associate-/l*59.8%

        \[\leadsto \color{blue}{y \cdot \frac{-\mathsf{expm1}\left(z\right)}{t}} \]
      6. distribute-neg-frac59.8%

        \[\leadsto y \cdot \color{blue}{\left(-\frac{\mathsf{expm1}\left(z\right)}{t}\right)} \]
      7. distribute-neg-frac259.8%

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

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

    if -5.0000000000000002e-211 < z

    1. Initial program 51.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 78.2% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_1 := x + \frac{-1}{\frac{-0.5 \cdot \frac{z \cdot t}{y} + \frac{t}{y}}{z}}\\
\mathbf{if}\;z \leq -9.2 \cdot 10^{+254}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;z \leq -4.7 \cdot 10^{-211}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -9.19999999999999994e254 or -3.6999999999999998e198 < z < -4.6999999999999997e-211

    1. Initial program 63.1%

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

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

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

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

      \[\leadsto x - \color{blue}{y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}} \]
    6. Step-by-step derivation
      1. associate-*r/84.2%

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

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

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

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

    if -9.19999999999999994e254 < z < -3.6999999999999998e198

    1. Initial program 51.8%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-y \cdot \mathsf{expm1}\left(z\right)}}{t} \]
      4. distribute-frac-neg60.0%

        \[\leadsto \color{blue}{-\frac{y \cdot \mathsf{expm1}\left(z\right)}{t}} \]
      5. *-commutative60.0%

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

        \[\leadsto -\color{blue}{\mathsf{expm1}\left(z\right) \cdot \frac{y}{t}} \]
      7. distribute-rgt-neg-in60.0%

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

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

    if -4.6999999999999997e-211 < z

    1. Initial program 51.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 85.6% accurate, 2.0× speedup?

\[\begin{array}{l} \\ x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t} \end{array} \]
(FPCore (x y z t) :precision binary64 (- x (* y (/ (expm1 z) t))))
double code(double x, double y, double z, double t) {
	return x - (y * (expm1(z) / t));
}
public static double code(double x, double y, double z, double t) {
	return x - (y * (Math.expm1(z) / t));
}
def code(x, y, z, t):
	return x - (y * (math.expm1(z) / t))
function code(x, y, z, t)
	return Float64(x - Float64(y * Float64(expm1(z) / t)))
end
code[x_, y_, z_, t_] := N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

Alternative 7: 85.7% accurate, 2.0× speedup?

\[\begin{array}{l} \\ x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}} \end{array} \]
(FPCore (x y z t) :precision binary64 (- x (/ y (/ t (expm1 z)))))
double code(double x, double y, double z, double t) {
	return x - (y / (t / expm1(z)));
}
public static double code(double x, double y, double z, double t) {
	return x - (y / (t / Math.expm1(z)));
}
def code(x, y, z, t):
	return x - (y / (t / math.expm1(z)))
function code(x, y, z, t)
	return Float64(x - Float64(y / Float64(t / expm1(z))))
end
code[x_, y_, z_, t_] := N[(x - N[(y / N[(t / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

Alternative 8: 80.2% accurate, 9.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{-211}:\\ \;\;\;\;x + \frac{-1}{\frac{-0.5 \cdot \frac{z \cdot t}{y} + \frac{t}{y}}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \frac{-1}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= z -5e-211)
   (+ x (/ -1.0 (/ (+ (* -0.5 (/ (* z t) y)) (/ t y)) z)))
   (+ x (* (* y z) (/ -1.0 t)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -5e-211) {
		tmp = x + (-1.0 / (((-0.5 * ((z * t) / y)) + (t / y)) / z));
	} else {
		tmp = x + ((y * z) * (-1.0 / t));
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (z <= (-5d-211)) then
        tmp = x + ((-1.0d0) / ((((-0.5d0) * ((z * t) / y)) + (t / y)) / z))
    else
        tmp = x + ((y * z) * ((-1.0d0) / t))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -5e-211) {
		tmp = x + (-1.0 / (((-0.5 * ((z * t) / y)) + (t / y)) / z));
	} else {
		tmp = x + ((y * z) * (-1.0 / t));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if z <= -5e-211:
		tmp = x + (-1.0 / (((-0.5 * ((z * t) / y)) + (t / y)) / z))
	else:
		tmp = x + ((y * z) * (-1.0 / t))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -5e-211)
		tmp = Float64(x + Float64(-1.0 / Float64(Float64(Float64(-0.5 * Float64(Float64(z * t) / y)) + Float64(t / y)) / z)));
	else
		tmp = Float64(x + Float64(Float64(y * z) * Float64(-1.0 / t)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= -5e-211)
		tmp = x + (-1.0 / (((-0.5 * ((z * t) / y)) + (t / y)) / z));
	else
		tmp = x + ((y * z) * (-1.0 / t));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[z, -5e-211], N[(x + N[(-1.0 / N[(N[(N[(-0.5 * N[(N[(z * t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(t / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y * z), $MachinePrecision] * N[(-1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 62.0%

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

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

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

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

      \[\leadsto x - \color{blue}{y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}} \]
    6. Step-by-step derivation
      1. associate-*r/82.5%

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

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

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

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

    if -5.0000000000000002e-211 < z

    1. Initial program 51.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 70.9% accurate, 13.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.7 \cdot 10^{-249}:\\
\;\;\;\;x\\

\mathbf{elif}\;t \leq 6.4 \cdot 10^{-261}:\\
\;\;\;\;\frac{z}{t} \cdot \left(-y\right)\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.6999999999999999e-249 or 6.40000000000000008e-261 < t

    1. Initial program 59.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.6999999999999999e-249 < t < 6.40000000000000008e-261

    1. Initial program 24.5%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\log \left(1 + y \cdot \left(e^{z} - 1\right)\right)}{t}} \]
    6. Step-by-step derivation
      1. mul-1-neg18.7%

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{y \cdot z}{t}} \]
    9. Step-by-step derivation
      1. mul-1-neg59.4%

        \[\leadsto \color{blue}{-\frac{y \cdot z}{t}} \]
      2. associate-/l*63.5%

        \[\leadsto -\color{blue}{y \cdot \frac{z}{t}} \]
      3. distribute-rgt-neg-in63.5%

        \[\leadsto \color{blue}{y \cdot \left(-\frac{z}{t}\right)} \]
    10. Simplified63.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.7 \cdot 10^{-249}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 6.4 \cdot 10^{-261}:\\ \;\;\;\;\frac{z}{t} \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 80.9% accurate, 17.6× speedup?

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

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

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


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

    1. Initial program 72.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.85e86 < z

    1. Initial program 53.5%

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

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

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

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

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

Alternative 11: 70.5% 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 57.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto x \]
  7. Add Preprocessing

Developer target: 73.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 2024078 
(FPCore (x y z t)
  :name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
  :precision binary64

  :alt
  (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)))