Average Error: 13.9 → 0.9
Time: 19.4s
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 6.028923623588758 \cdot 10^{-09}:\\ \;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(x \cdot wj\right)\\ \mathbf{else}:\\ \;\;\;\;wj - \frac{wj - \frac{x}{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
Herbie0.9
\[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 < 6.028923623588758e-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 6.028923623588758e-09 < wj

    1. Initial program 26.1

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

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

      \[\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-frac26.1

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

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

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

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

Reproduce

herbie shell --seed 2019004 
(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: 18.8s)Debug log

sample238.0ms

Algorithm
intervals

simplify186.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

186.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: 13.0b

localize33.0ms

Local error

Found 4 expressions with local error:

4.9b
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))
0.8b
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
0.0b
(+ (exp wj) (* wj (exp wj)))
0.0b
(* wj (exp wj))

rewrite15.0ms

Algorithm
rewrite-expression-head
Counts
4 → 76
Calls

4 calls. Slowest were:

9.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
3.0ms
(+ (exp wj) (* wj (exp wj)))
1.0ms
(* wj (exp wj))

series141.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

70.0ms
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))
33.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
20.0ms
(+ (exp wj) (* wj (exp wj)))
18.0ms
(* wj (exp wj))

simplify3.3s

Counts
64 → 88
Calls

64 calls. Slowest were:

934.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
689.0ms
(/ (* wj (exp wj)) (+ (exp wj) (* wj (exp wj))))
154.0ms
(+ (* (exp wj) (exp wj)) (- (* (* wj (exp wj)) (* wj (exp wj))) (* (exp wj) (* wj (exp wj)))))

prune841.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.2b

localize13.0ms

Local error

Found 2 expressions with local error:

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

rewrite22.0ms

Algorithm
rewrite-expression-head
Counts
2 → 22
Calls

2 calls. Slowest were:

20.0ms
(- (+ (pow wj 2) x) (* 2 (* x wj)))
2.0ms
(* 2 (* x wj))

series41.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

22.0ms
(- (+ (pow wj 2) x) (* 2 (* x wj)))
19.0ms
(* 2 (* x wj))

simplify425.0ms

Counts
8 → 28
Calls

8 calls. Slowest were:

154.0ms
(/ (exp (+ (pow wj 2) x)) (exp (* 2 (* x wj))))
93.0ms
(- (+ (pow wj 2) x) (* 2 (* x wj)))
86.0ms
(- (+ x (pow wj 2)) (* 2 (* x wj)))

prune259.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.2b

localize15.0ms

Local error

Found 3 expressions with local error:

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

rewrite5.0ms

Algorithm
rewrite-expression-head
Counts
3 → 56
Calls

3 calls. Slowest were:

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

series134.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

51.0ms
(/ x (exp wj))
49.0ms
(/ (- wj (/ x (exp wj))) (+ wj 1))
34.0ms
(- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1))))

simplify1.7s

Counts
42 → 65
Calls

42 calls. Slowest were:

537.0ms
(- (+ x (* 1/2 (* x (pow wj 2)))) (* x wj))
260.0ms
(- (pow wj 3) (pow (/ x (exp wj)) 3))
255.0ms
(/ (* (* (- wj (/ x (exp wj))) (- wj (/ x (exp wj)))) (- wj (/ x (exp wj)))) (* (* (+ wj 1) (+ wj 1)) (+ wj 1)))

prune571.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.2b

localize11.0ms

Local error

Found 4 expressions with local error:

4.9b
(- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1))))
4.9b
(- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1))))
4.9b
(- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1))))
0.5b
(cbrt (- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1)))))

rewrite3.0ms

Algorithm
rewrite-expression-head
Counts
4 → 46
Calls

4 calls. Slowest were:

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

series221.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

95.0ms
(cbrt (- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1)))))
49.0ms
(- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1))))
43.0ms
(- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1))))
34.0ms
(- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1))))

simplify1.6s

Counts
17 → 58
Calls

17 calls. Slowest were:

327.0ms
(cbrt (* (cbrt (- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1))))) (cbrt (- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1)))))))
273.0ms
(cbrt (sqrt (- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1))))))
192.0ms
(- (+ (* 7/18 (* (pow x 1/3) (pow wj 2))) (pow x 1/3)) (* 2/3 (* (pow x 1/3) wj)))

prune654.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.1b

regimes83.0ms

Accuracy

64.9% (0.6b remaining)

Error of 0.9b against oracle of 0.3b and baseline of 2.1b

bsearch64.0ms

end0.0ms

sample8.3s

Algorithm
intervals