Average Error: 13.7 → 1.9
Time: 28.2s
Precision: 64
Internal Precision: 128
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\left(x + {wj}^{2}\right) - \left(x \cdot wj\right) \cdot 2\]

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

Derivation

  1. Initial program 13.7

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

    \[\leadsto \color{blue}{\left({wj}^{2} + x\right) - 2 \cdot \left(x \cdot wj\right)}\]
  3. Final simplification1.9

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

Reproduce

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

sample226.0ms

Algorithm
intervals
Results
174.0ms224×body10240exit
18.0ms211×body80valid
7.0ms29×body320valid
4.0msbody640valid
3.0ms14×body160valid

simplify164.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
164.0ms
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 12.5b

localize17.0ms

Local error

Found 4 expressions with local error:

5.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))

rewrite29.0ms

Algorithm
rewrite-expression-head
Rules
20×*-un-lft-identity
15×add-cube-cbrt
15×times-frac
15×add-sqr-sqrt
add-log-exp
add-exp-log
add-cbrt-cube
distribute-rgt1-in
distribute-rgt-out
associate-/r*
pow1
associate-/l*
associate-*r*
associate-/l/
flip--
flip-+
associate-/r/
div-sub
flip3--
flip3-+
associate--r-
div-inv
*-commutative
div-exp
frac-2neg
sub-neg
sum-log
clear-num
+-commutative
cbrt-undiv
Counts
4 → 76
Calls
4 calls:
Slowest
18.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
7.0ms
(+ (exp wj) (* wj (exp wj)))
2.0ms
(* wj (exp wj))
0.0ms
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))

series156.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
49.0ms
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))
48.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
32.0ms
(+ (exp wj) (* wj (exp wj)))
26.0ms
(* wj (exp wj))

simplify3.0s

Counts
64 → 88
Calls
64 calls:
Slowest
730.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
618.0ms
(/ (* wj (exp wj)) (+ (exp wj) (* wj (exp wj))))
142.0ms
(+ (* (exp wj) (exp wj)) (- (* (* wj (exp wj)) (* wj (exp wj))) (* (exp wj) (* wj (exp wj)))))
121.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)))))
101.0ms
(- (* (* wj (exp wj)) (* wj (exp wj))) (* x x))

prune745.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

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))

rewrite29.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1
add-sqr-sqrt
flip--
flip-+
*-commutative
associate--l+
associate-*r*
diff-log
flip3--
flip3-+
sub-neg
+-commutative
Counts
3 → 32
Calls
3 calls:
Slowest
22.0ms
(- (+ (pow wj 2) x) (* 2 (* x wj)))
5.0ms
(+ (pow wj 2) x)
2.0ms
(* 2 (* x wj))

series65.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
28.0ms
(- (+ (pow wj 2) x) (* 2 (* x wj)))
19.0ms
(* 2 (* x wj))
18.0ms
(+ (pow wj 2) x)

simplify448.0ms

Counts
11 → 41
Calls
11 calls:
Slowest
159.0ms
(/ (exp (+ (pow wj 2) x)) (exp (* 2 (* x wj))))
89.0ms
(- (+ (pow wj 2) x) (* 2 (* x wj)))
85.0ms
(- (+ x (pow wj 2)) (* 2 (* x wj)))
61.0ms
(- (+ x (pow wj 2)) (* 2 (* x wj)))
14.0ms
(* 2 (* x wj))

prune471.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize32.0ms

Local error

Found 4 expressions with local error:

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

rewrite16.0ms

Algorithm
rewrite-expression-head
Rules
add-exp-log
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
pow1
associate-*l*
add-cbrt-cube
associate-/r*
sub-neg
add-log-exp
associate--r+
associate-/r/
distribute-lft-in
distribute-rgt-in
flip--
div-inv
associate-*r*
flip3--
flip-+
associate-*r/
prod-exp
flip3-+
frac-2neg
clear-num
rec-exp
frac-times
inv-pow
pow-flip
cbrt-unprod
*-commutative
associate-*l/
pow-prod-down
Counts
4 → 76
Calls
4 calls:
Slowest
9.0ms
(* (/ 1 (+ wj 1)) (- wj (/ x (exp wj))))
2.0ms
(- wj (* (/ 1 (+ wj 1)) (- wj (/ x (exp wj)))))
2.0ms
(/ 1 (+ wj 1))
1.0ms
(/ x (exp wj))

series167.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
54.0ms
(/ x (exp wj))
51.0ms
(- wj (* (/ 1 (+ wj 1)) (- wj (/ x (exp wj)))))
51.0ms
(* (/ 1 (+ wj 1)) (- wj (/ x (exp wj))))
10.0ms
(/ 1 (+ wj 1))

simplify5.7s

Counts
47 → 88
Calls
47 calls:
Slowest
1.0s
(* (* (* (/ 1 (+ wj 1)) (/ 1 (+ wj 1))) (/ 1 (+ wj 1))) (* (* (- wj (/ x (exp wj))) (- wj (/ x (exp wj)))) (- wj (/ x (exp wj)))))
612.0ms
(* 1 (- (pow wj 3) (pow (/ x (exp wj)) 3)))
353.0ms
(* 1 (- (* wj wj) (* (/ x (exp wj)) (/ x (exp wj)))))
340.0ms
(* (+ wj 1) (+ (* wj wj) (+ (* (/ x (exp wj)) (/ x (exp wj))) (* wj (/ x (exp wj))))))
310.0ms
(* (- (/ x (exp wj))) (/ 1 (+ wj 1)))

prune755.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0b

localize13.0ms

Local error

Found 4 expressions with local error:

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

rewrite21.0ms

Algorithm
rewrite-expression-head
Rules
add-exp-log
add-cube-cbrt
*-un-lft-identity
pow1
add-sqr-sqrt
associate-*l*
add-cbrt-cube
associate-/r*
sub-neg
add-log-exp
associate--r+
associate-/r/
distribute-lft-in
distribute-rgt-in
flip--
div-inv
associate-*r*
flip3--
rec-exp
inv-pow
pow-flip
flip-+
associate-*r/
prod-exp
flip3-+
frac-2neg
clear-num
frac-times
cbrt-unprod
*-commutative
associate-*l/
pow-prod-down
Counts
4 → 79
Calls
4 calls:
Slowest
14.0ms
(* (/ 1 (+ wj 1)) (- wj (* x (/ 1 (exp wj)))))
2.0ms
(- wj (* (/ 1 (+ wj 1)) (- wj (* x (/ 1 (exp wj))))))
2.0ms
(/ 1 (+ wj 1))
1.0ms
(/ 1 (exp wj))

series106.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
46.0ms
(* (/ 1 (+ wj 1)) (- wj (* x (/ 1 (exp wj)))))
35.0ms
(- wj (* (/ 1 (+ wj 1)) (- wj (* x (/ 1 (exp wj))))))
14.0ms
(/ 1 (exp wj))
11.0ms
(/ 1 (+ wj 1))

simplify6.0s

Counts
48 → 91
Calls
48 calls:
Slowest
563.0ms
(* (+ wj 1) (+ wj (* x (/ 1 (exp wj)))))
493.0ms
(* (- (* x (/ 1 (exp wj)))) (/ 1 (+ wj 1)))
461.0ms
(* (- (* x (/ 1 (exp wj)))) (/ 1 (+ wj 1)))
453.0ms
(* (/ 1 (+ wj 1)) (- wj (* x (/ 1 (exp wj)))))
452.0ms
(* (- (* x (/ 1 (exp wj)))) (/ 1 (+ wj 1)))

prune834.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0b

regimes61.0ms

Accuracy

0% (1.6b remaining)

Error of 1.9b against oracle of 0.3b and baseline of 1.9b

bsearch2.0ms

end0.0ms

sample8.1s

Algorithm
intervals
Results
6.7s7559×body10240exit
658.0ms6300×body80valid
232.0ms780×body320valid
200.0ms467×body640valid
159.0ms543×body160valid