Average Error: 13.9 → 0.3
Time: 29.7s
Precision: 64
Internal Precision: 896
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\begin{array}{l} \mathbf{if}\;wj \le -7.065298332585179 \cdot 10^{-09}:\\ \;\;\;\;wj - e^{-wj} \cdot \frac{wj \cdot e^{wj} - x}{1 + wj}\\ \mathbf{if}\;wj \le 9.200369675987498 \cdot 10^{-09}:\\ \;\;\;\;\left({wj}^{2} + x\right) - 2 \cdot \left(wj \cdot x\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

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

Derivation

  1. Split input into 3 regimes
  2. if wj < -7.065298332585179e-09

    1. Initial program 5.2

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity5.2

      \[\leadsto wj - \frac{wj \cdot e^{wj} - x}{\color{blue}{1 \cdot e^{wj}} + wj \cdot e^{wj}}\]
    4. Applied distribute-rgt-out5.2

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

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

      \[\leadsto wj - \color{blue}{\frac{1}{e^{wj}} \cdot \frac{wj \cdot e^{wj} - x}{1 + wj}}\]
    7. Applied simplify5.2

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

    if -7.065298332585179e-09 < wj < 9.200369675987498e-09

    1. Initial program 13.7

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

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

    if 9.200369675987498e-09 < wj

    1. Initial program 26.3

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

      \[\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-26.3

      \[\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 simplify2.5

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

Runtime

Time bar (total: 29.7s)Debug logProfile

herbie shell --seed '#(1064397287 3527694221 3797617954 1138343853 2854031332 1153838279)' +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))))))