Average Error: 0.5 → 0.4
Time: 14.2s
Precision: 64
Internal Precision: 128
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[\log_* (1 + e^{x}) - y \cdot x\]

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.5
Target0.1
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;x \le 0:\\ \;\;\;\;\log \left(1 + e^{x}\right) - x \cdot y\\ \mathbf{else}:\\ \;\;\;\;\log \left(1 + e^{-x}\right) - \left(-x\right) \cdot \left(1 - y\right)\\ \end{array}\]

Derivation

  1. Initial program 0.5

    \[\log \left(1 + e^{x}\right) - x \cdot y\]
  2. Initial simplification0.4

    \[\leadsto \log_* (1 + e^{x}) - y \cdot x\]
  3. Final simplification0.4

    \[\leadsto \log_* (1 + e^{x}) - y \cdot x\]

Reproduce

herbie shell --seed 2018362 +o rules:numerics
(FPCore (x y)
  :name "Logistic regression 2"

  :herbie-target
  (if (<= x 0) (- (log (+ 1 (exp x))) (* x y)) (- (log (+ 1 (exp (- x)))) (* (- x) (- 1 y))))

  (- (log (+ 1 (exp x))) (* x y)))

Details

Time bar (total: 8.4s)Debug log

start116.0ms

Algorithm
intervals

setup52.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 0.5b

localize14.0ms

Local error

Found 2 expressions with local error:

0.5b
(log1p (exp x))
0.0b
(- (log1p (exp x)) (* y x))

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
2 → 32
Calls

2 calls. Slowest were:

3.0ms
(- (log1p (exp x)) (* y x))
0.0ms
(log1p (exp x))

series103.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

57.0ms
(log1p (exp x))
46.0ms
(- (log1p (exp x)) (* y x))

simplify187.0ms

Counts
17 → 38
Calls

17 calls. Slowest were:

55.0ms
(+ (log 2) (+ (* 1/2 x) (* 1/8 (pow x 2))))
35.0ms
(+ (log 2) (+ (* 1/2 x) (* 1/8 (pow x 2))))
16.0ms
(fma (sqrt (log1p (exp x))) (sqrt (log1p (exp x))) (- (* x y)))

prune362.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.2b

localize20.0ms

Local error

Found 2 expressions with local error:

0.0b
(- (fma x (fma 1/8 x 1/2) (log 2)) (* y x))
0.0b
(fma x (fma 1/8 x 1/2) (log 2))

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
2 → 31
Calls

2 calls. Slowest were:

4.0ms
(- (fma x (fma 1/8 x 1/2) (log 2)) (* y x))
0.0ms
(fma x (fma 1/8 x 1/2) (log 2))

series51.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

34.0ms
(- (fma x (fma 1/8 x 1/2) (log 2)) (* y x))
17.0ms
(fma x (fma 1/8 x 1/2) (log 2))

simplify1.1s

Counts
16 → 37
Calls

16 calls. Slowest were:

197.0ms
(- (+ (* 1/2 x) (* 1/8 (pow x 2))) (* x y))
191.0ms
(- (+ (* 1/2 x) (* 1/8 (pow x 2))) (* x y))
113.0ms
(/ (exp (fma x (fma 1/8 x 1/2) (log 2))) (exp (* y x)))

prune527.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.2b

localize35.0ms

Local error

Found 2 expressions with local error:

49.6b
(fma (- x) y (* x y))
0.0b
(fma x (- (fma 1/8 x 1/2) y) (log 2))

rewrite1.0ms

Algorithm
rewrite-expression-head
Counts
2 → 20
Calls

2 calls. Slowest were:

0.0ms
(fma (- x) y (* x y))
0.0ms
(fma x (- (fma 1/8 x 1/2) y) (log 2))

series52.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

37.0ms
(fma x (- (fma 1/8 x 1/2) y) (log 2))
15.0ms
(fma (- x) y (* x y))

simplify378.0ms

Counts
6 → 26
Calls

6 calls. Slowest were:

189.0ms
(- (+ (* 1/2 x) (* 1/8 (pow x 2))) (* x y))
149.0ms
(- (+ (* 1/2 x) (* 1/8 (pow x 2))) (* x y))
36.0ms
(+ (log 2) (+ (* 1/2 x) (* 1/8 (pow x 2))))

prune537.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0.2b

localize18.0ms

Local error

Found 4 expressions with local error:

7.3b
(log (fma x (fma 1/8 x 1/2) (log 2)))
0.9b
(exp (log (fma x (fma 1/8 x 1/2) (log 2))))
0.0b
(- (exp (log (fma x (fma 1/8 x 1/2) (log 2)))) (* y x))
0.0b
(fma x (fma 1/8 x 1/2) (log 2))

rewrite29.0ms

Algorithm
rewrite-expression-head
Counts
4 → 67
Calls

4 calls. Slowest were:

21.0ms
(- (exp (log (fma x (fma 1/8 x 1/2) (log 2)))) (* y x))
4.0ms
(exp (log (fma x (fma 1/8 x 1/2) (log 2))))
2.0ms
(log (fma x (fma 1/8 x 1/2) (log 2)))

series128.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

43.0ms
(log (fma x (fma 1/8 x 1/2) (log 2)))
38.0ms
(- (exp (log (fma x (fma 1/8 x 1/2) (log 2)))) (* y x))
27.0ms
(fma x (fma 1/8 x 1/2) (log 2))
19.0ms
(exp (log (fma x (fma 1/8 x 1/2) (log 2))))

simplify3.4s

Counts
41 → 79
Calls

41 calls. Slowest were:

466.0ms
(- (+ (* 1/8 (/ (pow x 2) (log 2))) (+ (log (log 2)) (* 1/2 (/ x (log 2))))) (* 1/8 (/ (pow x 2) (pow (log 2) 2))))
324.0ms
(- (+ (log 1/8) (+ (* 8 (/ (log 2) (pow x 2))) (* 4 (/ 1 x)))) (+ (* 2 (log (/ 1 x))) (* 8 (/ 1 (pow x 2)))))
307.0ms
(/ (exp (exp (log (fma x (fma 1/8 x 1/2) (log 2))))) (exp (* y x)))

prune1.2s

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0.2b

regimes119.0ms

Accuracy

0% (0.2b remaining)

Error of 0.4b against oracle of 0.2b and baseline of 0.4b

bsearch1.0ms