Average Error: 13.3 → 1.4
Time: 20.5s
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 8.047259273015902 \cdot 10^{-23}:\\ \;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(x \cdot wj\right)\\ \mathbf{else}:\\ \;\;\;\;wj - \left(wj - 1\right) \cdot \frac{wj - \frac{x}{e^{wj}}}{wj \cdot 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.3
Target12.6
Herbie1.4
\[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 < 8.047259273015902e-23

    1. Initial program 12.7

      \[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 8.047259273015902e-23 < wj

    1. Initial program 23.0

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

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

      \[\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-frac23.0

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

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

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

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

      \[\leadsto wj - 1 \cdot \color{blue}{\left(\frac{wj - \frac{x}{e^{wj}}}{wj \cdot wj - 1 \cdot 1} \cdot \left(wj - 1\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.4

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

Reproduce

herbie shell --seed 2019007 
(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.7s)Debug log

sample216.0ms

Algorithm
intervals

simplify107.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 10.8b

localize23.0ms

Local error

Found 4 expressions with local error:

4.4b
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))
0.5b
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
0.0b
(+ (exp wj) (* wj (exp wj)))
0.0b
(* wj (exp wj))

rewrite28.0ms

Algorithm
rewrite-expression-head
Counts
4 → 76
Calls

4 calls. Slowest were:

17.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
6.0ms
(+ (exp wj) (* wj (exp wj)))
2.0ms
(* wj (exp wj))

series180.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

66.0ms
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))
53.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
33.0ms
(+ (exp wj) (* wj (exp wj)))
27.0ms
(* wj (exp wj))

simplify3.3s

Counts
64 → 88
Calls

64 calls. Slowest were:

825.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
759.0ms
(/ (* wj (exp wj)) (+ (exp wj) (* wj (exp wj))))
145.0ms
(+ (* (exp wj) (exp wj)) (- (* (* wj (exp wj)) (* wj (exp wj))) (* (exp wj) (* wj (exp wj)))))

prune917.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.2b

localize15.0ms

Local error

Found 2 expressions with local error:

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

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
2 → 19
Calls

2 calls. Slowest were:

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

series23.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

12.0ms
(* 2 (* x wj))
11.0ms
(+ (pow wj 2) x)

simplify38.0ms

Counts
6 → 25
Calls

6 calls. Slowest were:

12.0ms
(* 2 (* x wj))
12.0ms
(* 2 (* x wj))
8.0ms
(* 2 (* x wj))

prune271.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.1b

localize24.0ms

Local error

Found 4 expressions with local error:

0.6b
(cbrt (+ (pow wj 2) x))
0.6b
(cbrt (+ (pow wj 2) x))
0.6b
(cbrt (+ (pow wj 2) x))
0.5b
(* (cbrt (+ (pow wj 2) x)) (cbrt (+ (pow wj 2) x)))

rewrite32.0ms

Algorithm
rewrite-expression-head
Counts
4 → 75
Calls

4 calls. Slowest were:

20.0ms
(* (cbrt (+ (pow wj 2) x)) (cbrt (+ (pow wj 2) x)))
3.0ms
(cbrt (+ (pow wj 2) x))
3.0ms
(cbrt (+ (pow wj 2) x))

series432.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

120.0ms
(cbrt (+ (pow wj 2) x))
115.0ms
(* (cbrt (+ (pow wj 2) x)) (cbrt (+ (pow wj 2) x)))
102.0ms
(cbrt (+ (pow wj 2) x))
94.0ms
(cbrt (+ (pow wj 2) x))

simplify1.6s

Counts
59 → 87
Calls

59 calls. Slowest were:

152.0ms
(* (cbrt (- (* (pow wj 2) (pow wj 2)) (* x x))) (cbrt (+ (pow (pow wj 2) 3) (pow x 3))))
115.0ms
(* (cbrt (+ (pow (pow wj 2) 3) (pow x 3))) (cbrt (- (* (pow wj 2) (pow wj 2)) (* x x))))
103.0ms
(cbrt (+ (* (pow wj 2) (pow wj 2)) (- (* x x) (* (pow wj 2) x))))

prune1.1s

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 0.1b

localize31.0ms

Local error

Found 3 expressions with local error:

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

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
3 → 56
Calls

3 calls. Slowest were:

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

series140.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

58.0ms
(- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1))))
46.0ms
(/ x (exp wj))
36.0ms
(/ (- wj (/ x (exp wj))) (+ wj 1))

simplify1.4s

Counts
42 → 65
Calls

42 calls. Slowest were:

273.0ms
(/ (* (* (- wj (/ x (exp wj))) (- wj (/ x (exp wj)))) (- wj (/ x (exp wj)))) (* (* (+ wj 1) (+ wj 1)) (+ wj 1)))
254.0ms
(- (pow wj 3) (pow (/ x (exp wj)) 3))
162.0ms
(- (* wj wj) (* (/ x (exp wj)) (/ x (exp wj))))

prune745.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.1b

regimes119.0ms

Accuracy

46.6% (1.1b remaining)

Error of 1.4b against oracle of 0.3b and baseline of 2.3b

bsearch73.0ms

end0.0ms

sample8.8s

Algorithm
intervals