\[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: 12.1 s
Input Error: 29.5
Output Error: 0.2
Log:
Profile: 🕒
\(\begin{cases} \left(wj - \frac{wj}{e^{wj}}\right) + \frac{x}{\left(1 + wj\right) \cdot e^{wj}} & \text{when } wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \le -2.4472481520804102 \cdot 10^{+30} \\ \left({wj}^2 + x\right) - 2 \cdot \left(wj \cdot x\right) & \text{when } wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \le 1.0792540822943409 \cdot 10^{-17} \\ \left(wj - \frac{wj}{1 + wj}\right) + \frac{x}{e^{wj} + wj \cdot e^{wj}} & \text{otherwise} \end{cases}\)

    if (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))) < -2.4472481520804102e+30

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

    if -2.4472481520804102e+30 < (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))) < 1.0792540822943409e-17

    1. Started with
      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
      27.9
    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

    if 1.0792540822943409e-17 < (- wj (/ (- (* 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}}\]
      39.5
    2. Using strategy rm
      39.5
    3. Applied div-sub to get
      \[wj - \color{red}{\frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}} \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)}\]
      39.5
    4. Applied associate--r- to get
      \[\color{red}{wj - \left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)} \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}}}\]
      39.5
    5. Applied simplify to get
      \[\color{red}{\left(wj - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right)} + \frac{x}{e^{wj} + wj \cdot e^{wj}} \leadsto \color{blue}{\left(wj - \frac{wj}{1 + wj}\right)} + \frac{x}{e^{wj} + wj \cdot e^{wj}}\]
      0.3

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