Average Error: 28.8 → 0.1
Time: 36.3s
Precision: 64
Internal precision: 128
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\begin{array}{l} \mathbf{if}\;wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \le 1.1236023678861994 \cdot 10^{-11}:\\ \;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj \cdot wj + \left({wj}^{4} - {wj}^3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(wj - \frac{wj}{wj + 1}\right) + \frac{x}{e^{wj} + wj \cdot e^{wj}}\\ \end{array}\]

Error

Bits error versus wj

Bits error versus x

Target

Original28.8
Comparison9.2
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 (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))) < 1.1236023678861994e-11

    1. Initial program 18.5

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

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

      \[\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 simplify 9.8

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

      \[\leadsto \left(\left({wj}^{4} + {wj}^2\right) - {wj}^{3}\right) + \frac{x}{e^{wj} + wj \cdot e^{wj}}\]
    7. 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}}\]
    8. Applied simplify 0.0

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

    if 1.1236023678861994e-11 < (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))

    1. Initial program 38.8

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

      \[\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 simplify 0.1

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

Runtime

Time bar (total: 36.3s) Debug log

Please include this information when filing a bug report:

herbie --seed '#(2882512034 457837655 3838413025 890739493 4262219284 696798667)'
(FPCore (wj x)
  :name "Jmat.Real.lambertw, newton loop step"

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

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