Average Error: 0.6 → 0.5
Time: 48.1s
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.6
Target0.1
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.6

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

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

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

Reproduce

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

sample149.0ms

Algorithm
intervals

simplify15.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
15.0ms
(- (log (+ 1 (exp x))) (* x y))

prune16.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 0.5b

localize15.0ms

Local error

Found 2 expressions with local error:

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

rewrite5.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
prod-diff
fma-neg
expm1-log1p-u
log1p-expm1-u
add-exp-log
diff-log
add-cbrt-cube
log1p-udef
pow1
flip--
log1p-expm1
flip3--
sub-neg
Counts
2 → 32
Calls
2 calls:
Slowest
4.0ms
(- (log1p (exp x)) (* y x))
0.0ms
(log1p (exp x))

series109.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
69.0ms
(log1p (exp x))
39.0ms
(- (log1p (exp x)) (* y x))

simplify209.0ms

Counts
17 → 38
Calls
17 calls:
Slowest
33.0ms
(+ (log 2) (+ (* 1/2 x) (* 1/8 (pow x 2))))
32.0ms
(+ (log 2) (+ (* 1/2 x) (* 1/8 (pow x 2))))
22.0ms
(fma 1 (log1p (exp x)) (- (* x y)))
20.0ms
(fma (* (cbrt (log1p (exp x))) (cbrt (log1p (exp x)))) (cbrt (log1p (exp x))) (- (* x y)))
19.0ms
(- (log (+ (exp x) 1)) (* x y))

prune372.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.2b

localize20.0ms

Local error

Found 4 expressions with local error:

14.7b
(cbrt (* (* (- (log1p (exp x)) (* y x)) (- (log1p (exp x)) (* y x))) (- (log1p (exp x)) (* y x))))
0.6b
(* (- (log1p (exp x)) (* y x)) (- (log1p (exp x)) (* y x)))
0.5b
(log1p (exp x))
0.5b
(log1p (exp x))

rewrite58.0ms

Algorithm
rewrite-expression-head
Rules
33×flip--
33×flip3--
32×frac-times
26×cbrt-div
16×associate-*l/
10×associate-*r/
pow1
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-exp-log
prod-diff
add-cbrt-cube
expm1-log1p-u
distribute-lft-in
distribute-rgt-in
add-log-exp
log1p-expm1-u
associate-*l*
associate-*r*
log1p-expm1
sub-neg
log1p-udef
cbrt-unprod
rem-cbrt-cube
pow-prod-up
*-commutative
prod-exp
pow-prod-down
pow3
pow1/3
pow-plus
pow2
cbrt-prod
Counts
4 → 100
Calls
4 calls:
Slowest
37.0ms
(cbrt (* (* (- (log1p (exp x)) (* y x)) (- (log1p (exp x)) (* y x))) (- (log1p (exp x)) (* y x))))
18.0ms
(* (- (log1p (exp x)) (* y x)) (- (log1p (exp x)) (* y x)))
0.0ms
(log1p (exp x))
0.0ms
(log1p (exp x))

series243.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
82.0ms
(* (- (log1p (exp x)) (* y x)) (- (log1p (exp x)) (* y x)))
61.0ms
(log1p (exp x))
61.0ms
(log1p (exp x))
39.0ms
(cbrt (* (* (- (log1p (exp x)) (* y x)) (- (log1p (exp x)) (* y x))) (- (log1p (exp x)) (* y x))))

simplify23.4s

Counts
75 → 112
Calls
75 calls:
Slowest
1.4s
(* (fma (- x) y (* x y)) (- (log1p (exp x)) (* y x)))
1.4s
(* (fma (- x) y (* x y)) (- (log1p (exp x)) (* y x)))
1.3s
(* (fma (- x) y (* x y)) (- (log1p (exp x)) (* y x)))
1.3s
(* (- (log1p (exp x)) (* y x)) (fma (- x) y (* x y)))
1.2s
(* (- (log1p (exp x)) (* y x)) (fma (- x) y (* x y)))

prune1.8s

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.2b

localize37.0ms

Local error

Found 4 expressions with local error:

14.6b
(/ (- (pow (log1p (exp x)) 3) (pow (* y x) 3)) (+ (* (log1p (exp x)) (log1p (exp x))) (+ (* (* y x) (* y x)) (* (log1p (exp x)) (* y x)))))
0.7b
(pow (log1p (exp x)) 3)
0.7b
(* (log1p (exp x)) (log1p (exp x)))
0.5b
(log1p (exp x))

rewrite50.0ms

Algorithm
rewrite-expression-head
Rules
45×add-sqr-sqrt
29×*-un-lft-identity
24×times-frac
21×add-cube-cbrt
12×difference-of-squares
10×pow1
add-exp-log
add-cbrt-cube
associate-/l*
cube-prod
unpow-prod-down
expm1-log1p-u
add-log-exp
distribute-lft-out--
log1p-expm1-u
difference-cubes
associate-*l*
associate-*r*
associate-/r*
associate-/l/
associate-/r/
rem-cube-cbrt
flip--
div-inv
flip-+
cbrt-unprod
pow-prod-up
*-commutative
log1p-expm1
prod-exp
pow-exp
pow-prod-down
div-exp
div-sub
unpow3
flip3--
pow-plus
flip3-+
frac-2neg
pow-pow
clear-num
log1p-udef
cbrt-undiv
pow-to-exp
cube-mult
pow2
Counts
4 → 108
Calls
4 calls:
Slowest
40.0ms
(/ (- (pow (log1p (exp x)) 3) (pow (* y x) 3)) (+ (* (log1p (exp x)) (log1p (exp x))) (+ (* (* y x) (* y x)) (* (log1p (exp x)) (* y x)))))
4.0ms
(* (log1p (exp x)) (log1p (exp x)))
3.0ms
(log1p (exp x))
1.0ms
(pow (log1p (exp x)) 3)

series409.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
183.0ms
(/ (- (pow (log1p (exp x)) 3) (pow (* y x) 3)) (+ (* (log1p (exp x)) (log1p (exp x))) (+ (* (* y x) (* y x)) (* (log1p (exp x)) (* y x)))))
105.0ms
(pow (log1p (exp x)) 3)
67.0ms
(* (log1p (exp x)) (log1p (exp x)))
55.0ms
(log1p (exp x))

simplify12.9s

Counts
97 → 120
Calls
97 calls:
Slowest
455.0ms
(/ (cbrt (- (pow (log1p (exp x)) 3) (pow (* y x) 3))) (sqrt (+ (* (log1p (exp x)) (log1p (exp x))) (+ (* (* y x) (* y x)) (* (log1p (exp x)) (* y x))))))
401.0ms
(- (* (pow (log1p (exp x)) 3) (pow (log1p (exp x)) 3)) (* (pow (* y x) 3) (pow (* y x) 3)))
399.0ms
(/ (* (cbrt (- (pow (log1p (exp x)) 3) (pow (* y x) 3))) (cbrt (- (pow (log1p (exp x)) 3) (pow (* y x) 3)))) 1)
390.0ms
(/ (cbrt (- (pow (log1p (exp x)) 3) (pow (* y x) 3))) (+ (* (log1p (exp x)) (log1p (exp x))) (+ (* (* y x) (* y x)) (* (log1p (exp x)) (* y x)))))
381.0ms
(/ (* (cbrt (- (pow (log1p (exp x)) 3) (pow (* y x) 3))) (cbrt (- (pow (log1p (exp x)) 3) (pow (* y x) 3)))) (sqrt (+ (* (log1p (exp x)) (log1p (exp x))) (+ (* (* y x) (* y x)) (* (log1p (exp x)) (* y x))))))

prune1.8s

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0.2b

localize23.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
Rules
add-log-exp
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
prod-diff
fma-neg
log1p-expm1-u
fma-udef
add-exp-log
add-cbrt-cube
pow1
expm1-log1p-u
flip--
associate--l+
diff-log
flip3--
sub-neg
Counts
2 → 31
Calls
2 calls:
Slowest
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))

series68.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
38.0ms
(- (fma x (fma 1/8 x 1/2) (log 2)) (* y x))
30.0ms
(fma x (fma 1/8 x 1/2) (log 2))

simplify912.0ms

Counts
16 → 37
Calls
16 calls:
Slowest
176.0ms
(- (+ (* 1/2 x) (* 1/8 (pow x 2))) (* x y))
145.0ms
(- (+ (* 1/2 x) (* 1/8 (pow x 2))) (* x y))
99.0ms
(/ (exp (fma x (fma 1/8 x 1/2) (log 2))) (exp (* y x)))
88.0ms
(fma (* (cbrt (fma x (fma 1/8 x 1/2) (log 2))) (cbrt (fma x (fma 1/8 x 1/2) (log 2)))) (cbrt (fma x (fma 1/8 x 1/2) (log 2))) (- (* x y)))
81.0ms
(fma 1 (fma x (fma 1/8 x 1/2) (log 2)) (- (* x y)))

prune363.0ms

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0.2b

regimes61.0ms

Accuracy

0% (0.2b remaining)

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

bsearch1.0ms

end0.0ms

sample4.4s

Algorithm
intervals