\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
Test:
Jmat.Real.lambertw, newton loop step
Bits:
128 bits
Bits error versus wj
Bits error versus x
Time: 8.6 s
Input Error: 28.7
Output Error: 0.2
Log:
Profile: 🕒
\(\begin{cases} wj - \frac{1}{wj + 1} \cdot \left(wj - \frac{x}{e^{wj}}\right) & \text{when } \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \le -2.6321606157284434 \cdot 10^{-13} \\ (wj * wj + x)_* & \text{when } \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \le 4.315389515968691 \cdot 10^{-09} \\ wj - \frac{1}{wj + 1} \cdot \left(wj - \frac{x}{e^{wj}}\right) & \text{otherwise} \end{cases}\)

    if (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))) < -2.6321606157284434e-13 or 4.315389515968691e-09 < (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))

    1. Started with
      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
      0.5
    2. Using strategy rm
      0.5
    3. Applied distribute-rgt1-in to get
      \[wj - \frac{wj \cdot e^{wj} - x}{\color{red}{e^{wj} + wj \cdot e^{wj}}} \leadsto wj - \frac{wj \cdot e^{wj} - x}{\color{blue}{\left(wj + 1\right) \cdot e^{wj}}}\]
      0.5
    4. Applied *-un-lft-identity to get
      \[wj - \frac{\color{red}{wj \cdot e^{wj} - x}}{\left(wj + 1\right) \cdot e^{wj}} \leadsto wj - \frac{\color{blue}{1 \cdot \left(wj \cdot e^{wj} - x\right)}}{\left(wj + 1\right) \cdot e^{wj}}\]
      0.5
    5. Applied times-frac to get
      \[wj - \color{red}{\frac{1 \cdot \left(wj \cdot e^{wj} - x\right)}{\left(wj + 1\right) \cdot e^{wj}}} \leadsto wj - \color{blue}{\frac{1}{wj + 1} \cdot \frac{wj \cdot e^{wj} - x}{e^{wj}}}\]
      0.6
    6. Applied simplify to get
      \[wj - \frac{1}{wj + 1} \cdot \color{red}{\frac{wj \cdot e^{wj} - x}{e^{wj}}} \leadsto wj - \frac{1}{wj + 1} \cdot \color{blue}{\left(wj - \frac{x}{e^{wj}}\right)}\]
      0.5

    if -2.6321606157284434e-13 < (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))) < 4.315389515968691e-09

    1. Started with
      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
      44.3
    2. Applied taylor to get
      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \leadsto wj - \left(wj - \left({wj}^2 + x\right)\right)\]
      44.0
    3. Taylor expanded around 0 to get
      \[wj - \color{red}{\left(wj - \left({wj}^2 + x\right)\right)} \leadsto wj - \color{blue}{\left(wj - \left({wj}^2 + x\right)\right)}\]
      44.0
    4. Applied simplify to get
      \[\color{red}{wj - \left(wj - \left({wj}^2 + x\right)\right)} \leadsto \color{blue}{(wj * wj + x)_*}\]
      30.6

  1. Removed slow pow expressions

Original test:


(lambda ((wj default) (x default))
  #:name "Jmat.Real.lambertw, newton loop step"
  (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))
  #:target
  (- wj (- (/ wj (+ wj 1)) (/ x (+ (exp wj) (* wj (exp wj)))))))