Average Error: 13.8 → 1.1
Time: 4.1s
Precision: binary64
\[\]
\[\]
double code(double wj, double x) {
	return ((double) (wj - ((double) (((double) (((double) (wj * ((double) exp(wj)))) - x)) / ((double) (((double) exp(wj)) + ((double) (wj * ((double) exp(wj))))))))));
}
double code(double wj, double x) {
	return ((double) (((double) (((double) (wj * wj)) + ((double) (((double) pow(wj, 4.0)) - ((double) pow(wj, 3.0)))))) + ((double) (((double) (x / ((double) exp(wj)))) / ((double) (wj + 1.0))))));
}

Error

Bits error versus wj

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original13.8
Target13.2
Herbie1.1
\[\]

Derivation

  1. Initial program 13.8

    \[\]
  2. Simplified13.2

    \[\leadsto \]
  3. Using strategy rm
  4. Applied div-sub13.2

    \[\leadsto \]
  5. Applied associate--r-7.0

    \[\leadsto \]
  6. Taylor expanded around 0 1.1

    \[\leadsto \]
  7. Simplified1.1

    \[\leadsto \]
  8. Final simplification1.1

    \[\leadsto \]

Reproduce

herbie shell --seed 2020180 
(FPCore (wj x)
  :name "Jmat.Real.lambertw, newton loop step"
  :precision binary64

  :herbie-target
  (- wj (- (/ wj (+ wj 1.0)) (/ x (+ (exp wj) (* wj (exp wj))))))

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