Jmat.Real.lambertw, newton loop step

Percentage Accurate: 78.9% → 99.0%
Time: 12.3s
Alternatives: 18
Speedup: 313.0×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := wj \cdot e^{wj}\\ wj - \frac{t_0 - x}{e^{wj} + t_0} \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (let* ((t_0 (* wj (exp wj)))) (- wj (/ (- t_0 x) (+ (exp wj) t_0)))))
double code(double wj, double x) {
	double t_0 = wj * exp(wj);
	return wj - ((t_0 - x) / (exp(wj) + t_0));
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    real(8) :: t_0
    t_0 = wj * exp(wj)
    code = wj - ((t_0 - x) / (exp(wj) + t_0))
end function
public static double code(double wj, double x) {
	double t_0 = wj * Math.exp(wj);
	return wj - ((t_0 - x) / (Math.exp(wj) + t_0));
}
def code(wj, x):
	t_0 = wj * math.exp(wj)
	return wj - ((t_0 - x) / (math.exp(wj) + t_0))
function code(wj, x)
	t_0 = Float64(wj * exp(wj))
	return Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0)))
end
function tmp = code(wj, x)
	t_0 = wj * exp(wj);
	tmp = wj - ((t_0 - x) / (exp(wj) + t_0));
end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
wj - \frac{t_0 - x}{e^{wj} + t_0}
\end{array}
\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 18 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: 78.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := wj \cdot e^{wj}\\ wj - \frac{t_0 - x}{e^{wj} + t_0} \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (let* ((t_0 (* wj (exp wj)))) (- wj (/ (- t_0 x) (+ (exp wj) t_0)))))
double code(double wj, double x) {
	double t_0 = wj * exp(wj);
	return wj - ((t_0 - x) / (exp(wj) + t_0));
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    real(8) :: t_0
    t_0 = wj * exp(wj)
    code = wj - ((t_0 - x) / (exp(wj) + t_0))
end function
public static double code(double wj, double x) {
	double t_0 = wj * Math.exp(wj);
	return wj - ((t_0 - x) / (Math.exp(wj) + t_0));
}
def code(wj, x):
	t_0 = wj * math.exp(wj)
	return wj - ((t_0 - x) / (math.exp(wj) + t_0))
function code(wj, x)
	t_0 = Float64(wj * exp(wj))
	return Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0)))
end
function tmp = code(wj, x)
	t_0 = wj * exp(wj);
	tmp = wj - ((t_0 - x) / (exp(wj) + t_0));
end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
wj - \frac{t_0 - x}{e^{wj} + t_0}
\end{array}
\end{array}

Alternative 1: 99.0% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := wj \cdot e^{wj}\\ \mathbf{if}\;wj + \frac{x - t_0}{e^{wj} + t_0} \leq 4 \cdot 10^{-9}:\\ \;\;\;\;\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} + \left(\left({wj}^{4} - \left({wj}^{3} - {wj}^{2}\right)\right) - {wj}^{5}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right)\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (let* ((t_0 (* wj (exp wj))))
   (if (<= (+ wj (/ (- x t_0) (+ (exp wj) t_0))) 4e-9)
     (+
      (/ x (exp (+ wj (log1p wj))))
      (- (- (pow wj 4.0) (- (pow wj 3.0) (pow wj 2.0))) (pow wj 5.0)))
     (+ (/ x (* (exp wj) (+ wj 1.0))) (- wj (/ wj (+ wj 1.0)))))))
double code(double wj, double x) {
	double t_0 = wj * exp(wj);
	double tmp;
	if ((wj + ((x - t_0) / (exp(wj) + t_0))) <= 4e-9) {
		tmp = (x / exp((wj + log1p(wj)))) + ((pow(wj, 4.0) - (pow(wj, 3.0) - pow(wj, 2.0))) - pow(wj, 5.0));
	} else {
		tmp = (x / (exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)));
	}
	return tmp;
}
public static double code(double wj, double x) {
	double t_0 = wj * Math.exp(wj);
	double tmp;
	if ((wj + ((x - t_0) / (Math.exp(wj) + t_0))) <= 4e-9) {
		tmp = (x / Math.exp((wj + Math.log1p(wj)))) + ((Math.pow(wj, 4.0) - (Math.pow(wj, 3.0) - Math.pow(wj, 2.0))) - Math.pow(wj, 5.0));
	} else {
		tmp = (x / (Math.exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)));
	}
	return tmp;
}
def code(wj, x):
	t_0 = wj * math.exp(wj)
	tmp = 0
	if (wj + ((x - t_0) / (math.exp(wj) + t_0))) <= 4e-9:
		tmp = (x / math.exp((wj + math.log1p(wj)))) + ((math.pow(wj, 4.0) - (math.pow(wj, 3.0) - math.pow(wj, 2.0))) - math.pow(wj, 5.0))
	else:
		tmp = (x / (math.exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)))
	return tmp
function code(wj, x)
	t_0 = Float64(wj * exp(wj))
	tmp = 0.0
	if (Float64(wj + Float64(Float64(x - t_0) / Float64(exp(wj) + t_0))) <= 4e-9)
		tmp = Float64(Float64(x / exp(Float64(wj + log1p(wj)))) + Float64(Float64((wj ^ 4.0) - Float64((wj ^ 3.0) - (wj ^ 2.0))) - (wj ^ 5.0)));
	else
		tmp = Float64(Float64(x / Float64(exp(wj) * Float64(wj + 1.0))) + Float64(wj - Float64(wj / Float64(wj + 1.0))));
	end
	return tmp
end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(wj + N[(N[(x - t$95$0), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e-9], N[(N[(x / N[Exp[N[(wj + N[Log[1 + wj], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[wj, 4.0], $MachinePrecision] - N[(N[Power[wj, 3.0], $MachinePrecision] - N[Power[wj, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[wj, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(wj - N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
\mathbf{if}\;wj + \frac{x - t_0}{e^{wj} + t_0} \leq 4 \cdot 10^{-9}:\\
\;\;\;\;\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} + \left(\left({wj}^{4} - \left({wj}^{3} - {wj}^{2}\right)\right) - {wj}^{5}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 4.00000000000000025e-9

    1. Initial program 72.7%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg72.7%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub72.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg72.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative72.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in72.7%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg72.7%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg72.7%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub72.7%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in73.3%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/73.3%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified73.3%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Step-by-step derivation
      1. +-commutative73.3%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}} - wj}{wj + 1} + wj} \]
      2. div-sub73.3%

        \[\leadsto \color{blue}{\left(\frac{\frac{x}{e^{wj}}}{wj + 1} - \frac{wj}{wj + 1}\right)} + wj \]
      3. associate-+l-85.9%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}}}{wj + 1} - \left(\frac{wj}{wj + 1} - wj\right)} \]
      4. associate-/l/85.9%

        \[\leadsto \color{blue}{\frac{x}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      5. *-commutative85.9%

        \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot \left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      6. add-exp-log84.8%

        \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{e^{\log \left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      7. +-commutative84.8%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      8. log1p-udef84.8%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      9. prod-exp84.8%

        \[\leadsto \frac{x}{\color{blue}{e^{wj + \mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    5. Applied egg-rr84.8%

      \[\leadsto \color{blue}{\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\frac{wj}{wj + 1} - wj\right)} \]
    6. Taylor expanded in wj around 0 98.9%

      \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\left({wj}^{5} + \left(-1 \cdot {wj}^{4} + \left(-1 \cdot {wj}^{2} + {wj}^{3}\right)\right)\right)} \]

    if 4.00000000000000025e-9 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))))

    1. Initial program 95.6%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg95.6%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub95.6%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg95.6%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative95.6%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in95.6%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg95.6%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg95.6%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub95.6%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in98.4%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/98.3%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Step-by-step derivation
      1. +-commutative99.7%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}} - wj}{wj + 1} + wj} \]
      2. div-sub99.7%

        \[\leadsto \color{blue}{\left(\frac{\frac{x}{e^{wj}}}{wj + 1} - \frac{wj}{wj + 1}\right)} + wj \]
      3. associate-+l-99.7%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}}}{wj + 1} - \left(\frac{wj}{wj + 1} - wj\right)} \]
      4. associate-/l/99.8%

        \[\leadsto \color{blue}{\frac{x}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      5. *-commutative99.8%

        \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot \left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      6. add-exp-log97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{e^{\log \left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      7. +-commutative97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      8. log1p-udef97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      9. prod-exp96.9%

        \[\leadsto \frac{x}{\color{blue}{e^{wj + \mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    5. Applied egg-rr96.9%

      \[\leadsto \color{blue}{\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\frac{wj}{wj + 1} - wj\right)} \]
    6. Step-by-step derivation
      1. exp-sum97.0%

        \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot e^{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      2. log1p-udef97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\log \left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      3. +-commutative97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      4. add-exp-log99.8%

        \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{\left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      5. *-commutative99.8%

        \[\leadsto \frac{x}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      6. +-commutative99.8%

        \[\leadsto \frac{x}{\color{blue}{\left(1 + wj\right)} \cdot e^{wj}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    7. Applied egg-rr99.8%

      \[\leadsto \frac{x}{\color{blue}{\left(1 + wj\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;wj + \frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} \leq 4 \cdot 10^{-9}:\\ \;\;\;\;\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} + \left(\left({wj}^{4} - \left({wj}^{3} - {wj}^{2}\right)\right) - {wj}^{5}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right)\\ \end{array} \]

Alternative 2: 99.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := wj \cdot e^{wj}\\ \mathbf{if}\;wj + \frac{x - t_0}{e^{wj} + t_0} \leq 4 \cdot 10^{-9}:\\ \;\;\;\;\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} + \left(\left(wj \cdot wj - {wj}^{3}\right) + \left({wj}^{4} - {wj}^{5}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right)\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (let* ((t_0 (* wj (exp wj))))
   (if (<= (+ wj (/ (- x t_0) (+ (exp wj) t_0))) 4e-9)
     (+
      (/ x (exp (+ wj (log1p wj))))
      (+ (- (* wj wj) (pow wj 3.0)) (- (pow wj 4.0) (pow wj 5.0))))
     (+ (/ x (* (exp wj) (+ wj 1.0))) (- wj (/ wj (+ wj 1.0)))))))
double code(double wj, double x) {
	double t_0 = wj * exp(wj);
	double tmp;
	if ((wj + ((x - t_0) / (exp(wj) + t_0))) <= 4e-9) {
		tmp = (x / exp((wj + log1p(wj)))) + (((wj * wj) - pow(wj, 3.0)) + (pow(wj, 4.0) - pow(wj, 5.0)));
	} else {
		tmp = (x / (exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)));
	}
	return tmp;
}
public static double code(double wj, double x) {
	double t_0 = wj * Math.exp(wj);
	double tmp;
	if ((wj + ((x - t_0) / (Math.exp(wj) + t_0))) <= 4e-9) {
		tmp = (x / Math.exp((wj + Math.log1p(wj)))) + (((wj * wj) - Math.pow(wj, 3.0)) + (Math.pow(wj, 4.0) - Math.pow(wj, 5.0)));
	} else {
		tmp = (x / (Math.exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)));
	}
	return tmp;
}
def code(wj, x):
	t_0 = wj * math.exp(wj)
	tmp = 0
	if (wj + ((x - t_0) / (math.exp(wj) + t_0))) <= 4e-9:
		tmp = (x / math.exp((wj + math.log1p(wj)))) + (((wj * wj) - math.pow(wj, 3.0)) + (math.pow(wj, 4.0) - math.pow(wj, 5.0)))
	else:
		tmp = (x / (math.exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)))
	return tmp
function code(wj, x)
	t_0 = Float64(wj * exp(wj))
	tmp = 0.0
	if (Float64(wj + Float64(Float64(x - t_0) / Float64(exp(wj) + t_0))) <= 4e-9)
		tmp = Float64(Float64(x / exp(Float64(wj + log1p(wj)))) + Float64(Float64(Float64(wj * wj) - (wj ^ 3.0)) + Float64((wj ^ 4.0) - (wj ^ 5.0))));
	else
		tmp = Float64(Float64(x / Float64(exp(wj) * Float64(wj + 1.0))) + Float64(wj - Float64(wj / Float64(wj + 1.0))));
	end
	return tmp
end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(wj + N[(N[(x - t$95$0), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e-9], N[(N[(x / N[Exp[N[(wj + N[Log[1 + wj], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(wj * wj), $MachinePrecision] - N[Power[wj, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 4.0], $MachinePrecision] - N[Power[wj, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(wj - N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
\mathbf{if}\;wj + \frac{x - t_0}{e^{wj} + t_0} \leq 4 \cdot 10^{-9}:\\
\;\;\;\;\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} + \left(\left(wj \cdot wj - {wj}^{3}\right) + \left({wj}^{4} - {wj}^{5}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 4.00000000000000025e-9

    1. Initial program 72.7%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg72.7%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub72.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg72.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative72.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in72.7%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg72.7%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg72.7%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub72.7%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in73.3%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/73.3%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified73.3%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Step-by-step derivation
      1. +-commutative73.3%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}} - wj}{wj + 1} + wj} \]
      2. div-sub73.3%

        \[\leadsto \color{blue}{\left(\frac{\frac{x}{e^{wj}}}{wj + 1} - \frac{wj}{wj + 1}\right)} + wj \]
      3. associate-+l-85.9%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}}}{wj + 1} - \left(\frac{wj}{wj + 1} - wj\right)} \]
      4. associate-/l/85.9%

        \[\leadsto \color{blue}{\frac{x}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      5. *-commutative85.9%

        \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot \left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      6. add-exp-log84.8%

        \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{e^{\log \left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      7. +-commutative84.8%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      8. log1p-udef84.8%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      9. prod-exp84.8%

        \[\leadsto \frac{x}{\color{blue}{e^{wj + \mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    5. Applied egg-rr84.8%

      \[\leadsto \color{blue}{\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\frac{wj}{wj + 1} - wj\right)} \]
    6. Taylor expanded in wj around 0 98.9%

      \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\left({wj}^{5} + \left(-1 \cdot {wj}^{4} + \left(-1 \cdot {wj}^{2} + {wj}^{3}\right)\right)\right)} \]
    7. Step-by-step derivation
      1. associate-+r+98.9%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\left(\left({wj}^{5} + -1 \cdot {wj}^{4}\right) + \left(-1 \cdot {wj}^{2} + {wj}^{3}\right)\right)} \]
      2. +-commutative98.9%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\left(\left(-1 \cdot {wj}^{2} + {wj}^{3}\right) + \left({wj}^{5} + -1 \cdot {wj}^{4}\right)\right)} \]
      3. +-commutative98.9%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\color{blue}{\left({wj}^{3} + -1 \cdot {wj}^{2}\right)} + \left({wj}^{5} + -1 \cdot {wj}^{4}\right)\right) \]
      4. mul-1-neg98.9%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\left({wj}^{3} + \color{blue}{\left(-{wj}^{2}\right)}\right) + \left({wj}^{5} + -1 \cdot {wj}^{4}\right)\right) \]
      5. unsub-neg98.9%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\color{blue}{\left({wj}^{3} - {wj}^{2}\right)} + \left({wj}^{5} + -1 \cdot {wj}^{4}\right)\right) \]
      6. unpow298.9%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\left({wj}^{3} - \color{blue}{wj \cdot wj}\right) + \left({wj}^{5} + -1 \cdot {wj}^{4}\right)\right) \]
      7. mul-1-neg98.9%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\left({wj}^{3} - wj \cdot wj\right) + \left({wj}^{5} + \color{blue}{\left(-{wj}^{4}\right)}\right)\right) \]
      8. unsub-neg98.9%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\left({wj}^{3} - wj \cdot wj\right) + \color{blue}{\left({wj}^{5} - {wj}^{4}\right)}\right) \]
    8. Simplified98.9%

      \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\left(\left({wj}^{3} - wj \cdot wj\right) + \left({wj}^{5} - {wj}^{4}\right)\right)} \]

    if 4.00000000000000025e-9 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))))

    1. Initial program 95.6%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg95.6%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub95.6%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg95.6%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative95.6%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in95.6%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg95.6%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg95.6%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub95.6%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in98.4%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/98.3%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Step-by-step derivation
      1. +-commutative99.7%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}} - wj}{wj + 1} + wj} \]
      2. div-sub99.7%

        \[\leadsto \color{blue}{\left(\frac{\frac{x}{e^{wj}}}{wj + 1} - \frac{wj}{wj + 1}\right)} + wj \]
      3. associate-+l-99.7%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}}}{wj + 1} - \left(\frac{wj}{wj + 1} - wj\right)} \]
      4. associate-/l/99.8%

        \[\leadsto \color{blue}{\frac{x}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      5. *-commutative99.8%

        \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot \left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      6. add-exp-log97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{e^{\log \left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      7. +-commutative97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      8. log1p-udef97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      9. prod-exp96.9%

        \[\leadsto \frac{x}{\color{blue}{e^{wj + \mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    5. Applied egg-rr96.9%

      \[\leadsto \color{blue}{\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\frac{wj}{wj + 1} - wj\right)} \]
    6. Step-by-step derivation
      1. exp-sum97.0%

        \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot e^{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      2. log1p-udef97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\log \left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      3. +-commutative97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      4. add-exp-log99.8%

        \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{\left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      5. *-commutative99.8%

        \[\leadsto \frac{x}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      6. +-commutative99.8%

        \[\leadsto \frac{x}{\color{blue}{\left(1 + wj\right)} \cdot e^{wj}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    7. Applied egg-rr99.8%

      \[\leadsto \frac{x}{\color{blue}{\left(1 + wj\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;wj + \frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} \leq 4 \cdot 10^{-9}:\\ \;\;\;\;\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} + \left(\left(wj \cdot wj - {wj}^{3}\right) + \left({wj}^{4} - {wj}^{5}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right)\\ \end{array} \]

Alternative 3: 99.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := wj \cdot e^{wj}\\ \mathbf{if}\;wj + \frac{x - t_0}{e^{wj} + t_0} \leq 4 \cdot 10^{-9}:\\ \;\;\;\;\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} + \left({wj}^{4} - \left({wj}^{3} - wj \cdot wj\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right)\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (let* ((t_0 (* wj (exp wj))))
   (if (<= (+ wj (/ (- x t_0) (+ (exp wj) t_0))) 4e-9)
     (+
      (/ x (exp (+ wj (log1p wj))))
      (- (pow wj 4.0) (- (pow wj 3.0) (* wj wj))))
     (+ (/ x (* (exp wj) (+ wj 1.0))) (- wj (/ wj (+ wj 1.0)))))))
double code(double wj, double x) {
	double t_0 = wj * exp(wj);
	double tmp;
	if ((wj + ((x - t_0) / (exp(wj) + t_0))) <= 4e-9) {
		tmp = (x / exp((wj + log1p(wj)))) + (pow(wj, 4.0) - (pow(wj, 3.0) - (wj * wj)));
	} else {
		tmp = (x / (exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)));
	}
	return tmp;
}
public static double code(double wj, double x) {
	double t_0 = wj * Math.exp(wj);
	double tmp;
	if ((wj + ((x - t_0) / (Math.exp(wj) + t_0))) <= 4e-9) {
		tmp = (x / Math.exp((wj + Math.log1p(wj)))) + (Math.pow(wj, 4.0) - (Math.pow(wj, 3.0) - (wj * wj)));
	} else {
		tmp = (x / (Math.exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)));
	}
	return tmp;
}
def code(wj, x):
	t_0 = wj * math.exp(wj)
	tmp = 0
	if (wj + ((x - t_0) / (math.exp(wj) + t_0))) <= 4e-9:
		tmp = (x / math.exp((wj + math.log1p(wj)))) + (math.pow(wj, 4.0) - (math.pow(wj, 3.0) - (wj * wj)))
	else:
		tmp = (x / (math.exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)))
	return tmp
function code(wj, x)
	t_0 = Float64(wj * exp(wj))
	tmp = 0.0
	if (Float64(wj + Float64(Float64(x - t_0) / Float64(exp(wj) + t_0))) <= 4e-9)
		tmp = Float64(Float64(x / exp(Float64(wj + log1p(wj)))) + Float64((wj ^ 4.0) - Float64((wj ^ 3.0) - Float64(wj * wj))));
	else
		tmp = Float64(Float64(x / Float64(exp(wj) * Float64(wj + 1.0))) + Float64(wj - Float64(wj / Float64(wj + 1.0))));
	end
	return tmp
end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(wj + N[(N[(x - t$95$0), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e-9], N[(N[(x / N[Exp[N[(wj + N[Log[1 + wj], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 4.0], $MachinePrecision] - N[(N[Power[wj, 3.0], $MachinePrecision] - N[(wj * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(wj - N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
\mathbf{if}\;wj + \frac{x - t_0}{e^{wj} + t_0} \leq 4 \cdot 10^{-9}:\\
\;\;\;\;\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} + \left({wj}^{4} - \left({wj}^{3} - wj \cdot wj\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 4.00000000000000025e-9

    1. Initial program 72.7%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg72.7%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub72.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg72.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative72.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in72.7%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg72.7%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg72.7%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub72.7%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in73.3%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/73.3%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified73.3%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Step-by-step derivation
      1. +-commutative73.3%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}} - wj}{wj + 1} + wj} \]
      2. div-sub73.3%

        \[\leadsto \color{blue}{\left(\frac{\frac{x}{e^{wj}}}{wj + 1} - \frac{wj}{wj + 1}\right)} + wj \]
      3. associate-+l-85.9%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}}}{wj + 1} - \left(\frac{wj}{wj + 1} - wj\right)} \]
      4. associate-/l/85.9%

        \[\leadsto \color{blue}{\frac{x}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      5. *-commutative85.9%

        \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot \left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      6. add-exp-log84.8%

        \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{e^{\log \left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      7. +-commutative84.8%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      8. log1p-udef84.8%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      9. prod-exp84.8%

        \[\leadsto \frac{x}{\color{blue}{e^{wj + \mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    5. Applied egg-rr84.8%

      \[\leadsto \color{blue}{\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\frac{wj}{wj + 1} - wj\right)} \]
    6. Taylor expanded in wj around 0 98.8%

      \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\left(-1 \cdot {wj}^{4} + \left(-1 \cdot {wj}^{2} + {wj}^{3}\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutative98.8%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\left(\left(-1 \cdot {wj}^{2} + {wj}^{3}\right) + -1 \cdot {wj}^{4}\right)} \]
      2. mul-1-neg98.8%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\left(-1 \cdot {wj}^{2} + {wj}^{3}\right) + \color{blue}{\left(-{wj}^{4}\right)}\right) \]
      3. unsub-neg98.8%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\left(\left(-1 \cdot {wj}^{2} + {wj}^{3}\right) - {wj}^{4}\right)} \]
      4. +-commutative98.8%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\color{blue}{\left({wj}^{3} + -1 \cdot {wj}^{2}\right)} - {wj}^{4}\right) \]
      5. mul-1-neg98.8%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\left({wj}^{3} + \color{blue}{\left(-{wj}^{2}\right)}\right) - {wj}^{4}\right) \]
      6. unsub-neg98.8%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\color{blue}{\left({wj}^{3} - {wj}^{2}\right)} - {wj}^{4}\right) \]
      7. unpow298.8%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\left({wj}^{3} - \color{blue}{wj \cdot wj}\right) - {wj}^{4}\right) \]
    8. Simplified98.8%

      \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\left(\left({wj}^{3} - wj \cdot wj\right) - {wj}^{4}\right)} \]

    if 4.00000000000000025e-9 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))))

    1. Initial program 95.6%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg95.6%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub95.6%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg95.6%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative95.6%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in95.6%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg95.6%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg95.6%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub95.6%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in98.4%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/98.3%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Step-by-step derivation
      1. +-commutative99.7%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}} - wj}{wj + 1} + wj} \]
      2. div-sub99.7%

        \[\leadsto \color{blue}{\left(\frac{\frac{x}{e^{wj}}}{wj + 1} - \frac{wj}{wj + 1}\right)} + wj \]
      3. associate-+l-99.7%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}}}{wj + 1} - \left(\frac{wj}{wj + 1} - wj\right)} \]
      4. associate-/l/99.8%

        \[\leadsto \color{blue}{\frac{x}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      5. *-commutative99.8%

        \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot \left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      6. add-exp-log97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{e^{\log \left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      7. +-commutative97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      8. log1p-udef97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      9. prod-exp96.9%

        \[\leadsto \frac{x}{\color{blue}{e^{wj + \mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    5. Applied egg-rr96.9%

      \[\leadsto \color{blue}{\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\frac{wj}{wj + 1} - wj\right)} \]
    6. Step-by-step derivation
      1. exp-sum97.0%

        \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot e^{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      2. log1p-udef97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\log \left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      3. +-commutative97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      4. add-exp-log99.8%

        \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{\left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      5. *-commutative99.8%

        \[\leadsto \frac{x}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      6. +-commutative99.8%

        \[\leadsto \frac{x}{\color{blue}{\left(1 + wj\right)} \cdot e^{wj}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    7. Applied egg-rr99.8%

      \[\leadsto \frac{x}{\color{blue}{\left(1 + wj\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;wj + \frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} \leq 4 \cdot 10^{-9}:\\ \;\;\;\;\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} + \left({wj}^{4} - \left({wj}^{3} - wj \cdot wj\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right)\\ \end{array} \]

Alternative 4: 98.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := wj \cdot e^{wj}\\ \mathbf{if}\;wj + \frac{x - t_0}{e^{wj} + t_0} \leq 4 \cdot 10^{-9}:\\ \;\;\;\;\frac{x}{wj \cdot 2 + 1} + \left({wj}^{4} - \left({wj}^{3} - wj \cdot wj\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right)\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (let* ((t_0 (* wj (exp wj))))
   (if (<= (+ wj (/ (- x t_0) (+ (exp wj) t_0))) 4e-9)
     (+ (/ x (+ (* wj 2.0) 1.0)) (- (pow wj 4.0) (- (pow wj 3.0) (* wj wj))))
     (+ (/ x (* (exp wj) (+ wj 1.0))) (- wj (/ wj (+ wj 1.0)))))))
double code(double wj, double x) {
	double t_0 = wj * exp(wj);
	double tmp;
	if ((wj + ((x - t_0) / (exp(wj) + t_0))) <= 4e-9) {
		tmp = (x / ((wj * 2.0) + 1.0)) + (pow(wj, 4.0) - (pow(wj, 3.0) - (wj * wj)));
	} else {
		tmp = (x / (exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)));
	}
	return tmp;
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: tmp
    t_0 = wj * exp(wj)
    if ((wj + ((x - t_0) / (exp(wj) + t_0))) <= 4d-9) then
        tmp = (x / ((wj * 2.0d0) + 1.0d0)) + ((wj ** 4.0d0) - ((wj ** 3.0d0) - (wj * wj)))
    else
        tmp = (x / (exp(wj) * (wj + 1.0d0))) + (wj - (wj / (wj + 1.0d0)))
    end if
    code = tmp
end function
public static double code(double wj, double x) {
	double t_0 = wj * Math.exp(wj);
	double tmp;
	if ((wj + ((x - t_0) / (Math.exp(wj) + t_0))) <= 4e-9) {
		tmp = (x / ((wj * 2.0) + 1.0)) + (Math.pow(wj, 4.0) - (Math.pow(wj, 3.0) - (wj * wj)));
	} else {
		tmp = (x / (Math.exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)));
	}
	return tmp;
}
def code(wj, x):
	t_0 = wj * math.exp(wj)
	tmp = 0
	if (wj + ((x - t_0) / (math.exp(wj) + t_0))) <= 4e-9:
		tmp = (x / ((wj * 2.0) + 1.0)) + (math.pow(wj, 4.0) - (math.pow(wj, 3.0) - (wj * wj)))
	else:
		tmp = (x / (math.exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)))
	return tmp
function code(wj, x)
	t_0 = Float64(wj * exp(wj))
	tmp = 0.0
	if (Float64(wj + Float64(Float64(x - t_0) / Float64(exp(wj) + t_0))) <= 4e-9)
		tmp = Float64(Float64(x / Float64(Float64(wj * 2.0) + 1.0)) + Float64((wj ^ 4.0) - Float64((wj ^ 3.0) - Float64(wj * wj))));
	else
		tmp = Float64(Float64(x / Float64(exp(wj) * Float64(wj + 1.0))) + Float64(wj - Float64(wj / Float64(wj + 1.0))));
	end
	return tmp
end
function tmp_2 = code(wj, x)
	t_0 = wj * exp(wj);
	tmp = 0.0;
	if ((wj + ((x - t_0) / (exp(wj) + t_0))) <= 4e-9)
		tmp = (x / ((wj * 2.0) + 1.0)) + ((wj ^ 4.0) - ((wj ^ 3.0) - (wj * wj)));
	else
		tmp = (x / (exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)));
	end
	tmp_2 = tmp;
end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(wj + N[(N[(x - t$95$0), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e-9], N[(N[(x / N[(N[(wj * 2.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 4.0], $MachinePrecision] - N[(N[Power[wj, 3.0], $MachinePrecision] - N[(wj * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(wj - N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
\mathbf{if}\;wj + \frac{x - t_0}{e^{wj} + t_0} \leq 4 \cdot 10^{-9}:\\
\;\;\;\;\frac{x}{wj \cdot 2 + 1} + \left({wj}^{4} - \left({wj}^{3} - wj \cdot wj\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 4.00000000000000025e-9

    1. Initial program 72.7%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg72.7%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub72.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg72.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative72.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in72.7%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg72.7%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg72.7%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub72.7%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in73.3%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/73.3%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified73.3%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Step-by-step derivation
      1. +-commutative73.3%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}} - wj}{wj + 1} + wj} \]
      2. div-sub73.3%

        \[\leadsto \color{blue}{\left(\frac{\frac{x}{e^{wj}}}{wj + 1} - \frac{wj}{wj + 1}\right)} + wj \]
      3. associate-+l-85.9%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}}}{wj + 1} - \left(\frac{wj}{wj + 1} - wj\right)} \]
      4. associate-/l/85.9%

        \[\leadsto \color{blue}{\frac{x}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      5. *-commutative85.9%

        \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot \left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      6. add-exp-log84.8%

        \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{e^{\log \left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      7. +-commutative84.8%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      8. log1p-udef84.8%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      9. prod-exp84.8%

        \[\leadsto \frac{x}{\color{blue}{e^{wj + \mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    5. Applied egg-rr84.8%

      \[\leadsto \color{blue}{\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\frac{wj}{wj + 1} - wj\right)} \]
    6. Taylor expanded in wj around 0 98.8%

      \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\left(-1 \cdot {wj}^{4} + \left(-1 \cdot {wj}^{2} + {wj}^{3}\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutative98.8%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\left(\left(-1 \cdot {wj}^{2} + {wj}^{3}\right) + -1 \cdot {wj}^{4}\right)} \]
      2. mul-1-neg98.8%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\left(-1 \cdot {wj}^{2} + {wj}^{3}\right) + \color{blue}{\left(-{wj}^{4}\right)}\right) \]
      3. unsub-neg98.8%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\left(\left(-1 \cdot {wj}^{2} + {wj}^{3}\right) - {wj}^{4}\right)} \]
      4. +-commutative98.8%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\color{blue}{\left({wj}^{3} + -1 \cdot {wj}^{2}\right)} - {wj}^{4}\right) \]
      5. mul-1-neg98.8%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\left({wj}^{3} + \color{blue}{\left(-{wj}^{2}\right)}\right) - {wj}^{4}\right) \]
      6. unsub-neg98.8%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\color{blue}{\left({wj}^{3} - {wj}^{2}\right)} - {wj}^{4}\right) \]
      7. unpow298.8%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\left({wj}^{3} - \color{blue}{wj \cdot wj}\right) - {wj}^{4}\right) \]
    8. Simplified98.8%

      \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\left(\left({wj}^{3} - wj \cdot wj\right) - {wj}^{4}\right)} \]
    9. Taylor expanded in wj around 0 98.7%

      \[\leadsto \frac{x}{\color{blue}{1 + 2 \cdot wj}} - \left(\left({wj}^{3} - wj \cdot wj\right) - {wj}^{4}\right) \]
    10. Step-by-step derivation
      1. *-commutative84.7%

        \[\leadsto \frac{x}{1 + \color{blue}{wj \cdot 2}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{1 + wj} + wj} \]
    11. Simplified98.7%

      \[\leadsto \frac{x}{\color{blue}{1 + wj \cdot 2}} - \left(\left({wj}^{3} - wj \cdot wj\right) - {wj}^{4}\right) \]

    if 4.00000000000000025e-9 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))))

    1. Initial program 95.6%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg95.6%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub95.6%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg95.6%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative95.6%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in95.6%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg95.6%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg95.6%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub95.6%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in98.4%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/98.3%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Step-by-step derivation
      1. +-commutative99.7%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}} - wj}{wj + 1} + wj} \]
      2. div-sub99.7%

        \[\leadsto \color{blue}{\left(\frac{\frac{x}{e^{wj}}}{wj + 1} - \frac{wj}{wj + 1}\right)} + wj \]
      3. associate-+l-99.7%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}}}{wj + 1} - \left(\frac{wj}{wj + 1} - wj\right)} \]
      4. associate-/l/99.8%

        \[\leadsto \color{blue}{\frac{x}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      5. *-commutative99.8%

        \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot \left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      6. add-exp-log97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{e^{\log \left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      7. +-commutative97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      8. log1p-udef97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      9. prod-exp96.9%

        \[\leadsto \frac{x}{\color{blue}{e^{wj + \mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    5. Applied egg-rr96.9%

      \[\leadsto \color{blue}{\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\frac{wj}{wj + 1} - wj\right)} \]
    6. Step-by-step derivation
      1. exp-sum97.0%

        \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot e^{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      2. log1p-udef97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\log \left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      3. +-commutative97.0%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      4. add-exp-log99.8%

        \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{\left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      5. *-commutative99.8%

        \[\leadsto \frac{x}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      6. +-commutative99.8%

        \[\leadsto \frac{x}{\color{blue}{\left(1 + wj\right)} \cdot e^{wj}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    7. Applied egg-rr99.8%

      \[\leadsto \frac{x}{\color{blue}{\left(1 + wj\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;wj + \frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} \leq 4 \cdot 10^{-9}:\\ \;\;\;\;\frac{x}{wj \cdot 2 + 1} + \left({wj}^{4} - \left({wj}^{3} - wj \cdot wj\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right)\\ \end{array} \]

Alternative 5: 97.3% accurate, 2.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2.4 \cdot 10^{-39}:\\ \;\;\;\;{wj}^{3} \cdot \left(\left(\left(-1 - -2 \cdot \left(x \cdot -4 + x \cdot 1.5\right)\right) - x \cdot -3\right) - x \cdot 0.6666666666666666\right) + \left(\left(wj \cdot wj\right) \cdot \left(1 - x \cdot -2.5\right) + \left(x + -2 \cdot \left(wj \cdot x\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (if (<= x 2.4e-39)
   (+
    (*
     (pow wj 3.0)
     (-
      (- (- -1.0 (* -2.0 (+ (* x -4.0) (* x 1.5)))) (* x -3.0))
      (* x 0.6666666666666666)))
    (+ (* (* wj wj) (- 1.0 (* x -2.5))) (+ x (* -2.0 (* wj x)))))
   (+ wj (/ (- (* x (exp (- wj))) wj) (+ wj 1.0)))))
double code(double wj, double x) {
	double tmp;
	if (x <= 2.4e-39) {
		tmp = (pow(wj, 3.0) * (((-1.0 - (-2.0 * ((x * -4.0) + (x * 1.5)))) - (x * -3.0)) - (x * 0.6666666666666666))) + (((wj * wj) * (1.0 - (x * -2.5))) + (x + (-2.0 * (wj * x))));
	} else {
		tmp = wj + (((x * exp(-wj)) - wj) / (wj + 1.0));
	}
	return tmp;
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 2.4d-39) then
        tmp = ((wj ** 3.0d0) * ((((-1.0d0) - ((-2.0d0) * ((x * (-4.0d0)) + (x * 1.5d0)))) - (x * (-3.0d0))) - (x * 0.6666666666666666d0))) + (((wj * wj) * (1.0d0 - (x * (-2.5d0)))) + (x + ((-2.0d0) * (wj * x))))
    else
        tmp = wj + (((x * exp(-wj)) - wj) / (wj + 1.0d0))
    end if
    code = tmp
end function
public static double code(double wj, double x) {
	double tmp;
	if (x <= 2.4e-39) {
		tmp = (Math.pow(wj, 3.0) * (((-1.0 - (-2.0 * ((x * -4.0) + (x * 1.5)))) - (x * -3.0)) - (x * 0.6666666666666666))) + (((wj * wj) * (1.0 - (x * -2.5))) + (x + (-2.0 * (wj * x))));
	} else {
		tmp = wj + (((x * Math.exp(-wj)) - wj) / (wj + 1.0));
	}
	return tmp;
}
def code(wj, x):
	tmp = 0
	if x <= 2.4e-39:
		tmp = (math.pow(wj, 3.0) * (((-1.0 - (-2.0 * ((x * -4.0) + (x * 1.5)))) - (x * -3.0)) - (x * 0.6666666666666666))) + (((wj * wj) * (1.0 - (x * -2.5))) + (x + (-2.0 * (wj * x))))
	else:
		tmp = wj + (((x * math.exp(-wj)) - wj) / (wj + 1.0))
	return tmp
function code(wj, x)
	tmp = 0.0
	if (x <= 2.4e-39)
		tmp = Float64(Float64((wj ^ 3.0) * Float64(Float64(Float64(-1.0 - Float64(-2.0 * Float64(Float64(x * -4.0) + Float64(x * 1.5)))) - Float64(x * -3.0)) - Float64(x * 0.6666666666666666))) + Float64(Float64(Float64(wj * wj) * Float64(1.0 - Float64(x * -2.5))) + Float64(x + Float64(-2.0 * Float64(wj * x)))));
	else
		tmp = Float64(wj + Float64(Float64(Float64(x * exp(Float64(-wj))) - wj) / Float64(wj + 1.0)));
	end
	return tmp
end
function tmp_2 = code(wj, x)
	tmp = 0.0;
	if (x <= 2.4e-39)
		tmp = ((wj ^ 3.0) * (((-1.0 - (-2.0 * ((x * -4.0) + (x * 1.5)))) - (x * -3.0)) - (x * 0.6666666666666666))) + (((wj * wj) * (1.0 - (x * -2.5))) + (x + (-2.0 * (wj * x))));
	else
		tmp = wj + (((x * exp(-wj)) - wj) / (wj + 1.0));
	end
	tmp_2 = tmp;
end
code[wj_, x_] := If[LessEqual[x, 2.4e-39], N[(N[(N[Power[wj, 3.0], $MachinePrecision] * N[(N[(N[(-1.0 - N[(-2.0 * N[(N[(x * -4.0), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x * -3.0), $MachinePrecision]), $MachinePrecision] - N[(x * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(wj * wj), $MachinePrecision] * N[(1.0 - N[(x * -2.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(N[(x * N[Exp[(-wj)], $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.4 \cdot 10^{-39}:\\
\;\;\;\;{wj}^{3} \cdot \left(\left(\left(-1 - -2 \cdot \left(x \cdot -4 + x \cdot 1.5\right)\right) - x \cdot -3\right) - x \cdot 0.6666666666666666\right) + \left(\left(wj \cdot wj\right) \cdot \left(1 - x \cdot -2.5\right) + \left(x + -2 \cdot \left(wj \cdot x\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.40000000000000016e-39

    1. Initial program 70.9%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg70.9%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub70.9%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg70.9%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative70.9%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in70.9%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg70.9%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg70.9%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub70.9%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in71.4%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/71.4%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified72.0%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Taylor expanded in wj around 0 97.9%

      \[\leadsto \color{blue}{-1 \cdot \left(\left(0.6666666666666666 \cdot x + \left(-3 \cdot x + \left(1 + -2 \cdot \left(-4 \cdot x + 1.5 \cdot x\right)\right)\right)\right) \cdot {wj}^{3}\right) + \left(\left(1 - \left(-4 \cdot x + 1.5 \cdot x\right)\right) \cdot {wj}^{2} + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right)} \]
    5. Step-by-step derivation
      1. pow197.9%

        \[\leadsto -1 \cdot \left(\left(0.6666666666666666 \cdot x + \left(-3 \cdot x + \left(1 + -2 \cdot \left(-4 \cdot x + 1.5 \cdot x\right)\right)\right)\right) \cdot {wj}^{3}\right) + \left(\color{blue}{{\left(\left(1 - \left(-4 \cdot x + 1.5 \cdot x\right)\right) \cdot {wj}^{2}\right)}^{1}} + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right) \]
      2. distribute-rgt-out97.9%

        \[\leadsto -1 \cdot \left(\left(0.6666666666666666 \cdot x + \left(-3 \cdot x + \left(1 + -2 \cdot \left(-4 \cdot x + 1.5 \cdot x\right)\right)\right)\right) \cdot {wj}^{3}\right) + \left({\left(\left(1 - \color{blue}{x \cdot \left(-4 + 1.5\right)}\right) \cdot {wj}^{2}\right)}^{1} + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right) \]
      3. metadata-eval97.9%

        \[\leadsto -1 \cdot \left(\left(0.6666666666666666 \cdot x + \left(-3 \cdot x + \left(1 + -2 \cdot \left(-4 \cdot x + 1.5 \cdot x\right)\right)\right)\right) \cdot {wj}^{3}\right) + \left({\left(\left(1 - x \cdot \color{blue}{-2.5}\right) \cdot {wj}^{2}\right)}^{1} + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right) \]
      4. pow297.9%

        \[\leadsto -1 \cdot \left(\left(0.6666666666666666 \cdot x + \left(-3 \cdot x + \left(1 + -2 \cdot \left(-4 \cdot x + 1.5 \cdot x\right)\right)\right)\right) \cdot {wj}^{3}\right) + \left({\left(\left(1 - x \cdot -2.5\right) \cdot \color{blue}{\left(wj \cdot wj\right)}\right)}^{1} + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right) \]
    6. Applied egg-rr97.9%

      \[\leadsto -1 \cdot \left(\left(0.6666666666666666 \cdot x + \left(-3 \cdot x + \left(1 + -2 \cdot \left(-4 \cdot x + 1.5 \cdot x\right)\right)\right)\right) \cdot {wj}^{3}\right) + \left(\color{blue}{{\left(\left(1 - x \cdot -2.5\right) \cdot \left(wj \cdot wj\right)\right)}^{1}} + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right) \]
    7. Step-by-step derivation
      1. unpow197.9%

        \[\leadsto -1 \cdot \left(\left(0.6666666666666666 \cdot x + \left(-3 \cdot x + \left(1 + -2 \cdot \left(-4 \cdot x + 1.5 \cdot x\right)\right)\right)\right) \cdot {wj}^{3}\right) + \left(\color{blue}{\left(1 - x \cdot -2.5\right) \cdot \left(wj \cdot wj\right)} + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right) \]
      2. unpow297.9%

        \[\leadsto -1 \cdot \left(\left(0.6666666666666666 \cdot x + \left(-3 \cdot x + \left(1 + -2 \cdot \left(-4 \cdot x + 1.5 \cdot x\right)\right)\right)\right) \cdot {wj}^{3}\right) + \left(\left(1 - x \cdot -2.5\right) \cdot \color{blue}{{wj}^{2}} + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right) \]
      3. *-commutative97.9%

        \[\leadsto -1 \cdot \left(\left(0.6666666666666666 \cdot x + \left(-3 \cdot x + \left(1 + -2 \cdot \left(-4 \cdot x + 1.5 \cdot x\right)\right)\right)\right) \cdot {wj}^{3}\right) + \left(\color{blue}{{wj}^{2} \cdot \left(1 - x \cdot -2.5\right)} + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right) \]
      4. unpow297.9%

        \[\leadsto -1 \cdot \left(\left(0.6666666666666666 \cdot x + \left(-3 \cdot x + \left(1 + -2 \cdot \left(-4 \cdot x + 1.5 \cdot x\right)\right)\right)\right) \cdot {wj}^{3}\right) + \left(\color{blue}{\left(wj \cdot wj\right)} \cdot \left(1 - x \cdot -2.5\right) + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right) \]
    8. Simplified97.9%

      \[\leadsto -1 \cdot \left(\left(0.6666666666666666 \cdot x + \left(-3 \cdot x + \left(1 + -2 \cdot \left(-4 \cdot x + 1.5 \cdot x\right)\right)\right)\right) \cdot {wj}^{3}\right) + \left(\color{blue}{\left(wj \cdot wj\right) \cdot \left(1 - x \cdot -2.5\right)} + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right) \]

    if 2.40000000000000016e-39 < x

    1. Initial program 97.1%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg97.1%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub97.1%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg97.1%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative97.1%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in97.1%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg97.1%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg97.1%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub97.1%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in99.6%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/99.7%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Step-by-step derivation
      1. clear-num99.5%

        \[\leadsto wj + \frac{\color{blue}{\frac{1}{\frac{e^{wj}}{x}}} - wj}{wj + 1} \]
      2. associate-/r/99.7%

        \[\leadsto wj + \frac{\color{blue}{\frac{1}{e^{wj}} \cdot x} - wj}{wj + 1} \]
      3. rec-exp99.8%

        \[\leadsto wj + \frac{\color{blue}{e^{-wj}} \cdot x - wj}{wj + 1} \]
    5. Applied egg-rr99.8%

      \[\leadsto wj + \frac{\color{blue}{e^{-wj} \cdot x} - wj}{wj + 1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.4 \cdot 10^{-39}:\\ \;\;\;\;{wj}^{3} \cdot \left(\left(\left(-1 - -2 \cdot \left(x \cdot -4 + x \cdot 1.5\right)\right) - x \cdot -3\right) - x \cdot 0.6666666666666666\right) + \left(\left(wj \cdot wj\right) \cdot \left(1 - x \cdot -2.5\right) + \left(x + -2 \cdot \left(wj \cdot x\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\ \end{array} \]

Alternative 6: 97.2% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 4 \cdot 10^{-39}:\\ \;\;\;\;\left(wj \cdot wj + \left(x + -2 \cdot \left(wj \cdot x\right)\right)\right) - {wj}^{3} \cdot \left(x \cdot 0.6666666666666666 + \left(x \cdot -3 + \left(-2 \cdot \left(x \cdot -4 + x \cdot 1.5\right) + 1\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (if (<= x 4e-39)
   (-
    (+ (* wj wj) (+ x (* -2.0 (* wj x))))
    (*
     (pow wj 3.0)
     (+
      (* x 0.6666666666666666)
      (+ (* x -3.0) (+ (* -2.0 (+ (* x -4.0) (* x 1.5))) 1.0)))))
   (+ wj (/ (- (* x (exp (- wj))) wj) (+ wj 1.0)))))
double code(double wj, double x) {
	double tmp;
	if (x <= 4e-39) {
		tmp = ((wj * wj) + (x + (-2.0 * (wj * x)))) - (pow(wj, 3.0) * ((x * 0.6666666666666666) + ((x * -3.0) + ((-2.0 * ((x * -4.0) + (x * 1.5))) + 1.0))));
	} else {
		tmp = wj + (((x * exp(-wj)) - wj) / (wj + 1.0));
	}
	return tmp;
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 4d-39) then
        tmp = ((wj * wj) + (x + ((-2.0d0) * (wj * x)))) - ((wj ** 3.0d0) * ((x * 0.6666666666666666d0) + ((x * (-3.0d0)) + (((-2.0d0) * ((x * (-4.0d0)) + (x * 1.5d0))) + 1.0d0))))
    else
        tmp = wj + (((x * exp(-wj)) - wj) / (wj + 1.0d0))
    end if
    code = tmp
end function
public static double code(double wj, double x) {
	double tmp;
	if (x <= 4e-39) {
		tmp = ((wj * wj) + (x + (-2.0 * (wj * x)))) - (Math.pow(wj, 3.0) * ((x * 0.6666666666666666) + ((x * -3.0) + ((-2.0 * ((x * -4.0) + (x * 1.5))) + 1.0))));
	} else {
		tmp = wj + (((x * Math.exp(-wj)) - wj) / (wj + 1.0));
	}
	return tmp;
}
def code(wj, x):
	tmp = 0
	if x <= 4e-39:
		tmp = ((wj * wj) + (x + (-2.0 * (wj * x)))) - (math.pow(wj, 3.0) * ((x * 0.6666666666666666) + ((x * -3.0) + ((-2.0 * ((x * -4.0) + (x * 1.5))) + 1.0))))
	else:
		tmp = wj + (((x * math.exp(-wj)) - wj) / (wj + 1.0))
	return tmp
function code(wj, x)
	tmp = 0.0
	if (x <= 4e-39)
		tmp = Float64(Float64(Float64(wj * wj) + Float64(x + Float64(-2.0 * Float64(wj * x)))) - Float64((wj ^ 3.0) * Float64(Float64(x * 0.6666666666666666) + Float64(Float64(x * -3.0) + Float64(Float64(-2.0 * Float64(Float64(x * -4.0) + Float64(x * 1.5))) + 1.0)))));
	else
		tmp = Float64(wj + Float64(Float64(Float64(x * exp(Float64(-wj))) - wj) / Float64(wj + 1.0)));
	end
	return tmp
end
function tmp_2 = code(wj, x)
	tmp = 0.0;
	if (x <= 4e-39)
		tmp = ((wj * wj) + (x + (-2.0 * (wj * x)))) - ((wj ^ 3.0) * ((x * 0.6666666666666666) + ((x * -3.0) + ((-2.0 * ((x * -4.0) + (x * 1.5))) + 1.0))));
	else
		tmp = wj + (((x * exp(-wj)) - wj) / (wj + 1.0));
	end
	tmp_2 = tmp;
end
code[wj_, x_] := If[LessEqual[x, 4e-39], N[(N[(N[(wj * wj), $MachinePrecision] + N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Power[wj, 3.0], $MachinePrecision] * N[(N[(x * 0.6666666666666666), $MachinePrecision] + N[(N[(x * -3.0), $MachinePrecision] + N[(N[(-2.0 * N[(N[(x * -4.0), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(N[(x * N[Exp[(-wj)], $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4 \cdot 10^{-39}:\\
\;\;\;\;\left(wj \cdot wj + \left(x + -2 \cdot \left(wj \cdot x\right)\right)\right) - {wj}^{3} \cdot \left(x \cdot 0.6666666666666666 + \left(x \cdot -3 + \left(-2 \cdot \left(x \cdot -4 + x \cdot 1.5\right) + 1\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 3.99999999999999972e-39

    1. Initial program 70.9%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg70.9%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub70.9%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg70.9%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative70.9%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in70.9%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg70.9%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg70.9%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub70.9%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in71.4%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/71.4%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified72.0%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Taylor expanded in wj around 0 97.9%

      \[\leadsto \color{blue}{-1 \cdot \left(\left(0.6666666666666666 \cdot x + \left(-3 \cdot x + \left(1 + -2 \cdot \left(-4 \cdot x + 1.5 \cdot x\right)\right)\right)\right) \cdot {wj}^{3}\right) + \left(\left(1 - \left(-4 \cdot x + 1.5 \cdot x\right)\right) \cdot {wj}^{2} + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right)} \]
    5. Taylor expanded in x around 0 97.6%

      \[\leadsto -1 \cdot \left(\left(0.6666666666666666 \cdot x + \left(-3 \cdot x + \left(1 + -2 \cdot \left(-4 \cdot x + 1.5 \cdot x\right)\right)\right)\right) \cdot {wj}^{3}\right) + \left(\color{blue}{{wj}^{2}} + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right) \]
    6. Step-by-step derivation
      1. unpow297.6%

        \[\leadsto -1 \cdot \left(\left(0.6666666666666666 \cdot x + \left(-3 \cdot x + \left(1 + -2 \cdot \left(-4 \cdot x + 1.5 \cdot x\right)\right)\right)\right) \cdot {wj}^{3}\right) + \left(\color{blue}{wj \cdot wj} + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right) \]
    7. Simplified97.6%

      \[\leadsto -1 \cdot \left(\left(0.6666666666666666 \cdot x + \left(-3 \cdot x + \left(1 + -2 \cdot \left(-4 \cdot x + 1.5 \cdot x\right)\right)\right)\right) \cdot {wj}^{3}\right) + \left(\color{blue}{wj \cdot wj} + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right) \]

    if 3.99999999999999972e-39 < x

    1. Initial program 97.1%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg97.1%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub97.1%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg97.1%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative97.1%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in97.1%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg97.1%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg97.1%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub97.1%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in99.6%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/99.7%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Step-by-step derivation
      1. clear-num99.5%

        \[\leadsto wj + \frac{\color{blue}{\frac{1}{\frac{e^{wj}}{x}}} - wj}{wj + 1} \]
      2. associate-/r/99.7%

        \[\leadsto wj + \frac{\color{blue}{\frac{1}{e^{wj}} \cdot x} - wj}{wj + 1} \]
      3. rec-exp99.8%

        \[\leadsto wj + \frac{\color{blue}{e^{-wj}} \cdot x - wj}{wj + 1} \]
    5. Applied egg-rr99.8%

      \[\leadsto wj + \frac{\color{blue}{e^{-wj} \cdot x} - wj}{wj + 1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4 \cdot 10^{-39}:\\ \;\;\;\;\left(wj \cdot wj + \left(x + -2 \cdot \left(wj \cdot x\right)\right)\right) - {wj}^{3} \cdot \left(x \cdot 0.6666666666666666 + \left(x \cdot -3 + \left(-2 \cdot \left(x \cdot -4 + x \cdot 1.5\right) + 1\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\ \end{array} \]

Alternative 7: 97.8% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;wj \leq -6.4 \cdot 10^{-9}:\\ \;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(x + -2 \cdot \left(wj \cdot x\right)\right) + {wj}^{2} \cdot \left(1 - \left(x \cdot -4 + x \cdot 1.5\right)\right)\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (if (<= wj -6.4e-9)
   (+ wj (/ (- (* x (exp (- wj))) wj) (+ wj 1.0)))
   (+
    (+ x (* -2.0 (* wj x)))
    (* (pow wj 2.0) (- 1.0 (+ (* x -4.0) (* x 1.5)))))))
double code(double wj, double x) {
	double tmp;
	if (wj <= -6.4e-9) {
		tmp = wj + (((x * exp(-wj)) - wj) / (wj + 1.0));
	} else {
		tmp = (x + (-2.0 * (wj * x))) + (pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5))));
	}
	return tmp;
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    real(8) :: tmp
    if (wj <= (-6.4d-9)) then
        tmp = wj + (((x * exp(-wj)) - wj) / (wj + 1.0d0))
    else
        tmp = (x + ((-2.0d0) * (wj * x))) + ((wj ** 2.0d0) * (1.0d0 - ((x * (-4.0d0)) + (x * 1.5d0))))
    end if
    code = tmp
end function
public static double code(double wj, double x) {
	double tmp;
	if (wj <= -6.4e-9) {
		tmp = wj + (((x * Math.exp(-wj)) - wj) / (wj + 1.0));
	} else {
		tmp = (x + (-2.0 * (wj * x))) + (Math.pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5))));
	}
	return tmp;
}
def code(wj, x):
	tmp = 0
	if wj <= -6.4e-9:
		tmp = wj + (((x * math.exp(-wj)) - wj) / (wj + 1.0))
	else:
		tmp = (x + (-2.0 * (wj * x))) + (math.pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5))))
	return tmp
function code(wj, x)
	tmp = 0.0
	if (wj <= -6.4e-9)
		tmp = Float64(wj + Float64(Float64(Float64(x * exp(Float64(-wj))) - wj) / Float64(wj + 1.0)));
	else
		tmp = Float64(Float64(x + Float64(-2.0 * Float64(wj * x))) + Float64((wj ^ 2.0) * Float64(1.0 - Float64(Float64(x * -4.0) + Float64(x * 1.5)))));
	end
	return tmp
end
function tmp_2 = code(wj, x)
	tmp = 0.0;
	if (wj <= -6.4e-9)
		tmp = wj + (((x * exp(-wj)) - wj) / (wj + 1.0));
	else
		tmp = (x + (-2.0 * (wj * x))) + ((wj ^ 2.0) * (1.0 - ((x * -4.0) + (x * 1.5))));
	end
	tmp_2 = tmp;
end
code[wj_, x_] := If[LessEqual[wj, -6.4e-9], N[(wj + N[(N[(N[(x * N[Exp[(-wj)], $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 2.0], $MachinePrecision] * N[(1.0 - N[(N[(x * -4.0), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;wj \leq -6.4 \cdot 10^{-9}:\\
\;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\

\mathbf{else}:\\
\;\;\;\;\left(x + -2 \cdot \left(wj \cdot x\right)\right) + {wj}^{2} \cdot \left(1 - \left(x \cdot -4 + x \cdot 1.5\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if wj < -6.40000000000000023e-9

    1. Initial program 61.7%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg61.7%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub61.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg61.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative61.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in61.7%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg61.7%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg61.7%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub61.7%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in86.5%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/86.8%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified86.8%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Step-by-step derivation
      1. clear-num86.8%

        \[\leadsto wj + \frac{\color{blue}{\frac{1}{\frac{e^{wj}}{x}}} - wj}{wj + 1} \]
      2. associate-/r/86.9%

        \[\leadsto wj + \frac{\color{blue}{\frac{1}{e^{wj}} \cdot x} - wj}{wj + 1} \]
      3. rec-exp86.9%

        \[\leadsto wj + \frac{\color{blue}{e^{-wj}} \cdot x - wj}{wj + 1} \]
    5. Applied egg-rr86.9%

      \[\leadsto wj + \frac{\color{blue}{e^{-wj} \cdot x} - wj}{wj + 1} \]

    if -6.40000000000000023e-9 < wj

    1. Initial program 80.0%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg80.0%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub80.0%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg80.0%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative80.0%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in80.0%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg80.0%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg80.0%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub80.0%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in80.0%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/80.0%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified80.4%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Taylor expanded in wj around 0 98.2%

      \[\leadsto \color{blue}{\left(1 - \left(-4 \cdot x + 1.5 \cdot x\right)\right) \cdot {wj}^{2} + \left(-2 \cdot \left(wj \cdot x\right) + x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;wj \leq -6.4 \cdot 10^{-9}:\\ \;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(x + -2 \cdot \left(wj \cdot x\right)\right) + {wj}^{2} \cdot \left(1 - \left(x \cdot -4 + x \cdot 1.5\right)\right)\\ \end{array} \]

Alternative 8: 97.8% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;wj \leq -6.4 \cdot 10^{-9}:\\ \;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(x + -2 \cdot \left(wj \cdot x\right)\right) + {wj}^{2} \cdot \left(x + \left(x + 1\right)\right)\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (if (<= wj -6.4e-9)
   (+ wj (/ (- (* x (exp (- wj))) wj) (+ wj 1.0)))
   (+ (+ x (* -2.0 (* wj x))) (* (pow wj 2.0) (+ x (+ x 1.0))))))
double code(double wj, double x) {
	double tmp;
	if (wj <= -6.4e-9) {
		tmp = wj + (((x * exp(-wj)) - wj) / (wj + 1.0));
	} else {
		tmp = (x + (-2.0 * (wj * x))) + (pow(wj, 2.0) * (x + (x + 1.0)));
	}
	return tmp;
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    real(8) :: tmp
    if (wj <= (-6.4d-9)) then
        tmp = wj + (((x * exp(-wj)) - wj) / (wj + 1.0d0))
    else
        tmp = (x + ((-2.0d0) * (wj * x))) + ((wj ** 2.0d0) * (x + (x + 1.0d0)))
    end if
    code = tmp
end function
public static double code(double wj, double x) {
	double tmp;
	if (wj <= -6.4e-9) {
		tmp = wj + (((x * Math.exp(-wj)) - wj) / (wj + 1.0));
	} else {
		tmp = (x + (-2.0 * (wj * x))) + (Math.pow(wj, 2.0) * (x + (x + 1.0)));
	}
	return tmp;
}
def code(wj, x):
	tmp = 0
	if wj <= -6.4e-9:
		tmp = wj + (((x * math.exp(-wj)) - wj) / (wj + 1.0))
	else:
		tmp = (x + (-2.0 * (wj * x))) + (math.pow(wj, 2.0) * (x + (x + 1.0)))
	return tmp
function code(wj, x)
	tmp = 0.0
	if (wj <= -6.4e-9)
		tmp = Float64(wj + Float64(Float64(Float64(x * exp(Float64(-wj))) - wj) / Float64(wj + 1.0)));
	else
		tmp = Float64(Float64(x + Float64(-2.0 * Float64(wj * x))) + Float64((wj ^ 2.0) * Float64(x + Float64(x + 1.0))));
	end
	return tmp
end
function tmp_2 = code(wj, x)
	tmp = 0.0;
	if (wj <= -6.4e-9)
		tmp = wj + (((x * exp(-wj)) - wj) / (wj + 1.0));
	else
		tmp = (x + (-2.0 * (wj * x))) + ((wj ^ 2.0) * (x + (x + 1.0)));
	end
	tmp_2 = tmp;
end
code[wj_, x_] := If[LessEqual[wj, -6.4e-9], N[(wj + N[(N[(N[(x * N[Exp[(-wj)], $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 2.0], $MachinePrecision] * N[(x + N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;wj \leq -6.4 \cdot 10^{-9}:\\
\;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\

\mathbf{else}:\\
\;\;\;\;\left(x + -2 \cdot \left(wj \cdot x\right)\right) + {wj}^{2} \cdot \left(x + \left(x + 1\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if wj < -6.40000000000000023e-9

    1. Initial program 61.7%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg61.7%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub61.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg61.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative61.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in61.7%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg61.7%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg61.7%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub61.7%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in86.5%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/86.8%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified86.8%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Step-by-step derivation
      1. clear-num86.8%

        \[\leadsto wj + \frac{\color{blue}{\frac{1}{\frac{e^{wj}}{x}}} - wj}{wj + 1} \]
      2. associate-/r/86.9%

        \[\leadsto wj + \frac{\color{blue}{\frac{1}{e^{wj}} \cdot x} - wj}{wj + 1} \]
      3. rec-exp86.9%

        \[\leadsto wj + \frac{\color{blue}{e^{-wj}} \cdot x - wj}{wj + 1} \]
    5. Applied egg-rr86.9%

      \[\leadsto wj + \frac{\color{blue}{e^{-wj} \cdot x} - wj}{wj + 1} \]

    if -6.40000000000000023e-9 < wj

    1. Initial program 80.0%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg80.0%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub80.0%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg80.0%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative80.0%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in80.0%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg80.0%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg80.0%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub80.0%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in80.0%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/80.0%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified80.4%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Taylor expanded in wj around 0 79.5%

      \[\leadsto wj + \frac{\color{blue}{\left(-1 \cdot \left(wj \cdot x\right) + x\right)} - wj}{wj + 1} \]
    5. Step-by-step derivation
      1. +-commutative79.5%

        \[\leadsto wj + \frac{\color{blue}{\left(x + -1 \cdot \left(wj \cdot x\right)\right)} - wj}{wj + 1} \]
      2. mul-1-neg79.5%

        \[\leadsto wj + \frac{\left(x + \color{blue}{\left(-wj \cdot x\right)}\right) - wj}{wj + 1} \]
      3. unsub-neg79.5%

        \[\leadsto wj + \frac{\color{blue}{\left(x - wj \cdot x\right)} - wj}{wj + 1} \]
      4. *-commutative79.5%

        \[\leadsto wj + \frac{\left(x - \color{blue}{x \cdot wj}\right) - wj}{wj + 1} \]
    6. Simplified79.5%

      \[\leadsto wj + \frac{\color{blue}{\left(x - x \cdot wj\right)} - wj}{wj + 1} \]
    7. Taylor expanded in wj around 0 98.1%

      \[\leadsto \color{blue}{{wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-2 \cdot \left(wj \cdot x\right) + x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;wj \leq -6.4 \cdot 10^{-9}:\\ \;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(x + -2 \cdot \left(wj \cdot x\right)\right) + {wj}^{2} \cdot \left(x + \left(x + 1\right)\right)\\ \end{array} \]

Alternative 9: 90.0% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right) \end{array} \]
(FPCore (wj x)
 :precision binary64
 (+ (/ x (* (exp wj) (+ wj 1.0))) (- wj (/ wj (+ wj 1.0)))))
double code(double wj, double x) {
	return (x / (exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)));
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    code = (x / (exp(wj) * (wj + 1.0d0))) + (wj - (wj / (wj + 1.0d0)))
end function
public static double code(double wj, double x) {
	return (x / (Math.exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)));
}
def code(wj, x):
	return (x / (math.exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)))
function code(wj, x)
	return Float64(Float64(x / Float64(exp(wj) * Float64(wj + 1.0))) + Float64(wj - Float64(wj / Float64(wj + 1.0))))
end
function tmp = code(wj, x)
	tmp = (x / (exp(wj) * (wj + 1.0))) + (wj - (wj / (wj + 1.0)));
end
code[wj_, x_] := N[(N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(wj - N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right)
\end{array}
Derivation
  1. Initial program 79.2%

    \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
  2. Step-by-step derivation
    1. sub-neg79.2%

      \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    2. div-sub79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
    3. sub-neg79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
    4. +-commutative79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
    5. distribute-neg-in79.2%

      \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
    6. remove-double-neg79.2%

      \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
    7. sub-neg79.2%

      \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    8. div-sub79.2%

      \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
    9. distribute-rgt1-in80.3%

      \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
    10. associate-/l/80.3%

      \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
  3. Simplified80.7%

    \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
  4. Step-by-step derivation
    1. +-commutative80.7%

      \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}} - wj}{wj + 1} + wj} \]
    2. div-sub80.7%

      \[\leadsto \color{blue}{\left(\frac{\frac{x}{e^{wj}}}{wj + 1} - \frac{wj}{wj + 1}\right)} + wj \]
    3. associate-+l-89.8%

      \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}}}{wj + 1} - \left(\frac{wj}{wj + 1} - wj\right)} \]
    4. associate-/l/89.8%

      \[\leadsto \color{blue}{\frac{x}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    5. *-commutative89.8%

      \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot \left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    6. add-exp-log88.2%

      \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{e^{\log \left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    7. +-commutative88.2%

      \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    8. log1p-udef88.2%

      \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    9. prod-exp88.2%

      \[\leadsto \frac{x}{\color{blue}{e^{wj + \mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
  5. Applied egg-rr88.2%

    \[\leadsto \color{blue}{\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\frac{wj}{wj + 1} - wj\right)} \]
  6. Step-by-step derivation
    1. exp-sum88.2%

      \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot e^{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    2. log1p-udef88.2%

      \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\log \left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    3. +-commutative88.2%

      \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    4. add-exp-log89.8%

      \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{\left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    5. *-commutative89.8%

      \[\leadsto \frac{x}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    6. +-commutative89.8%

      \[\leadsto \frac{x}{\color{blue}{\left(1 + wj\right)} \cdot e^{wj}} - \left(\frac{wj}{wj + 1} - wj\right) \]
  7. Applied egg-rr89.8%

    \[\leadsto \frac{x}{\color{blue}{\left(1 + wj\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
  8. Final simplification89.8%

    \[\leadsto \frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right) \]

Alternative 10: 88.8% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{wj}{wj + 1}\\ \mathbf{if}\;wj \leq -6.4 \cdot 10^{-16}:\\ \;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\ \mathbf{elif}\;wj \leq -2.45 \cdot 10^{-23}:\\ \;\;\;\;\left(-wj\right) \cdot \mathsf{expm1}\left(-wj\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{wj \cdot 2 + 1} - \frac{t_0 \cdot t_0 - wj \cdot wj}{wj + t_0}\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (let* ((t_0 (/ wj (+ wj 1.0))))
   (if (<= wj -6.4e-16)
     (+ wj (/ (- (* x (exp (- wj))) wj) (+ wj 1.0)))
     (if (<= wj -2.45e-23)
       (* (- wj) (expm1 (- wj)))
       (-
        (/ x (+ (* wj 2.0) 1.0))
        (/ (- (* t_0 t_0) (* wj wj)) (+ wj t_0)))))))
double code(double wj, double x) {
	double t_0 = wj / (wj + 1.0);
	double tmp;
	if (wj <= -6.4e-16) {
		tmp = wj + (((x * exp(-wj)) - wj) / (wj + 1.0));
	} else if (wj <= -2.45e-23) {
		tmp = -wj * expm1(-wj);
	} else {
		tmp = (x / ((wj * 2.0) + 1.0)) - (((t_0 * t_0) - (wj * wj)) / (wj + t_0));
	}
	return tmp;
}
public static double code(double wj, double x) {
	double t_0 = wj / (wj + 1.0);
	double tmp;
	if (wj <= -6.4e-16) {
		tmp = wj + (((x * Math.exp(-wj)) - wj) / (wj + 1.0));
	} else if (wj <= -2.45e-23) {
		tmp = -wj * Math.expm1(-wj);
	} else {
		tmp = (x / ((wj * 2.0) + 1.0)) - (((t_0 * t_0) - (wj * wj)) / (wj + t_0));
	}
	return tmp;
}
def code(wj, x):
	t_0 = wj / (wj + 1.0)
	tmp = 0
	if wj <= -6.4e-16:
		tmp = wj + (((x * math.exp(-wj)) - wj) / (wj + 1.0))
	elif wj <= -2.45e-23:
		tmp = -wj * math.expm1(-wj)
	else:
		tmp = (x / ((wj * 2.0) + 1.0)) - (((t_0 * t_0) - (wj * wj)) / (wj + t_0))
	return tmp
function code(wj, x)
	t_0 = Float64(wj / Float64(wj + 1.0))
	tmp = 0.0
	if (wj <= -6.4e-16)
		tmp = Float64(wj + Float64(Float64(Float64(x * exp(Float64(-wj))) - wj) / Float64(wj + 1.0)));
	elseif (wj <= -2.45e-23)
		tmp = Float64(Float64(-wj) * expm1(Float64(-wj)));
	else
		tmp = Float64(Float64(x / Float64(Float64(wj * 2.0) + 1.0)) - Float64(Float64(Float64(t_0 * t_0) - Float64(wj * wj)) / Float64(wj + t_0)));
	end
	return tmp
end
code[wj_, x_] := Block[{t$95$0 = N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, -6.4e-16], N[(wj + N[(N[(N[(x * N[Exp[(-wj)], $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[wj, -2.45e-23], N[((-wj) * N[(Exp[(-wj)] - 1), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(N[(wj * 2.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(wj * wj), $MachinePrecision]), $MachinePrecision] / N[(wj + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{wj}{wj + 1}\\
\mathbf{if}\;wj \leq -6.4 \cdot 10^{-16}:\\
\;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\

\mathbf{elif}\;wj \leq -2.45 \cdot 10^{-23}:\\
\;\;\;\;\left(-wj\right) \cdot \mathsf{expm1}\left(-wj\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{wj \cdot 2 + 1} - \frac{t_0 \cdot t_0 - wj \cdot wj}{wj + t_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if wj < -6.40000000000000046e-16

    1. Initial program 64.7%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg64.7%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub64.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg64.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative64.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in64.7%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg64.7%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg64.7%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub64.7%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in87.5%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/87.7%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified87.7%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Step-by-step derivation
      1. clear-num87.8%

        \[\leadsto wj + \frac{\color{blue}{\frac{1}{\frac{e^{wj}}{x}}} - wj}{wj + 1} \]
      2. associate-/r/87.9%

        \[\leadsto wj + \frac{\color{blue}{\frac{1}{e^{wj}} \cdot x} - wj}{wj + 1} \]
      3. rec-exp87.9%

        \[\leadsto wj + \frac{\color{blue}{e^{-wj}} \cdot x - wj}{wj + 1} \]
    5. Applied egg-rr87.9%

      \[\leadsto wj + \frac{\color{blue}{e^{-wj} \cdot x} - wj}{wj + 1} \]

    if -6.40000000000000046e-16 < wj < -2.4499999999999999e-23

    1. Initial program 11.1%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. distribute-rgt1-in11.1%

        \[\leadsto wj - \frac{wj \cdot e^{wj} - x}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
    3. Simplified11.1%

      \[\leadsto \color{blue}{wj - \frac{wj \cdot e^{wj} - x}{\left(wj + 1\right) \cdot e^{wj}}} \]
    4. Taylor expanded in wj around 0 11.1%

      \[\leadsto wj - \frac{\color{blue}{\left({wj}^{2} + wj\right)} - x}{\left(wj + 1\right) \cdot e^{wj}} \]
    5. Step-by-step derivation
      1. +-commutative11.1%

        \[\leadsto wj - \frac{\color{blue}{\left(wj + {wj}^{2}\right)} - x}{\left(wj + 1\right) \cdot e^{wj}} \]
      2. unpow211.1%

        \[\leadsto wj - \frac{\left(wj + \color{blue}{wj \cdot wj}\right) - x}{\left(wj + 1\right) \cdot e^{wj}} \]
    6. Simplified11.1%

      \[\leadsto wj - \frac{\color{blue}{\left(wj + wj \cdot wj\right)} - x}{\left(wj + 1\right) \cdot e^{wj}} \]
    7. Taylor expanded in wj around -inf 10.8%

      \[\leadsto \color{blue}{-1 \cdot \left(wj \cdot \left(\frac{1}{e^{wj}} - 1\right)\right)} \]
    8. Step-by-step derivation
      1. associate-*r*10.8%

        \[\leadsto \color{blue}{\left(-1 \cdot wj\right) \cdot \left(\frac{1}{e^{wj}} - 1\right)} \]
      2. neg-mul-110.8%

        \[\leadsto \color{blue}{\left(-wj\right)} \cdot \left(\frac{1}{e^{wj}} - 1\right) \]
      3. rec-exp11.0%

        \[\leadsto \left(-wj\right) \cdot \left(\color{blue}{e^{-wj}} - 1\right) \]
      4. neg-mul-111.0%

        \[\leadsto \left(-wj\right) \cdot \left(e^{\color{blue}{-1 \cdot wj}} - 1\right) \]
      5. expm1-def99.1%

        \[\leadsto \left(-wj\right) \cdot \color{blue}{\mathsf{expm1}\left(-1 \cdot wj\right)} \]
      6. neg-mul-199.1%

        \[\leadsto \left(-wj\right) \cdot \mathsf{expm1}\left(\color{blue}{-wj}\right) \]
    9. Simplified99.1%

      \[\leadsto \color{blue}{\left(-wj\right) \cdot \mathsf{expm1}\left(-wj\right)} \]

    if -2.4499999999999999e-23 < wj

    1. Initial program 81.4%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg81.4%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub81.4%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg81.4%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative81.4%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in81.4%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg81.4%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg81.4%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub81.4%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in81.4%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/81.4%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified81.8%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Step-by-step derivation
      1. +-commutative81.8%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}} - wj}{wj + 1} + wj} \]
      2. div-sub81.8%

        \[\leadsto \color{blue}{\left(\frac{\frac{x}{e^{wj}}}{wj + 1} - \frac{wj}{wj + 1}\right)} + wj \]
      3. associate-+l-91.6%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}}}{wj + 1} - \left(\frac{wj}{wj + 1} - wj\right)} \]
      4. associate-/l/91.6%

        \[\leadsto \color{blue}{\frac{x}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      5. *-commutative91.6%

        \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot \left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      6. add-exp-log91.6%

        \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{e^{\log \left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      7. +-commutative91.6%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      8. log1p-udef91.6%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      9. prod-exp91.5%

        \[\leadsto \frac{x}{\color{blue}{e^{wj + \mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    5. Applied egg-rr91.5%

      \[\leadsto \color{blue}{\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\frac{wj}{wj + 1} - wj\right)} \]
    6. Step-by-step derivation
      1. flip--91.5%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\frac{\frac{wj}{wj + 1} \cdot \frac{wj}{wj + 1} - wj \cdot wj}{\frac{wj}{wj + 1} + wj}} \]
      2. +-commutative91.5%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \frac{\frac{wj}{\color{blue}{1 + wj}} \cdot \frac{wj}{wj + 1} - wj \cdot wj}{\frac{wj}{wj + 1} + wj} \]
      3. +-commutative91.5%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{\color{blue}{1 + wj}} - wj \cdot wj}{\frac{wj}{wj + 1} + wj} \]
      4. +-commutative91.5%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{\color{blue}{1 + wj}} + wj} \]
    7. Applied egg-rr91.5%

      \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{1 + wj} + wj}} \]
    8. Taylor expanded in wj around 0 90.6%

      \[\leadsto \frac{x}{\color{blue}{1 + 2 \cdot wj}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{1 + wj} + wj} \]
    9. Step-by-step derivation
      1. *-commutative90.6%

        \[\leadsto \frac{x}{1 + \color{blue}{wj \cdot 2}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{1 + wj} + wj} \]
    10. Simplified90.6%

      \[\leadsto \frac{x}{\color{blue}{1 + wj \cdot 2}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{1 + wj} + wj} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification90.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;wj \leq -6.4 \cdot 10^{-16}:\\ \;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\ \mathbf{elif}\;wj \leq -2.45 \cdot 10^{-23}:\\ \;\;\;\;\left(-wj\right) \cdot \mathsf{expm1}\left(-wj\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{wj \cdot 2 + 1} - \frac{\frac{wj}{wj + 1} \cdot \frac{wj}{wj + 1} - wj \cdot wj}{wj + \frac{wj}{wj + 1}}\\ \end{array} \]

Alternative 11: 88.8% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{wj}{wj + 1}\\ \mathbf{if}\;wj \leq -6.5 \cdot 10^{-16}:\\ \;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\ \mathbf{elif}\;wj \leq -1.55 \cdot 10^{-23}:\\ \;\;\;\;\left(-wj\right) \cdot \mathsf{expm1}\left(-wj\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{wj \cdot 2 + 1} - \frac{t_0 \cdot t_0 - wj \cdot wj}{wj + t_0}\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (let* ((t_0 (/ wj (+ wj 1.0))))
   (if (<= wj -6.5e-16)
     (+ wj (/ (- (/ x (exp wj)) wj) (+ wj 1.0)))
     (if (<= wj -1.55e-23)
       (* (- wj) (expm1 (- wj)))
       (-
        (/ x (+ (* wj 2.0) 1.0))
        (/ (- (* t_0 t_0) (* wj wj)) (+ wj t_0)))))))
double code(double wj, double x) {
	double t_0 = wj / (wj + 1.0);
	double tmp;
	if (wj <= -6.5e-16) {
		tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0));
	} else if (wj <= -1.55e-23) {
		tmp = -wj * expm1(-wj);
	} else {
		tmp = (x / ((wj * 2.0) + 1.0)) - (((t_0 * t_0) - (wj * wj)) / (wj + t_0));
	}
	return tmp;
}
public static double code(double wj, double x) {
	double t_0 = wj / (wj + 1.0);
	double tmp;
	if (wj <= -6.5e-16) {
		tmp = wj + (((x / Math.exp(wj)) - wj) / (wj + 1.0));
	} else if (wj <= -1.55e-23) {
		tmp = -wj * Math.expm1(-wj);
	} else {
		tmp = (x / ((wj * 2.0) + 1.0)) - (((t_0 * t_0) - (wj * wj)) / (wj + t_0));
	}
	return tmp;
}
def code(wj, x):
	t_0 = wj / (wj + 1.0)
	tmp = 0
	if wj <= -6.5e-16:
		tmp = wj + (((x / math.exp(wj)) - wj) / (wj + 1.0))
	elif wj <= -1.55e-23:
		tmp = -wj * math.expm1(-wj)
	else:
		tmp = (x / ((wj * 2.0) + 1.0)) - (((t_0 * t_0) - (wj * wj)) / (wj + t_0))
	return tmp
function code(wj, x)
	t_0 = Float64(wj / Float64(wj + 1.0))
	tmp = 0.0
	if (wj <= -6.5e-16)
		tmp = Float64(wj + Float64(Float64(Float64(x / exp(wj)) - wj) / Float64(wj + 1.0)));
	elseif (wj <= -1.55e-23)
		tmp = Float64(Float64(-wj) * expm1(Float64(-wj)));
	else
		tmp = Float64(Float64(x / Float64(Float64(wj * 2.0) + 1.0)) - Float64(Float64(Float64(t_0 * t_0) - Float64(wj * wj)) / Float64(wj + t_0)));
	end
	return tmp
end
code[wj_, x_] := Block[{t$95$0 = N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, -6.5e-16], N[(wj + N[(N[(N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[wj, -1.55e-23], N[((-wj) * N[(Exp[(-wj)] - 1), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(N[(wj * 2.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(wj * wj), $MachinePrecision]), $MachinePrecision] / N[(wj + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{wj}{wj + 1}\\
\mathbf{if}\;wj \leq -6.5 \cdot 10^{-16}:\\
\;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\

\mathbf{elif}\;wj \leq -1.55 \cdot 10^{-23}:\\
\;\;\;\;\left(-wj\right) \cdot \mathsf{expm1}\left(-wj\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{wj \cdot 2 + 1} - \frac{t_0 \cdot t_0 - wj \cdot wj}{wj + t_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if wj < -6.50000000000000011e-16

    1. Initial program 64.7%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg64.7%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub64.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg64.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative64.7%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in64.7%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg64.7%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg64.7%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub64.7%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in87.5%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/87.7%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified87.7%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]

    if -6.50000000000000011e-16 < wj < -1.5499999999999999e-23

    1. Initial program 11.1%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. distribute-rgt1-in11.1%

        \[\leadsto wj - \frac{wj \cdot e^{wj} - x}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
    3. Simplified11.1%

      \[\leadsto \color{blue}{wj - \frac{wj \cdot e^{wj} - x}{\left(wj + 1\right) \cdot e^{wj}}} \]
    4. Taylor expanded in wj around 0 11.1%

      \[\leadsto wj - \frac{\color{blue}{\left({wj}^{2} + wj\right)} - x}{\left(wj + 1\right) \cdot e^{wj}} \]
    5. Step-by-step derivation
      1. +-commutative11.1%

        \[\leadsto wj - \frac{\color{blue}{\left(wj + {wj}^{2}\right)} - x}{\left(wj + 1\right) \cdot e^{wj}} \]
      2. unpow211.1%

        \[\leadsto wj - \frac{\left(wj + \color{blue}{wj \cdot wj}\right) - x}{\left(wj + 1\right) \cdot e^{wj}} \]
    6. Simplified11.1%

      \[\leadsto wj - \frac{\color{blue}{\left(wj + wj \cdot wj\right)} - x}{\left(wj + 1\right) \cdot e^{wj}} \]
    7. Taylor expanded in wj around -inf 10.8%

      \[\leadsto \color{blue}{-1 \cdot \left(wj \cdot \left(\frac{1}{e^{wj}} - 1\right)\right)} \]
    8. Step-by-step derivation
      1. associate-*r*10.8%

        \[\leadsto \color{blue}{\left(-1 \cdot wj\right) \cdot \left(\frac{1}{e^{wj}} - 1\right)} \]
      2. neg-mul-110.8%

        \[\leadsto \color{blue}{\left(-wj\right)} \cdot \left(\frac{1}{e^{wj}} - 1\right) \]
      3. rec-exp11.0%

        \[\leadsto \left(-wj\right) \cdot \left(\color{blue}{e^{-wj}} - 1\right) \]
      4. neg-mul-111.0%

        \[\leadsto \left(-wj\right) \cdot \left(e^{\color{blue}{-1 \cdot wj}} - 1\right) \]
      5. expm1-def99.1%

        \[\leadsto \left(-wj\right) \cdot \color{blue}{\mathsf{expm1}\left(-1 \cdot wj\right)} \]
      6. neg-mul-199.1%

        \[\leadsto \left(-wj\right) \cdot \mathsf{expm1}\left(\color{blue}{-wj}\right) \]
    9. Simplified99.1%

      \[\leadsto \color{blue}{\left(-wj\right) \cdot \mathsf{expm1}\left(-wj\right)} \]

    if -1.5499999999999999e-23 < wj

    1. Initial program 81.4%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg81.4%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub81.4%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg81.4%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative81.4%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in81.4%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg81.4%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg81.4%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub81.4%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in81.4%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/81.4%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified81.8%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Step-by-step derivation
      1. +-commutative81.8%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}} - wj}{wj + 1} + wj} \]
      2. div-sub81.8%

        \[\leadsto \color{blue}{\left(\frac{\frac{x}{e^{wj}}}{wj + 1} - \frac{wj}{wj + 1}\right)} + wj \]
      3. associate-+l-91.6%

        \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}}}{wj + 1} - \left(\frac{wj}{wj + 1} - wj\right)} \]
      4. associate-/l/91.6%

        \[\leadsto \color{blue}{\frac{x}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      5. *-commutative91.6%

        \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot \left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      6. add-exp-log91.6%

        \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{e^{\log \left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      7. +-commutative91.6%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      8. log1p-udef91.6%

        \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
      9. prod-exp91.5%

        \[\leadsto \frac{x}{\color{blue}{e^{wj + \mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    5. Applied egg-rr91.5%

      \[\leadsto \color{blue}{\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\frac{wj}{wj + 1} - wj\right)} \]
    6. Step-by-step derivation
      1. flip--91.5%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\frac{\frac{wj}{wj + 1} \cdot \frac{wj}{wj + 1} - wj \cdot wj}{\frac{wj}{wj + 1} + wj}} \]
      2. +-commutative91.5%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \frac{\frac{wj}{\color{blue}{1 + wj}} \cdot \frac{wj}{wj + 1} - wj \cdot wj}{\frac{wj}{wj + 1} + wj} \]
      3. +-commutative91.5%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{\color{blue}{1 + wj}} - wj \cdot wj}{\frac{wj}{wj + 1} + wj} \]
      4. +-commutative91.5%

        \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{\color{blue}{1 + wj}} + wj} \]
    7. Applied egg-rr91.5%

      \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{1 + wj} + wj}} \]
    8. Taylor expanded in wj around 0 90.6%

      \[\leadsto \frac{x}{\color{blue}{1 + 2 \cdot wj}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{1 + wj} + wj} \]
    9. Step-by-step derivation
      1. *-commutative90.6%

        \[\leadsto \frac{x}{1 + \color{blue}{wj \cdot 2}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{1 + wj} + wj} \]
    10. Simplified90.6%

      \[\leadsto \frac{x}{\color{blue}{1 + wj \cdot 2}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{1 + wj} + wj} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification90.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;wj \leq -6.5 \cdot 10^{-16}:\\ \;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\ \mathbf{elif}\;wj \leq -1.55 \cdot 10^{-23}:\\ \;\;\;\;\left(-wj\right) \cdot \mathsf{expm1}\left(-wj\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{wj \cdot 2 + 1} - \frac{\frac{wj}{wj + 1} \cdot \frac{wj}{wj + 1} - wj \cdot wj}{wj + \frac{wj}{wj + 1}}\\ \end{array} \]

Alternative 12: 87.8% accurate, 10.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{wj}{wj + 1}\\ \frac{x}{wj \cdot 2 + 1} - \frac{t_0 \cdot t_0 - wj \cdot wj}{wj + t_0} \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (let* ((t_0 (/ wj (+ wj 1.0))))
   (- (/ x (+ (* wj 2.0) 1.0)) (/ (- (* t_0 t_0) (* wj wj)) (+ wj t_0)))))
double code(double wj, double x) {
	double t_0 = wj / (wj + 1.0);
	return (x / ((wj * 2.0) + 1.0)) - (((t_0 * t_0) - (wj * wj)) / (wj + t_0));
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    real(8) :: t_0
    t_0 = wj / (wj + 1.0d0)
    code = (x / ((wj * 2.0d0) + 1.0d0)) - (((t_0 * t_0) - (wj * wj)) / (wj + t_0))
end function
public static double code(double wj, double x) {
	double t_0 = wj / (wj + 1.0);
	return (x / ((wj * 2.0) + 1.0)) - (((t_0 * t_0) - (wj * wj)) / (wj + t_0));
}
def code(wj, x):
	t_0 = wj / (wj + 1.0)
	return (x / ((wj * 2.0) + 1.0)) - (((t_0 * t_0) - (wj * wj)) / (wj + t_0))
function code(wj, x)
	t_0 = Float64(wj / Float64(wj + 1.0))
	return Float64(Float64(x / Float64(Float64(wj * 2.0) + 1.0)) - Float64(Float64(Float64(t_0 * t_0) - Float64(wj * wj)) / Float64(wj + t_0)))
end
function tmp = code(wj, x)
	t_0 = wj / (wj + 1.0);
	tmp = (x / ((wj * 2.0) + 1.0)) - (((t_0 * t_0) - (wj * wj)) / (wj + t_0));
end
code[wj_, x_] := Block[{t$95$0 = N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(x / N[(N[(wj * 2.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(wj * wj), $MachinePrecision]), $MachinePrecision] / N[(wj + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{wj}{wj + 1}\\
\frac{x}{wj \cdot 2 + 1} - \frac{t_0 \cdot t_0 - wj \cdot wj}{wj + t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 79.2%

    \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
  2. Step-by-step derivation
    1. sub-neg79.2%

      \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    2. div-sub79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
    3. sub-neg79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
    4. +-commutative79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
    5. distribute-neg-in79.2%

      \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
    6. remove-double-neg79.2%

      \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
    7. sub-neg79.2%

      \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    8. div-sub79.2%

      \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
    9. distribute-rgt1-in80.3%

      \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
    10. associate-/l/80.3%

      \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
  3. Simplified80.7%

    \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
  4. Step-by-step derivation
    1. +-commutative80.7%

      \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}} - wj}{wj + 1} + wj} \]
    2. div-sub80.7%

      \[\leadsto \color{blue}{\left(\frac{\frac{x}{e^{wj}}}{wj + 1} - \frac{wj}{wj + 1}\right)} + wj \]
    3. associate-+l-89.8%

      \[\leadsto \color{blue}{\frac{\frac{x}{e^{wj}}}{wj + 1} - \left(\frac{wj}{wj + 1} - wj\right)} \]
    4. associate-/l/89.8%

      \[\leadsto \color{blue}{\frac{x}{\left(wj + 1\right) \cdot e^{wj}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    5. *-commutative89.8%

      \[\leadsto \frac{x}{\color{blue}{e^{wj} \cdot \left(wj + 1\right)}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    6. add-exp-log88.2%

      \[\leadsto \frac{x}{e^{wj} \cdot \color{blue}{e^{\log \left(wj + 1\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    7. +-commutative88.2%

      \[\leadsto \frac{x}{e^{wj} \cdot e^{\log \color{blue}{\left(1 + wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    8. log1p-udef88.2%

      \[\leadsto \frac{x}{e^{wj} \cdot e^{\color{blue}{\mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
    9. prod-exp88.2%

      \[\leadsto \frac{x}{\color{blue}{e^{wj + \mathsf{log1p}\left(wj\right)}}} - \left(\frac{wj}{wj + 1} - wj\right) \]
  5. Applied egg-rr88.2%

    \[\leadsto \color{blue}{\frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \left(\frac{wj}{wj + 1} - wj\right)} \]
  6. Step-by-step derivation
    1. flip--88.2%

      \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\frac{\frac{wj}{wj + 1} \cdot \frac{wj}{wj + 1} - wj \cdot wj}{\frac{wj}{wj + 1} + wj}} \]
    2. +-commutative88.2%

      \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \frac{\frac{wj}{\color{blue}{1 + wj}} \cdot \frac{wj}{wj + 1} - wj \cdot wj}{\frac{wj}{wj + 1} + wj} \]
    3. +-commutative88.2%

      \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{\color{blue}{1 + wj}} - wj \cdot wj}{\frac{wj}{wj + 1} + wj} \]
    4. +-commutative88.2%

      \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{\color{blue}{1 + wj}} + wj} \]
  7. Applied egg-rr88.2%

    \[\leadsto \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}} - \color{blue}{\frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{1 + wj} + wj}} \]
  8. Taylor expanded in wj around 0 87.3%

    \[\leadsto \frac{x}{\color{blue}{1 + 2 \cdot wj}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{1 + wj} + wj} \]
  9. Step-by-step derivation
    1. *-commutative87.3%

      \[\leadsto \frac{x}{1 + \color{blue}{wj \cdot 2}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{1 + wj} + wj} \]
  10. Simplified87.3%

    \[\leadsto \frac{x}{\color{blue}{1 + wj \cdot 2}} - \frac{\frac{wj}{1 + wj} \cdot \frac{wj}{1 + wj} - wj \cdot wj}{\frac{wj}{1 + wj} + wj} \]
  11. Final simplification87.3%

    \[\leadsto \frac{x}{wj \cdot 2 + 1} - \frac{\frac{wj}{wj + 1} \cdot \frac{wj}{wj + 1} - wj \cdot wj}{wj + \frac{wj}{wj + 1}} \]

Alternative 13: 86.5% accurate, 20.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;wj \leq -5.3 \cdot 10^{-17}:\\
\;\;\;\;wj + \frac{\left(x - wj \cdot x\right) - wj}{wj + 1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if wj < -5.2999999999999998e-17

    1. Initial program 59.1%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg59.1%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub59.1%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg59.1%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative59.1%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in59.1%

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

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

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub59.1%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in78.9%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/79.0%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified79.0%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Taylor expanded in wj around 0 52.7%

      \[\leadsto wj + \frac{\color{blue}{\left(-1 \cdot \left(wj \cdot x\right) + x\right)} - wj}{wj + 1} \]
    5. Step-by-step derivation
      1. +-commutative52.7%

        \[\leadsto wj + \frac{\color{blue}{\left(x + -1 \cdot \left(wj \cdot x\right)\right)} - wj}{wj + 1} \]
      2. mul-1-neg52.7%

        \[\leadsto wj + \frac{\left(x + \color{blue}{\left(-wj \cdot x\right)}\right) - wj}{wj + 1} \]
      3. unsub-neg52.7%

        \[\leadsto wj + \frac{\color{blue}{\left(x - wj \cdot x\right)} - wj}{wj + 1} \]
      4. *-commutative52.7%

        \[\leadsto wj + \frac{\left(x - \color{blue}{x \cdot wj}\right) - wj}{wj + 1} \]
    6. Simplified52.7%

      \[\leadsto wj + \frac{\color{blue}{\left(x - x \cdot wj\right)} - wj}{wj + 1} \]

    if -5.2999999999999998e-17 < wj

    1. Initial program 80.4%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. sub-neg80.4%

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub80.4%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      3. sub-neg80.4%

        \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
      4. +-commutative80.4%

        \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
      5. distribute-neg-in80.4%

        \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
      6. remove-double-neg80.4%

        \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
      7. sub-neg80.4%

        \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      8. div-sub80.4%

        \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      9. distribute-rgt1-in80.4%

        \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
      10. associate-/l/80.4%

        \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
    3. Simplified80.8%

      \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
    4. Taylor expanded in wj around 0 79.9%

      \[\leadsto wj + \frac{\color{blue}{\left(-1 \cdot \left(wj \cdot x\right) + x\right)} - wj}{wj + 1} \]
    5. Step-by-step derivation
      1. +-commutative79.9%

        \[\leadsto wj + \frac{\color{blue}{\left(x + -1 \cdot \left(wj \cdot x\right)\right)} - wj}{wj + 1} \]
      2. mul-1-neg79.9%

        \[\leadsto wj + \frac{\left(x + \color{blue}{\left(-wj \cdot x\right)}\right) - wj}{wj + 1} \]
      3. unsub-neg79.9%

        \[\leadsto wj + \frac{\color{blue}{\left(x - wj \cdot x\right)} - wj}{wj + 1} \]
      4. *-commutative79.9%

        \[\leadsto wj + \frac{\left(x - \color{blue}{x \cdot wj}\right) - wj}{wj + 1} \]
    6. Simplified79.9%

      \[\leadsto wj + \frac{\color{blue}{\left(x - x \cdot wj\right)} - wj}{wj + 1} \]
    7. Step-by-step derivation
      1. add-cbrt-cube36.0%

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)}} \]
      2. associate--l-36.0%

        \[\leadsto \sqrt[3]{\left(\left(wj + \frac{\color{blue}{x - \left(x \cdot wj + wj\right)}}{wj + 1}\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)} \]
      3. +-commutative36.0%

        \[\leadsto \sqrt[3]{\left(\left(wj + \frac{x - \left(x \cdot wj + wj\right)}{\color{blue}{1 + wj}}\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)} \]
      4. associate--l-36.0%

        \[\leadsto \sqrt[3]{\left(\left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right) \cdot \left(wj + \frac{\color{blue}{x - \left(x \cdot wj + wj\right)}}{wj + 1}\right)\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)} \]
      5. +-commutative36.0%

        \[\leadsto \sqrt[3]{\left(\left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right) \cdot \left(wj + \frac{x - \left(x \cdot wj + wj\right)}{\color{blue}{1 + wj}}\right)\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)} \]
      6. associate--l-36.0%

        \[\leadsto \sqrt[3]{\left(\left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right) \cdot \left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right)\right) \cdot \left(wj + \frac{\color{blue}{x - \left(x \cdot wj + wj\right)}}{wj + 1}\right)} \]
      7. +-commutative36.0%

        \[\leadsto \sqrt[3]{\left(\left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right) \cdot \left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right)\right) \cdot \left(wj + \frac{x - \left(x \cdot wj + wj\right)}{\color{blue}{1 + wj}}\right)} \]
    8. Applied egg-rr36.0%

      \[\leadsto \color{blue}{\sqrt[3]{\left(\left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right) \cdot \left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right)\right) \cdot \left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right)}} \]
    9. Taylor expanded in x around -inf 88.3%

      \[\leadsto \color{blue}{\frac{\left(1 + -1 \cdot wj\right) \cdot x}{1 + wj}} \]
    10. Step-by-step derivation
      1. *-commutative88.3%

        \[\leadsto \frac{\color{blue}{x \cdot \left(1 + -1 \cdot wj\right)}}{1 + wj} \]
      2. neg-mul-188.3%

        \[\leadsto \frac{x \cdot \left(1 + \color{blue}{\left(-wj\right)}\right)}{1 + wj} \]
      3. sub-neg88.3%

        \[\leadsto \frac{x \cdot \color{blue}{\left(1 - wj\right)}}{1 + wj} \]
      4. +-commutative88.3%

        \[\leadsto \frac{x \cdot \left(1 - wj\right)}{\color{blue}{wj + 1}} \]
    11. Simplified88.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;wj \leq -5.3 \cdot 10^{-17}:\\ \;\;\;\;wj + \frac{\left(x - wj \cdot x\right) - wj}{wj + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(1 - wj\right)}{wj + 1}\\ \end{array} \]

Alternative 14: 85.4% accurate, 34.8× speedup?

\[\begin{array}{l} \\ \frac{x}{\frac{wj + 1}{1 - wj}} \end{array} \]
(FPCore (wj x) :precision binary64 (/ x (/ (+ wj 1.0) (- 1.0 wj))))
double code(double wj, double x) {
	return x / ((wj + 1.0) / (1.0 - wj));
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    code = x / ((wj + 1.0d0) / (1.0d0 - wj))
end function
public static double code(double wj, double x) {
	return x / ((wj + 1.0) / (1.0 - wj));
}
def code(wj, x):
	return x / ((wj + 1.0) / (1.0 - wj))
function code(wj, x)
	return Float64(x / Float64(Float64(wj + 1.0) / Float64(1.0 - wj)))
end
function tmp = code(wj, x)
	tmp = x / ((wj + 1.0) / (1.0 - wj));
end
code[wj_, x_] := N[(x / N[(N[(wj + 1.0), $MachinePrecision] / N[(1.0 - wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x}{\frac{wj + 1}{1 - wj}}
\end{array}
Derivation
  1. Initial program 79.2%

    \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
  2. Step-by-step derivation
    1. sub-neg79.2%

      \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    2. div-sub79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
    3. sub-neg79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
    4. +-commutative79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
    5. distribute-neg-in79.2%

      \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
    6. remove-double-neg79.2%

      \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
    7. sub-neg79.2%

      \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    8. div-sub79.2%

      \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
    9. distribute-rgt1-in80.3%

      \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
    10. associate-/l/80.3%

      \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
  3. Simplified80.7%

    \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
  4. Taylor expanded in wj around 0 78.3%

    \[\leadsto wj + \frac{\color{blue}{\left(-1 \cdot \left(wj \cdot x\right) + x\right)} - wj}{wj + 1} \]
  5. Step-by-step derivation
    1. +-commutative78.3%

      \[\leadsto wj + \frac{\color{blue}{\left(x + -1 \cdot \left(wj \cdot x\right)\right)} - wj}{wj + 1} \]
    2. mul-1-neg78.3%

      \[\leadsto wj + \frac{\left(x + \color{blue}{\left(-wj \cdot x\right)}\right) - wj}{wj + 1} \]
    3. unsub-neg78.3%

      \[\leadsto wj + \frac{\color{blue}{\left(x - wj \cdot x\right)} - wj}{wj + 1} \]
    4. *-commutative78.3%

      \[\leadsto wj + \frac{\left(x - \color{blue}{x \cdot wj}\right) - wj}{wj + 1} \]
  6. Simplified78.3%

    \[\leadsto wj + \frac{\color{blue}{\left(x - x \cdot wj\right)} - wj}{wj + 1} \]
  7. Taylor expanded in x around -inf 84.6%

    \[\leadsto \color{blue}{\frac{\left(1 + -1 \cdot wj\right) \cdot x}{1 + wj}} \]
  8. Step-by-step derivation
    1. *-commutative84.6%

      \[\leadsto \frac{\color{blue}{x \cdot \left(1 + -1 \cdot wj\right)}}{1 + wj} \]
    2. associate-/l*84.6%

      \[\leadsto \color{blue}{\frac{x}{\frac{1 + wj}{1 + -1 \cdot wj}}} \]
    3. +-commutative84.6%

      \[\leadsto \frac{x}{\frac{\color{blue}{wj + 1}}{1 + -1 \cdot wj}} \]
    4. neg-mul-184.6%

      \[\leadsto \frac{x}{\frac{wj + 1}{1 + \color{blue}{\left(-wj\right)}}} \]
    5. sub-neg84.6%

      \[\leadsto \frac{x}{\frac{wj + 1}{\color{blue}{1 - wj}}} \]
  9. Simplified84.6%

    \[\leadsto \color{blue}{\frac{x}{\frac{wj + 1}{1 - wj}}} \]
  10. Final simplification84.6%

    \[\leadsto \frac{x}{\frac{wj + 1}{1 - wj}} \]

Alternative 15: 85.5% accurate, 34.8× speedup?

\[\begin{array}{l} \\ \frac{x \cdot \left(1 - wj\right)}{wj + 1} \end{array} \]
(FPCore (wj x) :precision binary64 (/ (* x (- 1.0 wj)) (+ wj 1.0)))
double code(double wj, double x) {
	return (x * (1.0 - wj)) / (wj + 1.0);
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    code = (x * (1.0d0 - wj)) / (wj + 1.0d0)
end function
public static double code(double wj, double x) {
	return (x * (1.0 - wj)) / (wj + 1.0);
}
def code(wj, x):
	return (x * (1.0 - wj)) / (wj + 1.0)
function code(wj, x)
	return Float64(Float64(x * Float64(1.0 - wj)) / Float64(wj + 1.0))
end
function tmp = code(wj, x)
	tmp = (x * (1.0 - wj)) / (wj + 1.0);
end
code[wj_, x_] := N[(N[(x * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot \left(1 - wj\right)}{wj + 1}
\end{array}
Derivation
  1. Initial program 79.2%

    \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
  2. Step-by-step derivation
    1. sub-neg79.2%

      \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    2. div-sub79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
    3. sub-neg79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
    4. +-commutative79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
    5. distribute-neg-in79.2%

      \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
    6. remove-double-neg79.2%

      \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
    7. sub-neg79.2%

      \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    8. div-sub79.2%

      \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
    9. distribute-rgt1-in80.3%

      \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
    10. associate-/l/80.3%

      \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
  3. Simplified80.7%

    \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
  4. Taylor expanded in wj around 0 78.3%

    \[\leadsto wj + \frac{\color{blue}{\left(-1 \cdot \left(wj \cdot x\right) + x\right)} - wj}{wj + 1} \]
  5. Step-by-step derivation
    1. +-commutative78.3%

      \[\leadsto wj + \frac{\color{blue}{\left(x + -1 \cdot \left(wj \cdot x\right)\right)} - wj}{wj + 1} \]
    2. mul-1-neg78.3%

      \[\leadsto wj + \frac{\left(x + \color{blue}{\left(-wj \cdot x\right)}\right) - wj}{wj + 1} \]
    3. unsub-neg78.3%

      \[\leadsto wj + \frac{\color{blue}{\left(x - wj \cdot x\right)} - wj}{wj + 1} \]
    4. *-commutative78.3%

      \[\leadsto wj + \frac{\left(x - \color{blue}{x \cdot wj}\right) - wj}{wj + 1} \]
  6. Simplified78.3%

    \[\leadsto wj + \frac{\color{blue}{\left(x - x \cdot wj\right)} - wj}{wj + 1} \]
  7. Step-by-step derivation
    1. add-cbrt-cube37.4%

      \[\leadsto \color{blue}{\sqrt[3]{\left(\left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)}} \]
    2. associate--l-37.4%

      \[\leadsto \sqrt[3]{\left(\left(wj + \frac{\color{blue}{x - \left(x \cdot wj + wj\right)}}{wj + 1}\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)} \]
    3. +-commutative37.4%

      \[\leadsto \sqrt[3]{\left(\left(wj + \frac{x - \left(x \cdot wj + wj\right)}{\color{blue}{1 + wj}}\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)} \]
    4. associate--l-37.4%

      \[\leadsto \sqrt[3]{\left(\left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right) \cdot \left(wj + \frac{\color{blue}{x - \left(x \cdot wj + wj\right)}}{wj + 1}\right)\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)} \]
    5. +-commutative37.4%

      \[\leadsto \sqrt[3]{\left(\left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right) \cdot \left(wj + \frac{x - \left(x \cdot wj + wj\right)}{\color{blue}{1 + wj}}\right)\right) \cdot \left(wj + \frac{\left(x - x \cdot wj\right) - wj}{wj + 1}\right)} \]
    6. associate--l-37.4%

      \[\leadsto \sqrt[3]{\left(\left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right) \cdot \left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right)\right) \cdot \left(wj + \frac{\color{blue}{x - \left(x \cdot wj + wj\right)}}{wj + 1}\right)} \]
    7. +-commutative37.4%

      \[\leadsto \sqrt[3]{\left(\left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right) \cdot \left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right)\right) \cdot \left(wj + \frac{x - \left(x \cdot wj + wj\right)}{\color{blue}{1 + wj}}\right)} \]
  8. Applied egg-rr37.4%

    \[\leadsto \color{blue}{\sqrt[3]{\left(\left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right) \cdot \left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right)\right) \cdot \left(wj + \frac{x - \left(x \cdot wj + wj\right)}{1 + wj}\right)}} \]
  9. Taylor expanded in x around -inf 84.6%

    \[\leadsto \color{blue}{\frac{\left(1 + -1 \cdot wj\right) \cdot x}{1 + wj}} \]
  10. Step-by-step derivation
    1. *-commutative84.6%

      \[\leadsto \frac{\color{blue}{x \cdot \left(1 + -1 \cdot wj\right)}}{1 + wj} \]
    2. neg-mul-184.6%

      \[\leadsto \frac{x \cdot \left(1 + \color{blue}{\left(-wj\right)}\right)}{1 + wj} \]
    3. sub-neg84.6%

      \[\leadsto \frac{x \cdot \color{blue}{\left(1 - wj\right)}}{1 + wj} \]
    4. +-commutative84.6%

      \[\leadsto \frac{x \cdot \left(1 - wj\right)}{\color{blue}{wj + 1}} \]
  11. Simplified84.6%

    \[\leadsto \color{blue}{\frac{x \cdot \left(1 - wj\right)}{wj + 1}} \]
  12. Final simplification84.6%

    \[\leadsto \frac{x \cdot \left(1 - wj\right)}{wj + 1} \]

Alternative 16: 85.3% accurate, 44.7× speedup?

\[\begin{array}{l} \\ x + -2 \cdot \left(wj \cdot x\right) \end{array} \]
(FPCore (wj x) :precision binary64 (+ x (* -2.0 (* wj x))))
double code(double wj, double x) {
	return x + (-2.0 * (wj * x));
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    code = x + ((-2.0d0) * (wj * x))
end function
public static double code(double wj, double x) {
	return x + (-2.0 * (wj * x));
}
def code(wj, x):
	return x + (-2.0 * (wj * x))
function code(wj, x)
	return Float64(x + Float64(-2.0 * Float64(wj * x)))
end
function tmp = code(wj, x)
	tmp = x + (-2.0 * (wj * x));
end
code[wj_, x_] := N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + -2 \cdot \left(wj \cdot x\right)
\end{array}
Derivation
  1. Initial program 79.2%

    \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
  2. Step-by-step derivation
    1. sub-neg79.2%

      \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    2. div-sub79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
    3. sub-neg79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
    4. +-commutative79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
    5. distribute-neg-in79.2%

      \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
    6. remove-double-neg79.2%

      \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
    7. sub-neg79.2%

      \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    8. div-sub79.2%

      \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
    9. distribute-rgt1-in80.3%

      \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
    10. associate-/l/80.3%

      \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
  3. Simplified80.7%

    \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
  4. Taylor expanded in wj around 0 84.4%

    \[\leadsto \color{blue}{-2 \cdot \left(wj \cdot x\right) + x} \]
  5. Final simplification84.4%

    \[\leadsto x + -2 \cdot \left(wj \cdot x\right) \]

Alternative 17: 4.3% accurate, 313.0× speedup?

\[\begin{array}{l} \\ wj \end{array} \]
(FPCore (wj x) :precision binary64 wj)
double code(double wj, double x) {
	return wj;
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    code = wj
end function
public static double code(double wj, double x) {
	return wj;
}
def code(wj, x):
	return wj
function code(wj, x)
	return wj
end
function tmp = code(wj, x)
	tmp = wj;
end
code[wj_, x_] := wj
\begin{array}{l}

\\
wj
\end{array}
Derivation
  1. Initial program 79.2%

    \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
  2. Step-by-step derivation
    1. sub-neg79.2%

      \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    2. div-sub79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
    3. sub-neg79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
    4. +-commutative79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
    5. distribute-neg-in79.2%

      \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
    6. remove-double-neg79.2%

      \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
    7. sub-neg79.2%

      \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    8. div-sub79.2%

      \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
    9. distribute-rgt1-in80.3%

      \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
    10. associate-/l/80.3%

      \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
  3. Simplified80.7%

    \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
  4. Taylor expanded in wj around inf 4.2%

    \[\leadsto \color{blue}{wj} \]
  5. Final simplification4.2%

    \[\leadsto wj \]

Alternative 18: 84.9% accurate, 313.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (wj x) :precision binary64 x)
double code(double wj, double x) {
	return x;
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    code = x
end function
public static double code(double wj, double x) {
	return x;
}
def code(wj, x):
	return x
function code(wj, x)
	return x
end
function tmp = code(wj, x)
	tmp = x;
end
code[wj_, x_] := x
\begin{array}{l}

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

    \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
  2. Step-by-step derivation
    1. sub-neg79.2%

      \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    2. div-sub79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
    3. sub-neg79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right)}\right) \]
    4. +-commutative79.2%

      \[\leadsto wj + \left(-\color{blue}{\left(\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)}\right) \]
    5. distribute-neg-in79.2%

      \[\leadsto wj + \color{blue}{\left(\left(-\left(-\frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\right) + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right)} \]
    6. remove-double-neg79.2%

      \[\leadsto wj + \left(\color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} + \left(-\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)\right) \]
    7. sub-neg79.2%

      \[\leadsto wj + \color{blue}{\left(\frac{x}{e^{wj} + wj \cdot e^{wj}} - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    8. div-sub79.2%

      \[\leadsto wj + \color{blue}{\frac{x - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
    9. distribute-rgt1-in80.3%

      \[\leadsto wj + \frac{x - wj \cdot e^{wj}}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}} \]
    10. associate-/l/80.3%

      \[\leadsto wj + \color{blue}{\frac{\frac{x - wj \cdot e^{wj}}{e^{wj}}}{wj + 1}} \]
  3. Simplified80.7%

    \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
  4. Taylor expanded in wj around 0 83.7%

    \[\leadsto \color{blue}{x} \]
  5. Final simplification83.7%

    \[\leadsto x \]

Developer target: 79.9% accurate, 1.5× speedup?

\[\begin{array}{l} \\ wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right) \end{array} \]
(FPCore (wj x)
 :precision binary64
 (- wj (- (/ wj (+ wj 1.0)) (/ x (+ (exp wj) (* wj (exp wj)))))))
double code(double wj, double x) {
	return wj - ((wj / (wj + 1.0)) - (x / (exp(wj) + (wj * exp(wj)))));
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    code = wj - ((wj / (wj + 1.0d0)) - (x / (exp(wj) + (wj * exp(wj)))))
end function
public static double code(double wj, double x) {
	return wj - ((wj / (wj + 1.0)) - (x / (Math.exp(wj) + (wj * Math.exp(wj)))));
}
def code(wj, x):
	return wj - ((wj / (wj + 1.0)) - (x / (math.exp(wj) + (wj * math.exp(wj)))))
function code(wj, x)
	return Float64(wj - Float64(Float64(wj / Float64(wj + 1.0)) - Float64(x / Float64(exp(wj) + Float64(wj * exp(wj))))))
end
function tmp = code(wj, x)
	tmp = wj - ((wj / (wj + 1.0)) - (x / (exp(wj) + (wj * exp(wj)))));
end
code[wj_, x_] := N[(wj - N[(N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision] - N[(x / N[(N[Exp[wj], $MachinePrecision] + N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)
\end{array}

Reproduce

?
herbie shell --seed 2023240 
(FPCore (wj x)
  :name "Jmat.Real.lambertw, newton loop step"
  :precision binary64

  :herbie-target
  (- wj (- (/ wj (+ wj 1.0)) (/ x (+ (exp wj) (* wj (exp wj))))))

  (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))