Average Error: 13.9 → 1.0
Time: 20.6s
Precision: 64
Internal Precision: 128
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\begin{array}{l} \mathbf{if}\;wj \le 4.458584244320131 \cdot 10^{-09}:\\ \;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(x \cdot wj\right)\\ \mathbf{else}:\\ \;\;\;\;wj - \frac{wj - \frac{\frac{x}{\sqrt{e^{wj}}}}{\sqrt{e^{wj}}}}{wj + 1}\\ \end{array}\]

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.9
Target13.3
Herbie1.0
\[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)\]

Derivation

  1. Split input into 2 regimes
  2. if wj < 4.458584244320131e-09

    1. Initial program 13.6

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Taylor expanded around 0 0.9

      \[\leadsto \color{blue}{\left({wj}^{2} + x\right) - 2 \cdot \left(x \cdot wj\right)}\]

    if 4.458584244320131e-09 < wj

    1. Initial program 24.5

      \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity24.5

      \[\leadsto wj - \frac{wj \cdot e^{wj} - x}{\color{blue}{1 \cdot \left(e^{wj} + wj \cdot e^{wj}\right)}}\]
    4. Applied *-un-lft-identity24.5

      \[\leadsto wj - \frac{\color{blue}{1 \cdot \left(wj \cdot e^{wj} - x\right)}}{1 \cdot \left(e^{wj} + wj \cdot e^{wj}\right)}\]
    5. Applied times-frac24.5

      \[\leadsto wj - \color{blue}{\frac{1}{1} \cdot \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}}\]
    6. Simplified24.5

      \[\leadsto wj - \color{blue}{1} \cdot \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
    7. Simplified3.1

      \[\leadsto wj - 1 \cdot \color{blue}{\frac{wj - \frac{x}{e^{wj}}}{wj + 1}}\]
    8. Using strategy rm
    9. Applied add-sqr-sqrt3.2

      \[\leadsto wj - 1 \cdot \frac{wj - \frac{x}{\color{blue}{\sqrt{e^{wj}} \cdot \sqrt{e^{wj}}}}}{wj + 1}\]
    10. Applied associate-/r*3.2

      \[\leadsto wj - 1 \cdot \frac{wj - \color{blue}{\frac{\frac{x}{\sqrt{e^{wj}}}}{\sqrt{e^{wj}}}}}{wj + 1}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;wj \le 4.458584244320131 \cdot 10^{-09}:\\ \;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(x \cdot wj\right)\\ \mathbf{else}:\\ \;\;\;\;wj - \frac{wj - \frac{\frac{x}{\sqrt{e^{wj}}}}{\sqrt{e^{wj}}}}{wj + 1}\\ \end{array}\]

Reproduce

herbie shell --seed 2019002 
(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))))))

Details

Time bar (total: 19.9s)Debug log

sample272.0ms

Algorithm
intervals

simplify156.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune10.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 14.7b

localize33.0ms

Local error

Found 4 expressions with local error:

4.8b
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))
0.3b
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
0.0b
(+ (exp wj) (* wj (exp wj)))
0.0b
(* wj (exp wj))

rewrite25.0ms

Algorithm
rewrite-expression-head
Counts
4 → 76
Calls

4 calls. Slowest were:

14.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
5.0ms
(* wj (exp wj))
3.0ms
(+ (exp wj) (* wj (exp wj)))

series148.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

53.0ms
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))
40.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
30.0ms
(* wj (exp wj))
24.0ms
(+ (exp wj) (* wj (exp wj)))

simplify3.3s

Counts
64 → 88
Calls

64 calls. Slowest were:

815.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
614.0ms
(/ (* wj (exp wj)) (+ (exp wj) (* wj (exp wj))))
159.0ms
(/ (* (* (- (* wj (exp wj)) x) (- (* wj (exp wj)) x)) (- (* wj (exp wj)) x)) (* (* (+ (exp wj) (* wj (exp wj))) (+ (exp wj) (* wj (exp wj)))) (+ (exp wj) (* wj (exp wj)))))

prune854.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.2b

localize18.0ms

Local error

Found 3 expressions with local error:

0.0b
(- (+ (pow wj 2) x) (* 2 (* x wj)))
0.0b
(* 2 (* x wj))
0.0b
(+ (pow wj 2) x)

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
3 → 32
Calls

3 calls. Slowest were:

14.0ms
(- (+ (pow wj 2) x) (* 2 (* x wj)))
2.0ms
(+ (pow wj 2) x)
1.0ms
(* 2 (* x wj))

series50.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

24.0ms
(- (+ (pow wj 2) x) (* 2 (* x wj)))
15.0ms
(* 2 (* x wj))
11.0ms
(+ (pow wj 2) x)

simplify465.0ms

Counts
11 → 41
Calls

11 calls. Slowest were:

207.0ms
(/ (exp (+ (pow wj 2) x)) (exp (* 2 (* x wj))))
86.0ms
(- (+ x (pow wj 2)) (* 2 (* x wj)))
62.0ms
(- (+ x (pow wj 2)) (* 2 (* x wj)))

prune370.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0.2b

localize26.0ms

Local error

Found 3 expressions with local error:

4.8b
(- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1))))
0.0b
(/ (- wj (/ x (exp wj))) (+ wj 1))
0.0b
(/ x (exp wj))

rewrite8.0ms

Algorithm
rewrite-expression-head
Counts
3 → 56
Calls

3 calls. Slowest were:

5.0ms
(/ (- wj (/ x (exp wj))) (+ wj 1))
1.0ms
(- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1))))
1.0ms
(/ x (exp wj))

series134.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

56.0ms
(- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1))))
48.0ms
(/ (- wj (/ x (exp wj))) (+ wj 1))
31.0ms
(/ x (exp wj))

simplify1.5s

Counts
42 → 65
Calls

42 calls. Slowest were:

338.0ms
(- (pow wj 3) (pow (/ x (exp wj)) 3))
293.0ms
(/ (* (* (- wj (/ x (exp wj))) (- wj (/ x (exp wj)))) (- wj (/ x (exp wj)))) (* (* (+ wj 1) (+ wj 1)) (+ wj 1)))
168.0ms
(- (* wj wj) (* (/ x (exp wj)) (/ x (exp wj))))

prune648.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.2b

localize30.0ms

Local error

Found 4 expressions with local error:

4.8b
(- wj (* 1 (/ (- wj (/ (/ x (sqrt (exp wj))) (sqrt (exp wj)))) (+ wj 1))))
0.0b
(/ (- wj (/ (/ x (sqrt (exp wj))) (sqrt (exp wj)))) (+ wj 1))
0.0b
(/ (/ x (sqrt (exp wj))) (sqrt (exp wj)))
0.0b
(sqrt (exp wj))

rewrite19.0ms

Algorithm
rewrite-expression-head
Counts
4 → 102
Calls

4 calls. Slowest were:

8.0ms
(/ (/ x (sqrt (exp wj))) (sqrt (exp wj)))
6.0ms
(/ (- wj (/ (/ x (sqrt (exp wj))) (sqrt (exp wj)))) (+ wj 1))
1.0ms
(- wj (* 1 (/ (- wj (/ (/ x (sqrt (exp wj))) (sqrt (exp wj)))) (+ wj 1))))

series157.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

59.0ms
(- wj (* 1 (/ (- wj (/ (/ x (sqrt (exp wj))) (sqrt (exp wj)))) (+ wj 1))))
48.0ms
(/ (- wj (/ (/ x (sqrt (exp wj))) (sqrt (exp wj)))) (+ wj 1))
36.0ms
(/ (/ x (sqrt (exp wj))) (sqrt (exp wj)))
13.0ms
(sqrt (exp wj))

simplify2.4s

Counts
104 → 114
Calls

104 calls. Slowest were:

510.0ms
(/ (* (* (/ x (sqrt (exp wj))) (/ x (sqrt (exp wj)))) (/ x (sqrt (exp wj)))) (* (* (sqrt (exp wj)) (sqrt (exp wj))) (sqrt (exp wj))))
348.0ms
(/ (* (* (- wj (/ (/ x (sqrt (exp wj))) (sqrt (exp wj)))) (- wj (/ (/ x (sqrt (exp wj))) (sqrt (exp wj))))) (- wj (/ (/ x (sqrt (exp wj))) (sqrt (exp wj))))) (* (* (+ wj 1) (+ wj 1)) (+ wj 1)))
249.0ms
(- (* wj wj) (* (/ (/ x (sqrt (exp wj))) (sqrt (exp wj))) (/ (/ x (sqrt (exp wj))) (sqrt (exp wj)))))

prune1.1s

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.2b

regimes126.0ms

Accuracy

62.9% (0.7b remaining)

Error of 1.0b against oracle of 0.3b and baseline of 2.2b

bsearch50.0ms

end0.0ms

sample8.0s

Algorithm
intervals