Average Error: 13.5 → 1.2
Time: 29.7s
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 1.7333967120862666 \cdot 10^{-08}:\\ \;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(x \cdot wj\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\left(wj - \left(wj - 1\right) \cdot \frac{wj - \frac{x}{e^{wj}}}{wj \cdot wj - 1}\right) \cdot \left(\left(wj - \left(wj - 1\right) \cdot \frac{wj - \frac{x}{e^{wj}}}{wj \cdot wj - 1}\right) \cdot \left(wj - \left(wj - 1\right) \cdot \frac{wj - \frac{x}{e^{wj}}}{wj \cdot wj - 1}\right)\right)}\\ \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.5
Target12.8
Herbie1.2
\[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 < 1.7333967120862666e-08

    1. Initial program 13.1

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

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

    if 1.7333967120862666e-08 < wj

    1. Initial program 27.2

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

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

      \[\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-frac27.2

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

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

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

      \[\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/3.0

      \[\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)}\]
    11. Using strategy rm
    12. Applied add-cbrt-cube12.8

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

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

Reproduce

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

sample195.0ms

Algorithm
intervals

simplify145.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

145.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: 15.6b

localize32.0ms

Local error

Found 4 expressions with local error:

4.7b
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))
1.0b
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
0.0b
(* wj (exp wj))
0.0b
(* wj (exp wj))

rewrite26.0ms

Algorithm
rewrite-expression-head
Counts
4 → 74
Calls

4 calls. Slowest were:

18.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
2.0ms
(* wj (exp wj))
2.0ms
(* wj (exp wj))

series152.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

62.0ms
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))
39.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
27.0ms
(* wj (exp wj))
23.0ms
(* wj (exp wj))

simplify3.2s

Counts
63 → 86
Calls

63 calls. Slowest were:

759.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
696.0ms
(/ (* wj (exp wj)) (+ (exp wj) (* wj (exp wj))))
133.0ms
(+ (* (exp wj) (exp wj)) (- (* (* wj (exp wj)) (* wj (exp wj))) (* (exp wj) (* wj (exp wj)))))

prune822.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.5b

localize13.0ms

Local error

Found 3 expressions with local error:

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

rewrite23.0ms

Algorithm
rewrite-expression-head
Counts
3 → 32
Calls

3 calls. Slowest were:

16.0ms
(- (+ (pow wj 2) x) (* 2 (* x wj)))
4.0ms
(+ (pow wj 2) x)
2.0ms
(* 2 (* x wj))

series59.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

23.0ms
(- (+ (pow wj 2) x) (* 2 (* x wj)))
18.0ms
(+ (pow wj 2) x)
18.0ms
(* 2 (* x wj))

simplify408.0ms

Counts
11 → 41
Calls

11 calls. Slowest were:

187.0ms
(/ (exp (+ (pow wj 2) x)) (exp (* 2 (* x wj))))
77.0ms
(- (+ x (pow wj 2)) (* 2 (* x wj)))
58.0ms
(- (+ (pow wj 2) x) (* 2 (* x wj)))

prune307.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.5b

localize34.0ms

Local error

Found 3 expressions with local error:

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

rewrite9.0ms

Algorithm
rewrite-expression-head
Counts
3 → 56
Calls

3 calls. Slowest were:

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

series135.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

54.0ms
(/ x (exp wj))
52.0ms
(- wj (* 1 (/ (- wj (/ x (exp wj))) (+ wj 1))))
29.0ms
(/ (- wj (/ x (exp wj))) (+ wj 1))

simplify1.5s

Counts
42 → 65
Calls

42 calls. Slowest were:

303.0ms
(- (pow wj 3) (pow (/ x (exp wj)) 3))
254.0ms
(/ (* (* (- wj (/ x (exp wj))) (- wj (/ x (exp wj)))) (- wj (/ x (exp wj)))) (* (* (+ wj 1) (+ wj 1)) (+ wj 1)))
134.0ms
(- (* wj wj) (* (/ x (exp wj)) (/ x (exp wj))))

prune631.0ms

Pruning

8 alts after pruning (6 fresh and 2 done)

Merged error: 0.5b

localize40.0ms

Local error

Found 4 expressions with local error:

4.7b
(- wj (* 1 (* (/ (- wj (/ x (exp wj))) (- (* wj wj) (* 1 1))) (- wj 1))))
0.0b
(* (/ (- wj (/ x (exp wj))) (- (* wj wj) (* 1 1))) (- wj 1))
0.0b
(/ (- wj (/ x (exp wj))) (- (* wj wj) (* 1 1)))
0.0b
(/ x (exp wj))

rewrite31.0ms

Algorithm
rewrite-expression-head
Counts
4 → 111
Calls

4 calls. Slowest were:

16.0ms
(* (/ (- wj (/ x (exp wj))) (- (* wj wj) (* 1 1))) (- wj 1))
9.0ms
(/ (- wj (/ x (exp wj))) (- (* wj wj) (* 1 1)))
3.0ms
(- wj (* 1 (* (/ (- wj (/ x (exp wj))) (- (* wj wj) (* 1 1))) (- wj 1))))

series230.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

95.0ms
(- wj (* 1 (* (/ (- wj (/ x (exp wj))) (- (* wj wj) (* 1 1))) (- wj 1))))
61.0ms
(/ (- wj (/ x (exp wj))) (- (* wj wj) (* 1 1)))
42.0ms
(* (/ (- wj (/ x (exp wj))) (- (* wj wj) (* 1 1))) (- wj 1))
32.0ms
(/ x (exp wj))

simplify10.4s

Counts
96 → 123
Calls

96 calls. Slowest were:

706.0ms
(- (pow wj 3) (pow (/ x (exp wj)) 3))
532.0ms
(* (- (* wj wj) (* 1 1)) (+ wj 1))
400.0ms
(* 1 (* (/ (- wj (/ x (exp wj))) (- (* wj wj) (* 1 1))) (- 1)))

prune1.4s

Pruning

9 alts after pruning (6 fresh and 3 done)

Merged error: 0.5b

regimes168.0ms

Accuracy

53% (0.9b remaining)

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

bsearch82.0ms

end0.0ms

sample8.7s

Algorithm
intervals