Jmat.Real.lambertw, newton loop step

Percentage Accurate: 77.8% → 99.9%
Time: 13.6s
Alternatives: 9
Speedup: 331.0×

Specification

?
\[\begin{array}{l} t_0 := wj \cdot e^{wj}\\ wj - \frac{t\_0 - x}{e^{wj} + t\_0} \end{array} \]
(FPCore (wj x)
  :precision binary64
  (let* ((t_0 (* wj (exp wj)))) (- wj (/ (- t_0 x) (+ (exp wj) t_0)))))
double code(double wj, double x) {
	double t_0 = wj * exp(wj);
	return wj - ((t_0 - x) / (exp(wj) + t_0));
}
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}
t_0 := wj \cdot e^{wj}\\
wj - \frac{t\_0 - x}{e^{wj} + t\_0}
\end{array}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 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.8% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := wj \cdot e^{wj}\\ wj - \frac{t\_0 - x}{e^{wj} + t\_0} \end{array} \]
(FPCore (wj x)
  :precision binary64
  (let* ((t_0 (* wj (exp wj)))) (- wj (/ (- t_0 x) (+ (exp wj) t_0)))))
double code(double wj, double x) {
	double t_0 = wj * exp(wj);
	return wj - ((t_0 - x) / (exp(wj) + t_0));
}
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}
t_0 := wj \cdot e^{wj}\\
wj - \frac{t\_0 - x}{e^{wj} + t\_0}
\end{array}

Alternative 1: 99.9% accurate, 1.0× speedup?

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

\mathbf{else}:\\
\;\;\;\;wj - \frac{wj}{wj - -1}\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if wj < 500

    1. Initial program 77.8%

      \[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. lower-/.f64N/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}}} \]
    3. Applied rewrites88.4%

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

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

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

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

    if 500 < wj

    1. Initial program 77.8%

      \[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. lower-/.f64N/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}}} \]
    3. Applied rewrites88.4%

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

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

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

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

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

        \[\leadsto \frac{wj \cdot \left(1 + wj\right) - wj}{1 + wj} \]
      5. lower-+.f646.5%

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

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

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

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

        \[\leadsto \frac{wj \cdot \left(1 + wj\right) - wj}{1 + wj} \]
      4. sub-to-fraction-revN/A

        \[\leadsto wj - \color{blue}{\frac{wj}{1 + wj}} \]
      5. lower--.f64N/A

        \[\leadsto wj - \color{blue}{\frac{wj}{1 + wj}} \]
      6. lift-+.f64N/A

        \[\leadsto wj - \frac{wj}{1 + \color{blue}{wj}} \]
      7. +-commutativeN/A

        \[\leadsto wj - \frac{wj}{wj + \color{blue}{1}} \]
      8. metadata-evalN/A

        \[\leadsto wj - \frac{wj}{wj + \left(\mathsf{neg}\left(-1\right)\right)} \]
      9. sub-flipN/A

        \[\leadsto wj - \frac{wj}{wj - \color{blue}{-1}} \]
      10. lift--.f64N/A

        \[\leadsto wj - \frac{wj}{wj - \color{blue}{-1}} \]
      11. lower-/.f646.5%

        \[\leadsto wj - \frac{wj}{\color{blue}{wj - -1}} \]
    8. Applied rewrites6.5%

      \[\leadsto wj - \color{blue}{\frac{wj}{wj - -1}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 99.5% accurate, 0.6× speedup?

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

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


\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))))) < 5.7500000000000002e-11

    1. Initial program 77.8%

      \[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. lower-/.f64N/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}}} \]
    3. Applied rewrites88.4%

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

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

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

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

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

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

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

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

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

    if 5.7500000000000002e-11 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))))

    1. Initial program 77.8%

      \[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. sub-flipN/A

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

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

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

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

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

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

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

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

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

Alternative 3: 98.9% accurate, 0.7× speedup?

\[\begin{array}{l} t_0 := wj \cdot e^{wj}\\ \mathbf{if}\;wj - \frac{t\_0 - x}{e^{wj} + t\_0} \leq 0.02:\\ \;\;\;\;\frac{\left(wj \cdot wj\right) \cdot 1 + x}{\left(wj - -1\right) \cdot 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(wj - -1\right) \cdot e^{wj}} - \left(\frac{wj}{wj - -1} - wj\right)\\ \end{array} \]
(FPCore (wj x)
  :precision binary64
  (let* ((t_0 (* wj (exp wj))))
  (if (<= (- wj (/ (- t_0 x) (+ (exp wj) t_0))) 0.02)
    (/ (+ (* (* wj wj) 1.0) x) (* (- wj -1.0) 1.0))
    (- (/ x (* (- wj -1.0) (exp wj))) (- (/ wj (- wj -1.0)) wj)))))
double code(double wj, double x) {
	double t_0 = wj * exp(wj);
	double tmp;
	if ((wj - ((t_0 - x) / (exp(wj) + t_0))) <= 0.02) {
		tmp = (((wj * wj) * 1.0) + x) / ((wj - -1.0) * 1.0);
	} else {
		tmp = (x / ((wj - -1.0) * exp(wj))) - ((wj / (wj - -1.0)) - wj);
	}
	return tmp;
}
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
    real(8) :: tmp
    t_0 = wj * exp(wj)
    if ((wj - ((t_0 - x) / (exp(wj) + t_0))) <= 0.02d0) then
        tmp = (((wj * wj) * 1.0d0) + x) / ((wj - (-1.0d0)) * 1.0d0)
    else
        tmp = (x / ((wj - (-1.0d0)) * exp(wj))) - ((wj / (wj - (-1.0d0))) - wj)
    end if
    code = tmp
end function
public static double code(double wj, double x) {
	double t_0 = wj * Math.exp(wj);
	double tmp;
	if ((wj - ((t_0 - x) / (Math.exp(wj) + t_0))) <= 0.02) {
		tmp = (((wj * wj) * 1.0) + x) / ((wj - -1.0) * 1.0);
	} else {
		tmp = (x / ((wj - -1.0) * Math.exp(wj))) - ((wj / (wj - -1.0)) - wj);
	}
	return tmp;
}
def code(wj, x):
	t_0 = wj * math.exp(wj)
	tmp = 0
	if (wj - ((t_0 - x) / (math.exp(wj) + t_0))) <= 0.02:
		tmp = (((wj * wj) * 1.0) + x) / ((wj - -1.0) * 1.0)
	else:
		tmp = (x / ((wj - -1.0) * math.exp(wj))) - ((wj / (wj - -1.0)) - wj)
	return tmp
function code(wj, x)
	t_0 = Float64(wj * exp(wj))
	tmp = 0.0
	if (Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0))) <= 0.02)
		tmp = Float64(Float64(Float64(Float64(wj * wj) * 1.0) + x) / Float64(Float64(wj - -1.0) * 1.0));
	else
		tmp = Float64(Float64(x / Float64(Float64(wj - -1.0) * exp(wj))) - Float64(Float64(wj / Float64(wj - -1.0)) - wj));
	end
	return tmp
end
function tmp_2 = code(wj, x)
	t_0 = wj * exp(wj);
	tmp = 0.0;
	if ((wj - ((t_0 - x) / (exp(wj) + t_0))) <= 0.02)
		tmp = (((wj * wj) * 1.0) + x) / ((wj - -1.0) * 1.0);
	else
		tmp = (x / ((wj - -1.0) * exp(wj))) - ((wj / (wj - -1.0)) - wj);
	end
	tmp_2 = tmp;
end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.02], N[(N[(N[(N[(wj * wj), $MachinePrecision] * 1.0), $MachinePrecision] + x), $MachinePrecision] / N[(N[(wj - -1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(N[(wj - -1.0), $MachinePrecision] * N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(wj / N[(wj - -1.0), $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
\mathbf{if}\;wj - \frac{t\_0 - x}{e^{wj} + t\_0} \leq 0.02:\\
\;\;\;\;\frac{\left(wj \cdot wj\right) \cdot 1 + x}{\left(wj - -1\right) \cdot 1}\\

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


\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))))) < 0.02

    1. Initial program 77.8%

      \[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. lower-/.f64N/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}}} \]
    3. Applied rewrites88.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 0.02 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))))

        1. Initial program 77.8%

          \[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. sub-flipN/A

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

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

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

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

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

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

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

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

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

      Alternative 4: 97.3% accurate, 10.7× speedup?

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

        1. Initial program 77.8%

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

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

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

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

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

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

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

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

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

            \[\leadsto x + wj \cdot \left(wj \cdot \left(1 - \left(-4 \cdot x + \frac{3}{2} \cdot x\right)\right) - 2 \cdot x\right) \]
          9. lower-*.f6495.7%

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

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

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

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

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

            \[\leadsto x + wj \cdot \left(wj + x \cdot \left(\frac{5}{2} \cdot wj - 2\right)\right) \]
          4. lower-*.f6495.8%

            \[\leadsto x + wj \cdot \left(wj + x \cdot \left(2.5 \cdot wj - 2\right)\right) \]
        7. Applied rewrites95.8%

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

        if 7.5000000000000002e-6 < wj

        1. Initial program 77.8%

          \[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. lower-/.f64N/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}}} \]
        3. Applied rewrites88.4%

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

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

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

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

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

            \[\leadsto \frac{wj \cdot \left(1 + wj\right) - wj}{1 + wj} \]
          5. lower-+.f646.5%

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

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

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

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

            \[\leadsto \frac{wj \cdot \left(1 + wj\right) - wj}{1 + wj} \]
          4. sub-to-fraction-revN/A

            \[\leadsto wj - \color{blue}{\frac{wj}{1 + wj}} \]
          5. lower--.f64N/A

            \[\leadsto wj - \color{blue}{\frac{wj}{1 + wj}} \]
          6. lift-+.f64N/A

            \[\leadsto wj - \frac{wj}{1 + \color{blue}{wj}} \]
          7. +-commutativeN/A

            \[\leadsto wj - \frac{wj}{wj + \color{blue}{1}} \]
          8. metadata-evalN/A

            \[\leadsto wj - \frac{wj}{wj + \left(\mathsf{neg}\left(-1\right)\right)} \]
          9. sub-flipN/A

            \[\leadsto wj - \frac{wj}{wj - \color{blue}{-1}} \]
          10. lift--.f64N/A

            \[\leadsto wj - \frac{wj}{wj - \color{blue}{-1}} \]
          11. lower-/.f646.5%

            \[\leadsto wj - \frac{wj}{\color{blue}{wj - -1}} \]
        8. Applied rewrites6.5%

          \[\leadsto wj - \color{blue}{\frac{wj}{wj - -1}} \]
      3. Recombined 2 regimes into one program.
      4. Add Preprocessing

      Alternative 5: 97.1% accurate, 13.8× speedup?

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

        1. Initial program 77.8%

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto x + wj \cdot \left(wj \cdot \left(1 + -1 \cdot wj\right)\right) \]
        10. Applied rewrites95.5%

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

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

          if 7.5000000000000002e-6 < wj

          1. Initial program 77.8%

            \[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. lower-/.f64N/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}}} \]
          3. Applied rewrites88.4%

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

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

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

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

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

              \[\leadsto \frac{wj \cdot \left(1 + wj\right) - wj}{1 + wj} \]
            5. lower-+.f646.5%

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

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

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

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

              \[\leadsto \frac{wj \cdot \left(1 + wj\right) - wj}{1 + wj} \]
            4. sub-to-fraction-revN/A

              \[\leadsto wj - \color{blue}{\frac{wj}{1 + wj}} \]
            5. lower--.f64N/A

              \[\leadsto wj - \color{blue}{\frac{wj}{1 + wj}} \]
            6. lift-+.f64N/A

              \[\leadsto wj - \frac{wj}{1 + \color{blue}{wj}} \]
            7. +-commutativeN/A

              \[\leadsto wj - \frac{wj}{wj + \color{blue}{1}} \]
            8. metadata-evalN/A

              \[\leadsto wj - \frac{wj}{wj + \left(\mathsf{neg}\left(-1\right)\right)} \]
            9. sub-flipN/A

              \[\leadsto wj - \frac{wj}{wj - \color{blue}{-1}} \]
            10. lift--.f64N/A

              \[\leadsto wj - \frac{wj}{wj - \color{blue}{-1}} \]
            11. lower-/.f646.5%

              \[\leadsto wj - \frac{wj}{\color{blue}{wj - -1}} \]
          8. Applied rewrites6.5%

            \[\leadsto wj - \color{blue}{\frac{wj}{wj - -1}} \]
        12. Recombined 2 regimes into one program.
        13. Add Preprocessing

        Alternative 6: 97.1% accurate, 10.0× speedup?

        \[\frac{\left(wj \cdot wj\right) \cdot 1 + x}{\left(wj - -1\right) \cdot 1} \]
        (FPCore (wj x)
          :precision binary64
          (/ (+ (* (* wj wj) 1.0) x) (* (- wj -1.0) 1.0)))
        double code(double wj, double x) {
        	return (((wj * wj) * 1.0) + x) / ((wj - -1.0) * 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 = (((wj * wj) * 1.0d0) + x) / ((wj - (-1.0d0)) * 1.0d0)
        end function
        
        public static double code(double wj, double x) {
        	return (((wj * wj) * 1.0) + x) / ((wj - -1.0) * 1.0);
        }
        
        def code(wj, x):
        	return (((wj * wj) * 1.0) + x) / ((wj - -1.0) * 1.0)
        
        function code(wj, x)
        	return Float64(Float64(Float64(Float64(wj * wj) * 1.0) + x) / Float64(Float64(wj - -1.0) * 1.0))
        end
        
        function tmp = code(wj, x)
        	tmp = (((wj * wj) * 1.0) + x) / ((wj - -1.0) * 1.0);
        end
        
        code[wj_, x_] := N[(N[(N[(N[(wj * wj), $MachinePrecision] * 1.0), $MachinePrecision] + x), $MachinePrecision] / N[(N[(wj - -1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision]
        
        \frac{\left(wj \cdot wj\right) \cdot 1 + x}{\left(wj - -1\right) \cdot 1}
        
        Derivation
        1. Initial program 77.8%

          \[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. lower-/.f64N/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}}} \]
        3. Applied rewrites88.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Alternative 7: 95.5% accurate, 19.5× speedup?

            \[\left(\left(1 - wj\right) \cdot wj\right) \cdot wj + x \]
            (FPCore (wj x)
              :precision binary64
              (+ (* (* (- 1.0 wj) wj) wj) x))
            double code(double wj, double x) {
            	return (((1.0 - wj) * wj) * 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 = (((1.0d0 - wj) * wj) * wj) + x
            end function
            
            public static double code(double wj, double x) {
            	return (((1.0 - wj) * wj) * wj) + x;
            }
            
            def code(wj, x):
            	return (((1.0 - wj) * wj) * wj) + x
            
            function code(wj, x)
            	return Float64(Float64(Float64(Float64(1.0 - wj) * wj) * wj) + x)
            end
            
            function tmp = code(wj, x)
            	tmp = (((1.0 - wj) * wj) * wj) + x;
            end
            
            code[wj_, x_] := N[(N[(N[(N[(1.0 - wj), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision] + x), $MachinePrecision]
            
            \left(\left(1 - wj\right) \cdot wj\right) \cdot wj + x
            
            Derivation
            1. Initial program 77.8%

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto x + wj \cdot \left(wj \cdot \left(1 + -1 \cdot wj\right)\right) \]
            10. Applied rewrites95.5%

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

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

              Alternative 8: 84.8% accurate, 23.6× speedup?

              \[x + -2 \cdot \left(wj \cdot x\right) \]
              (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]
              
              x + -2 \cdot \left(wj \cdot x\right)
              
              Derivation
              1. Initial program 77.8%

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

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

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

              Alternative 9: 84.3% accurate, 331.0× speedup?

              \[x \]
              (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
              
              x
              
              Derivation
              1. Initial program 77.8%

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

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

                Reproduce

                ?
                herbie shell --seed 2025258 
                (FPCore (wj x)
                  :name "Jmat.Real.lambertw, newton loop step"
                  :precision binary64
                  (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))