Average Error: 14.0 → 0.1
Time: 1.1m
Precision: 64
Internal Precision: 832
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\begin{array}{l} \mathbf{if}\;e^{\log \left(wj - \frac{(wj \cdot \left(e^{wj}\right) + \left(-x\right))_*}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*}\right)} \le 1.0539839733040413 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{(\left(e^{wj}\right) \cdot wj + \left(e^{wj}\right))_*} + \left(wj \cdot wj - {wj}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(wj - \frac{wj}{1 + wj}\right) + \frac{x}{e^{wj} + wj \cdot e^{wj}}\\ \end{array}\]

Error

Bits error versus wj

Bits error versus x

Target

Original14.0
Target13.3
Herbie0.1
\[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\]

Derivation

  1. Split input into 2 regimes
  2. if (exp (log (- wj (/ (fma wj (exp wj) (- x)) (fma wj (exp wj) (exp wj)))))) < 1.0539839733040413e-13

    1. Initial program 38.7

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Using strategy rm
    3. Applied div-sub38.7

      \[\leadsto wj - \color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\]
    4. Applied associate--r-20.2

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

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

      \[\leadsto \left(wj - \color{blue}{\left(\left({wj}^{3} + wj\right) - {wj}^{2}\right)}\right) + \frac{x}{e^{wj} + wj \cdot e^{wj}}\]
    7. Applied simplify0.0

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

    if 1.0539839733040413e-13 < (exp (log (- wj (/ (fma wj (exp wj) (- x)) (fma wj (exp wj) (exp wj))))))

    1. Initial program 1.6

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Using strategy rm
    3. Applied div-sub1.6

      \[\leadsto wj - \color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\]
    4. Applied associate--r-1.2

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

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

Runtime

Time bar (total: 1.1m)Debug logProfile

herbie shell --seed 2018214 +o rules:numerics
(FPCore (wj x)
  :name "Jmat.Real.lambertw, newton loop step"

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

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