Average Error: 13.4 → 1.2
Time: 1.6m
Precision: 64
Internal Precision: 896
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\frac{x}{\left(1 + wj\right) \cdot e^{wj}} + \sqrt{wj \cdot wj + \left({wj}^{4} - {wj}^{3}\right)} \cdot \sqrt{wj \cdot wj + \left({wj}^{4} - {wj}^{3}\right)}\]

Error

Bits error versus wj

Bits error versus x

Target

Original13.4
Target12.8
Herbie1.2
\[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\]

Derivation

  1. Initial program 13.4

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

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

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

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

    \[\leadsto \color{blue}{\frac{x}{\left(1 + wj\right) \cdot e^{wj}} + \left(wj \cdot wj + \left({wj}^{4} - {wj}^{3}\right)\right)}\]
  8. Using strategy rm
  9. Applied add-sqr-sqrt1.2

    \[\leadsto \frac{x}{\left(1 + wj\right) \cdot e^{wj}} + \color{blue}{\sqrt{wj \cdot wj + \left({wj}^{4} - {wj}^{3}\right)} \cdot \sqrt{wj \cdot wj + \left({wj}^{4} - {wj}^{3}\right)}}\]
  10. Removed slow pow expressions.

Runtime

Time bar (total: 1.6m)Debug logProfile

herbie shell --seed '#(1063185673 2139736501 2393378123 1907444849 1070993796 1007244912)' 
(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))))))