Average Error: 13.5 → 0.1
Time: 22.7s
Precision: 64
Internal Precision: 896
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*} + \sqrt[3]{{\left((wj \cdot \left(wj - wj \cdot wj\right) + \left({wj}^{4}\right))_*\right)}^{3}} \le 7.565976676170708 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*} + (wj \cdot \left(\frac{wj \cdot wj - \left(wj \cdot wj\right) \cdot \left(wj \cdot wj\right)}{(wj \cdot wj + wj)_*}\right) + \left({wj}^{4}\right))_*\\ \mathbf{if}\;\frac{x}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*} + \sqrt[3]{{\left((wj \cdot \left(wj - wj \cdot wj\right) + \left({wj}^{4}\right))_*\right)}^{3}} \le +\infty:\\ \;\;\;\;\left(wj - \frac{wj}{1 + wj}\right) + \frac{x}{e^{wj} + wj \cdot e^{wj}}\\ \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.5
Target12.9
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 (+ (/ x (fma wj (exp wj) (exp wj))) (cbrt (pow (fma wj (- wj (* wj wj)) (pow wj 4)) 3))) < 7.565976676170708e-13

    1. Initial program 17.8

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

      \[\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-9.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 simplify9.3

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

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

      \[\leadsto \color{blue}{\frac{x}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*} + (wj \cdot \left(wj - wj \cdot wj\right) + \left({wj}^{4}\right))_*}\]
    8. Using strategy rm
    9. Applied flip--0.0

      \[\leadsto \frac{x}{(wj \cdot \left(e^{wj}\right) + \left(e^{wj}\right))_*} + (wj \cdot \color{blue}{\left(\frac{wj \cdot wj - \left(wj \cdot wj\right) \cdot \left(wj \cdot wj\right)}{wj + wj \cdot wj}\right)} + \left({wj}^{4}\right))_*\]
    10. Applied simplify0.0

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

    if 7.565976676170708e-13 < (+ (/ x (fma wj (exp wj) (exp wj))) (cbrt (pow (fma wj (- wj (* wj wj)) (pow wj 4)) 3)))

    1. Initial program 2.6

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Using strategy rm
    3. Applied div-sub2.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-2.6

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

      \[\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: 22.7s)Debug logProfile

herbie shell --seed '#(1070131407 1246090267 3027482374 2150728003 2026520792 2347815650)' +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))))))