Jmat.Real.lambertw, newton loop step

Percentage Accurate: 41.1% → 98.3%
Time: 7.6s
Alternatives: 8
Speedup: 51.6×

Specification

?
\[\begin{array}{l} t_0 := wj \cdot e^{wj}\\ wj - \frac{t\_0 - x}{e^{wj} + t\_0} \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)
use fmin_fmax_functions
    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}
t_0 := wj \cdot e^{wj}\\
wj - \frac{t\_0 - x}{e^{wj} + t\_0}
\end{array}

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 8 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: 41.1% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := wj \cdot e^{wj}\\ wj - \frac{t\_0 - x}{e^{wj} + t\_0} \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)
use fmin_fmax_functions
    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}
t_0 := wj \cdot e^{wj}\\
wj - \frac{t\_0 - x}{e^{wj} + t\_0}
\end{array}

Alternative 1: 98.3% accurate, 1.1× speedup?

\[\begin{array}{l} t_0 := 0 - 0 \cdot \left(1 - -2 \cdot x\right)\\ \mathbf{if}\;wj \leq -0.102:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;wj \leq 155000:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 2.5, 1 - \mathsf{fma}\left(\mathsf{fma}\left(-3, x, \mathsf{fma}\left(x, 5, 0.6666666666666666 \cdot x\right)\right), wj, wj\right)\right), wj, -2 \cdot x\right), wj, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (wj x)
  :precision binary64
  (let* ((t_0 (- 0.0 (* 0.0 (- 1.0 (* -2.0 x))))))
  (if (<= wj -0.102)
    t_0
    (if (<= wj 155000.0)
      (fma
       (fma
        (fma
         x
         2.5
         (-
          1.0
          (fma
           (fma -3.0 x (fma x 5.0 (* 0.6666666666666666 x)))
           wj
           wj)))
        wj
        (* -2.0 x))
       wj
       x)
      t_0))))
double code(double wj, double x) {
	double t_0 = 0.0 - (0.0 * (1.0 - (-2.0 * x)));
	double tmp;
	if (wj <= -0.102) {
		tmp = t_0;
	} else if (wj <= 155000.0) {
		tmp = fma(fma(fma(x, 2.5, (1.0 - fma(fma(-3.0, x, fma(x, 5.0, (0.6666666666666666 * x))), wj, wj))), wj, (-2.0 * x)), wj, x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(wj, x)
	t_0 = Float64(0.0 - Float64(0.0 * Float64(1.0 - Float64(-2.0 * x))))
	tmp = 0.0
	if (wj <= -0.102)
		tmp = t_0;
	elseif (wj <= 155000.0)
		tmp = fma(fma(fma(x, 2.5, Float64(1.0 - fma(fma(-3.0, x, fma(x, 5.0, Float64(0.6666666666666666 * x))), wj, wj))), wj, Float64(-2.0 * x)), wj, x);
	else
		tmp = t_0;
	end
	return tmp
end
code[wj_, x_] := Block[{t$95$0 = N[(0.0 - N[(0.0 * N[(1.0 - N[(-2.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, -0.102], t$95$0, If[LessEqual[wj, 155000.0], N[(N[(N[(x * 2.5 + N[(1.0 - N[(N[(-3.0 * x + N[(x * 5.0 + N[(0.6666666666666666 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * wj + wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * wj + N[(-2.0 * x), $MachinePrecision]), $MachinePrecision] * wj + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := 0 - 0 \cdot \left(1 - -2 \cdot x\right)\\
\mathbf{if}\;wj \leq -0.102:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;wj \leq 155000:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 2.5, 1 - \mathsf{fma}\left(\mathsf{fma}\left(-3, x, \mathsf{fma}\left(x, 5, 0.6666666666666666 \cdot x\right)\right), wj, wj\right)\right), wj, -2 \cdot x\right), wj, x\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if wj < -0.10199999999999999 or 155000 < wj

    1. Initial program 41.1%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Taylor expanded in wj around 0

      \[\leadsto wj - \color{blue}{\left(-1 \cdot x + wj \cdot \left(1 - -2 \cdot x\right)\right)} \]
    3. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto wj - \mathsf{fma}\left(-1, \color{blue}{x}, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto wj - \mathsf{fma}\left(-1, x, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
      3. lower--.f64N/A

        \[\leadsto wj - \mathsf{fma}\left(-1, x, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
      4. lower-*.f6462.6%

        \[\leadsto wj - \mathsf{fma}\left(-1, x, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
    4. Applied rewrites62.6%

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

      \[\leadsto wj - -1 \cdot \color{blue}{x} \]
    6. Step-by-step derivation
      1. lower-*.f6439.0%

        \[\leadsto wj - -1 \cdot x \]
    7. Applied rewrites39.0%

      \[\leadsto wj - -1 \cdot \color{blue}{x} \]
    8. Taylor expanded in wj around inf

      \[\leadsto wj - wj \cdot \color{blue}{\left(1 - -2 \cdot x\right)} \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto wj - wj \cdot \left(1 - \color{blue}{-2 \cdot x}\right) \]
      2. lower--.f64N/A

        \[\leadsto wj - wj \cdot \left(1 - -2 \cdot \color{blue}{x}\right) \]
      3. lower-*.f6425.3%

        \[\leadsto wj - wj \cdot \left(1 - -2 \cdot x\right) \]
    10. Applied rewrites25.3%

      \[\leadsto wj - wj \cdot \color{blue}{\left(1 - -2 \cdot x\right)} \]
    11. Taylor expanded in undef-var around zero

      \[\leadsto \color{blue}{0} - wj \cdot \left(1 - -2 \cdot x\right) \]
    12. Step-by-step derivation
      1. Applied rewrites3.1%

        \[\leadsto \color{blue}{0} - wj \cdot \left(1 - -2 \cdot x\right) \]
      2. Taylor expanded in undef-var around zero

        \[\leadsto 0 - 0 \cdot \left(1 - \color{blue}{-2} \cdot x\right) \]
      3. Step-by-step derivation
        1. Applied rewrites49.8%

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

        if -0.10199999999999999 < wj < 155000

        1. Initial program 41.1%

          \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
        2. Taylor expanded in wj around 0

          \[\leadsto \color{blue}{x + wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
        3. Step-by-step derivation
          1. lower-+.f64N/A

            \[\leadsto x + \color{blue}{wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
          2. lower-*.f64N/A

            \[\leadsto x + wj \cdot \color{blue}{\left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
          3. lower--.f64N/A

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

          \[\leadsto \color{blue}{x + wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \mathsf{fma}\left(-3, x, \mathsf{fma}\left(-2, \mathsf{fma}\left(-4, x, 1.5 \cdot x\right), 0.6666666666666666 \cdot x\right)\right)\right)\right)\right) - \mathsf{fma}\left(-4, x, 1.5 \cdot x\right)\right) - 2 \cdot x\right)} \]
        5. Applied rewrites51.1%

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 2.5, 1 - \mathsf{fma}\left(\mathsf{fma}\left(-3, x, \mathsf{fma}\left(x, 5, 0.6666666666666666 \cdot x\right)\right), wj, wj\right)\right), wj, -2 \cdot x\right), \color{blue}{wj}, x\right) \]
      4. Recombined 2 regimes into one program.
      5. Add Preprocessing

      Alternative 2: 98.1% accurate, 1.8× speedup?

      \[\begin{array}{l} t_0 := 0 - 0 \cdot \left(1 - -2 \cdot x\right)\\ \mathbf{if}\;wj \leq -0.102:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;wj \leq 155000:\\ \;\;\;\;x + wj \cdot \left(wj \cdot \left(1 + -1 \cdot wj\right) - 2 \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
      (FPCore (wj x)
        :precision binary64
        (let* ((t_0 (- 0.0 (* 0.0 (- 1.0 (* -2.0 x))))))
        (if (<= wj -0.102)
          t_0
          (if (<= wj 155000.0)
            (+ x (* wj (- (* wj (+ 1.0 (* -1.0 wj))) (* 2.0 x))))
            t_0))))
      double code(double wj, double x) {
      	double t_0 = 0.0 - (0.0 * (1.0 - (-2.0 * x)));
      	double tmp;
      	if (wj <= -0.102) {
      		tmp = t_0;
      	} else if (wj <= 155000.0) {
      		tmp = x + (wj * ((wj * (1.0 + (-1.0 * wj))) - (2.0 * x)));
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      real(8) function code(wj, x)
      use fmin_fmax_functions
          real(8), intent (in) :: wj
          real(8), intent (in) :: x
          real(8) :: t_0
          real(8) :: tmp
          t_0 = 0.0d0 - (0.0d0 * (1.0d0 - ((-2.0d0) * x)))
          if (wj <= (-0.102d0)) then
              tmp = t_0
          else if (wj <= 155000.0d0) then
              tmp = x + (wj * ((wj * (1.0d0 + ((-1.0d0) * wj))) - (2.0d0 * x)))
          else
              tmp = t_0
          end if
          code = tmp
      end function
      
      public static double code(double wj, double x) {
      	double t_0 = 0.0 - (0.0 * (1.0 - (-2.0 * x)));
      	double tmp;
      	if (wj <= -0.102) {
      		tmp = t_0;
      	} else if (wj <= 155000.0) {
      		tmp = x + (wj * ((wj * (1.0 + (-1.0 * wj))) - (2.0 * x)));
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(wj, x):
      	t_0 = 0.0 - (0.0 * (1.0 - (-2.0 * x)))
      	tmp = 0
      	if wj <= -0.102:
      		tmp = t_0
      	elif wj <= 155000.0:
      		tmp = x + (wj * ((wj * (1.0 + (-1.0 * wj))) - (2.0 * x)))
      	else:
      		tmp = t_0
      	return tmp
      
      function code(wj, x)
      	t_0 = Float64(0.0 - Float64(0.0 * Float64(1.0 - Float64(-2.0 * x))))
      	tmp = 0.0
      	if (wj <= -0.102)
      		tmp = t_0;
      	elseif (wj <= 155000.0)
      		tmp = Float64(x + Float64(wj * Float64(Float64(wj * Float64(1.0 + Float64(-1.0 * wj))) - Float64(2.0 * x))));
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(wj, x)
      	t_0 = 0.0 - (0.0 * (1.0 - (-2.0 * x)));
      	tmp = 0.0;
      	if (wj <= -0.102)
      		tmp = t_0;
      	elseif (wj <= 155000.0)
      		tmp = x + (wj * ((wj * (1.0 + (-1.0 * wj))) - (2.0 * x)));
      	else
      		tmp = t_0;
      	end
      	tmp_2 = tmp;
      end
      
      code[wj_, x_] := Block[{t$95$0 = N[(0.0 - N[(0.0 * N[(1.0 - N[(-2.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, -0.102], t$95$0, If[LessEqual[wj, 155000.0], N[(x + N[(wj * N[(N[(wj * N[(1.0 + N[(-1.0 * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      t_0 := 0 - 0 \cdot \left(1 - -2 \cdot x\right)\\
      \mathbf{if}\;wj \leq -0.102:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;wj \leq 155000:\\
      \;\;\;\;x + wj \cdot \left(wj \cdot \left(1 + -1 \cdot wj\right) - 2 \cdot x\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if wj < -0.10199999999999999 or 155000 < wj

        1. Initial program 41.1%

          \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
        2. Taylor expanded in wj around 0

          \[\leadsto wj - \color{blue}{\left(-1 \cdot x + wj \cdot \left(1 - -2 \cdot x\right)\right)} \]
        3. Step-by-step derivation
          1. lower-fma.f64N/A

            \[\leadsto wj - \mathsf{fma}\left(-1, \color{blue}{x}, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
          2. lower-*.f64N/A

            \[\leadsto wj - \mathsf{fma}\left(-1, x, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
          3. lower--.f64N/A

            \[\leadsto wj - \mathsf{fma}\left(-1, x, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
          4. lower-*.f6462.6%

            \[\leadsto wj - \mathsf{fma}\left(-1, x, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
        4. Applied rewrites62.6%

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

          \[\leadsto wj - -1 \cdot \color{blue}{x} \]
        6. Step-by-step derivation
          1. lower-*.f6439.0%

            \[\leadsto wj - -1 \cdot x \]
        7. Applied rewrites39.0%

          \[\leadsto wj - -1 \cdot \color{blue}{x} \]
        8. Taylor expanded in wj around inf

          \[\leadsto wj - wj \cdot \color{blue}{\left(1 - -2 \cdot x\right)} \]
        9. Step-by-step derivation
          1. lower-*.f64N/A

            \[\leadsto wj - wj \cdot \left(1 - \color{blue}{-2 \cdot x}\right) \]
          2. lower--.f64N/A

            \[\leadsto wj - wj \cdot \left(1 - -2 \cdot \color{blue}{x}\right) \]
          3. lower-*.f6425.3%

            \[\leadsto wj - wj \cdot \left(1 - -2 \cdot x\right) \]
        10. Applied rewrites25.3%

          \[\leadsto wj - wj \cdot \color{blue}{\left(1 - -2 \cdot x\right)} \]
        11. Taylor expanded in undef-var around zero

          \[\leadsto \color{blue}{0} - wj \cdot \left(1 - -2 \cdot x\right) \]
        12. Step-by-step derivation
          1. Applied rewrites3.1%

            \[\leadsto \color{blue}{0} - wj \cdot \left(1 - -2 \cdot x\right) \]
          2. Taylor expanded in undef-var around zero

            \[\leadsto 0 - 0 \cdot \left(1 - \color{blue}{-2} \cdot x\right) \]
          3. Step-by-step derivation
            1. Applied rewrites49.8%

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

            if -0.10199999999999999 < wj < 155000

            1. Initial program 41.1%

              \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
            2. Taylor expanded in wj around 0

              \[\leadsto \color{blue}{x + wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
            3. Step-by-step derivation
              1. lower-+.f64N/A

                \[\leadsto x + \color{blue}{wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
              2. lower-*.f64N/A

                \[\leadsto x + wj \cdot \color{blue}{\left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
              3. lower--.f64N/A

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

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

              \[\leadsto x + wj \cdot \left(wj \cdot \left(1 + -1 \cdot wj\right) - \color{blue}{2} \cdot x\right) \]
            6. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto x + wj \cdot \left(wj \cdot \left(1 + -1 \cdot wj\right) - 2 \cdot x\right) \]
              2. lower-+.f64N/A

                \[\leadsto x + wj \cdot \left(wj \cdot \left(1 + -1 \cdot wj\right) - 2 \cdot x\right) \]
              3. lower-*.f6451.0%

                \[\leadsto x + wj \cdot \left(wj \cdot \left(1 + -1 \cdot wj\right) - 2 \cdot x\right) \]
            7. Applied rewrites51.0%

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

          Alternative 3: 97.9% accurate, 2.6× speedup?

          \[\begin{array}{l} t_0 := 0 - 0 \cdot \left(1 - -2 \cdot x\right)\\ \mathbf{if}\;wj \leq -0.102:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;wj \leq 0.00021:\\ \;\;\;\;\mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
          (FPCore (wj x)
            :precision binary64
            (let* ((t_0 (- 0.0 (* 0.0 (- 1.0 (* -2.0 x))))))
            (if (<= wj -0.102)
              t_0
              (if (<= wj 0.00021) (fma (* wj (- 1.0 wj)) wj x) t_0))))
          double code(double wj, double x) {
          	double t_0 = 0.0 - (0.0 * (1.0 - (-2.0 * x)));
          	double tmp;
          	if (wj <= -0.102) {
          		tmp = t_0;
          	} else if (wj <= 0.00021) {
          		tmp = fma((wj * (1.0 - wj)), wj, x);
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          function code(wj, x)
          	t_0 = Float64(0.0 - Float64(0.0 * Float64(1.0 - Float64(-2.0 * x))))
          	tmp = 0.0
          	if (wj <= -0.102)
          		tmp = t_0;
          	elseif (wj <= 0.00021)
          		tmp = fma(Float64(wj * Float64(1.0 - wj)), wj, x);
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          code[wj_, x_] := Block[{t$95$0 = N[(0.0 - N[(0.0 * N[(1.0 - N[(-2.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, -0.102], t$95$0, If[LessEqual[wj, 0.00021], N[(N[(wj * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision] * wj + x), $MachinePrecision], t$95$0]]]
          
          \begin{array}{l}
          t_0 := 0 - 0 \cdot \left(1 - -2 \cdot x\right)\\
          \mathbf{if}\;wj \leq -0.102:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;wj \leq 0.00021:\\
          \;\;\;\;\mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if wj < -0.10199999999999999 or 2.1000000000000001e-4 < wj

            1. Initial program 41.1%

              \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
            2. Taylor expanded in wj around 0

              \[\leadsto wj - \color{blue}{\left(-1 \cdot x + wj \cdot \left(1 - -2 \cdot x\right)\right)} \]
            3. Step-by-step derivation
              1. lower-fma.f64N/A

                \[\leadsto wj - \mathsf{fma}\left(-1, \color{blue}{x}, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
              2. lower-*.f64N/A

                \[\leadsto wj - \mathsf{fma}\left(-1, x, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
              3. lower--.f64N/A

                \[\leadsto wj - \mathsf{fma}\left(-1, x, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
              4. lower-*.f6462.6%

                \[\leadsto wj - \mathsf{fma}\left(-1, x, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
            4. Applied rewrites62.6%

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

              \[\leadsto wj - -1 \cdot \color{blue}{x} \]
            6. Step-by-step derivation
              1. lower-*.f6439.0%

                \[\leadsto wj - -1 \cdot x \]
            7. Applied rewrites39.0%

              \[\leadsto wj - -1 \cdot \color{blue}{x} \]
            8. Taylor expanded in wj around inf

              \[\leadsto wj - wj \cdot \color{blue}{\left(1 - -2 \cdot x\right)} \]
            9. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto wj - wj \cdot \left(1 - \color{blue}{-2 \cdot x}\right) \]
              2. lower--.f64N/A

                \[\leadsto wj - wj \cdot \left(1 - -2 \cdot \color{blue}{x}\right) \]
              3. lower-*.f6425.3%

                \[\leadsto wj - wj \cdot \left(1 - -2 \cdot x\right) \]
            10. Applied rewrites25.3%

              \[\leadsto wj - wj \cdot \color{blue}{\left(1 - -2 \cdot x\right)} \]
            11. Taylor expanded in undef-var around zero

              \[\leadsto \color{blue}{0} - wj \cdot \left(1 - -2 \cdot x\right) \]
            12. Step-by-step derivation
              1. Applied rewrites3.1%

                \[\leadsto \color{blue}{0} - wj \cdot \left(1 - -2 \cdot x\right) \]
              2. Taylor expanded in undef-var around zero

                \[\leadsto 0 - 0 \cdot \left(1 - \color{blue}{-2} \cdot x\right) \]
              3. Step-by-step derivation
                1. Applied rewrites49.8%

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

                if -0.10199999999999999 < wj < 2.1000000000000001e-4

                1. Initial program 41.1%

                  \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
                2. Taylor expanded in wj around 0

                  \[\leadsto \color{blue}{x + wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
                3. Step-by-step derivation
                  1. lower-+.f64N/A

                    \[\leadsto x + \color{blue}{wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
                  2. lower-*.f64N/A

                    \[\leadsto x + wj \cdot \color{blue}{\left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
                  3. lower--.f64N/A

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

                  \[\leadsto \color{blue}{x + wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \mathsf{fma}\left(-3, x, \mathsf{fma}\left(-2, \mathsf{fma}\left(-4, x, 1.5 \cdot x\right), 0.6666666666666666 \cdot x\right)\right)\right)\right)\right) - \mathsf{fma}\left(-4, x, 1.5 \cdot x\right)\right) - 2 \cdot x\right)} \]
                5. Applied rewrites51.1%

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 2.5, 1 - \mathsf{fma}\left(\mathsf{fma}\left(-3, x, \mathsf{fma}\left(x, 5, 0.6666666666666666 \cdot x\right)\right), wj, wj\right)\right), wj, -2 \cdot x\right), \color{blue}{wj}, x\right) \]
                6. Taylor expanded in x around 0

                  \[\leadsto \mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right) \]
                7. Step-by-step derivation
                  1. lower-*.f64N/A

                    \[\leadsto \mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right) \]
                  2. lower--.f6450.7%

                    \[\leadsto \mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right) \]
                8. Applied rewrites50.7%

                  \[\leadsto \mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right) \]
              4. Recombined 2 regimes into one program.
              5. Add Preprocessing

              Alternative 4: 97.8% accurate, 2.0× speedup?

              \[\begin{array}{l} \mathbf{if}\;wj \leq -0.102:\\ \;\;\;\;0 - 0 \cdot \left(1 - -2 \cdot x\right)\\ \mathbf{elif}\;wj \leq 400:\\ \;\;\;\;\mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{wj \cdot e^{wj}}\\ \end{array} \]
              (FPCore (wj x)
                :precision binary64
                (if (<= wj -0.102)
                (- 0.0 (* 0.0 (- 1.0 (* -2.0 x))))
                (if (<= wj 400.0)
                  (fma (* wj (- 1.0 wj)) wj x)
                  (/ x (* wj (exp wj))))))
              double code(double wj, double x) {
              	double tmp;
              	if (wj <= -0.102) {
              		tmp = 0.0 - (0.0 * (1.0 - (-2.0 * x)));
              	} else if (wj <= 400.0) {
              		tmp = fma((wj * (1.0 - wj)), wj, x);
              	} else {
              		tmp = x / (wj * exp(wj));
              	}
              	return tmp;
              }
              
              function code(wj, x)
              	tmp = 0.0
              	if (wj <= -0.102)
              		tmp = Float64(0.0 - Float64(0.0 * Float64(1.0 - Float64(-2.0 * x))));
              	elseif (wj <= 400.0)
              		tmp = fma(Float64(wj * Float64(1.0 - wj)), wj, x);
              	else
              		tmp = Float64(x / Float64(wj * exp(wj)));
              	end
              	return tmp
              end
              
              code[wj_, x_] := If[LessEqual[wj, -0.102], N[(0.0 - N[(0.0 * N[(1.0 - N[(-2.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[wj, 400.0], N[(N[(wj * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision] * wj + x), $MachinePrecision], N[(x / N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
              
              \begin{array}{l}
              \mathbf{if}\;wj \leq -0.102:\\
              \;\;\;\;0 - 0 \cdot \left(1 - -2 \cdot x\right)\\
              
              \mathbf{elif}\;wj \leq 400:\\
              \;\;\;\;\mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;\frac{x}{wj \cdot e^{wj}}\\
              
              
              \end{array}
              
              Derivation
              1. Split input into 3 regimes
              2. if wj < -0.10199999999999999

                1. Initial program 41.1%

                  \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
                2. Taylor expanded in wj around 0

                  \[\leadsto wj - \color{blue}{\left(-1 \cdot x + wj \cdot \left(1 - -2 \cdot x\right)\right)} \]
                3. Step-by-step derivation
                  1. lower-fma.f64N/A

                    \[\leadsto wj - \mathsf{fma}\left(-1, \color{blue}{x}, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
                  2. lower-*.f64N/A

                    \[\leadsto wj - \mathsf{fma}\left(-1, x, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
                  3. lower--.f64N/A

                    \[\leadsto wj - \mathsf{fma}\left(-1, x, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
                  4. lower-*.f6462.6%

                    \[\leadsto wj - \mathsf{fma}\left(-1, x, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
                4. Applied rewrites62.6%

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

                  \[\leadsto wj - -1 \cdot \color{blue}{x} \]
                6. Step-by-step derivation
                  1. lower-*.f6439.0%

                    \[\leadsto wj - -1 \cdot x \]
                7. Applied rewrites39.0%

                  \[\leadsto wj - -1 \cdot \color{blue}{x} \]
                8. Taylor expanded in wj around inf

                  \[\leadsto wj - wj \cdot \color{blue}{\left(1 - -2 \cdot x\right)} \]
                9. Step-by-step derivation
                  1. lower-*.f64N/A

                    \[\leadsto wj - wj \cdot \left(1 - \color{blue}{-2 \cdot x}\right) \]
                  2. lower--.f64N/A

                    \[\leadsto wj - wj \cdot \left(1 - -2 \cdot \color{blue}{x}\right) \]
                  3. lower-*.f6425.3%

                    \[\leadsto wj - wj \cdot \left(1 - -2 \cdot x\right) \]
                10. Applied rewrites25.3%

                  \[\leadsto wj - wj \cdot \color{blue}{\left(1 - -2 \cdot x\right)} \]
                11. Taylor expanded in undef-var around zero

                  \[\leadsto \color{blue}{0} - wj \cdot \left(1 - -2 \cdot x\right) \]
                12. Step-by-step derivation
                  1. Applied rewrites3.1%

                    \[\leadsto \color{blue}{0} - wj \cdot \left(1 - -2 \cdot x\right) \]
                  2. Taylor expanded in undef-var around zero

                    \[\leadsto 0 - 0 \cdot \left(1 - \color{blue}{-2} \cdot x\right) \]
                  3. Step-by-step derivation
                    1. Applied rewrites49.8%

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

                    if -0.10199999999999999 < wj < 400

                    1. Initial program 41.1%

                      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
                    2. Taylor expanded in wj around 0

                      \[\leadsto \color{blue}{x + wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
                    3. Step-by-step derivation
                      1. lower-+.f64N/A

                        \[\leadsto x + \color{blue}{wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
                      2. lower-*.f64N/A

                        \[\leadsto x + wj \cdot \color{blue}{\left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
                      3. lower--.f64N/A

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

                      \[\leadsto \color{blue}{x + wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \mathsf{fma}\left(-3, x, \mathsf{fma}\left(-2, \mathsf{fma}\left(-4, x, 1.5 \cdot x\right), 0.6666666666666666 \cdot x\right)\right)\right)\right)\right) - \mathsf{fma}\left(-4, x, 1.5 \cdot x\right)\right) - 2 \cdot x\right)} \]
                    5. Applied rewrites51.1%

                      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 2.5, 1 - \mathsf{fma}\left(\mathsf{fma}\left(-3, x, \mathsf{fma}\left(x, 5, 0.6666666666666666 \cdot x\right)\right), wj, wj\right)\right), wj, -2 \cdot x\right), \color{blue}{wj}, x\right) \]
                    6. Taylor expanded in x around 0

                      \[\leadsto \mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right) \]
                    7. Step-by-step derivation
                      1. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right) \]
                      2. lower--.f6450.7%

                        \[\leadsto \mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right) \]
                    8. Applied rewrites50.7%

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

                    if 400 < wj

                    1. Initial program 41.1%

                      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
                    2. Taylor expanded in x around inf

                      \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
                    3. Step-by-step derivation
                      1. lower-/.f64N/A

                        \[\leadsto \frac{x}{\color{blue}{e^{wj} + wj \cdot e^{wj}}} \]
                      2. lower-+.f64N/A

                        \[\leadsto \frac{x}{e^{wj} + \color{blue}{wj \cdot e^{wj}}} \]
                      3. lower-exp.f64N/A

                        \[\leadsto \frac{x}{e^{wj} + \color{blue}{wj} \cdot e^{wj}} \]
                      4. lower-*.f64N/A

                        \[\leadsto \frac{x}{e^{wj} + wj \cdot \color{blue}{e^{wj}}} \]
                      5. lower-exp.f6469.4%

                        \[\leadsto \frac{x}{e^{wj} + wj \cdot e^{wj}} \]
                    4. Applied rewrites69.4%

                      \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
                    5. Taylor expanded in wj around 0

                      \[\leadsto \frac{x}{e^{wj} + wj \cdot \color{blue}{\left(1 + wj \cdot \left(1 + wj \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot wj\right)\right)\right)}} \]
                    6. Step-by-step derivation
                      1. lower-*.f64N/A

                        \[\leadsto \frac{x}{e^{wj} + wj \cdot \left(1 + \color{blue}{wj \cdot \left(1 + wj \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot wj\right)\right)}\right)} \]
                      2. lower-+.f64N/A

                        \[\leadsto \frac{x}{e^{wj} + wj \cdot \left(1 + wj \cdot \color{blue}{\left(1 + wj \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot wj\right)\right)}\right)} \]
                      3. lower-*.f64N/A

                        \[\leadsto \frac{x}{e^{wj} + wj \cdot \left(1 + wj \cdot \left(1 + \color{blue}{wj \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot wj\right)}\right)\right)} \]
                      4. lower-+.f64N/A

                        \[\leadsto \frac{x}{e^{wj} + wj \cdot \left(1 + wj \cdot \left(1 + wj \cdot \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot wj\right)}\right)\right)} \]
                      5. lower-*.f64N/A

                        \[\leadsto \frac{x}{e^{wj} + wj \cdot \left(1 + wj \cdot \left(1 + wj \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{6} \cdot wj}\right)\right)\right)} \]
                      6. lower-+.f64N/A

                        \[\leadsto \frac{x}{e^{wj} + wj \cdot \left(1 + wj \cdot \left(1 + wj \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot \color{blue}{wj}\right)\right)\right)} \]
                      7. lower-*.f6488.4%

                        \[\leadsto \frac{x}{e^{wj} + wj \cdot \left(1 + wj \cdot \left(1 + wj \cdot \left(0.5 + 0.16666666666666666 \cdot wj\right)\right)\right)} \]
                    7. Applied rewrites88.4%

                      \[\leadsto \frac{x}{e^{wj} + wj \cdot \color{blue}{\left(1 + wj \cdot \left(1 + wj \cdot \left(0.5 + 0.16666666666666666 \cdot wj\right)\right)\right)}} \]
                    8. Taylor expanded in wj around inf

                      \[\leadsto \frac{x}{\color{blue}{wj \cdot e^{wj}}} \]
                    9. Step-by-step derivation
                      1. lower-/.f64N/A

                        \[\leadsto \frac{x}{wj \cdot \color{blue}{e^{wj}}} \]
                      2. lower-*.f64N/A

                        \[\leadsto \frac{x}{wj \cdot e^{wj}} \]
                      3. lower-exp.f6427.0%

                        \[\leadsto \frac{x}{wj \cdot e^{wj}} \]
                    10. Applied rewrites27.0%

                      \[\leadsto \frac{x}{\color{blue}{wj \cdot e^{wj}}} \]
                  4. Recombined 3 regimes into one program.
                  5. Add Preprocessing

                  Alternative 5: 73.1% accurate, 2.7× speedup?

                  \[\begin{array}{l} t_0 := wj - \left(1 + \left(x + x\right)\right) \cdot wj\\ \mathbf{if}\;wj \leq -0.49:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;wj \leq 95000:\\ \;\;\;\;\mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
                  (FPCore (wj x)
                    :precision binary64
                    (let* ((t_0 (- wj (* (+ 1.0 (+ x x)) wj))))
                    (if (<= wj -0.49)
                      t_0
                      (if (<= wj 95000.0) (fma (* wj (- 1.0 wj)) wj x) t_0))))
                  double code(double wj, double x) {
                  	double t_0 = wj - ((1.0 + (x + x)) * wj);
                  	double tmp;
                  	if (wj <= -0.49) {
                  		tmp = t_0;
                  	} else if (wj <= 95000.0) {
                  		tmp = fma((wj * (1.0 - wj)), wj, x);
                  	} else {
                  		tmp = t_0;
                  	}
                  	return tmp;
                  }
                  
                  function code(wj, x)
                  	t_0 = Float64(wj - Float64(Float64(1.0 + Float64(x + x)) * wj))
                  	tmp = 0.0
                  	if (wj <= -0.49)
                  		tmp = t_0;
                  	elseif (wj <= 95000.0)
                  		tmp = fma(Float64(wj * Float64(1.0 - wj)), wj, x);
                  	else
                  		tmp = t_0;
                  	end
                  	return tmp
                  end
                  
                  code[wj_, x_] := Block[{t$95$0 = N[(wj - N[(N[(1.0 + N[(x + x), $MachinePrecision]), $MachinePrecision] * wj), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, -0.49], t$95$0, If[LessEqual[wj, 95000.0], N[(N[(wj * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision] * wj + x), $MachinePrecision], t$95$0]]]
                  
                  \begin{array}{l}
                  t_0 := wj - \left(1 + \left(x + x\right)\right) \cdot wj\\
                  \mathbf{if}\;wj \leq -0.49:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{elif}\;wj \leq 95000:\\
                  \;\;\;\;\mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_0\\
                  
                  
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if wj < -0.48999999999999999 or 95000 < wj

                    1. Initial program 41.1%

                      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
                    2. Taylor expanded in wj around 0

                      \[\leadsto wj - \color{blue}{\left(-1 \cdot x + wj \cdot \left(1 - -2 \cdot x\right)\right)} \]
                    3. Step-by-step derivation
                      1. lower-fma.f64N/A

                        \[\leadsto wj - \mathsf{fma}\left(-1, \color{blue}{x}, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
                      2. lower-*.f64N/A

                        \[\leadsto wj - \mathsf{fma}\left(-1, x, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
                      3. lower--.f64N/A

                        \[\leadsto wj - \mathsf{fma}\left(-1, x, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
                      4. lower-*.f6462.6%

                        \[\leadsto wj - \mathsf{fma}\left(-1, x, wj \cdot \left(1 - -2 \cdot x\right)\right) \]
                    4. Applied rewrites62.6%

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

                      \[\leadsto wj - -1 \cdot \color{blue}{x} \]
                    6. Step-by-step derivation
                      1. lower-*.f6439.0%

                        \[\leadsto wj - -1 \cdot x \]
                    7. Applied rewrites39.0%

                      \[\leadsto wj - -1 \cdot \color{blue}{x} \]
                    8. Taylor expanded in wj around inf

                      \[\leadsto wj - wj \cdot \color{blue}{\left(1 - -2 \cdot x\right)} \]
                    9. Step-by-step derivation
                      1. lower-*.f64N/A

                        \[\leadsto wj - wj \cdot \left(1 - \color{blue}{-2 \cdot x}\right) \]
                      2. lower--.f64N/A

                        \[\leadsto wj - wj \cdot \left(1 - -2 \cdot \color{blue}{x}\right) \]
                      3. lower-*.f6425.3%

                        \[\leadsto wj - wj \cdot \left(1 - -2 \cdot x\right) \]
                    10. Applied rewrites25.3%

                      \[\leadsto wj - wj \cdot \color{blue}{\left(1 - -2 \cdot x\right)} \]
                    11. Step-by-step derivation
                      1. lift-*.f64N/A

                        \[\leadsto wj - wj \cdot \left(1 - \color{blue}{-2 \cdot x}\right) \]
                      2. *-commutativeN/A

                        \[\leadsto wj - \left(1 - -2 \cdot x\right) \cdot wj \]
                      3. lower-*.f6425.3%

                        \[\leadsto wj - \left(1 - -2 \cdot x\right) \cdot wj \]
                      4. lift--.f64N/A

                        \[\leadsto wj - \left(1 - -2 \cdot x\right) \cdot wj \]
                      5. lift-*.f64N/A

                        \[\leadsto wj - \left(1 - -2 \cdot x\right) \cdot wj \]
                      6. fp-cancel-sub-sign-invN/A

                        \[\leadsto wj - \left(1 + \left(\mathsf{neg}\left(-2\right)\right) \cdot x\right) \cdot wj \]
                      7. metadata-evalN/A

                        \[\leadsto wj - \left(1 + 2 \cdot x\right) \cdot wj \]
                      8. lower-+.f64N/A

                        \[\leadsto wj - \left(1 + 2 \cdot x\right) \cdot wj \]
                      9. count-2-revN/A

                        \[\leadsto wj - \left(1 + \left(x + x\right)\right) \cdot wj \]
                      10. lower-+.f6425.3%

                        \[\leadsto wj - \left(1 + \left(x + x\right)\right) \cdot wj \]
                    12. Applied rewrites25.3%

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

                    if -0.48999999999999999 < wj < 95000

                    1. Initial program 41.1%

                      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
                    2. Taylor expanded in wj around 0

                      \[\leadsto \color{blue}{x + wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
                    3. Step-by-step derivation
                      1. lower-+.f64N/A

                        \[\leadsto x + \color{blue}{wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
                      2. lower-*.f64N/A

                        \[\leadsto x + wj \cdot \color{blue}{\left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
                      3. lower--.f64N/A

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

                      \[\leadsto \color{blue}{x + wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \mathsf{fma}\left(-3, x, \mathsf{fma}\left(-2, \mathsf{fma}\left(-4, x, 1.5 \cdot x\right), 0.6666666666666666 \cdot x\right)\right)\right)\right)\right) - \mathsf{fma}\left(-4, x, 1.5 \cdot x\right)\right) - 2 \cdot x\right)} \]
                    5. Applied rewrites51.1%

                      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 2.5, 1 - \mathsf{fma}\left(\mathsf{fma}\left(-3, x, \mathsf{fma}\left(x, 5, 0.6666666666666666 \cdot x\right)\right), wj, wj\right)\right), wj, -2 \cdot x\right), \color{blue}{wj}, x\right) \]
                    6. Taylor expanded in x around 0

                      \[\leadsto \mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right) \]
                    7. Step-by-step derivation
                      1. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right) \]
                      2. lower--.f6450.7%

                        \[\leadsto \mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right) \]
                    8. Applied rewrites50.7%

                      \[\leadsto \mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right) \]
                  3. Recombined 2 regimes into one program.
                  4. Add Preprocessing

                  Alternative 6: 63.8% accurate, 0.4× speedup?

                  \[\begin{array}{l} t_0 := wj \cdot e^{wj}\\ t_1 := wj - \frac{t\_0 - x}{e^{wj} + t\_0}\\ t_2 := \frac{x}{1 + 2 \cdot wj}\\ \mathbf{if}\;t\_1 \leq -2 \cdot 10^{+76}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-8}:\\ \;\;\;\;\mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \]
                  (FPCore (wj x)
                    :precision binary64
                    (let* ((t_0 (* wj (exp wj)))
                         (t_1 (- wj (/ (- t_0 x) (+ (exp wj) t_0))))
                         (t_2 (/ x (+ 1.0 (* 2.0 wj)))))
                    (if (<= t_1 -2e+76)
                      t_2
                      (if (<= t_1 5e-8) (fma (* wj (- 1.0 wj)) wj x) t_2))))
                  double code(double wj, double x) {
                  	double t_0 = wj * exp(wj);
                  	double t_1 = wj - ((t_0 - x) / (exp(wj) + t_0));
                  	double t_2 = x / (1.0 + (2.0 * wj));
                  	double tmp;
                  	if (t_1 <= -2e+76) {
                  		tmp = t_2;
                  	} else if (t_1 <= 5e-8) {
                  		tmp = fma((wj * (1.0 - wj)), wj, x);
                  	} else {
                  		tmp = t_2;
                  	}
                  	return tmp;
                  }
                  
                  function code(wj, x)
                  	t_0 = Float64(wj * exp(wj))
                  	t_1 = Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0)))
                  	t_2 = Float64(x / Float64(1.0 + Float64(2.0 * wj)))
                  	tmp = 0.0
                  	if (t_1 <= -2e+76)
                  		tmp = t_2;
                  	elseif (t_1 <= 5e-8)
                  		tmp = fma(Float64(wj * Float64(1.0 - wj)), wj, x);
                  	else
                  		tmp = t_2;
                  	end
                  	return tmp
                  end
                  
                  code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x / N[(1.0 + N[(2.0 * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+76], t$95$2, If[LessEqual[t$95$1, 5e-8], N[(N[(wj * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision] * wj + x), $MachinePrecision], t$95$2]]]]]
                  
                  \begin{array}{l}
                  t_0 := wj \cdot e^{wj}\\
                  t_1 := wj - \frac{t\_0 - x}{e^{wj} + t\_0}\\
                  t_2 := \frac{x}{1 + 2 \cdot wj}\\
                  \mathbf{if}\;t\_1 \leq -2 \cdot 10^{+76}:\\
                  \;\;\;\;t\_2\\
                  
                  \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-8}:\\
                  \;\;\;\;\mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_2\\
                  
                  
                  \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))))) < -2.0000000000000001e76 or 4.9999999999999998e-8 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))))

                    1. Initial program 41.1%

                      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
                    2. Taylor expanded in x around inf

                      \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
                    3. Step-by-step derivation
                      1. lower-/.f64N/A

                        \[\leadsto \frac{x}{\color{blue}{e^{wj} + wj \cdot e^{wj}}} \]
                      2. lower-+.f64N/A

                        \[\leadsto \frac{x}{e^{wj} + \color{blue}{wj \cdot e^{wj}}} \]
                      3. lower-exp.f64N/A

                        \[\leadsto \frac{x}{e^{wj} + \color{blue}{wj} \cdot e^{wj}} \]
                      4. lower-*.f64N/A

                        \[\leadsto \frac{x}{e^{wj} + wj \cdot \color{blue}{e^{wj}}} \]
                      5. lower-exp.f6469.4%

                        \[\leadsto \frac{x}{e^{wj} + wj \cdot e^{wj}} \]
                    4. Applied rewrites69.4%

                      \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
                    5. Taylor expanded in wj around 0

                      \[\leadsto \frac{x}{1 + \color{blue}{2 \cdot wj}} \]
                    6. Step-by-step derivation
                      1. lower-+.f64N/A

                        \[\leadsto \frac{x}{1 + 2 \cdot \color{blue}{wj}} \]
                      2. lower-*.f6458.1%

                        \[\leadsto \frac{x}{1 + 2 \cdot wj} \]
                    7. Applied rewrites58.1%

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

                    if -2.0000000000000001e76 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 4.9999999999999998e-8

                    1. Initial program 41.1%

                      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
                    2. Taylor expanded in wj around 0

                      \[\leadsto \color{blue}{x + wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
                    3. Step-by-step derivation
                      1. lower-+.f64N/A

                        \[\leadsto x + \color{blue}{wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
                      2. lower-*.f64N/A

                        \[\leadsto x + wj \cdot \color{blue}{\left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \left(-3 \cdot x + \left(-2 \cdot \left(-4 \cdot x + \frac{3}{2} \cdot x\right) + \frac{2}{3} \cdot x\right)\right)\right)\right)\right) - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right)} \]
                      3. lower--.f64N/A

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

                      \[\leadsto \color{blue}{x + wj \cdot \left(wj \cdot \left(\left(1 + -1 \cdot \left(wj \cdot \left(1 + \mathsf{fma}\left(-3, x, \mathsf{fma}\left(-2, \mathsf{fma}\left(-4, x, 1.5 \cdot x\right), 0.6666666666666666 \cdot x\right)\right)\right)\right)\right) - \mathsf{fma}\left(-4, x, 1.5 \cdot x\right)\right) - 2 \cdot x\right)} \]
                    5. Applied rewrites51.1%

                      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 2.5, 1 - \mathsf{fma}\left(\mathsf{fma}\left(-3, x, \mathsf{fma}\left(x, 5, 0.6666666666666666 \cdot x\right)\right), wj, wj\right)\right), wj, -2 \cdot x\right), \color{blue}{wj}, x\right) \]
                    6. Taylor expanded in x around 0

                      \[\leadsto \mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right) \]
                    7. Step-by-step derivation
                      1. lower-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right) \]
                      2. lower--.f6450.7%

                        \[\leadsto \mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right) \]
                    8. Applied rewrites50.7%

                      \[\leadsto \mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right) \]
                  3. Recombined 2 regimes into one program.
                  4. Add Preprocessing

                  Alternative 7: 58.1% accurate, 5.0× speedup?

                  \[\frac{x}{1 + 2 \cdot wj} \]
                  (FPCore (wj x)
                    :precision binary64
                    (/ x (+ 1.0 (* 2.0 wj))))
                  double code(double wj, double x) {
                  	return x / (1.0 + (2.0 * wj));
                  }
                  
                  real(8) function code(wj, x)
                  use fmin_fmax_functions
                      real(8), intent (in) :: wj
                      real(8), intent (in) :: x
                      code = x / (1.0d0 + (2.0d0 * wj))
                  end function
                  
                  public static double code(double wj, double x) {
                  	return x / (1.0 + (2.0 * wj));
                  }
                  
                  def code(wj, x):
                  	return x / (1.0 + (2.0 * wj))
                  
                  function code(wj, x)
                  	return Float64(x / Float64(1.0 + Float64(2.0 * wj)))
                  end
                  
                  function tmp = code(wj, x)
                  	tmp = x / (1.0 + (2.0 * wj));
                  end
                  
                  code[wj_, x_] := N[(x / N[(1.0 + N[(2.0 * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                  
                  \frac{x}{1 + 2 \cdot wj}
                  
                  Derivation
                  1. Initial program 41.1%

                    \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
                  2. Taylor expanded in x around inf

                    \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
                  3. Step-by-step derivation
                    1. lower-/.f64N/A

                      \[\leadsto \frac{x}{\color{blue}{e^{wj} + wj \cdot e^{wj}}} \]
                    2. lower-+.f64N/A

                      \[\leadsto \frac{x}{e^{wj} + \color{blue}{wj \cdot e^{wj}}} \]
                    3. lower-exp.f64N/A

                      \[\leadsto \frac{x}{e^{wj} + \color{blue}{wj} \cdot e^{wj}} \]
                    4. lower-*.f64N/A

                      \[\leadsto \frac{x}{e^{wj} + wj \cdot \color{blue}{e^{wj}}} \]
                    5. lower-exp.f6469.4%

                      \[\leadsto \frac{x}{e^{wj} + wj \cdot e^{wj}} \]
                  4. Applied rewrites69.4%

                    \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
                  5. Taylor expanded in wj around 0

                    \[\leadsto \frac{x}{1 + \color{blue}{2 \cdot wj}} \]
                  6. Step-by-step derivation
                    1. lower-+.f64N/A

                      \[\leadsto \frac{x}{1 + 2 \cdot \color{blue}{wj}} \]
                    2. lower-*.f6458.1%

                      \[\leadsto \frac{x}{1 + 2 \cdot wj} \]
                  7. Applied rewrites58.1%

                    \[\leadsto \frac{x}{1 + \color{blue}{2 \cdot wj}} \]
                  8. Add Preprocessing

                  Alternative 8: 45.9% accurate, 51.6× speedup?

                  \[x \]
                  (FPCore (wj x)
                    :precision binary64
                    x)
                  double code(double wj, double x) {
                  	return x;
                  }
                  
                  real(8) function code(wj, x)
                  use fmin_fmax_functions
                      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
                  
                  x
                  
                  Derivation
                  1. Initial program 41.1%

                    \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
                  2. Taylor expanded in wj around 0

                    \[\leadsto \color{blue}{x} \]
                  3. Step-by-step derivation
                    1. Applied rewrites45.9%

                      \[\leadsto \color{blue}{x} \]
                    2. Add Preprocessing

                    Developer Target 1: 42.1% accurate, 1.2× speedup?

                    \[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right) \]
                    (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)
                    use fmin_fmax_functions
                        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]
                    
                    wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)
                    

                    Reproduce

                    ?
                    herbie shell --seed 2025313 -o setup:search
                    (FPCore (wj x)
                      :name "Jmat.Real.lambertw, newton loop step"
                      :precision binary64
                    
                      :alt
                      (! :herbie-platform c (let ((ew (exp wj))) (- wj (- (/ wj (+ wj 1)) (/ x (+ ew (* wj ew)))))))
                    
                      (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))