Average Error: 13.6 → 0.7
Time: 18.7s
Precision: binary64
Cost: 33284
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
\[\begin{array}{l} \mathbf{if}\;wj \leq 2.7426313464338834 \cdot 10^{-7}:\\ \;\;\;\;\mathsf{fma}\left(wj, wj \cdot \mathsf{fma}\left(x, 2.5, 1\right), \mathsf{fma}\left(-1 + x \cdot -2.6666666666666665, {wj}^{3}, \mathsf{fma}\left(wj, x \cdot -2, x\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;wj + \frac{wj - \frac{x}{e^{wj}}}{\mathsf{fma}\left(wj, wj, -1\right)} \cdot \left(1 - wj\right)\\ \end{array} \]
(FPCore (wj x)
 :precision binary64
 (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))
(FPCore (wj x)
 :precision binary64
 (if (<= wj 2.7426313464338834e-7)
   (fma
    wj
    (* wj (fma x 2.5 1.0))
    (fma
     (+ -1.0 (* x -2.6666666666666665))
     (pow wj 3.0)
     (fma wj (* x -2.0) x)))
   (+ wj (* (/ (- wj (/ x (exp wj))) (fma wj wj -1.0)) (- 1.0 wj)))))
double code(double wj, double x) {
	return wj - (((wj * exp(wj)) - x) / (exp(wj) + (wj * exp(wj))));
}
double code(double wj, double x) {
	double tmp;
	if (wj <= 2.7426313464338834e-7) {
		tmp = fma(wj, (wj * fma(x, 2.5, 1.0)), fma((-1.0 + (x * -2.6666666666666665)), pow(wj, 3.0), fma(wj, (x * -2.0), x)));
	} else {
		tmp = wj + (((wj - (x / exp(wj))) / fma(wj, wj, -1.0)) * (1.0 - wj));
	}
	return tmp;
}
function code(wj, x)
	return Float64(wj - Float64(Float64(Float64(wj * exp(wj)) - x) / Float64(exp(wj) + Float64(wj * exp(wj)))))
end
function code(wj, x)
	tmp = 0.0
	if (wj <= 2.7426313464338834e-7)
		tmp = fma(wj, Float64(wj * fma(x, 2.5, 1.0)), fma(Float64(-1.0 + Float64(x * -2.6666666666666665)), (wj ^ 3.0), fma(wj, Float64(x * -2.0), x)));
	else
		tmp = Float64(wj + Float64(Float64(Float64(wj - Float64(x / exp(wj))) / fma(wj, wj, -1.0)) * Float64(1.0 - wj)));
	end
	return tmp
end
code[wj_, x_] := N[(wj - N[(N[(N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[wj_, x_] := If[LessEqual[wj, 2.7426313464338834e-7], N[(wj * N[(wj * N[(x * 2.5 + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 + N[(x * -2.6666666666666665), $MachinePrecision]), $MachinePrecision] * N[Power[wj, 3.0], $MachinePrecision] + N[(wj * N[(x * -2.0), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(N[(wj - N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(wj * wj + -1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
\begin{array}{l}
\mathbf{if}\;wj \leq 2.7426313464338834 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(wj, wj \cdot \mathsf{fma}\left(x, 2.5, 1\right), \mathsf{fma}\left(-1 + x \cdot -2.6666666666666665, {wj}^{3}, \mathsf{fma}\left(wj, x \cdot -2, x\right)\right)\right)\\

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


\end{array}

Error

Target

Original13.6
Target12.9
Herbie0.7
\[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right) \]

Derivation

  1. Split input into 2 regimes
  2. if wj < 2.74263134643388342e-7

    1. Initial program 13.2

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Simplified13.2

      \[\leadsto \color{blue}{wj - \frac{wj - \frac{x}{e^{wj}}}{wj + 1}} \]
      Proof
      (-.f64 wj (/.f64 (-.f64 wj (/.f64 x (exp.f64 wj))) (+.f64 wj 1))): 0 points increase in error, 0 points decrease in error
      (-.f64 wj (Rewrite=> div-sub_binary64 (-.f64 (/.f64 wj (+.f64 wj 1)) (/.f64 (/.f64 x (exp.f64 wj)) (+.f64 wj 1))))): 0 points increase in error, 1 points decrease in error
      (-.f64 wj (-.f64 (Rewrite<= *-rgt-identity_binary64 (*.f64 (/.f64 wj (+.f64 wj 1)) 1)) (/.f64 (/.f64 x (exp.f64 wj)) (+.f64 wj 1)))): 0 points increase in error, 0 points decrease in error
      (-.f64 wj (-.f64 (*.f64 (/.f64 wj (+.f64 wj 1)) (Rewrite<= *-inverses_binary64 (/.f64 (exp.f64 wj) (exp.f64 wj)))) (/.f64 (/.f64 x (exp.f64 wj)) (+.f64 wj 1)))): 3 points increase in error, 0 points decrease in error
      (-.f64 wj (-.f64 (Rewrite<= times-frac_binary64 (/.f64 (*.f64 wj (exp.f64 wj)) (*.f64 (+.f64 wj 1) (exp.f64 wj)))) (/.f64 (/.f64 x (exp.f64 wj)) (+.f64 wj 1)))): 4 points increase in error, 1 points decrease in error
      (-.f64 wj (-.f64 (/.f64 (*.f64 wj (exp.f64 wj)) (Rewrite<= distribute-rgt1-in_binary64 (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) (/.f64 (/.f64 x (exp.f64 wj)) (+.f64 wj 1)))): 1 points increase in error, 2 points decrease in error
      (-.f64 wj (-.f64 (/.f64 (*.f64 wj (exp.f64 wj)) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))) (Rewrite=> associate-/l/_binary64 (/.f64 x (*.f64 (+.f64 wj 1) (exp.f64 wj)))))): 1 points increase in error, 1 points decrease in error
      (-.f64 wj (-.f64 (/.f64 (*.f64 wj (exp.f64 wj)) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))) (/.f64 x (Rewrite<= distribute-rgt1-in_binary64 (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))))): 0 points increase in error, 2 points decrease in error
      (-.f64 wj (Rewrite<= div-sub_binary64 (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))))): 0 points increase in error, 0 points decrease in error
    3. Applied egg-rr13.2

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

      \[\leadsto \color{blue}{\left(\left(1 + \left(0.5 \cdot x + x\right)\right) - -1 \cdot x\right) \cdot {wj}^{2} + \left(\left(\left(-1 \cdot x + -0.16666666666666666 \cdot x\right) - \left(1 + \left(0.5 \cdot x + x\right)\right)\right) \cdot {wj}^{3} + \left(\left(-1 \cdot x - x\right) \cdot wj + x\right)\right)} \]
    5. Simplified0.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(wj, wj \cdot \mathsf{fma}\left(x, 2.5, 1\right), \mathsf{fma}\left(x \cdot -2.6666666666666665 + -1, {wj}^{3}, \mathsf{fma}\left(wj, x \cdot -2, x\right)\right)\right)} \]
      Proof
      (fma.f64 wj (*.f64 wj (fma.f64 x 5/2 1)) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (fma.f64 x (Rewrite<= metadata-eval (neg.f64 -5/2)) 1)) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (fma.f64 x (neg.f64 (Rewrite<= metadata-eval (+.f64 -1/2 -2))) 1)) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x (neg.f64 (+.f64 -1/2 -2))) 1))) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (+.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 x (+.f64 -1/2 -2)))) 1)) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (+.f64 (neg.f64 (Rewrite<= distribute-rgt-out_binary64 (+.f64 (*.f64 -1/2 x) (*.f64 -2 x)))) 1)) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (Rewrite<= +-commutative_binary64 (+.f64 1 (neg.f64 (+.f64 (*.f64 -1/2 x) (*.f64 -2 x)))))) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (+.f64 1 (neg.f64 (Rewrite=> distribute-rgt-out_binary64 (*.f64 x (+.f64 -1/2 -2)))))) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (+.f64 1 (Rewrite=> distribute-rgt-neg-in_binary64 (*.f64 x (neg.f64 (+.f64 -1/2 -2)))))) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (+.f64 1 (*.f64 x (neg.f64 (Rewrite=> metadata-eval -5/2))))) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (+.f64 1 (*.f64 x (Rewrite=> metadata-eval 5/2)))) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (+.f64 1 (*.f64 x (Rewrite<= metadata-eval (-.f64 3/2 -1))))) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (+.f64 1 (*.f64 x (-.f64 (Rewrite<= metadata-eval (/.f64 3 2)) -1)))) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (+.f64 1 (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 (/.f64 3 2) x) (*.f64 -1 x))))) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (+.f64 1 (-.f64 (*.f64 (Rewrite=> metadata-eval 3/2) x) (*.f64 -1 x)))) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (+.f64 1 (-.f64 (*.f64 (Rewrite<= metadata-eval (+.f64 1/2 1)) x) (*.f64 -1 x)))) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (+.f64 1 (-.f64 (Rewrite<= distribute-lft1-in_binary64 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x)))) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x)))) (fma.f64 (+.f64 (*.f64 x -8/3) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (+.f64 (*.f64 x (Rewrite<= metadata-eval (-.f64 -7/6 3/2))) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 3 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (+.f64 (*.f64 x (-.f64 (Rewrite<= metadata-eval (+.f64 -1 -1/6)) 3/2)) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (+.f64 (*.f64 x (-.f64 (+.f64 -1 -1/6) (Rewrite<= metadata-eval (/.f64 3 2)))) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (+.f64 (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 (+.f64 -1 -1/6) x) (*.f64 (/.f64 3 2) x))) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 2 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (+.f64 (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 x (+.f64 -1 -1/6))) (*.f64 (/.f64 3 2) x)) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (+.f64 (-.f64 (Rewrite<= distribute-rgt-out_binary64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x))) (*.f64 (/.f64 3 2) x)) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 1 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (+.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (*.f64 (Rewrite=> metadata-eval 3/2) x)) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (+.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (*.f64 (Rewrite<= metadata-eval (+.f64 1/2 1)) x)) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (+.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (Rewrite<= distribute-lft1-in_binary64 (+.f64 (*.f64 1/2 x) x))) -1) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (+.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (+.f64 (*.f64 1/2 x) x)) (Rewrite<= metadata-eval (neg.f64 1))) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (Rewrite<= sub-neg_binary64 (-.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (+.f64 (*.f64 1/2 x) x)) 1)) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (Rewrite<= associate--r+_binary64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (+.f64 (+.f64 (*.f64 1/2 x) x) 1))) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (Rewrite<= +-commutative_binary64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)))) (pow.f64 wj 3) (fma.f64 wj (*.f64 x -2) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (+.f64 1 (+.f64 (*.f64 1/2 x) x))) (pow.f64 wj 3) (fma.f64 wj (*.f64 x (Rewrite<= metadata-eval (-.f64 -1 1))) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (+.f64 1 (+.f64 (*.f64 1/2 x) x))) (pow.f64 wj 3) (fma.f64 wj (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 -1 x) (*.f64 1 x))) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (+.f64 1 (+.f64 (*.f64 1/2 x) x))) (pow.f64 wj 3) (fma.f64 wj (-.f64 (*.f64 -1 x) (Rewrite=> *-lft-identity_binary64 x)) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (+.f64 1 (+.f64 (*.f64 1/2 x) x))) (pow.f64 wj 3) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 wj (-.f64 (*.f64 -1 x) x)) x)))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (fma.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (+.f64 1 (+.f64 (*.f64 1/2 x) x))) (pow.f64 wj 3) (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (-.f64 (*.f64 -1 x) x) wj)) x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (+.f64 1 (+.f64 (*.f64 1/2 x) x))) (pow.f64 wj 3)) (+.f64 (*.f64 (-.f64 (*.f64 -1 x) x) wj) x)))): 2 points increase in error, 1 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 wj (*.f64 wj (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x)))) (+.f64 (*.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (+.f64 1 (+.f64 (*.f64 1/2 x) x))) (pow.f64 wj 3)) (+.f64 (*.f64 (-.f64 (*.f64 -1 x) x) wj) x)))): 2 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 wj wj) (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x)))) (+.f64 (*.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (+.f64 1 (+.f64 (*.f64 1/2 x) x))) (pow.f64 wj 3)) (+.f64 (*.f64 (-.f64 (*.f64 -1 x) x) wj) x))): 0 points increase in error, 1 points decrease in error
      (+.f64 (*.f64 (Rewrite<= unpow2_binary64 (pow.f64 wj 2)) (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x))) (+.f64 (*.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (+.f64 1 (+.f64 (*.f64 1/2 x) x))) (pow.f64 wj 3)) (+.f64 (*.f64 (-.f64 (*.f64 -1 x) x) wj) x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (-.f64 (+.f64 1 (+.f64 (*.f64 1/2 x) x)) (*.f64 -1 x)) (pow.f64 wj 2))) (+.f64 (*.f64 (-.f64 (+.f64 (*.f64 -1 x) (*.f64 -1/6 x)) (+.f64 1 (+.f64 (*.f64 1/2 x) x))) (pow.f64 wj 3)) (+.f64 (*.f64 (-.f64 (*.f64 -1 x) x) wj) x))): 0 points increase in error, 0 points decrease in error

    if 2.74263134643388342e-7 < wj

    1. Initial program 26.8

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
    2. Simplified2.3

      \[\leadsto \color{blue}{wj - \frac{wj - \frac{x}{e^{wj}}}{wj + 1}} \]
      Proof
      (-.f64 wj (/.f64 (-.f64 wj (/.f64 x (exp.f64 wj))) (+.f64 wj 1))): 0 points increase in error, 0 points decrease in error
      (-.f64 wj (Rewrite=> div-sub_binary64 (-.f64 (/.f64 wj (+.f64 wj 1)) (/.f64 (/.f64 x (exp.f64 wj)) (+.f64 wj 1))))): 0 points increase in error, 1 points decrease in error
      (-.f64 wj (-.f64 (Rewrite<= *-rgt-identity_binary64 (*.f64 (/.f64 wj (+.f64 wj 1)) 1)) (/.f64 (/.f64 x (exp.f64 wj)) (+.f64 wj 1)))): 0 points increase in error, 0 points decrease in error
      (-.f64 wj (-.f64 (*.f64 (/.f64 wj (+.f64 wj 1)) (Rewrite<= *-inverses_binary64 (/.f64 (exp.f64 wj) (exp.f64 wj)))) (/.f64 (/.f64 x (exp.f64 wj)) (+.f64 wj 1)))): 3 points increase in error, 0 points decrease in error
      (-.f64 wj (-.f64 (Rewrite<= times-frac_binary64 (/.f64 (*.f64 wj (exp.f64 wj)) (*.f64 (+.f64 wj 1) (exp.f64 wj)))) (/.f64 (/.f64 x (exp.f64 wj)) (+.f64 wj 1)))): 4 points increase in error, 1 points decrease in error
      (-.f64 wj (-.f64 (/.f64 (*.f64 wj (exp.f64 wj)) (Rewrite<= distribute-rgt1-in_binary64 (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) (/.f64 (/.f64 x (exp.f64 wj)) (+.f64 wj 1)))): 1 points increase in error, 2 points decrease in error
      (-.f64 wj (-.f64 (/.f64 (*.f64 wj (exp.f64 wj)) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))) (Rewrite=> associate-/l/_binary64 (/.f64 x (*.f64 (+.f64 wj 1) (exp.f64 wj)))))): 1 points increase in error, 1 points decrease in error
      (-.f64 wj (-.f64 (/.f64 (*.f64 wj (exp.f64 wj)) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))) (/.f64 x (Rewrite<= distribute-rgt1-in_binary64 (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))))): 0 points increase in error, 2 points decrease in error
      (-.f64 wj (Rewrite<= div-sub_binary64 (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj)))))): 0 points increase in error, 0 points decrease in error
    3. Applied egg-rr2.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;wj \leq 2.7426313464338834 \cdot 10^{-7}:\\ \;\;\;\;\mathsf{fma}\left(wj, wj \cdot \mathsf{fma}\left(x, 2.5, 1\right), \mathsf{fma}\left(-1 + x \cdot -2.6666666666666665, {wj}^{3}, \mathsf{fma}\left(wj, x \cdot -2, x\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;wj + \frac{wj - \frac{x}{e^{wj}}}{\mathsf{fma}\left(wj, wj, -1\right)} \cdot \left(1 - wj\right)\\ \end{array} \]

Alternatives

Alternative 1
Error0.7
Cost15684
\[\begin{array}{l} t_0 := x \cdot 1.5 - x \cdot 4\\ \mathbf{if}\;wj \leq 2.7426313464338834 \cdot 10^{-7}:\\ \;\;\;\;{wj}^{3} \cdot \left(x \cdot -0.6666666666666666 + \left(x \cdot 3 - \left(1 + -2 \cdot t_0\right)\right)\right) + \left(\left(1 - t_0\right) \cdot {wj}^{2} + \left(x + -2 \cdot \left(wj \cdot x\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;wj + \frac{wj - \frac{x}{e^{wj}}}{\mathsf{fma}\left(wj, wj, -1\right)} \cdot \left(1 - wj\right)\\ \end{array} \]
Alternative 2
Error0.7
Cost14084
\[\begin{array}{l} \mathbf{if}\;wj \leq 2.7426313464338834 \cdot 10^{-7}:\\ \;\;\;\;\mathsf{fma}\left(wj, wj, -2 \cdot \left(wj \cdot x\right) + \left(x + {wj}^{3} \cdot \left(-1 + x \cdot -2.6666666666666665\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;wj + \frac{wj - \frac{x}{e^{wj}}}{\mathsf{fma}\left(wj, wj, -1\right)} \cdot \left(1 - wj\right)\\ \end{array} \]
Alternative 3
Error0.8
Cost13892
\[\begin{array}{l} \mathbf{if}\;wj \leq 2.7426313464338834 \cdot 10^{-7}:\\ \;\;\;\;\left(\left(x + -2 \cdot \left(wj \cdot x\right)\right) + wj \cdot wj\right) - {wj}^{3} \cdot \left(x \cdot 0.6666666666666666 + \left(x \cdot -3 + \left(1 + -2 \cdot \left(x \cdot 1.5 - x \cdot 4\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;wj + \frac{wj - \frac{x}{e^{wj}}}{\mathsf{fma}\left(wj, wj, -1\right)} \cdot \left(1 - wj\right)\\ \end{array} \]
Alternative 4
Error0.8
Cost8708
\[\begin{array}{l} \mathbf{if}\;wj \leq 2.7426313464338834 \cdot 10^{-7}:\\ \;\;\;\;\left(\left(x + -2 \cdot \left(wj \cdot x\right)\right) + wj \cdot wj\right) - {wj}^{3} \cdot \left(x \cdot 0.6666666666666666 + \left(x \cdot -3 + \left(1 + -2 \cdot \left(x \cdot 1.5 - x \cdot 4\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(wj + \frac{x}{e^{wj} \cdot \left(wj + 1\right)}\right) - \frac{wj}{wj + 1}\\ \end{array} \]
Alternative 5
Error1.0
Cost7556
\[\begin{array}{l} \mathbf{if}\;wj \leq 1.917356992263066 \cdot 10^{-12}:\\ \;\;\;\;\left(x + -2 \cdot \left(wj \cdot x\right)\right) + {wj}^{2} \cdot \left(1 + x \cdot 2.5\right)\\ \mathbf{else}:\\ \;\;\;\;\left(wj + \frac{x}{e^{wj} \cdot \left(wj + 1\right)}\right) - \frac{wj}{wj + 1}\\ \end{array} \]
Alternative 6
Error1.0
Cost7492
\[\begin{array}{l} \mathbf{if}\;wj \leq 1.917356992263066 \cdot 10^{-12}:\\ \;\;\;\;{wj}^{2} + \left(x + -2 \cdot \left(wj \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(wj + \frac{x}{e^{wj} \cdot \left(wj + 1\right)}\right) - \frac{wj}{wj + 1}\\ \end{array} \]
Alternative 7
Error1.0
Cost7300
\[\begin{array}{l} \mathbf{if}\;wj \leq 1.917356992263066 \cdot 10^{-12}:\\ \;\;\;\;{wj}^{2} + \left(x + -2 \cdot \left(wj \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\ \end{array} \]
Alternative 8
Error1.0
Cost7236
\[\begin{array}{l} \mathbf{if}\;wj \leq 1.917356992263066 \cdot 10^{-12}:\\ \;\;\;\;{wj}^{2} + \left(x + -2 \cdot \left(wj \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\ \end{array} \]
Alternative 9
Error2.1
Cost7172
\[\begin{array}{l} \mathbf{if}\;wj \leq 3.043355083406525 \cdot 10^{-19}:\\ \;\;\;\;{wj}^{2} + \left(x + -2 \cdot \left(wj \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{wj} + \frac{1}{wj \cdot wj}}\\ \end{array} \]
Alternative 10
Error10.2
Cost1604
\[\begin{array}{l} \mathbf{if}\;wj \leq -2.8983829829178065 \cdot 10^{-62}:\\ \;\;\;\;\left(wj + \frac{x}{1 + wj \cdot \left(2 + wj \cdot \left(1.5 + wj \cdot 0.6666666666666666\right)\right)}\right) - \frac{wj}{wj + 1}\\ \mathbf{elif}\;wj \leq -1.018606014095833 \cdot 10^{-70}:\\ \;\;\;\;wj \cdot \left(wj \cdot \left(1 - wj\right)\right)\\ \mathbf{elif}\;wj \leq 1.2903221710893936 \cdot 10^{-69}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{wj} + \frac{1}{wj \cdot wj}}\\ \end{array} \]
Alternative 11
Error10.2
Cost1348
\[\begin{array}{l} \mathbf{if}\;wj \leq -2.8983829829178065 \cdot 10^{-62}:\\ \;\;\;\;wj + \frac{\left(x + wj \cdot \left(0.5 \cdot \left(wj \cdot x\right) - x\right)\right) - wj}{wj + 1}\\ \mathbf{elif}\;wj \leq -1.018606014095833 \cdot 10^{-70}:\\ \;\;\;\;wj \cdot \left(wj \cdot \left(1 - wj\right)\right)\\ \mathbf{elif}\;wj \leq 1.2903221710893936 \cdot 10^{-69}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{wj} + \frac{1}{wj \cdot wj}}\\ \end{array} \]
Alternative 12
Error10.4
Cost1100
\[\begin{array}{l} \mathbf{if}\;wj \leq -2.8983829829178065 \cdot 10^{-62}:\\ \;\;\;\;x + \left(wj - \frac{wj}{wj + 1}\right)\\ \mathbf{elif}\;wj \leq -1.018606014095833 \cdot 10^{-70}:\\ \;\;\;\;wj \cdot \left(wj \cdot \left(1 - wj\right)\right)\\ \mathbf{elif}\;wj \leq 1.2903221710893936 \cdot 10^{-69}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{wj} + \frac{1}{wj \cdot wj}}\\ \end{array} \]
Alternative 13
Error10.3
Cost1100
\[\begin{array}{l} \mathbf{if}\;wj \leq -2.8983829829178065 \cdot 10^{-62}:\\ \;\;\;\;wj + \frac{\left(x - wj \cdot x\right) - wj}{wj + 1}\\ \mathbf{elif}\;wj \leq -1.018606014095833 \cdot 10^{-70}:\\ \;\;\;\;wj \cdot \left(wj \cdot \left(1 - wj\right)\right)\\ \mathbf{elif}\;wj \leq 1.2903221710893936 \cdot 10^{-69}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{wj} + \frac{1}{wj \cdot wj}}\\ \end{array} \]
Alternative 14
Error10.9
Cost976
\[\begin{array}{l} t_0 := wj \cdot \left(wj \cdot \left(1 - wj\right)\right)\\ \mathbf{if}\;wj \leq -2.8983829829178065 \cdot 10^{-62}:\\ \;\;\;\;x + -2 \cdot \left(wj \cdot x\right)\\ \mathbf{elif}\;wj \leq -1.018606014095833 \cdot 10^{-70}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;wj \leq 1.2903221710893936 \cdot 10^{-69}:\\ \;\;\;\;x\\ \mathbf{elif}\;wj \leq 2.7426313464338834 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;wj - \frac{wj}{wj + 1}\\ \end{array} \]
Alternative 15
Error10.4
Cost976
\[\begin{array}{l} t_0 := wj - \frac{wj}{wj + 1}\\ t_1 := wj \cdot \left(wj \cdot \left(1 - wj\right)\right)\\ \mathbf{if}\;wj \leq -2.8983829829178065 \cdot 10^{-62}:\\ \;\;\;\;x + t_0\\ \mathbf{elif}\;wj \leq -1.018606014095833 \cdot 10^{-70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;wj \leq 1.2903221710893936 \cdot 10^{-69}:\\ \;\;\;\;x\\ \mathbf{elif}\;wj \leq 2.7426313464338834 \cdot 10^{-7}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 16
Error8.9
Cost580
\[\begin{array}{l} \mathbf{if}\;wj \leq 3.043355083406525 \cdot 10^{-19}:\\ \;\;\;\;x + -2 \cdot \left(wj \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;wj - \frac{wj}{wj + 1}\\ \end{array} \]
Alternative 17
Error9.2
Cost448
\[x + -2 \cdot \left(wj \cdot x\right) \]
Alternative 18
Error61.2
Cost64
\[wj \]
Alternative 19
Error9.5
Cost64
\[x \]

Error

Reproduce

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

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

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