Average Error: 0.5 → 0.5
Time: 10.6s
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.0
Herbie0.5
\[\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.5

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

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

Reproduce

herbie shell --seed 2018365 +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: 5.7s)Debug log

start135.0ms

Algorithm
intervals

setup51.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 0.5b

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

series114.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

65.0ms
(- (log1p (exp x)) (* y x))
50.0ms
(log1p (exp x))

simplify227.0ms

Counts
17 → 38
Calls

17 calls. Slowest were:

70.0ms
(+ (log 2) (+ (* 1/2 x) (* 1/8 (pow x 2))))
35.0ms
(+ (log 2) (+ (* 1/2 x) (* 1/8 (pow x 2))))
23.0ms
(/ (exp (log1p (exp x))) (exp (* y x)))

prune308.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.2b

localize27.0ms

Local error

Found 1 expressions with local error:

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

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
1 → 21
Calls

1 calls. Slowest were:

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

series49.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

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

simplify928.0ms

Counts
13 → 24
Calls

13 calls. Slowest were:

178.0ms
(- (+ (* 1/2 x) (* 1/8 (pow x 2))) (* x y))
161.0ms
(- (+ (* 1/2 x) (* 1/8 (pow x 2))) (* x y))
159.0ms
(/ (exp (fma x (fma 1/8 x 1/2) (log 2))) (exp (* y x)))

prune364.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.2b

localize37.0ms

Local error

Found 2 expressions with local error:

50.7b
(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))

series67.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

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

simplify355.0ms

Counts
6 → 26
Calls

6 calls. Slowest were:

164.0ms
(- (+ (* 1/2 x) (* 1/8 (pow x 2))) (* x y))
140.0ms
(- (+ (* 1/2 x) (* 1/8 (pow x 2))) (* x y))
47.0ms
(+ (log 2) (+ (* 1/2 x) (* 1/8 (pow x 2))))

prune466.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.2b

localize11.0ms

Local error

Found 4 expressions with local error:

3.3b
(log (/ (+ 1 (exp x)) (exp (* y x))))
0.3b
(/ (+ 1 (exp x)) (exp (* y x)))
0.0b
(exp (* y x))
0.0b
(+ 1 (exp x))

rewrite12.0ms

Algorithm
rewrite-expression-head
Counts
4 → 80
Calls

4 calls. Slowest were:

6.0ms
(/ (+ 1 (exp x)) (exp (* y x)))
2.0ms
(log (/ (+ 1 (exp x)) (exp (* y x))))
1.0ms
(+ 1 (exp x))

series119.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

57.0ms
(log (/ (+ 1 (exp x)) (exp (* y x))))
35.0ms
(/ (+ 1 (exp x)) (exp (* y x)))
17.0ms
(exp (* y x))
11.0ms
(+ 1 (exp x))

simplify1.2s

Counts
57 → 92
Calls

57 calls. Slowest were:

325.0ms
(/ (* (* (+ 1 (exp x)) (+ 1 (exp x))) (+ 1 (exp x))) (* (* (exp (* y x)) (exp (* y x))) (exp (* y x))))
133.0ms
(+ (* 1/2 (* (pow x 2) (pow y 2))) (+ 1 (* x y)))
67.0ms
(log (/ (* (cbrt (+ 1 (exp x))) (cbrt (+ 1 (exp x)))) 1))

prune1.1s

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0.2b

regimes91.0ms

Accuracy

0% (0.2b remaining)

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

bsearch1.0ms