Jmat.Real.lambertw, newton loop step

Percentage Accurate: 77.6% → 99.8%
Time: 5.3s
Alternatives: 13
Speedup: 48.6×

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));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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}

\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
wj - \frac{t\_0 - x}{e^{wj} + t\_0}
\end{array}
\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 13 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.6% 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));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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}

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

Alternative 1: 99.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := wj \cdot e^{wj}\\ t_1 := wj - \frac{t\_0 - x}{e^{wj} + t\_0}\\ t_2 := e^{-wj}\\ \mathbf{if}\;t\_1 \leq -4:\\ \;\;\;\;\frac{\mathsf{fma}\left(t\_2, x, \mathsf{fma}\left(wj, wj, wj\right) - wj\right)}{wj - -1}\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-12}:\\ \;\;\;\;\mathsf{fma}\left(1, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-t\_2, x, \mathsf{fma}\left(wj, -1 - wj, wj\right)\right)}{-1 - wj}\\ \end{array} \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 (exp (- wj))))
   (if (<= t_1 -4.0)
     (/ (fma t_2 x (- (fma wj wj wj) wj)) (- wj -1.0))
     (if (<= t_1 5e-12)
       (fma 1.0 x (fma wj wj (* (* (* (- wj 1.0) wj) wj) wj)))
       (/ (fma (- t_2) x (fma wj (- -1.0 wj) wj)) (- -1.0 wj))))))
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 = exp(-wj);
	double tmp;
	if (t_1 <= -4.0) {
		tmp = fma(t_2, x, (fma(wj, wj, wj) - wj)) / (wj - -1.0);
	} else if (t_1 <= 5e-12) {
		tmp = fma(1.0, x, fma(wj, wj, ((((wj - 1.0) * wj) * wj) * wj)));
	} else {
		tmp = fma(-t_2, x, fma(wj, (-1.0 - wj), wj)) / (-1.0 - wj);
	}
	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 = exp(Float64(-wj))
	tmp = 0.0
	if (t_1 <= -4.0)
		tmp = Float64(fma(t_2, x, Float64(fma(wj, wj, wj) - wj)) / Float64(wj - -1.0));
	elseif (t_1 <= 5e-12)
		tmp = fma(1.0, x, fma(wj, wj, Float64(Float64(Float64(Float64(wj - 1.0) * wj) * wj) * wj)));
	else
		tmp = Float64(fma(Float64(-t_2), x, fma(wj, Float64(-1.0 - wj), wj)) / Float64(-1.0 - wj));
	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[Exp[(-wj)], $MachinePrecision]}, If[LessEqual[t$95$1, -4.0], N[(N[(t$95$2 * x + N[(N[(wj * wj + wj), $MachinePrecision] - wj), $MachinePrecision]), $MachinePrecision] / N[(wj - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-12], N[(1.0 * x + N[(wj * wj + N[(N[(N[(N[(wj - 1.0), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-t$95$2) * x + N[(wj * N[(-1.0 - wj), $MachinePrecision] + wj), $MachinePrecision]), $MachinePrecision] / N[(-1.0 - wj), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
t_1 := wj - \frac{t\_0 - x}{e^{wj} + t\_0}\\
t_2 := e^{-wj}\\
\mathbf{if}\;t\_1 \leq -4:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_2, x, \mathsf{fma}\left(wj, wj, wj\right) - wj\right)}{wj - -1}\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(1, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-t\_2, x, \mathsf{fma}\left(wj, -1 - wj, wj\right)\right)}{-1 - wj}\\


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

    1. Initial program 77.6%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
      3. sub-to-fractionN/A

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

        \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
      5. associate--r-N/A

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

        \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
      7. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      8. mult-flipN/A

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    3. Applied rewrites88.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, wj - \frac{wj}{wj - -1}\right)} \]
    4. Step-by-step derivation
      1. lift-fma.f64N/A

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

        \[\leadsto \color{blue}{\frac{e^{-wj}}{wj - -1}} \cdot x + \left(wj - \frac{wj}{wj - -1}\right) \]
      3. associate-*l/N/A

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

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

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

        \[\leadsto \frac{e^{-wj} \cdot x}{wj - -1} + \color{blue}{\frac{wj \cdot \left(wj - -1\right) - wj}{wj - -1}} \]
      7. div-add-revN/A

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(e^{-wj}, x, \color{blue}{wj \cdot \left(wj - -1\right) - wj}\right)}{wj - -1} \]
      11. lift--.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(e^{-wj}, x, wj \cdot \color{blue}{\left(wj - -1\right)} - wj\right)}{wj - -1} \]
      12. sub-flipN/A

        \[\leadsto \frac{\mathsf{fma}\left(e^{-wj}, x, wj \cdot \color{blue}{\left(wj + \left(\mathsf{neg}\left(-1\right)\right)\right)} - wj\right)}{wj - -1} \]
      13. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(e^{-wj}, x, wj \cdot \left(wj + \color{blue}{1}\right) - wj\right)}{wj - -1} \]
      14. distribute-rgt-inN/A

        \[\leadsto \frac{\mathsf{fma}\left(e^{-wj}, x, \color{blue}{\left(wj \cdot wj + 1 \cdot wj\right)} - wj\right)}{wj - -1} \]
      15. *-lft-identityN/A

        \[\leadsto \frac{\mathsf{fma}\left(e^{-wj}, x, \left(wj \cdot wj + \color{blue}{wj}\right) - wj\right)}{wj - -1} \]
      16. lower-fma.f6488.8

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(e^{-wj}, x, \mathsf{fma}\left(wj, wj, wj\right) - wj\right)}{wj - -1}} \]

    if -4 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 4.9999999999999997e-12

    1. Initial program 77.6%

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
      3. sub-to-fractionN/A

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

        \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
      5. associate--r-N/A

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

        \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
      7. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
      8. mult-flipN/A

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
    3. Applied rewrites88.8%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} \cdot \left(1 + wj \cdot \color{blue}{\left(wj - 1\right)}\right)\right) \]
      5. lower--.f6498.2

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} \cdot \left(1 + \color{blue}{wj \cdot \left(wj - 1\right)}\right)\right) \]
      3. distribute-rgt-inN/A

        \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, 1 \cdot {wj}^{2} + \color{blue}{\left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}}\right) \]
      4. *-lft-identityN/A

        \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} + \color{blue}{\left(wj \cdot \left(wj - 1\right)\right)} \cdot {wj}^{2}\right) \]
      5. lift-pow.f64N/A

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

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

        \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, \color{blue}{wj}, \left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}\right)\right) \]
      8. lift-pow.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(wj \cdot \left(wj - 1\right)\right) \cdot \left(wj \cdot wj\right)\right)\right) \]
      10. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
      11. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
      12. lower-*.f6498.2

        \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
      13. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
      15. lower-*.f6498.2

        \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
    8. Applied rewrites98.2%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
    10. Step-by-step derivation
      1. Applied rewrites95.6%

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

      if 4.9999999999999997e-12 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))))

      1. Initial program 77.6%

        \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
      2. Step-by-step derivation
        1. lift--.f64N/A

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

          \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
        3. sub-to-fractionN/A

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

          \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
        5. associate--r-N/A

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

          \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
        7. +-commutativeN/A

          \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
        8. mult-flipN/A

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      3. Applied rewrites88.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, wj - \frac{wj}{wj - -1}\right)} \]
      4. Step-by-step derivation
        1. lift-fma.f64N/A

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

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

          \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(e^{-wj}\right)}{\mathsf{neg}\left(\left(wj - -1\right)\right)}} \cdot x + \left(wj - \frac{wj}{wj - -1}\right) \]
        4. associate-*l/N/A

          \[\leadsto \color{blue}{\frac{\left(\mathsf{neg}\left(e^{-wj}\right)\right) \cdot x}{\mathsf{neg}\left(\left(wj - -1\right)\right)}} + \left(wj - \frac{wj}{wj - -1}\right) \]
        5. lift--.f64N/A

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

          \[\leadsto \frac{\left(\mathsf{neg}\left(e^{-wj}\right)\right) \cdot x}{\mathsf{neg}\left(\left(wj - -1\right)\right)} + \left(wj - \color{blue}{\frac{wj}{wj - -1}}\right) \]
        7. frac-2negN/A

          \[\leadsto \frac{\left(\mathsf{neg}\left(e^{-wj}\right)\right) \cdot x}{\mathsf{neg}\left(\left(wj - -1\right)\right)} + \left(wj - \color{blue}{\frac{\mathsf{neg}\left(wj\right)}{\mathsf{neg}\left(\left(wj - -1\right)\right)}}\right) \]
        8. lift-neg.f64N/A

          \[\leadsto \frac{\left(\mathsf{neg}\left(e^{-wj}\right)\right) \cdot x}{\mathsf{neg}\left(\left(wj - -1\right)\right)} + \left(wj - \frac{\color{blue}{-wj}}{\mathsf{neg}\left(\left(wj - -1\right)\right)}\right) \]
        9. sub-to-fractionN/A

          \[\leadsto \frac{\left(\mathsf{neg}\left(e^{-wj}\right)\right) \cdot x}{\mathsf{neg}\left(\left(wj - -1\right)\right)} + \color{blue}{\frac{wj \cdot \left(\mathsf{neg}\left(\left(wj - -1\right)\right)\right) - \left(-wj\right)}{\mathsf{neg}\left(\left(wj - -1\right)\right)}} \]
        10. div-add-revN/A

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-e^{-wj}, x, \mathsf{fma}\left(wj, -1 - wj, wj\right)\right)}{-1 - wj}} \]
    11. Recombined 3 regimes into one program.
    12. Add Preprocessing

    Alternative 2: 99.8% accurate, 0.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := wj \cdot e^{wj}\\ t_1 := wj - \frac{t\_0 - x}{e^{wj} + t\_0}\\ t_2 := \frac{\mathsf{fma}\left(e^{-wj}, x, \mathsf{fma}\left(wj, wj, wj\right) - wj\right)}{wj - -1}\\ \mathbf{if}\;t\_1 \leq -4:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-12}:\\ \;\;\;\;\mathsf{fma}\left(1, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \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 (/ (fma (exp (- wj)) x (- (fma wj wj wj) wj)) (- wj -1.0))))
       (if (<= t_1 -4.0)
         t_2
         (if (<= t_1 5e-12)
           (fma 1.0 x (fma wj wj (* (* (* (- wj 1.0) wj) wj) wj)))
           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 = fma(exp(-wj), x, (fma(wj, wj, wj) - wj)) / (wj - -1.0);
    	double tmp;
    	if (t_1 <= -4.0) {
    		tmp = t_2;
    	} else if (t_1 <= 5e-12) {
    		tmp = fma(1.0, x, fma(wj, wj, ((((wj - 1.0) * wj) * wj) * wj)));
    	} 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(fma(exp(Float64(-wj)), x, Float64(fma(wj, wj, wj) - wj)) / Float64(wj - -1.0))
    	tmp = 0.0
    	if (t_1 <= -4.0)
    		tmp = t_2;
    	elseif (t_1 <= 5e-12)
    		tmp = fma(1.0, x, fma(wj, wj, Float64(Float64(Float64(Float64(wj - 1.0) * wj) * wj) * wj)));
    	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[(N[(N[Exp[(-wj)], $MachinePrecision] * x + N[(N[(wj * wj + wj), $MachinePrecision] - wj), $MachinePrecision]), $MachinePrecision] / N[(wj - -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4.0], t$95$2, If[LessEqual[t$95$1, 5e-12], N[(1.0 * x + N[(wj * wj + N[(N[(N[(N[(wj - 1.0), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := wj \cdot e^{wj}\\
    t_1 := wj - \frac{t\_0 - x}{e^{wj} + t\_0}\\
    t_2 := \frac{\mathsf{fma}\left(e^{-wj}, x, \mathsf{fma}\left(wj, wj, wj\right) - wj\right)}{wj - -1}\\
    \mathbf{if}\;t\_1 \leq -4:\\
    \;\;\;\;t\_2\\
    
    \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-12}:\\
    \;\;\;\;\mathsf{fma}\left(1, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_2\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < -4 or 4.9999999999999997e-12 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))))

      1. Initial program 77.6%

        \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
      2. Step-by-step derivation
        1. lift--.f64N/A

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

          \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
        3. sub-to-fractionN/A

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

          \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
        5. associate--r-N/A

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

          \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
        7. +-commutativeN/A

          \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
        8. mult-flipN/A

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      3. Applied rewrites88.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, wj - \frac{wj}{wj - -1}\right)} \]
      4. Step-by-step derivation
        1. lift-fma.f64N/A

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

          \[\leadsto \color{blue}{\frac{e^{-wj}}{wj - -1}} \cdot x + \left(wj - \frac{wj}{wj - -1}\right) \]
        3. associate-*l/N/A

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

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

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

          \[\leadsto \frac{e^{-wj} \cdot x}{wj - -1} + \color{blue}{\frac{wj \cdot \left(wj - -1\right) - wj}{wj - -1}} \]
        7. div-add-revN/A

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

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

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

          \[\leadsto \frac{\mathsf{fma}\left(e^{-wj}, x, \color{blue}{wj \cdot \left(wj - -1\right) - wj}\right)}{wj - -1} \]
        11. lift--.f64N/A

          \[\leadsto \frac{\mathsf{fma}\left(e^{-wj}, x, wj \cdot \color{blue}{\left(wj - -1\right)} - wj\right)}{wj - -1} \]
        12. sub-flipN/A

          \[\leadsto \frac{\mathsf{fma}\left(e^{-wj}, x, wj \cdot \color{blue}{\left(wj + \left(\mathsf{neg}\left(-1\right)\right)\right)} - wj\right)}{wj - -1} \]
        13. metadata-evalN/A

          \[\leadsto \frac{\mathsf{fma}\left(e^{-wj}, x, wj \cdot \left(wj + \color{blue}{1}\right) - wj\right)}{wj - -1} \]
        14. distribute-rgt-inN/A

          \[\leadsto \frac{\mathsf{fma}\left(e^{-wj}, x, \color{blue}{\left(wj \cdot wj + 1 \cdot wj\right)} - wj\right)}{wj - -1} \]
        15. *-lft-identityN/A

          \[\leadsto \frac{\mathsf{fma}\left(e^{-wj}, x, \left(wj \cdot wj + \color{blue}{wj}\right) - wj\right)}{wj - -1} \]
        16. lower-fma.f6488.8

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

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(e^{-wj}, x, \mathsf{fma}\left(wj, wj, wj\right) - wj\right)}{wj - -1}} \]

      if -4 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 4.9999999999999997e-12

      1. Initial program 77.6%

        \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
      2. Step-by-step derivation
        1. lift--.f64N/A

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

          \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
        3. sub-to-fractionN/A

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

          \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
        5. associate--r-N/A

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

          \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
        7. +-commutativeN/A

          \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
        8. mult-flipN/A

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
      3. Applied rewrites88.8%

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} \cdot \left(1 + wj \cdot \color{blue}{\left(wj - 1\right)}\right)\right) \]
        5. lower--.f6498.2

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

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

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

          \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} \cdot \left(1 + \color{blue}{wj \cdot \left(wj - 1\right)}\right)\right) \]
        3. distribute-rgt-inN/A

          \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, 1 \cdot {wj}^{2} + \color{blue}{\left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}}\right) \]
        4. *-lft-identityN/A

          \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} + \color{blue}{\left(wj \cdot \left(wj - 1\right)\right)} \cdot {wj}^{2}\right) \]
        5. lift-pow.f64N/A

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

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

          \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, \color{blue}{wj}, \left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}\right)\right) \]
        8. lift-pow.f64N/A

          \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}\right)\right) \]
        9. unpow2N/A

          \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(wj \cdot \left(wj - 1\right)\right) \cdot \left(wj \cdot wj\right)\right)\right) \]
        10. associate-*r*N/A

          \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
        11. lower-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
        12. lower-*.f6498.2

          \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
        13. lift-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
        14. *-commutativeN/A

          \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
        15. lower-*.f6498.2

          \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
      8. Applied rewrites98.2%

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
      10. Step-by-step derivation
        1. Applied rewrites95.6%

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

      Alternative 3: 99.8% accurate, 0.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := wj \cdot e^{wj}\\ t_1 := wj - \frac{t\_0 - x}{e^{wj} + t\_0}\\ t_2 := \frac{x}{e^{wj}}\\ \mathbf{if}\;t\_1 \leq -4:\\ \;\;\;\;\mathsf{fma}\left(t\_2 - wj, \frac{1}{wj - -1}, wj\right)\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-12}:\\ \;\;\;\;\mathsf{fma}\left(1, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right)\\ \mathbf{else}:\\ \;\;\;\;wj - \frac{wj - t\_2}{wj - -1}\\ \end{array} \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 (exp wj))))
         (if (<= t_1 -4.0)
           (fma (- t_2 wj) (/ 1.0 (- wj -1.0)) wj)
           (if (<= t_1 5e-12)
             (fma 1.0 x (fma wj wj (* (* (* (- wj 1.0) wj) wj) wj)))
             (- wj (/ (- wj t_2) (- wj -1.0)))))))
      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 / exp(wj);
      	double tmp;
      	if (t_1 <= -4.0) {
      		tmp = fma((t_2 - wj), (1.0 / (wj - -1.0)), wj);
      	} else if (t_1 <= 5e-12) {
      		tmp = fma(1.0, x, fma(wj, wj, ((((wj - 1.0) * wj) * wj) * wj)));
      	} else {
      		tmp = wj - ((wj - t_2) / (wj - -1.0));
      	}
      	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 / exp(wj))
      	tmp = 0.0
      	if (t_1 <= -4.0)
      		tmp = fma(Float64(t_2 - wj), Float64(1.0 / Float64(wj - -1.0)), wj);
      	elseif (t_1 <= 5e-12)
      		tmp = fma(1.0, x, fma(wj, wj, Float64(Float64(Float64(Float64(wj - 1.0) * wj) * wj) * wj)));
      	else
      		tmp = Float64(wj - Float64(Float64(wj - t_2) / Float64(wj - -1.0)));
      	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[Exp[wj], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4.0], N[(N[(t$95$2 - wj), $MachinePrecision] * N[(1.0 / N[(wj - -1.0), $MachinePrecision]), $MachinePrecision] + wj), $MachinePrecision], If[LessEqual[t$95$1, 5e-12], N[(1.0 * x + N[(wj * wj + N[(N[(N[(N[(wj - 1.0), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj - N[(N[(wj - t$95$2), $MachinePrecision] / N[(wj - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := wj \cdot e^{wj}\\
      t_1 := wj - \frac{t\_0 - x}{e^{wj} + t\_0}\\
      t_2 := \frac{x}{e^{wj}}\\
      \mathbf{if}\;t\_1 \leq -4:\\
      \;\;\;\;\mathsf{fma}\left(t\_2 - wj, \frac{1}{wj - -1}, wj\right)\\
      
      \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-12}:\\
      \;\;\;\;\mathsf{fma}\left(1, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;wj - \frac{wj - t\_2}{wj - -1}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < -4

        1. Initial program 77.6%

          \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
        2. Step-by-step derivation
          1. lift--.f64N/A

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

            \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
          3. sub-to-fractionN/A

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

            \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
          5. associate--r-N/A

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

            \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
          7. +-commutativeN/A

            \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
          8. mult-flipN/A

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
        3. Applied rewrites88.8%

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, wj - \frac{wj}{wj - -1}\right)} \]
        4. Step-by-step derivation
          1. lift-fma.f64N/A

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

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

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

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

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

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

            \[\leadsto wj - \left(\frac{wj}{wj - -1} - \color{blue}{\frac{e^{-wj}}{wj - -1}} \cdot x\right) \]
          8. associate-*l/N/A

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

            \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{x \cdot e^{-wj}}}{wj - -1}\right) \]
          10. lift-exp.f64N/A

            \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \color{blue}{e^{-wj}}}{wj - -1}\right) \]
          11. lift-neg.f64N/A

            \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot e^{\color{blue}{\mathsf{neg}\left(wj\right)}}}{wj - -1}\right) \]
          12. exp-negN/A

            \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \color{blue}{\frac{1}{e^{wj}}}}{wj - -1}\right) \]
          13. lift-exp.f64N/A

            \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \frac{1}{\color{blue}{e^{wj}}}}{wj - -1}\right) \]
          14. mult-flipN/A

            \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{\frac{x}{e^{wj}}}}{wj - -1}\right) \]
          15. lift-/.f64N/A

            \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{\frac{x}{e^{wj}}}}{wj - -1}\right) \]
          16. sub-divN/A

            \[\leadsto wj - \color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
          17. lower-/.f64N/A

            \[\leadsto wj - \color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
          18. lower--.f6479.7

            \[\leadsto wj - \frac{\color{blue}{wj - \frac{x}{e^{wj}}}}{wj - -1} \]
        5. Applied rewrites79.7%

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

            \[\leadsto \color{blue}{wj - \frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
          2. sub-flipN/A

            \[\leadsto \color{blue}{wj + \left(\mathsf{neg}\left(\frac{wj - \frac{x}{e^{wj}}}{wj - -1}\right)\right)} \]
          3. +-commutativeN/A

            \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{wj - \frac{x}{e^{wj}}}{wj - -1}\right)\right) + wj} \]
          4. lift-/.f64N/A

            \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj - -1}}\right)\right) + wj \]
          5. mult-flipN/A

            \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(wj - \frac{x}{e^{wj}}\right) \cdot \frac{1}{wj - -1}}\right)\right) + wj \]
          6. distribute-lft-neg-inN/A

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\left(wj - \frac{x}{e^{wj}}\right)\right), \frac{1}{wj - -1}, wj\right)} \]
          8. lift--.f64N/A

            \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(wj - \frac{x}{e^{wj}}\right)}\right), \frac{1}{wj - -1}, wj\right) \]
          9. sub-negate-revN/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{x}{e^{wj}} - wj}, \frac{1}{wj - -1}, wj\right) \]
          10. lower--.f64N/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{x}{e^{wj}} - wj}, \frac{1}{wj - -1}, wj\right) \]
          11. lower-/.f6479.7

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{e^{wj}} - wj, \frac{1}{wj - -1}, wj\right)} \]

        if -4 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 4.9999999999999997e-12

        1. Initial program 77.6%

          \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
        2. Step-by-step derivation
          1. lift--.f64N/A

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

            \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
          3. sub-to-fractionN/A

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

            \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
          5. associate--r-N/A

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

            \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
          7. +-commutativeN/A

            \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
          8. mult-flipN/A

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
        3. Applied rewrites88.8%

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} \cdot \left(1 + wj \cdot \color{blue}{\left(wj - 1\right)}\right)\right) \]
          5. lower--.f6498.2

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} \cdot \left(1 + \color{blue}{wj \cdot \left(wj - 1\right)}\right)\right) \]
          3. distribute-rgt-inN/A

            \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, 1 \cdot {wj}^{2} + \color{blue}{\left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}}\right) \]
          4. *-lft-identityN/A

            \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} + \color{blue}{\left(wj \cdot \left(wj - 1\right)\right)} \cdot {wj}^{2}\right) \]
          5. lift-pow.f64N/A

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

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

            \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, \color{blue}{wj}, \left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}\right)\right) \]
          8. lift-pow.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}\right)\right) \]
          9. unpow2N/A

            \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(wj \cdot \left(wj - 1\right)\right) \cdot \left(wj \cdot wj\right)\right)\right) \]
          10. associate-*r*N/A

            \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
          11. lower-*.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
          12. lower-*.f6498.2

            \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
          13. lift-*.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
          14. *-commutativeN/A

            \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
          15. lower-*.f6498.2

            \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
        8. Applied rewrites98.2%

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
        10. Step-by-step derivation
          1. Applied rewrites95.6%

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

          if 4.9999999999999997e-12 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))))

          1. Initial program 77.6%

            \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
          2. Step-by-step derivation
            1. lift--.f64N/A

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

              \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
            3. sub-to-fractionN/A

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

              \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
            5. associate--r-N/A

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

              \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
            7. +-commutativeN/A

              \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
            8. mult-flipN/A

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
          3. Applied rewrites88.8%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, wj - \frac{wj}{wj - -1}\right)} \]
          4. Step-by-step derivation
            1. lift-fma.f64N/A

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

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

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

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

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

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

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \color{blue}{\frac{e^{-wj}}{wj - -1}} \cdot x\right) \]
            8. associate-*l/N/A

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

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{x \cdot e^{-wj}}}{wj - -1}\right) \]
            10. lift-exp.f64N/A

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \color{blue}{e^{-wj}}}{wj - -1}\right) \]
            11. lift-neg.f64N/A

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot e^{\color{blue}{\mathsf{neg}\left(wj\right)}}}{wj - -1}\right) \]
            12. exp-negN/A

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \color{blue}{\frac{1}{e^{wj}}}}{wj - -1}\right) \]
            13. lift-exp.f64N/A

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \frac{1}{\color{blue}{e^{wj}}}}{wj - -1}\right) \]
            14. mult-flipN/A

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{\frac{x}{e^{wj}}}}{wj - -1}\right) \]
            15. lift-/.f64N/A

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{\frac{x}{e^{wj}}}}{wj - -1}\right) \]
            16. sub-divN/A

              \[\leadsto wj - \color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
            17. lower-/.f64N/A

              \[\leadsto wj - \color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
            18. lower--.f6479.7

              \[\leadsto wj - \frac{\color{blue}{wj - \frac{x}{e^{wj}}}}{wj - -1} \]
          5. Applied rewrites79.7%

            \[\leadsto \color{blue}{wj - \frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
        11. Recombined 3 regimes into one program.
        12. Add Preprocessing

        Alternative 4: 99.8% accurate, 0.4× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := wj \cdot e^{wj}\\ t_1 := wj - \frac{t\_0 - x}{e^{wj} + t\_0}\\ t_2 := wj - \frac{wj - \frac{x}{e^{wj}}}{wj - -1}\\ \mathbf{if}\;t\_1 \leq -4:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-12}:\\ \;\;\;\;\mathsf{fma}\left(1, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \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 (- wj (/ (- wj (/ x (exp wj))) (- wj -1.0)))))
           (if (<= t_1 -4.0)
             t_2
             (if (<= t_1 5e-12)
               (fma 1.0 x (fma wj wj (* (* (* (- wj 1.0) wj) wj) wj)))
               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 = wj - ((wj - (x / exp(wj))) / (wj - -1.0));
        	double tmp;
        	if (t_1 <= -4.0) {
        		tmp = t_2;
        	} else if (t_1 <= 5e-12) {
        		tmp = fma(1.0, x, fma(wj, wj, ((((wj - 1.0) * wj) * wj) * wj)));
        	} 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(wj - Float64(Float64(wj - Float64(x / exp(wj))) / Float64(wj - -1.0)))
        	tmp = 0.0
        	if (t_1 <= -4.0)
        		tmp = t_2;
        	elseif (t_1 <= 5e-12)
        		tmp = fma(1.0, x, fma(wj, wj, Float64(Float64(Float64(Float64(wj - 1.0) * wj) * wj) * wj)));
        	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[(wj - N[(N[(wj - N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(wj - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4.0], t$95$2, If[LessEqual[t$95$1, 5e-12], N[(1.0 * x + N[(wj * wj + N[(N[(N[(N[(wj - 1.0), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := wj \cdot e^{wj}\\
        t_1 := wj - \frac{t\_0 - x}{e^{wj} + t\_0}\\
        t_2 := wj - \frac{wj - \frac{x}{e^{wj}}}{wj - -1}\\
        \mathbf{if}\;t\_1 \leq -4:\\
        \;\;\;\;t\_2\\
        
        \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-12}:\\
        \;\;\;\;\mathsf{fma}\left(1, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_2\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < -4 or 4.9999999999999997e-12 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))))

          1. Initial program 77.6%

            \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
          2. Step-by-step derivation
            1. lift--.f64N/A

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

              \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
            3. sub-to-fractionN/A

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

              \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
            5. associate--r-N/A

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

              \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
            7. +-commutativeN/A

              \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
            8. mult-flipN/A

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
          3. Applied rewrites88.8%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, wj - \frac{wj}{wj - -1}\right)} \]
          4. Step-by-step derivation
            1. lift-fma.f64N/A

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

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

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

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

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

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

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \color{blue}{\frac{e^{-wj}}{wj - -1}} \cdot x\right) \]
            8. associate-*l/N/A

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

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{x \cdot e^{-wj}}}{wj - -1}\right) \]
            10. lift-exp.f64N/A

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \color{blue}{e^{-wj}}}{wj - -1}\right) \]
            11. lift-neg.f64N/A

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot e^{\color{blue}{\mathsf{neg}\left(wj\right)}}}{wj - -1}\right) \]
            12. exp-negN/A

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \color{blue}{\frac{1}{e^{wj}}}}{wj - -1}\right) \]
            13. lift-exp.f64N/A

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \frac{1}{\color{blue}{e^{wj}}}}{wj - -1}\right) \]
            14. mult-flipN/A

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{\frac{x}{e^{wj}}}}{wj - -1}\right) \]
            15. lift-/.f64N/A

              \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{\frac{x}{e^{wj}}}}{wj - -1}\right) \]
            16. sub-divN/A

              \[\leadsto wj - \color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
            17. lower-/.f64N/A

              \[\leadsto wj - \color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
            18. lower--.f6479.7

              \[\leadsto wj - \frac{\color{blue}{wj - \frac{x}{e^{wj}}}}{wj - -1} \]
          5. Applied rewrites79.7%

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

          if -4 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 4.9999999999999997e-12

          1. Initial program 77.6%

            \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
          2. Step-by-step derivation
            1. lift--.f64N/A

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

              \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
            3. sub-to-fractionN/A

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

              \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
            5. associate--r-N/A

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

              \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
            7. +-commutativeN/A

              \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
            8. mult-flipN/A

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
          3. Applied rewrites88.8%

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} \cdot \left(1 + wj \cdot \color{blue}{\left(wj - 1\right)}\right)\right) \]
            5. lower--.f6498.2

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

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

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

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} \cdot \left(1 + \color{blue}{wj \cdot \left(wj - 1\right)}\right)\right) \]
            3. distribute-rgt-inN/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, 1 \cdot {wj}^{2} + \color{blue}{\left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}}\right) \]
            4. *-lft-identityN/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} + \color{blue}{\left(wj \cdot \left(wj - 1\right)\right)} \cdot {wj}^{2}\right) \]
            5. lift-pow.f64N/A

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

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

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, \color{blue}{wj}, \left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}\right)\right) \]
            8. lift-pow.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}\right)\right) \]
            9. unpow2N/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(wj \cdot \left(wj - 1\right)\right) \cdot \left(wj \cdot wj\right)\right)\right) \]
            10. associate-*r*N/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
            11. lower-*.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
            12. lower-*.f6498.2

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
            13. lift-*.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
            14. *-commutativeN/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
            15. lower-*.f6498.2

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
          8. Applied rewrites98.2%

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

            \[\leadsto \mathsf{fma}\left(\color{blue}{1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
          10. Step-by-step derivation
            1. Applied rewrites95.6%

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

          Alternative 5: 98.2% accurate, 1.2× speedup?

          \[\begin{array}{l} \\ \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \end{array} \]
          (FPCore (wj x)
           :precision binary64
           (fma
            (/ (exp (- wj)) (- wj -1.0))
            x
            (fma wj wj (* (* (* (- wj 1.0) wj) wj) wj))))
          double code(double wj, double x) {
          	return fma((exp(-wj) / (wj - -1.0)), x, fma(wj, wj, ((((wj - 1.0) * wj) * wj) * wj)));
          }
          
          function code(wj, x)
          	return fma(Float64(exp(Float64(-wj)) / Float64(wj - -1.0)), x, fma(wj, wj, Float64(Float64(Float64(Float64(wj - 1.0) * wj) * wj) * wj)))
          end
          
          code[wj_, x_] := N[(N[(N[Exp[(-wj)], $MachinePrecision] / N[(wj - -1.0), $MachinePrecision]), $MachinePrecision] * x + N[(wj * wj + N[(N[(N[(N[(wj - 1.0), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right)
          \end{array}
          
          Derivation
          1. Initial program 77.6%

            \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
          2. Step-by-step derivation
            1. lift--.f64N/A

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

              \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
            3. sub-to-fractionN/A

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

              \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
            5. associate--r-N/A

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

              \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
            7. +-commutativeN/A

              \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
            8. mult-flipN/A

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
          3. Applied rewrites88.8%

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} \cdot \left(1 + wj \cdot \color{blue}{\left(wj - 1\right)}\right)\right) \]
            5. lower--.f6498.2

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

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

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

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} \cdot \left(1 + \color{blue}{wj \cdot \left(wj - 1\right)}\right)\right) \]
            3. distribute-rgt-inN/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, 1 \cdot {wj}^{2} + \color{blue}{\left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}}\right) \]
            4. *-lft-identityN/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} + \color{blue}{\left(wj \cdot \left(wj - 1\right)\right)} \cdot {wj}^{2}\right) \]
            5. lift-pow.f64N/A

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

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

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, \color{blue}{wj}, \left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}\right)\right) \]
            8. lift-pow.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}\right)\right) \]
            9. unpow2N/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(wj \cdot \left(wj - 1\right)\right) \cdot \left(wj \cdot wj\right)\right)\right) \]
            10. associate-*r*N/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
            11. lower-*.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
            12. lower-*.f6498.2

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
            13. lift-*.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
            14. *-commutativeN/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
            15. lower-*.f6498.2

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
          8. Applied rewrites98.2%

            \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, \color{blue}{wj}, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
          9. Add Preprocessing

          Alternative 6: 95.6% accurate, 2.2× speedup?

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

            \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
          2. Step-by-step derivation
            1. lift--.f64N/A

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

              \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
            3. sub-to-fractionN/A

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

              \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
            5. associate--r-N/A

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

              \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
            7. +-commutativeN/A

              \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
            8. mult-flipN/A

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
          3. Applied rewrites88.8%

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} \cdot \left(1 + wj \cdot \color{blue}{\left(wj - 1\right)}\right)\right) \]
            5. lower--.f6498.2

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

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

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

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} \cdot \left(1 + \color{blue}{wj \cdot \left(wj - 1\right)}\right)\right) \]
            3. distribute-rgt-inN/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, 1 \cdot {wj}^{2} + \color{blue}{\left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}}\right) \]
            4. *-lft-identityN/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, {wj}^{2} + \color{blue}{\left(wj \cdot \left(wj - 1\right)\right)} \cdot {wj}^{2}\right) \]
            5. lift-pow.f64N/A

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

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

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, \color{blue}{wj}, \left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}\right)\right) \]
            8. lift-pow.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(wj \cdot \left(wj - 1\right)\right) \cdot {wj}^{2}\right)\right) \]
            9. unpow2N/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(wj \cdot \left(wj - 1\right)\right) \cdot \left(wj \cdot wj\right)\right)\right) \]
            10. associate-*r*N/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
            11. lower-*.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
            12. lower-*.f6498.2

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
            13. lift-*.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(wj \cdot \left(wj - 1\right)\right) \cdot wj\right) \cdot wj\right)\right) \]
            14. *-commutativeN/A

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
            15. lower-*.f6498.2

              \[\leadsto \mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
          8. Applied rewrites98.2%

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

            \[\leadsto \mathsf{fma}\left(\color{blue}{1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
          10. Step-by-step derivation
            1. Applied rewrites95.6%

              \[\leadsto \mathsf{fma}\left(\color{blue}{1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right) \]
            2. Add Preprocessing

            Alternative 7: 85.9% accurate, 2.3× speedup?

            \[\begin{array}{l} \\ \frac{x \cdot e^{-wj}}{1 + wj} \end{array} \]
            (FPCore (wj x) :precision binary64 (/ (* x (exp (- wj))) (+ 1.0 wj)))
            double code(double wj, double x) {
            	return (x * exp(-wj)) / (1.0 + wj);
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(wj, x)
            use fmin_fmax_functions
                real(8), intent (in) :: wj
                real(8), intent (in) :: x
                code = (x * exp(-wj)) / (1.0d0 + wj)
            end function
            
            public static double code(double wj, double x) {
            	return (x * Math.exp(-wj)) / (1.0 + wj);
            }
            
            def code(wj, x):
            	return (x * math.exp(-wj)) / (1.0 + wj)
            
            function code(wj, x)
            	return Float64(Float64(x * exp(Float64(-wj))) / Float64(1.0 + wj))
            end
            
            function tmp = code(wj, x)
            	tmp = (x * exp(-wj)) / (1.0 + wj);
            end
            
            code[wj_, x_] := N[(N[(x * N[Exp[(-wj)], $MachinePrecision]), $MachinePrecision] / N[(1.0 + wj), $MachinePrecision]), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \frac{x \cdot e^{-wj}}{1 + wj}
            \end{array}
            
            Derivation
            1. Initial program 77.6%

              \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
            2. Step-by-step derivation
              1. lift--.f64N/A

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

                \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
              3. sub-to-fractionN/A

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

                \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
              5. associate--r-N/A

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

                \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
              7. +-commutativeN/A

                \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
              8. mult-flipN/A

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
            3. Applied rewrites88.8%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, wj - \frac{wj}{wj - -1}\right)} \]
            4. Taylor expanded in x around inf

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

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

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

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

                \[\leadsto \frac{x \cdot e^{-wj}}{1 + wj} \]
              5. lower-+.f6485.9

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

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

            Alternative 8: 85.9% accurate, 2.3× speedup?

            \[\begin{array}{l} \\ \frac{e^{-wj}}{wj - -1} \cdot x \end{array} \]
            (FPCore (wj x) :precision binary64 (* (/ (exp (- wj)) (- wj -1.0)) x))
            double code(double wj, double x) {
            	return (exp(-wj) / (wj - -1.0)) * x;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(wj, x)
            use fmin_fmax_functions
                real(8), intent (in) :: wj
                real(8), intent (in) :: x
                code = (exp(-wj) / (wj - (-1.0d0))) * x
            end function
            
            public static double code(double wj, double x) {
            	return (Math.exp(-wj) / (wj - -1.0)) * x;
            }
            
            def code(wj, x):
            	return (math.exp(-wj) / (wj - -1.0)) * x
            
            function code(wj, x)
            	return Float64(Float64(exp(Float64(-wj)) / Float64(wj - -1.0)) * x)
            end
            
            function tmp = code(wj, x)
            	tmp = (exp(-wj) / (wj - -1.0)) * x;
            end
            
            code[wj_, x_] := N[(N[(N[Exp[(-wj)], $MachinePrecision] / N[(wj - -1.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \frac{e^{-wj}}{wj - -1} \cdot x
            \end{array}
            
            Derivation
            1. Initial program 77.6%

              \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
            2. Step-by-step derivation
              1. lift--.f64N/A

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

                \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
              3. sub-to-fractionN/A

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

                \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
              5. associate--r-N/A

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

                \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
              7. +-commutativeN/A

                \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
              8. mult-flipN/A

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
            3. Applied rewrites88.8%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, wj - \frac{wj}{wj - -1}\right)} \]
            4. Step-by-step derivation
              1. lift-fma.f64N/A

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

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

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

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

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

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

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \color{blue}{\frac{e^{-wj}}{wj - -1}} \cdot x\right) \]
              8. associate-*l/N/A

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

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{x \cdot e^{-wj}}}{wj - -1}\right) \]
              10. lift-exp.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \color{blue}{e^{-wj}}}{wj - -1}\right) \]
              11. lift-neg.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot e^{\color{blue}{\mathsf{neg}\left(wj\right)}}}{wj - -1}\right) \]
              12. exp-negN/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \color{blue}{\frac{1}{e^{wj}}}}{wj - -1}\right) \]
              13. lift-exp.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \frac{1}{\color{blue}{e^{wj}}}}{wj - -1}\right) \]
              14. mult-flipN/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{\frac{x}{e^{wj}}}}{wj - -1}\right) \]
              15. lift-/.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{\frac{x}{e^{wj}}}}{wj - -1}\right) \]
              16. sub-divN/A

                \[\leadsto wj - \color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
              17. lower-/.f64N/A

                \[\leadsto wj - \color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
              18. lower--.f6479.7

                \[\leadsto wj - \frac{\color{blue}{wj - \frac{x}{e^{wj}}}}{wj - -1} \]
            5. Applied rewrites79.7%

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{x}{e^{wj} \cdot \left(wj + \color{blue}{1}\right)} \]
              5. metadata-evalN/A

                \[\leadsto \frac{x}{e^{wj} \cdot \left(wj + \left(\mathsf{neg}\left(-1\right)\right)\right)} \]
              6. sub-flipN/A

                \[\leadsto \frac{x}{e^{wj} \cdot \left(wj - \color{blue}{-1}\right)} \]
              7. associate-/l/N/A

                \[\leadsto \frac{\frac{x}{e^{wj}}}{\color{blue}{wj - -1}} \]
              8. mult-flipN/A

                \[\leadsto \frac{x \cdot \frac{1}{e^{wj}}}{\color{blue}{wj} - -1} \]
              9. lift-exp.f64N/A

                \[\leadsto \frac{x \cdot \frac{1}{e^{wj}}}{wj - -1} \]
              10. exp-negN/A

                \[\leadsto \frac{x \cdot e^{\mathsf{neg}\left(wj\right)}}{wj - -1} \]
              11. lift-neg.f64N/A

                \[\leadsto \frac{x \cdot e^{-wj}}{wj - -1} \]
              12. lift-exp.f64N/A

                \[\leadsto \frac{x \cdot e^{-wj}}{wj - -1} \]
              13. associate-/l*N/A

                \[\leadsto x \cdot \color{blue}{\frac{e^{-wj}}{wj - -1}} \]
              14. lift-/.f64N/A

                \[\leadsto x \cdot \frac{e^{-wj}}{\color{blue}{wj - -1}} \]
              15. lift--.f64N/A

                \[\leadsto x \cdot \frac{e^{-wj}}{wj - \color{blue}{-1}} \]
              16. *-commutativeN/A

                \[\leadsto \frac{e^{-wj}}{wj - -1} \cdot \color{blue}{x} \]
              17. lower-*.f6485.9

                \[\leadsto \frac{e^{-wj}}{wj - -1} \cdot \color{blue}{x} \]
            10. Applied rewrites85.9%

              \[\leadsto \frac{e^{-wj}}{wj - -1} \cdot \color{blue}{x} \]
            11. Add Preprocessing

            Alternative 9: 85.9% accurate, 2.4× speedup?

            \[\begin{array}{l} \\ \frac{x}{e^{wj} \cdot \left(wj - -1\right)} \end{array} \]
            (FPCore (wj x) :precision binary64 (/ x (* (exp wj) (- wj -1.0))))
            double code(double wj, double x) {
            	return x / (exp(wj) * (wj - -1.0));
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(wj, x)
            use fmin_fmax_functions
                real(8), intent (in) :: wj
                real(8), intent (in) :: x
                code = x / (exp(wj) * (wj - (-1.0d0)))
            end function
            
            public static double code(double wj, double x) {
            	return x / (Math.exp(wj) * (wj - -1.0));
            }
            
            def code(wj, x):
            	return x / (math.exp(wj) * (wj - -1.0))
            
            function code(wj, x)
            	return Float64(x / Float64(exp(wj) * Float64(wj - -1.0)))
            end
            
            function tmp = code(wj, x)
            	tmp = x / (exp(wj) * (wj - -1.0));
            end
            
            code[wj_, x_] := N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \frac{x}{e^{wj} \cdot \left(wj - -1\right)}
            \end{array}
            
            Derivation
            1. Initial program 77.6%

              \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
            2. Step-by-step derivation
              1. lift--.f64N/A

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

                \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
              3. sub-to-fractionN/A

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

                \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
              5. associate--r-N/A

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

                \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
              7. +-commutativeN/A

                \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
              8. mult-flipN/A

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
            3. Applied rewrites88.8%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, wj - \frac{wj}{wj - -1}\right)} \]
            4. Step-by-step derivation
              1. lift-fma.f64N/A

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

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

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

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

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

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

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \color{blue}{\frac{e^{-wj}}{wj - -1}} \cdot x\right) \]
              8. associate-*l/N/A

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

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{x \cdot e^{-wj}}}{wj - -1}\right) \]
              10. lift-exp.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \color{blue}{e^{-wj}}}{wj - -1}\right) \]
              11. lift-neg.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot e^{\color{blue}{\mathsf{neg}\left(wj\right)}}}{wj - -1}\right) \]
              12. exp-negN/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \color{blue}{\frac{1}{e^{wj}}}}{wj - -1}\right) \]
              13. lift-exp.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \frac{1}{\color{blue}{e^{wj}}}}{wj - -1}\right) \]
              14. mult-flipN/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{\frac{x}{e^{wj}}}}{wj - -1}\right) \]
              15. lift-/.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{\frac{x}{e^{wj}}}}{wj - -1}\right) \]
              16. sub-divN/A

                \[\leadsto wj - \color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
              17. lower-/.f64N/A

                \[\leadsto wj - \color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
              18. lower--.f6479.7

                \[\leadsto wj - \frac{\color{blue}{wj - \frac{x}{e^{wj}}}}{wj - -1} \]
            5. Applied rewrites79.7%

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

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

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

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

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

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

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

                \[\leadsto \frac{x}{e^{wj} \cdot \left(1 + wj\right)} \]
              2. sub-to-fractionN/A

                \[\leadsto \frac{x}{e^{wj} \cdot \left(1 + wj\right)} \]
              3. lift-exp.f64N/A

                \[\leadsto \frac{x}{e^{wj} \cdot \left(1 + wj\right)} \]
              4. associate-/l/N/A

                \[\leadsto \frac{x}{e^{wj} \cdot \left(1 + wj\right)} \]
              5. *-commutativeN/A

                \[\leadsto \frac{x}{e^{wj} \cdot \left(1 + wj\right)} \]
              6. sub-flipN/A

                \[\leadsto \frac{x}{e^{wj} \cdot \left(1 + wj\right)} \]
              7. metadata-evalN/A

                \[\leadsto \frac{x}{e^{wj} \cdot \left(1 + wj\right)} \]
              8. distribute-rgt1-inN/A

                \[\leadsto \frac{x}{e^{wj} \cdot \left(1 + wj\right)} \]
              9. lift-exp.f64N/A

                \[\leadsto \frac{x}{e^{wj} \cdot \left(1 + wj\right)} \]
              10. lift-exp.f6485.9

                \[\leadsto \frac{x}{e^{wj} \cdot \left(1 + wj\right)} \]
              11. lift-+.f64N/A

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

                \[\leadsto \frac{x}{e^{wj} \cdot \left(wj + \color{blue}{1}\right)} \]
              13. metadata-evalN/A

                \[\leadsto \frac{x}{e^{wj} \cdot \left(wj + \left(\mathsf{neg}\left(-1\right)\right)\right)} \]
              14. sub-flipN/A

                \[\leadsto \frac{x}{e^{wj} \cdot \left(wj - \color{blue}{-1}\right)} \]
              15. lift--.f6485.9

                \[\leadsto \frac{x}{e^{wj} \cdot \left(wj - \color{blue}{-1}\right)} \]
            10. Applied rewrites85.9%

              \[\leadsto \color{blue}{\frac{x}{e^{wj} \cdot \left(wj - -1\right)}} \]
            11. Add Preprocessing

            Alternative 10: 84.2% accurate, 3.1× speedup?

            \[\begin{array}{l} \\ \frac{x}{1 + wj \cdot \left(2 + 1.5 \cdot wj\right)} \end{array} \]
            (FPCore (wj x) :precision binary64 (/ x (+ 1.0 (* wj (+ 2.0 (* 1.5 wj))))))
            double code(double wj, double x) {
            	return x / (1.0 + (wj * (2.0 + (1.5 * wj))));
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(wj, x)
            use fmin_fmax_functions
                real(8), intent (in) :: wj
                real(8), intent (in) :: x
                code = x / (1.0d0 + (wj * (2.0d0 + (1.5d0 * wj))))
            end function
            
            public static double code(double wj, double x) {
            	return x / (1.0 + (wj * (2.0 + (1.5 * wj))));
            }
            
            def code(wj, x):
            	return x / (1.0 + (wj * (2.0 + (1.5 * wj))))
            
            function code(wj, x)
            	return Float64(x / Float64(1.0 + Float64(wj * Float64(2.0 + Float64(1.5 * wj)))))
            end
            
            function tmp = code(wj, x)
            	tmp = x / (1.0 + (wj * (2.0 + (1.5 * wj))));
            end
            
            code[wj_, x_] := N[(x / N[(1.0 + N[(wj * N[(2.0 + N[(1.5 * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \frac{x}{1 + wj \cdot \left(2 + 1.5 \cdot wj\right)}
            \end{array}
            
            Derivation
            1. Initial program 77.6%

              \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
            2. Step-by-step derivation
              1. lift--.f64N/A

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

                \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
              3. sub-to-fractionN/A

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

                \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
              5. associate--r-N/A

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

                \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
              7. +-commutativeN/A

                \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
              8. mult-flipN/A

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
            3. Applied rewrites88.8%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, wj - \frac{wj}{wj - -1}\right)} \]
            4. Step-by-step derivation
              1. lift-fma.f64N/A

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

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

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

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

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

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

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \color{blue}{\frac{e^{-wj}}{wj - -1}} \cdot x\right) \]
              8. associate-*l/N/A

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

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{x \cdot e^{-wj}}}{wj - -1}\right) \]
              10. lift-exp.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \color{blue}{e^{-wj}}}{wj - -1}\right) \]
              11. lift-neg.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot e^{\color{blue}{\mathsf{neg}\left(wj\right)}}}{wj - -1}\right) \]
              12. exp-negN/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \color{blue}{\frac{1}{e^{wj}}}}{wj - -1}\right) \]
              13. lift-exp.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \frac{1}{\color{blue}{e^{wj}}}}{wj - -1}\right) \]
              14. mult-flipN/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{\frac{x}{e^{wj}}}}{wj - -1}\right) \]
              15. lift-/.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{\frac{x}{e^{wj}}}}{wj - -1}\right) \]
              16. sub-divN/A

                \[\leadsto wj - \color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
              17. lower-/.f64N/A

                \[\leadsto wj - \color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
              18. lower--.f6479.7

                \[\leadsto wj - \frac{\color{blue}{wj - \frac{x}{e^{wj}}}}{wj - -1} \]
            5. Applied rewrites79.7%

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{x}{1 + wj \cdot \left(2 + 1.5 \cdot wj\right)} \]
            11. Applied rewrites84.2%

              \[\leadsto \frac{x}{1 + \color{blue}{wj \cdot \left(2 + 1.5 \cdot wj\right)}} \]
            12. Add Preprocessing

            Alternative 11: 84.0% accurate, 4.8× speedup?

            \[\begin{array}{l} \\ \frac{x}{1 + 2 \cdot wj} \end{array} \]
            (FPCore (wj x) :precision binary64 (/ x (+ 1.0 (* 2.0 wj))))
            double code(double wj, double x) {
            	return x / (1.0 + (2.0 * wj));
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            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]
            
            \begin{array}{l}
            
            \\
            \frac{x}{1 + 2 \cdot wj}
            \end{array}
            
            Derivation
            1. Initial program 77.6%

              \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
            2. Step-by-step derivation
              1. lift--.f64N/A

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

                \[\leadsto wj - \color{blue}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \]
              3. sub-to-fractionN/A

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

                \[\leadsto \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - \color{blue}{\left(wj \cdot e^{wj} - x\right)}}{e^{wj} + wj \cdot e^{wj}} \]
              5. associate--r-N/A

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

                \[\leadsto \color{blue}{\frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} + \frac{x}{e^{wj} + wj \cdot e^{wj}}} \]
              7. +-commutativeN/A

                \[\leadsto \color{blue}{\frac{x}{e^{wj} + wj \cdot e^{wj}} + \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}} \]
              8. mult-flipN/A

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{e^{wj} + wj \cdot e^{wj}}, x, \frac{wj \cdot \left(e^{wj} + wj \cdot e^{wj}\right) - wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} \]
            3. Applied rewrites88.8%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, wj - \frac{wj}{wj - -1}\right)} \]
            4. Step-by-step derivation
              1. lift-fma.f64N/A

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

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

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

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

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

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

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \color{blue}{\frac{e^{-wj}}{wj - -1}} \cdot x\right) \]
              8. associate-*l/N/A

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

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{x \cdot e^{-wj}}}{wj - -1}\right) \]
              10. lift-exp.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \color{blue}{e^{-wj}}}{wj - -1}\right) \]
              11. lift-neg.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot e^{\color{blue}{\mathsf{neg}\left(wj\right)}}}{wj - -1}\right) \]
              12. exp-negN/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \color{blue}{\frac{1}{e^{wj}}}}{wj - -1}\right) \]
              13. lift-exp.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{x \cdot \frac{1}{\color{blue}{e^{wj}}}}{wj - -1}\right) \]
              14. mult-flipN/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{\frac{x}{e^{wj}}}}{wj - -1}\right) \]
              15. lift-/.f64N/A

                \[\leadsto wj - \left(\frac{wj}{wj - -1} - \frac{\color{blue}{\frac{x}{e^{wj}}}}{wj - -1}\right) \]
              16. sub-divN/A

                \[\leadsto wj - \color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
              17. lower-/.f64N/A

                \[\leadsto wj - \color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj - -1}} \]
              18. lower--.f6479.7

                \[\leadsto wj - \frac{\color{blue}{wj - \frac{x}{e^{wj}}}}{wj - -1} \]
            5. Applied rewrites79.7%

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{x}{1 + 2 \cdot wj} \]
            11. Applied rewrites84.0%

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

            Alternative 12: 83.9% accurate, 5.0× speedup?

            \[\begin{array}{l} \\ x + -2 \cdot \left(wj \cdot x\right) \end{array} \]
            (FPCore (wj x) :precision binary64 (+ x (* -2.0 (* wj x))))
            double code(double wj, double x) {
            	return x + (-2.0 * (wj * x));
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(wj, x)
            use fmin_fmax_functions
                real(8), intent (in) :: wj
                real(8), intent (in) :: x
                code = x + ((-2.0d0) * (wj * x))
            end function
            
            public static double code(double wj, double x) {
            	return x + (-2.0 * (wj * x));
            }
            
            def code(wj, x):
            	return x + (-2.0 * (wj * x))
            
            function code(wj, x)
            	return Float64(x + Float64(-2.0 * Float64(wj * x)))
            end
            
            function tmp = code(wj, x)
            	tmp = x + (-2.0 * (wj * x));
            end
            
            code[wj_, x_] := N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            x + -2 \cdot \left(wj \cdot x\right)
            \end{array}
            
            Derivation
            1. Initial program 77.6%

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

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

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

                \[\leadsto x + -2 \cdot \color{blue}{\left(wj \cdot x\right)} \]
              3. lower-*.f6483.9

                \[\leadsto x + -2 \cdot \left(wj \cdot \color{blue}{x}\right) \]
            4. Applied rewrites83.9%

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

            Alternative 13: 83.4% accurate, 48.6× speedup?

            \[\begin{array}{l} \\ x \end{array} \]
            (FPCore (wj x) :precision binary64 x)
            double code(double wj, double x) {
            	return x;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            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
            
            \begin{array}{l}
            
            \\
            x
            \end{array}
            
            Derivation
            1. Initial program 77.6%

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

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

              Developer Target 1: 78.8% accurate, 1.2× 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)))));
              }
              
              module fmin_fmax_functions
                  implicit none
                  private
                  public fmax
                  public fmin
              
                  interface fmax
                      module procedure fmax88
                      module procedure fmax44
                      module procedure fmax84
                      module procedure fmax48
                  end interface
                  interface fmin
                      module procedure fmin88
                      module procedure fmin44
                      module procedure fmin84
                      module procedure fmin48
                  end interface
              contains
                  real(8) function fmax88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmax44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmax84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmax48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                  end function
                  real(8) function fmin88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmin44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmin84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmin48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                  end function
              end module
              
              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]
              
              \begin{array}{l}
              
              \\
              wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)
              \end{array}
              

              Reproduce

              ?
              herbie shell --seed 2025156 
              (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))))))