Jmat.Real.lambertw, newton loop step

Percentage Accurate: 77.4% → 98.5%
Time: 10.4s
Alternatives: 14
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 14 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: 77.4% 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: 98.5% 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 1.35 \cdot 10^{-17}:\\ \;\;\;\;wj \cdot wj - \left(wj \cdot \left(x + x\right) + \left({wj}^{3} - x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{e^{wj}} - wj, \frac{1}{wj + 1}, wj\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))) 1.35e-17)
     (- (* wj wj) (+ (* wj (+ x x)) (- (pow wj 3.0) x)))
     (fma (- (/ x (exp wj)) wj) (/ 1.0 (+ wj 1.0)) wj))))
double code(double wj, double x) {
	double t_0 = wj * exp(wj);
	double tmp;
	if ((wj + ((x - t_0) / (exp(wj) + t_0))) <= 1.35e-17) {
		tmp = (wj * wj) - ((wj * (x + x)) + (pow(wj, 3.0) - x));
	} else {
		tmp = fma(((x / exp(wj)) - wj), (1.0 / (wj + 1.0)), wj);
	}
	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))) <= 1.35e-17)
		tmp = Float64(Float64(wj * wj) - Float64(Float64(wj * Float64(x + x)) + Float64((wj ^ 3.0) - x)));
	else
		tmp = fma(Float64(Float64(x / exp(wj)) - wj), Float64(1.0 / Float64(wj + 1.0)), wj);
	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], 1.35e-17], N[(N[(wj * wj), $MachinePrecision] - N[(N[(wj * N[(x + x), $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 3.0], $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] * N[(1.0 / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision] + wj), $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 1.35 \cdot 10^{-17}:\\
\;\;\;\;wj \cdot wj - \left(wj \cdot \left(x + x\right) + \left({wj}^{3} - x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{e^{wj}} - wj, \frac{1}{wj + 1}, wj\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))))) < 1.3500000000000001e-17

    1. Initial program 67.9%

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

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub67.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-neg67.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. +-commutative67.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-in67.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-neg67.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-neg67.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-sub67.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{wj \cdot wj} + \left(\left(-1 \cdot x - x\right) \cdot wj + \left(\left(-1 \cdot x - \left(1 + x\right)\right) \cdot {wj}^{3} + x\right)\right) \]
    8. Simplified98.9%

      \[\leadsto \color{blue}{wj \cdot wj} + \left(\left(-1 \cdot x - x\right) \cdot wj + \left(\left(-1 \cdot x - \left(1 + x\right)\right) \cdot {wj}^{3} + x\right)\right) \]
    9. Taylor expanded in x around 0 98.9%

      \[\leadsto wj \cdot wj + \left(\left(-1 \cdot x - x\right) \cdot wj + \left(\color{blue}{-1 \cdot {wj}^{3}} + x\right)\right) \]
    10. Step-by-step derivation
      1. mul-1-neg98.9%

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

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

    if 1.3500000000000001e-17 < (-.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-in96.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{e^{wj}} - wj, \frac{1}{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 1.35 \cdot 10^{-17}:\\ \;\;\;\;wj \cdot wj - \left(wj \cdot \left(x + x\right) + \left({wj}^{3} - x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{e^{wj}} - wj, \frac{1}{wj + 1}, wj\right)\\ \end{array} \]

Alternative 2: 96.0% accurate, 2.7× speedup?

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

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

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

      \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    2. div-sub76.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-neg76.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. +-commutative76.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-in76.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-neg76.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-neg76.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-sub76.1%

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

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

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

    \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}} \]
  4. Taylor expanded in wj around 0 96.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 96.7%

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

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

    \[\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) \]
  8. Taylor expanded in x around 0 97.1%

    \[\leadsto -1 \cdot \color{blue}{{wj}^{3}} + \left(wj \cdot wj + \left(-2 \cdot \left(wj \cdot x\right) + x\right)\right) \]
  9. Final simplification97.1%

    \[\leadsto \left(wj \cdot wj + \left(x + -2 \cdot \left(wj \cdot x\right)\right)\right) - {wj}^{3} \]

Alternative 3: 95.9% accurate, 2.7× speedup?

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

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

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

      \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    2. div-sub76.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-neg76.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. +-commutative76.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-in76.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-neg76.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-neg76.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-sub76.1%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{wj \cdot wj} + \left(\left(-1 \cdot x - x\right) \cdot wj + \left(\left(-1 \cdot x - \left(1 + x\right)\right) \cdot {wj}^{3} + x\right)\right) \]
  9. Taylor expanded in x around 0 97.1%

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

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

    \[\leadsto wj \cdot wj + \left(\left(-1 \cdot x - x\right) \cdot wj + \left(\color{blue}{\left(-{wj}^{3}\right)} + x\right)\right) \]
  12. Final simplification97.1%

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

Alternative 4: 95.6% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(wj, \left(wj + \left(wj \cdot x\right) \cdot 2\right) + x \cdot -2, x\right) \end{array} \]
(FPCore (wj x)
 :precision binary64
 (fma wj (+ (+ wj (* (* wj x) 2.0)) (* x -2.0)) x))
double code(double wj, double x) {
	return fma(wj, ((wj + ((wj * x) * 2.0)) + (x * -2.0)), x);
}
function code(wj, x)
	return fma(wj, Float64(Float64(wj + Float64(Float64(wj * x) * 2.0)) + Float64(x * -2.0)), x)
end
code[wj_, x_] := N[(wj * N[(N[(wj + N[(N[(wj * x), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] + N[(x * -2.0), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}

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

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

      \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    2. div-sub76.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-neg76.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. +-commutative76.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-in76.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-neg76.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-neg76.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-sub76.1%

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

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

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

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

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

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

    \[\leadsto \color{blue}{{wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(\left(-1 \cdot x - x\right) \cdot wj + x\right)} \]
  7. Step-by-step derivation
    1. associate-+r+96.7%

      \[\leadsto \color{blue}{\left({wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-1 \cdot x - x\right) \cdot wj\right) + x} \]
    2. remove-double-neg96.7%

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

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

      \[\leadsto \left(\color{blue}{\left(wj \cdot wj\right)} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
    5. sub-neg96.7%

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

      \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \left(-\color{blue}{\left(-x\right)}\right)\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
    7. remove-double-neg96.7%

      \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \color{blue}{x}\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
    8. associate-*l*96.7%

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

      \[\leadsto \left(wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right)\right) + \color{blue}{wj \cdot \left(-1 \cdot x - x\right)}\right) - \left(-x\right) \]
    10. distribute-lft-out96.7%

      \[\leadsto \color{blue}{wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right)\right)} - \left(-x\right) \]
    11. fma-neg96.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right), -\left(-x\right)\right)} \]
  8. Simplified96.7%

    \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \mathsf{fma}\left(2, x, 1\right) + x \cdot -2, x\right)} \]
  9. Taylor expanded in x around 0 96.7%

    \[\leadsto \mathsf{fma}\left(wj, \color{blue}{\left(wj + 2 \cdot \left(wj \cdot x\right)\right)} + x \cdot -2, x\right) \]
  10. Final simplification96.7%

    \[\leadsto \mathsf{fma}\left(wj, \left(wj + \left(wj \cdot x\right) \cdot 2\right) + x \cdot -2, x\right) \]

Alternative 5: 83.8% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{wj}{wj + 1}\\ \mathbf{if}\;x \leq -1.5 \cdot 10^{-138} \lor \neg \left(x \leq -1.05 \cdot 10^{-225}\right):\\ \;\;\;\;\left(wj - t_0\right) + x \cdot \left(\frac{1}{wj + 1} - t_0\right)\\ \mathbf{else}:\\ \;\;\;\;wj \cdot wj - {wj}^{3}\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (let* ((t_0 (/ wj (+ wj 1.0))))
   (if (or (<= x -1.5e-138) (not (<= x -1.05e-225)))
     (+ (- wj t_0) (* x (- (/ 1.0 (+ wj 1.0)) t_0)))
     (- (* wj wj) (pow wj 3.0)))))
double code(double wj, double x) {
	double t_0 = wj / (wj + 1.0);
	double tmp;
	if ((x <= -1.5e-138) || !(x <= -1.05e-225)) {
		tmp = (wj - t_0) + (x * ((1.0 / (wj + 1.0)) - t_0));
	} else {
		tmp = (wj * wj) - pow(wj, 3.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 / (wj + 1.0d0)
    if ((x <= (-1.5d-138)) .or. (.not. (x <= (-1.05d-225)))) then
        tmp = (wj - t_0) + (x * ((1.0d0 / (wj + 1.0d0)) - t_0))
    else
        tmp = (wj * wj) - (wj ** 3.0d0)
    end if
    code = tmp
end function
public static double code(double wj, double x) {
	double t_0 = wj / (wj + 1.0);
	double tmp;
	if ((x <= -1.5e-138) || !(x <= -1.05e-225)) {
		tmp = (wj - t_0) + (x * ((1.0 / (wj + 1.0)) - t_0));
	} else {
		tmp = (wj * wj) - Math.pow(wj, 3.0);
	}
	return tmp;
}
def code(wj, x):
	t_0 = wj / (wj + 1.0)
	tmp = 0
	if (x <= -1.5e-138) or not (x <= -1.05e-225):
		tmp = (wj - t_0) + (x * ((1.0 / (wj + 1.0)) - t_0))
	else:
		tmp = (wj * wj) - math.pow(wj, 3.0)
	return tmp
function code(wj, x)
	t_0 = Float64(wj / Float64(wj + 1.0))
	tmp = 0.0
	if ((x <= -1.5e-138) || !(x <= -1.05e-225))
		tmp = Float64(Float64(wj - t_0) + Float64(x * Float64(Float64(1.0 / Float64(wj + 1.0)) - t_0)));
	else
		tmp = Float64(Float64(wj * wj) - (wj ^ 3.0));
	end
	return tmp
end
function tmp_2 = code(wj, x)
	t_0 = wj / (wj + 1.0);
	tmp = 0.0;
	if ((x <= -1.5e-138) || ~((x <= -1.05e-225)))
		tmp = (wj - t_0) + (x * ((1.0 / (wj + 1.0)) - t_0));
	else
		tmp = (wj * wj) - (wj ^ 3.0);
	end
	tmp_2 = tmp;
end
code[wj_, x_] := Block[{t$95$0 = N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[x, -1.5e-138], N[Not[LessEqual[x, -1.05e-225]], $MachinePrecision]], N[(N[(wj - t$95$0), $MachinePrecision] + N[(x * N[(N[(1.0 / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(wj * wj), $MachinePrecision] - N[Power[wj, 3.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{wj}{wj + 1}\\
\mathbf{if}\;x \leq -1.5 \cdot 10^{-138} \lor \neg \left(x \leq -1.05 \cdot 10^{-225}\right):\\
\;\;\;\;\left(wj - t_0\right) + x \cdot \left(\frac{1}{wj + 1} - t_0\right)\\

\mathbf{else}:\\
\;\;\;\;wj \cdot wj - {wj}^{3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.5e-138 or -1.05e-225 < x

    1. Initial program 79.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(wj - \frac{wj}{wj + 1}\right) - x \cdot \left(\frac{wj}{wj + 1} + \left(-\frac{1}{\color{blue}{wj + 1}}\right)\right) \]
      12. distribute-neg-frac91.7%

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

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

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

    if -1.5e-138 < x < -1.05e-225

    1. Initial program 16.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{wj}^{2} + -1 \cdot {wj}^{3}} \]
    7. Step-by-step derivation
      1. mul-1-neg68.7%

        \[\leadsto {wj}^{2} + \color{blue}{\left(-{wj}^{3}\right)} \]
      2. unsub-neg68.7%

        \[\leadsto \color{blue}{{wj}^{2} - {wj}^{3}} \]
      3. unpow268.7%

        \[\leadsto \color{blue}{wj \cdot wj} - {wj}^{3} \]
    8. Simplified68.7%

      \[\leadsto \color{blue}{wj \cdot wj - {wj}^{3}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{-138} \lor \neg \left(x \leq -1.05 \cdot 10^{-225}\right):\\ \;\;\;\;\left(wj - \frac{wj}{wj + 1}\right) + x \cdot \left(\frac{1}{wj + 1} - \frac{wj}{wj + 1}\right)\\ \mathbf{else}:\\ \;\;\;\;wj \cdot wj - {wj}^{3}\\ \end{array} \]

Alternative 6: 95.5% accurate, 2.8× speedup?

\[\begin{array}{l} \\ wj \cdot wj + \mathsf{fma}\left(\left(-x\right) - x, wj, x\right) \end{array} \]
(FPCore (wj x) :precision binary64 (+ (* wj wj) (fma (- (- x) x) wj x)))
double code(double wj, double x) {
	return (wj * wj) + fma((-x - x), wj, x);
}
function code(wj, x)
	return Float64(Float64(wj * wj) + fma(Float64(Float64(-x) - x), wj, x))
end
code[wj_, x_] := N[(N[(wj * wj), $MachinePrecision] + N[(N[((-x) - x), $MachinePrecision] * wj + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
wj \cdot wj + \mathsf{fma}\left(\left(-x\right) - x, wj, x\right)
\end{array}
Derivation
  1. Initial program 76.1%

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

      \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    2. div-sub76.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-neg76.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. +-commutative76.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-in76.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-neg76.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-neg76.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-sub76.1%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{wj \cdot wj} + \left(\left(-1 \cdot x - x\right) \cdot wj + \left(\left(-1 \cdot x - \left(1 + x\right)\right) \cdot {wj}^{3} + x\right)\right) \]
  9. Taylor expanded in wj around 0 96.7%

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

      \[\leadsto \color{blue}{\left(\left(-1 \cdot x - x\right) \cdot wj + x\right) + {wj}^{2}} \]
    2. fma-def96.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot x - x, wj, x\right)} + {wj}^{2} \]
    3. neg-mul-196.7%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(-x\right)} - x, wj, x\right) + {wj}^{2} \]
    4. unpow296.7%

      \[\leadsto \mathsf{fma}\left(\left(-x\right) - x, wj, x\right) + \color{blue}{wj \cdot wj} \]
  11. Simplified96.7%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(-x\right) - x, wj, x\right) + wj \cdot wj} \]
  12. Final simplification96.7%

    \[\leadsto wj \cdot wj + \mathsf{fma}\left(\left(-x\right) - x, wj, x\right) \]

Alternative 7: 83.7% accurate, 12.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{wj}{wj + 1}\\ \mathbf{if}\;x \leq -1.5 \cdot 10^{-138} \lor \neg \left(x \leq -1.05 \cdot 10^{-225}\right):\\ \;\;\;\;\left(wj - t_0\right) + x \cdot \left(\frac{1}{wj + 1} - t_0\right)\\ \mathbf{else}:\\ \;\;\;\;wj \cdot wj\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (let* ((t_0 (/ wj (+ wj 1.0))))
   (if (or (<= x -1.5e-138) (not (<= x -1.05e-225)))
     (+ (- wj t_0) (* x (- (/ 1.0 (+ wj 1.0)) t_0)))
     (* wj wj))))
double code(double wj, double x) {
	double t_0 = wj / (wj + 1.0);
	double tmp;
	if ((x <= -1.5e-138) || !(x <= -1.05e-225)) {
		tmp = (wj - t_0) + (x * ((1.0 / (wj + 1.0)) - t_0));
	} else {
		tmp = wj * wj;
	}
	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 / (wj + 1.0d0)
    if ((x <= (-1.5d-138)) .or. (.not. (x <= (-1.05d-225)))) then
        tmp = (wj - t_0) + (x * ((1.0d0 / (wj + 1.0d0)) - t_0))
    else
        tmp = wj * wj
    end if
    code = tmp
end function
public static double code(double wj, double x) {
	double t_0 = wj / (wj + 1.0);
	double tmp;
	if ((x <= -1.5e-138) || !(x <= -1.05e-225)) {
		tmp = (wj - t_0) + (x * ((1.0 / (wj + 1.0)) - t_0));
	} else {
		tmp = wj * wj;
	}
	return tmp;
}
def code(wj, x):
	t_0 = wj / (wj + 1.0)
	tmp = 0
	if (x <= -1.5e-138) or not (x <= -1.05e-225):
		tmp = (wj - t_0) + (x * ((1.0 / (wj + 1.0)) - t_0))
	else:
		tmp = wj * wj
	return tmp
function code(wj, x)
	t_0 = Float64(wj / Float64(wj + 1.0))
	tmp = 0.0
	if ((x <= -1.5e-138) || !(x <= -1.05e-225))
		tmp = Float64(Float64(wj - t_0) + Float64(x * Float64(Float64(1.0 / Float64(wj + 1.0)) - t_0)));
	else
		tmp = Float64(wj * wj);
	end
	return tmp
end
function tmp_2 = code(wj, x)
	t_0 = wj / (wj + 1.0);
	tmp = 0.0;
	if ((x <= -1.5e-138) || ~((x <= -1.05e-225)))
		tmp = (wj - t_0) + (x * ((1.0 / (wj + 1.0)) - t_0));
	else
		tmp = wj * wj;
	end
	tmp_2 = tmp;
end
code[wj_, x_] := Block[{t$95$0 = N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[x, -1.5e-138], N[Not[LessEqual[x, -1.05e-225]], $MachinePrecision]], N[(N[(wj - t$95$0), $MachinePrecision] + N[(x * N[(N[(1.0 / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj * wj), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{wj}{wj + 1}\\
\mathbf{if}\;x \leq -1.5 \cdot 10^{-138} \lor \neg \left(x \leq -1.05 \cdot 10^{-225}\right):\\
\;\;\;\;\left(wj - t_0\right) + x \cdot \left(\frac{1}{wj + 1} - t_0\right)\\

\mathbf{else}:\\
\;\;\;\;wj \cdot wj\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.5e-138 or -1.05e-225 < x

    1. Initial program 79.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(wj - \frac{wj}{wj + 1}\right) - x \cdot \left(\frac{wj}{wj + 1} + \left(-\frac{1}{\color{blue}{wj + 1}}\right)\right) \]
      12. distribute-neg-frac91.7%

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

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

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

    if -1.5e-138 < x < -1.05e-225

    1. Initial program 16.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(\left(-1 \cdot x - x\right) \cdot wj + x\right)} \]
    7. Step-by-step derivation
      1. associate-+r+93.4%

        \[\leadsto \color{blue}{\left({wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-1 \cdot x - x\right) \cdot wj\right) + x} \]
      2. remove-double-neg93.4%

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

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

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

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

        \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \left(-\color{blue}{\left(-x\right)}\right)\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      7. remove-double-neg93.4%

        \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \color{blue}{x}\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      8. associate-*l*93.4%

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

        \[\leadsto \left(wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right)\right) + \color{blue}{wj \cdot \left(-1 \cdot x - x\right)}\right) - \left(-x\right) \]
      10. distribute-lft-out93.4%

        \[\leadsto \color{blue}{wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right)\right)} - \left(-x\right) \]
      11. fma-neg93.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right), -\left(-x\right)\right)} \]
    8. Simplified93.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \mathsf{fma}\left(2, x, 1\right) + x \cdot -2, x\right)} \]
    9. Taylor expanded in x around 0 68.7%

      \[\leadsto \color{blue}{{wj}^{2}} \]
    10. Step-by-step derivation
      1. unpow268.7%

        \[\leadsto \color{blue}{wj \cdot wj} \]
    11. Simplified68.7%

      \[\leadsto \color{blue}{wj \cdot wj} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{-138} \lor \neg \left(x \leq -1.05 \cdot 10^{-225}\right):\\ \;\;\;\;\left(wj - \frac{wj}{wj + 1}\right) + x \cdot \left(\frac{1}{wj + 1} - \frac{wj}{wj + 1}\right)\\ \mathbf{else}:\\ \;\;\;\;wj \cdot wj\\ \end{array} \]

Alternative 8: 80.9% accurate, 20.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{-138}:\\ \;\;\;\;x \cdot \frac{1 - wj}{wj + 1}\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-282}:\\ \;\;\;\;wj \cdot wj\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(wj \cdot \left(wj \cdot 2 - 2\right) + 1\right)\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (if (<= x -1.5e-138)
   (* x (/ (- 1.0 wj) (+ wj 1.0)))
   (if (<= x -4e-282) (* wj wj) (* x (+ (* wj (- (* wj 2.0) 2.0)) 1.0)))))
double code(double wj, double x) {
	double tmp;
	if (x <= -1.5e-138) {
		tmp = x * ((1.0 - wj) / (wj + 1.0));
	} else if (x <= -4e-282) {
		tmp = wj * wj;
	} else {
		tmp = x * ((wj * ((wj * 2.0) - 2.0)) + 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 <= (-1.5d-138)) then
        tmp = x * ((1.0d0 - wj) / (wj + 1.0d0))
    else if (x <= (-4d-282)) then
        tmp = wj * wj
    else
        tmp = x * ((wj * ((wj * 2.0d0) - 2.0d0)) + 1.0d0)
    end if
    code = tmp
end function
public static double code(double wj, double x) {
	double tmp;
	if (x <= -1.5e-138) {
		tmp = x * ((1.0 - wj) / (wj + 1.0));
	} else if (x <= -4e-282) {
		tmp = wj * wj;
	} else {
		tmp = x * ((wj * ((wj * 2.0) - 2.0)) + 1.0);
	}
	return tmp;
}
def code(wj, x):
	tmp = 0
	if x <= -1.5e-138:
		tmp = x * ((1.0 - wj) / (wj + 1.0))
	elif x <= -4e-282:
		tmp = wj * wj
	else:
		tmp = x * ((wj * ((wj * 2.0) - 2.0)) + 1.0)
	return tmp
function code(wj, x)
	tmp = 0.0
	if (x <= -1.5e-138)
		tmp = Float64(x * Float64(Float64(1.0 - wj) / Float64(wj + 1.0)));
	elseif (x <= -4e-282)
		tmp = Float64(wj * wj);
	else
		tmp = Float64(x * Float64(Float64(wj * Float64(Float64(wj * 2.0) - 2.0)) + 1.0));
	end
	return tmp
end
function tmp_2 = code(wj, x)
	tmp = 0.0;
	if (x <= -1.5e-138)
		tmp = x * ((1.0 - wj) / (wj + 1.0));
	elseif (x <= -4e-282)
		tmp = wj * wj;
	else
		tmp = x * ((wj * ((wj * 2.0) - 2.0)) + 1.0);
	end
	tmp_2 = tmp;
end
code[wj_, x_] := If[LessEqual[x, -1.5e-138], N[(x * N[(N[(1.0 - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -4e-282], N[(wj * wj), $MachinePrecision], N[(x * N[(N[(wj * N[(N[(wj * 2.0), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -4 \cdot 10^{-282}:\\
\;\;\;\;wj \cdot wj\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.5e-138

    1. Initial program 92.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\frac{1 - wj}{wj + 1}} \]
    10. Simplified95.9%

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

    if -1.5e-138 < x < -4.0000000000000001e-282

    1. Initial program 19.4%

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

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub19.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-neg19.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. +-commutative19.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-in19.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-neg19.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-neg19.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-sub19.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{{wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(\left(-1 \cdot x - x\right) \cdot wj + x\right)} \]
    7. Step-by-step derivation
      1. associate-+r+93.7%

        \[\leadsto \color{blue}{\left({wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-1 \cdot x - x\right) \cdot wj\right) + x} \]
      2. remove-double-neg93.7%

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

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

        \[\leadsto \left(\color{blue}{\left(wj \cdot wj\right)} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      5. sub-neg93.7%

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

        \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \left(-\color{blue}{\left(-x\right)}\right)\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      7. remove-double-neg93.7%

        \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \color{blue}{x}\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      8. associate-*l*93.7%

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

        \[\leadsto \left(wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right)\right) + \color{blue}{wj \cdot \left(-1 \cdot x - x\right)}\right) - \left(-x\right) \]
      10. distribute-lft-out93.7%

        \[\leadsto \color{blue}{wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right)\right)} - \left(-x\right) \]
      11. fma-neg93.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right), -\left(-x\right)\right)} \]
    8. Simplified93.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \mathsf{fma}\left(2, x, 1\right) + x \cdot -2, x\right)} \]
    9. Taylor expanded in x around 0 59.2%

      \[\leadsto \color{blue}{{wj}^{2}} \]
    10. Step-by-step derivation
      1. unpow259.2%

        \[\leadsto \color{blue}{wj \cdot wj} \]
    11. Simplified59.2%

      \[\leadsto \color{blue}{wj \cdot wj} \]

    if -4.0000000000000001e-282 < x

    1. Initial program 76.7%

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

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub76.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-neg76.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. +-commutative76.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-in76.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-neg76.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-neg76.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-sub76.7%

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

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

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

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

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

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

      \[\leadsto \color{blue}{{wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(\left(-1 \cdot x - x\right) \cdot wj + x\right)} \]
    7. Step-by-step derivation
      1. associate-+r+97.0%

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

        \[\leadsto \left({wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-1 \cdot x - x\right) \cdot wj\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
      3. unsub-neg97.0%

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

        \[\leadsto \left(\color{blue}{\left(wj \cdot wj\right)} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      5. sub-neg97.0%

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

        \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \left(-\color{blue}{\left(-x\right)}\right)\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      7. remove-double-neg97.0%

        \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \color{blue}{x}\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      8. associate-*l*97.0%

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

        \[\leadsto \left(wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right)\right) + \color{blue}{wj \cdot \left(-1 \cdot x - x\right)}\right) - \left(-x\right) \]
      10. distribute-lft-out97.0%

        \[\leadsto \color{blue}{wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right)\right)} - \left(-x\right) \]
      11. fma-neg97.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right), -\left(-x\right)\right)} \]
    8. Simplified97.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \mathsf{fma}\left(2, x, 1\right) + x \cdot -2, x\right)} \]
    9. Taylor expanded in x around inf 89.6%

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

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

Alternative 9: 81.0% accurate, 23.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{-138} \lor \neg \left(x \leq -8.5 \cdot 10^{-280}\right):\\
\;\;\;\;x \cdot \frac{1 - wj}{wj + 1}\\

\mathbf{else}:\\
\;\;\;\;wj \cdot wj\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.5e-138 or -8.50000000000000037e-280 < x

    1. Initial program 83.1%

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

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub83.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-neg83.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. +-commutative83.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-in83.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-neg83.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-neg83.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-sub83.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.5e-138 < x < -8.50000000000000037e-280

    1. Initial program 19.4%

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

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub19.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-neg19.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. +-commutative19.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-in19.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-neg19.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-neg19.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-sub19.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{{wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(\left(-1 \cdot x - x\right) \cdot wj + x\right)} \]
    7. Step-by-step derivation
      1. associate-+r+93.7%

        \[\leadsto \color{blue}{\left({wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-1 \cdot x - x\right) \cdot wj\right) + x} \]
      2. remove-double-neg93.7%

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

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

        \[\leadsto \left(\color{blue}{\left(wj \cdot wj\right)} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      5. sub-neg93.7%

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

        \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \left(-\color{blue}{\left(-x\right)}\right)\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      7. remove-double-neg93.7%

        \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \color{blue}{x}\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      8. associate-*l*93.7%

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

        \[\leadsto \left(wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right)\right) + \color{blue}{wj \cdot \left(-1 \cdot x - x\right)}\right) - \left(-x\right) \]
      10. distribute-lft-out93.7%

        \[\leadsto \color{blue}{wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right)\right)} - \left(-x\right) \]
      11. fma-neg93.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right), -\left(-x\right)\right)} \]
    8. Simplified93.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \mathsf{fma}\left(2, x, 1\right) + x \cdot -2, x\right)} \]
    9. Taylor expanded in x around 0 59.2%

      \[\leadsto \color{blue}{{wj}^{2}} \]
    10. Step-by-step derivation
      1. unpow259.2%

        \[\leadsto \color{blue}{wj \cdot wj} \]
    11. Simplified59.2%

      \[\leadsto \color{blue}{wj \cdot wj} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{-138} \lor \neg \left(x \leq -8.5 \cdot 10^{-280}\right):\\ \;\;\;\;x \cdot \frac{1 - wj}{wj + 1}\\ \mathbf{else}:\\ \;\;\;\;wj \cdot wj\\ \end{array} \]

Alternative 10: 80.9% accurate, 28.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{-138} \lor \neg \left(x \leq -2.6 \cdot 10^{-279}\right):\\ \;\;\;\;x \cdot \left(wj \cdot -2 + 1\right)\\ \mathbf{else}:\\ \;\;\;\;wj \cdot wj\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (if (or (<= x -1.5e-138) (not (<= x -2.6e-279)))
   (* x (+ (* wj -2.0) 1.0))
   (* wj wj)))
double code(double wj, double x) {
	double tmp;
	if ((x <= -1.5e-138) || !(x <= -2.6e-279)) {
		tmp = x * ((wj * -2.0) + 1.0);
	} else {
		tmp = wj * wj;
	}
	return tmp;
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    real(8) :: tmp
    if ((x <= (-1.5d-138)) .or. (.not. (x <= (-2.6d-279)))) then
        tmp = x * ((wj * (-2.0d0)) + 1.0d0)
    else
        tmp = wj * wj
    end if
    code = tmp
end function
public static double code(double wj, double x) {
	double tmp;
	if ((x <= -1.5e-138) || !(x <= -2.6e-279)) {
		tmp = x * ((wj * -2.0) + 1.0);
	} else {
		tmp = wj * wj;
	}
	return tmp;
}
def code(wj, x):
	tmp = 0
	if (x <= -1.5e-138) or not (x <= -2.6e-279):
		tmp = x * ((wj * -2.0) + 1.0)
	else:
		tmp = wj * wj
	return tmp
function code(wj, x)
	tmp = 0.0
	if ((x <= -1.5e-138) || !(x <= -2.6e-279))
		tmp = Float64(x * Float64(Float64(wj * -2.0) + 1.0));
	else
		tmp = Float64(wj * wj);
	end
	return tmp
end
function tmp_2 = code(wj, x)
	tmp = 0.0;
	if ((x <= -1.5e-138) || ~((x <= -2.6e-279)))
		tmp = x * ((wj * -2.0) + 1.0);
	else
		tmp = wj * wj;
	end
	tmp_2 = tmp;
end
code[wj_, x_] := If[Or[LessEqual[x, -1.5e-138], N[Not[LessEqual[x, -2.6e-279]], $MachinePrecision]], N[(x * N[(N[(wj * -2.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(wj * wj), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{-138} \lor \neg \left(x \leq -2.6 \cdot 10^{-279}\right):\\
\;\;\;\;x \cdot \left(wj \cdot -2 + 1\right)\\

\mathbf{else}:\\
\;\;\;\;wj \cdot wj\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.5e-138 or -2.6000000000000002e-279 < x

    1. Initial program 83.1%

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

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub83.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-neg83.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. +-commutative83.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-in83.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-neg83.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-neg83.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-sub83.1%

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

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

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

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

      \[\leadsto \color{blue}{-2 \cdot \left(wj \cdot x\right) + x} \]
    5. Taylor expanded in x around 0 92.1%

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

    if -1.5e-138 < x < -2.6000000000000002e-279

    1. Initial program 19.4%

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

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub19.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-neg19.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. +-commutative19.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-in19.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-neg19.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-neg19.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-sub19.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{{wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(\left(-1 \cdot x - x\right) \cdot wj + x\right)} \]
    7. Step-by-step derivation
      1. associate-+r+93.7%

        \[\leadsto \color{blue}{\left({wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-1 \cdot x - x\right) \cdot wj\right) + x} \]
      2. remove-double-neg93.7%

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

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

        \[\leadsto \left(\color{blue}{\left(wj \cdot wj\right)} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      5. sub-neg93.7%

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

        \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \left(-\color{blue}{\left(-x\right)}\right)\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      7. remove-double-neg93.7%

        \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \color{blue}{x}\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      8. associate-*l*93.7%

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

        \[\leadsto \left(wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right)\right) + \color{blue}{wj \cdot \left(-1 \cdot x - x\right)}\right) - \left(-x\right) \]
      10. distribute-lft-out93.7%

        \[\leadsto \color{blue}{wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right)\right)} - \left(-x\right) \]
      11. fma-neg93.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right), -\left(-x\right)\right)} \]
    8. Simplified93.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \mathsf{fma}\left(2, x, 1\right) + x \cdot -2, x\right)} \]
    9. Taylor expanded in x around 0 59.2%

      \[\leadsto \color{blue}{{wj}^{2}} \]
    10. Step-by-step derivation
      1. unpow259.2%

        \[\leadsto \color{blue}{wj \cdot wj} \]
    11. Simplified59.2%

      \[\leadsto \color{blue}{wj \cdot wj} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{-138} \lor \neg \left(x \leq -2.6 \cdot 10^{-279}\right):\\ \;\;\;\;x \cdot \left(wj \cdot -2 + 1\right)\\ \mathbf{else}:\\ \;\;\;\;wj \cdot wj\\ \end{array} \]

Alternative 11: 80.9% accurate, 28.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{-138}:\\ \;\;\;\;x + -2 \cdot \left(wj \cdot x\right)\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-279}:\\ \;\;\;\;wj \cdot wj\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(wj \cdot -2 + 1\right)\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (if (<= x -1.5e-138)
   (+ x (* -2.0 (* wj x)))
   (if (<= x -2.8e-279) (* wj wj) (* x (+ (* wj -2.0) 1.0)))))
double code(double wj, double x) {
	double tmp;
	if (x <= -1.5e-138) {
		tmp = x + (-2.0 * (wj * x));
	} else if (x <= -2.8e-279) {
		tmp = wj * wj;
	} else {
		tmp = x * ((wj * -2.0) + 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 <= (-1.5d-138)) then
        tmp = x + ((-2.0d0) * (wj * x))
    else if (x <= (-2.8d-279)) then
        tmp = wj * wj
    else
        tmp = x * ((wj * (-2.0d0)) + 1.0d0)
    end if
    code = tmp
end function
public static double code(double wj, double x) {
	double tmp;
	if (x <= -1.5e-138) {
		tmp = x + (-2.0 * (wj * x));
	} else if (x <= -2.8e-279) {
		tmp = wj * wj;
	} else {
		tmp = x * ((wj * -2.0) + 1.0);
	}
	return tmp;
}
def code(wj, x):
	tmp = 0
	if x <= -1.5e-138:
		tmp = x + (-2.0 * (wj * x))
	elif x <= -2.8e-279:
		tmp = wj * wj
	else:
		tmp = x * ((wj * -2.0) + 1.0)
	return tmp
function code(wj, x)
	tmp = 0.0
	if (x <= -1.5e-138)
		tmp = Float64(x + Float64(-2.0 * Float64(wj * x)));
	elseif (x <= -2.8e-279)
		tmp = Float64(wj * wj);
	else
		tmp = Float64(x * Float64(Float64(wj * -2.0) + 1.0));
	end
	return tmp
end
function tmp_2 = code(wj, x)
	tmp = 0.0;
	if (x <= -1.5e-138)
		tmp = x + (-2.0 * (wj * x));
	elseif (x <= -2.8e-279)
		tmp = wj * wj;
	else
		tmp = x * ((wj * -2.0) + 1.0);
	end
	tmp_2 = tmp;
end
code[wj_, x_] := If[LessEqual[x, -1.5e-138], N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.8e-279], N[(wj * wj), $MachinePrecision], N[(x * N[(N[(wj * -2.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -2.8 \cdot 10^{-279}:\\
\;\;\;\;wj \cdot wj\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.5e-138

    1. Initial program 92.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.5e-138 < x < -2.8000000000000001e-279

    1. Initial program 19.4%

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

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub19.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-neg19.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. +-commutative19.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-in19.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-neg19.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-neg19.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-sub19.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{{wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(\left(-1 \cdot x - x\right) \cdot wj + x\right)} \]
    7. Step-by-step derivation
      1. associate-+r+93.7%

        \[\leadsto \color{blue}{\left({wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-1 \cdot x - x\right) \cdot wj\right) + x} \]
      2. remove-double-neg93.7%

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

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

        \[\leadsto \left(\color{blue}{\left(wj \cdot wj\right)} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      5. sub-neg93.7%

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

        \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \left(-\color{blue}{\left(-x\right)}\right)\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      7. remove-double-neg93.7%

        \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \color{blue}{x}\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      8. associate-*l*93.7%

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

        \[\leadsto \left(wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right)\right) + \color{blue}{wj \cdot \left(-1 \cdot x - x\right)}\right) - \left(-x\right) \]
      10. distribute-lft-out93.7%

        \[\leadsto \color{blue}{wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right)\right)} - \left(-x\right) \]
      11. fma-neg93.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right), -\left(-x\right)\right)} \]
    8. Simplified93.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \mathsf{fma}\left(2, x, 1\right) + x \cdot -2, x\right)} \]
    9. Taylor expanded in x around 0 59.2%

      \[\leadsto \color{blue}{{wj}^{2}} \]
    10. Step-by-step derivation
      1. unpow259.2%

        \[\leadsto \color{blue}{wj \cdot wj} \]
    11. Simplified59.2%

      \[\leadsto \color{blue}{wj \cdot wj} \]

    if -2.8000000000000001e-279 < x

    1. Initial program 76.7%

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

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub76.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-neg76.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. +-commutative76.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-in76.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-neg76.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-neg76.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-sub76.7%

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

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

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

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

      \[\leadsto \color{blue}{-2 \cdot \left(wj \cdot x\right) + x} \]
    5. Taylor expanded in x around 0 89.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{-138}:\\ \;\;\;\;x + -2 \cdot \left(wj \cdot x\right)\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-279}:\\ \;\;\;\;wj \cdot wj\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(wj \cdot -2 + 1\right)\\ \end{array} \]

Alternative 12: 80.4% accurate, 43.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{-138}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-280}:\\ \;\;\;\;wj \cdot wj\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (wj x)
 :precision binary64
 (if (<= x -1.5e-138) x (if (<= x -6e-280) (* wj wj) x)))
double code(double wj, double x) {
	double tmp;
	if (x <= -1.5e-138) {
		tmp = x;
	} else if (x <= -6e-280) {
		tmp = wj * wj;
	} else {
		tmp = x;
	}
	return tmp;
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-1.5d-138)) then
        tmp = x
    else if (x <= (-6d-280)) then
        tmp = wj * wj
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double wj, double x) {
	double tmp;
	if (x <= -1.5e-138) {
		tmp = x;
	} else if (x <= -6e-280) {
		tmp = wj * wj;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(wj, x):
	tmp = 0
	if x <= -1.5e-138:
		tmp = x
	elif x <= -6e-280:
		tmp = wj * wj
	else:
		tmp = x
	return tmp
function code(wj, x)
	tmp = 0.0
	if (x <= -1.5e-138)
		tmp = x;
	elseif (x <= -6e-280)
		tmp = Float64(wj * wj);
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(wj, x)
	tmp = 0.0;
	if (x <= -1.5e-138)
		tmp = x;
	elseif (x <= -6e-280)
		tmp = wj * wj;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[wj_, x_] := If[LessEqual[x, -1.5e-138], x, If[LessEqual[x, -6e-280], N[(wj * wj), $MachinePrecision], x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{-138}:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq -6 \cdot 10^{-280}:\\
\;\;\;\;wj \cdot wj\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.5e-138 or -5.99999999999999974e-280 < x

    1. Initial program 83.1%

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

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub83.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-neg83.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. +-commutative83.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-in83.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-neg83.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-neg83.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-sub83.1%

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

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

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

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

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

    if -1.5e-138 < x < -5.99999999999999974e-280

    1. Initial program 19.4%

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

        \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      2. div-sub19.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-neg19.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. +-commutative19.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-in19.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-neg19.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-neg19.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-sub19.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{{wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(\left(-1 \cdot x - x\right) \cdot wj + x\right)} \]
    7. Step-by-step derivation
      1. associate-+r+93.7%

        \[\leadsto \color{blue}{\left({wj}^{2} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-1 \cdot x - x\right) \cdot wj\right) + x} \]
      2. remove-double-neg93.7%

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

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

        \[\leadsto \left(\color{blue}{\left(wj \cdot wj\right)} \cdot \left(\left(1 + x\right) - -1 \cdot x\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      5. sub-neg93.7%

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

        \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \left(-\color{blue}{\left(-x\right)}\right)\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      7. remove-double-neg93.7%

        \[\leadsto \left(\left(wj \cdot wj\right) \cdot \left(\left(1 + x\right) + \color{blue}{x}\right) + \left(-1 \cdot x - x\right) \cdot wj\right) - \left(-x\right) \]
      8. associate-*l*93.7%

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

        \[\leadsto \left(wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right)\right) + \color{blue}{wj \cdot \left(-1 \cdot x - x\right)}\right) - \left(-x\right) \]
      10. distribute-lft-out93.7%

        \[\leadsto \color{blue}{wj \cdot \left(wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right)\right)} - \left(-x\right) \]
      11. fma-neg93.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \left(\left(1 + x\right) + x\right) + \left(-1 \cdot x - x\right), -\left(-x\right)\right)} \]
    8. Simplified93.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \mathsf{fma}\left(2, x, 1\right) + x \cdot -2, x\right)} \]
    9. Taylor expanded in x around 0 59.2%

      \[\leadsto \color{blue}{{wj}^{2}} \]
    10. Step-by-step derivation
      1. unpow259.2%

        \[\leadsto \color{blue}{wj \cdot wj} \]
    11. Simplified59.2%

      \[\leadsto \color{blue}{wj \cdot wj} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{-138}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-280}:\\ \;\;\;\;wj \cdot wj\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 13: 4.4% 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 76.1%

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

      \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    2. div-sub76.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-neg76.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. +-commutative76.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-in76.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-neg76.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-neg76.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-sub76.1%

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

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

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

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

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

    \[\leadsto wj \]

Alternative 14: 83.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 76.1%

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

      \[\leadsto \color{blue}{wj + \left(-\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    2. div-sub76.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-neg76.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. +-commutative76.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-in76.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-neg76.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-neg76.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-sub76.1%

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

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

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

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

    \[\leadsto \color{blue}{x} \]
  5. Final simplification85.3%

    \[\leadsto x \]

Developer target: 78.5% 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 2023238 
(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))))))