\[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: 10.7 s
Input Error: 9.4
Output Error: 0.3
Log:
Profile: 🕒
\(\begin{cases} wj - \frac{1}{wj + 1} \cdot \left(wj - \frac{x}{e^{wj}}\right) & \text{when } wj \le -3.1807354f-05 \\ (\left(wj - 2 \cdot x\right) * wj + x)_* & \text{when } wj \le 0.00012837857f0 \\ wj - \frac{1}{wj + 1} \cdot \left(wj - \frac{x}{e^{wj}}\right) & \text{otherwise} \end{cases}\)

    if wj < -3.1807354f-05 or 0.00012837857f0 < wj

    1. Started with
      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
      21.2
    2. Using strategy rm
      21.2
    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}}}\]
      21.6
    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}}\]
      21.6
    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}}}\]
      21.7
    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.6

    if -3.1807354f-05 < wj < 0.00012837857f0

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

  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)))))))