Average Error: 13.2 → 1.0
Time: 20.8s
Precision: 64
Internal Precision: 128
\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
\[\frac{x}{wj + 1} \cdot \frac{1}{e^{wj}} + \left(\left({wj}^{2} + {wj}^{4}\right) - {wj}^{3}\right)\]

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

Derivation

  1. Initial program 13.2

    \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\]
  2. Using strategy rm
  3. Applied div-sub13.2

    \[\leadsto wj - \color{blue}{\left(\frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)}\]
  4. Applied associate--r-7.4

    \[\leadsto \color{blue}{\left(wj - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right) + \frac{x}{e^{wj} + wj \cdot e^{wj}}}\]
  5. Simplified7.4

    \[\leadsto \left(wj - \frac{wj \cdot e^{wj}}{e^{wj} + wj \cdot e^{wj}}\right) + \color{blue}{\frac{\frac{x}{wj + 1}}{e^{wj}}}\]
  6. Taylor expanded around 0 1.0

    \[\leadsto \color{blue}{\left(\left({wj}^{2} + {wj}^{4}\right) - {wj}^{3}\right)} + \frac{\frac{x}{wj + 1}}{e^{wj}}\]
  7. Using strategy rm
  8. Applied div-inv1.0

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

    \[\leadsto \frac{x}{wj + 1} \cdot \frac{1}{e^{wj}} + \left(\left({wj}^{2} + {wj}^{4}\right) - {wj}^{3}\right)\]

Reproduce

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

sample239.0ms

Algorithm
intervals
Results
192.0ms270×body10240exit
17.0ms205×body80valid
8.0ms19×body640valid
5.0ms21×body320valid
3.0ms15×body160valid

simplify158.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
157.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: 13.4b

localize19.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
(* wj (exp wj))
0.0b
(* wj (exp wj))

rewrite12.0ms

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

series162.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
64.0ms
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj)))))
53.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
23.0ms
(* wj (exp wj))
23.0ms
(* wj (exp wj))

simplify3.1s

Counts
63 → 86
Calls
63 calls:
Slowest
816.0ms
(/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))
671.0ms
(/ (* wj (exp wj)) (+ (exp wj) (* wj (exp wj))))
155.0ms
(+ (* (exp wj) (exp wj)) (- (* (* wj (exp wj)) (* wj (exp wj))) (* (exp wj) (* wj (exp wj)))))
121.0ms
(- (* (* wj (exp wj)) (* wj (exp wj))) (* x x))
95.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)))))

prune691.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.2b

localize14.0ms

Local error

Found 1 expressions with local error:

0.0b
(* 2 (* x wj))

rewrite1.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
add-cube-cbrt
*-commutative
add-exp-log
associate-*r*
add-cbrt-cube
*-un-lft-identity
pow1
add-sqr-sqrt
Counts
1 → 9
Calls
1 calls:
Slowest
1.0ms
(* 2 (* x wj))

series11.0ms

Counts
1 → 3
Calls
1 calls:
Slowest
11.0ms
(* 2 (* x wj))

simplify17.0ms

Counts
3 → 12
Calls
3 calls:
Slowest
5.0ms
(* 2 (* x wj))
5.0ms
(* 2 (* x wj))
5.0ms
(* 2 (* x wj))

prune140.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0.2b

localize15.0ms

Local error

Found 4 expressions with local error:

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

rewrite12.0ms

Algorithm
rewrite-expression-head
Rules
23×times-frac
20×*-un-lft-identity
18×add-cube-cbrt
18×add-sqr-sqrt
10×associate-/r/
add-cbrt-cube
associate-/r*
associate-/l*
add-exp-log
div-inv
flip-+
flip3-+
add-log-exp
pow1
associate-*r*
distribute-rgt1-in
div-exp
distribute-rgt-out
frac-2neg
clear-num
cbrt-undiv
associate-/l/
flip--
*-commutative
flip3--
sub-neg
Counts
4 → 87
Calls
4 calls:
Slowest
6.0ms
(/ (* wj (exp wj)) (+ (exp wj) (* wj (exp wj))))
3.0ms
(/ (/ x (+ wj 1)) (exp wj))
1.0ms
(* wj (exp wj))
1.0ms
(- wj (/ (* wj (exp wj)) (+ (exp wj) (* wj (exp wj)))))

series152.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
58.0ms
(/ (/ x (+ wj 1)) (exp wj))
39.0ms
(/ (* wj (exp wj)) (+ (exp wj) (* wj (exp wj))))
39.0ms
(- wj (/ (* wj (exp wj)) (+ (exp wj) (* wj (exp wj)))))
16.0ms
(* wj (exp wj))

simplify2.7s

Counts
79 → 99
Calls
79 calls:
Slowest
289.0ms
(/ (/ x (+ (pow wj 3) (pow 1 3))) (* (cbrt (exp wj)) (cbrt (exp wj))))
240.0ms
(/ (* (* (/ x (+ wj 1)) (/ x (+ wj 1))) (/ x (+ wj 1))) (* (* (exp wj) (exp wj)) (exp wj)))
187.0ms
(/ (/ x (- (* wj wj) (* 1 1))) (sqrt (exp wj)))
163.0ms
(- (+ x (* 5/2 (* x (pow wj 2)))) (* 2 (* x wj)))
132.0ms
(+ (* (exp wj) (exp wj)) (- (* (* wj (exp wj)) (* wj (exp wj))) (* (exp wj) (* wj (exp wj)))))

prune1.1s

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize27.0ms

Local error

Found 4 expressions with local error:

0.0b
(+ (pow wj 2) (pow wj 4))
0.0b
(- (+ (pow wj 2) (pow wj 4)) (pow wj 3))
0.0b
(/ (/ x (+ wj 1)) (exp wj))
0.0b
(/ x (+ wj 1))

rewrite35.0ms

Algorithm
rewrite-expression-head
Rules
23×*-un-lft-identity
18×times-frac
18×add-sqr-sqrt
16×add-cube-cbrt
11×add-log-exp
10×associate-/r/
associate-/l*
div-inv
flip-+
add-cbrt-cube
flip3-+
associate-/r*
add-exp-log
pow1
distribute-lft-out--
distribute-lft-out
diff-log
frac-2neg
sum-log
clear-num
associate-/l/
difference-of-squares
flip--
associate--l+
div-exp
flip3--
sub-neg
+-commutative
cbrt-undiv
Counts
4 → 84
Calls
4 calls:
Slowest
23.0ms
(- (+ (pow wj 2) (pow wj 4)) (pow wj 3))
7.0ms
(+ (pow wj 2) (pow wj 4))
3.0ms
(/ (/ x (+ wj 1)) (exp wj))
0.0ms
(/ x (+ wj 1))

series139.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
61.0ms
(/ (/ x (+ wj 1)) (exp wj))
38.0ms
(+ (pow wj 2) (pow wj 4))
20.0ms
(- (+ (pow wj 2) (pow wj 4)) (pow wj 3))
18.0ms
(/ x (+ wj 1))

simplify2.3s

Counts
71 → 96
Calls
71 calls:
Slowest
229.0ms
(/ (/ x (- (* wj wj) (* 1 1))) (sqrt (exp wj)))
227.0ms
(/ (/ x (+ (pow wj 3) (pow 1 3))) (* (cbrt (exp wj)) (cbrt (exp wj))))
207.0ms
(/ (* (* (/ x (+ wj 1)) (/ x (+ wj 1))) (/ x (+ wj 1))) (* (* (exp wj) (exp wj)) (exp wj)))
204.0ms
(- (+ x (* 5/2 (* x (pow wj 2)))) (* 2 (* x wj)))
96.0ms
(/ (/ x (- (* wj wj) (* 1 1))) (* (cbrt (exp wj)) (cbrt (exp wj))))

prune1.3s

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

regimes68.0ms

Accuracy

0% (1.0b remaining)

Error of 1.0b against oracle of 0.1b and baseline of 1.0b

bsearch2.0ms

end0.0ms

sample7.9s

Algorithm
intervals
Results
6.0s7607×body10240exit
1.1s6359×body80valid
235.0ms772×body320valid
180.0ms444×body640valid
148.0ms513×body160valid