Average Error: 29.7 → 0.0
Time: 14.8s
Precision: 64
Internal Precision: 128
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.007001752143352149 \lor \neg \left(x \le 0.00831717270129426\right):\\ \;\;\;\;\log \left(e^{\frac{2}{e^{-2 \cdot x} + 1} - 1}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{2}{15} \cdot {x}^{5} + x\right) - {x}^{3} \cdot \frac{1}{3}\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -0.007001752143352149 or 0.00831717270129426 < x

    1. Initial program 0.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Initial simplification0.0

      \[\leadsto \frac{2}{1 + e^{-2 \cdot x}} - 1\]
    3. Using strategy rm
    4. Applied add-log-exp0.0

      \[\leadsto \color{blue}{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\]

    if -0.007001752143352149 < x < 0.00831717270129426

    1. Initial program 58.9

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Initial simplification58.9

      \[\leadsto \frac{2}{1 + e^{-2 \cdot x}} - 1\]
    3. Taylor expanded around 0 0.0

      \[\leadsto \color{blue}{\left(x + \frac{2}{15} \cdot {x}^{5}\right) - \frac{1}{3} \cdot {x}^{3}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.007001752143352149 \lor \neg \left(x \le 0.00831717270129426\right):\\ \;\;\;\;\log \left(e^{\frac{2}{e^{-2 \cdot x} + 1} - 1}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{2}{15} \cdot {x}^{5} + x\right) - {x}^{3} \cdot \frac{1}{3}\\ \end{array}\]

Reproduce

herbie shell --seed 2018365 
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  (- (/ 2 (+ 1 (exp (* -2 x)))) 1))

Details

Time bar (total: 8.9s)Debug log

start114.0ms

Algorithm
intervals

setup18.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 28.6b

localize25.0ms

Local error

Found 3 expressions with local error:

3.6b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
0.0b
(/ 2 (+ 1 (exp (* -2 x))))
0.0b
(+ 1 (exp (* -2 x)))

rewrite31.0ms

Algorithm
rewrite-expression-head
Counts
3 → 37
Calls

3 calls. Slowest were:

8.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
2.0ms
(+ 1 (exp (* -2 x)))
1.0ms
(/ 2 (+ 1 (exp (* -2 x))))

series83.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

60.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
15.0ms
(/ 2 (+ 1 (exp (* -2 x))))
8.0ms
(+ 1 (exp (* -2 x)))

simplify560.0ms

Counts
15 → 46
Calls

15 calls. Slowest were:

223.0ms
(- (+ (* 2 (pow x 2)) 2) (* 2 x))
73.0ms
(+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x)))))
66.0ms
(- (+ x 1) (* 1/3 (pow x 3)))

prune590.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.0b

localize6.0ms

Local error

Found 4 expressions with local error:

3.6b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
3.6b
(log (exp (- (/ 2 (+ 1 (exp (* -2 x)))) 1)))
0.0b
(/ 2 (+ 1 (exp (* -2 x))))
0.0b
(+ 1 (exp (* -2 x)))

rewrite15.0ms

Algorithm
rewrite-expression-head
Counts
4 → 56
Calls

4 calls. Slowest were:

9.0ms
(log (exp (- (/ 2 (+ 1 (exp (* -2 x)))) 1)))
4.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
1.0ms
(+ 1 (exp (* -2 x)))

series149.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

58.0ms
(log (exp (- (/ 2 (+ 1 (exp (* -2 x)))) 1)))
55.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
26.0ms
(/ 2 (+ 1 (exp (* -2 x))))
9.0ms
(+ 1 (exp (* -2 x)))

simplify765.0ms

Counts
29 → 68
Calls

29 calls. Slowest were:

167.0ms
(- (+ (* 2 (pow x 2)) 2) (* 2 x))
95.0ms
(+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x)))))
87.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

prune842.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize10.0ms

Local error

Found 4 expressions with local error:

3.6b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
3.6b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
3.6b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
3.6b
(log (exp (- (/ 2 (+ 1 (exp (* -2 x)))) 1)))

rewrite23.0ms

Algorithm
rewrite-expression-head
Counts
4 → 55
Calls

4 calls. Slowest were:

9.0ms
(log (exp (- (/ 2 (+ 1 (exp (* -2 x)))) 1)))
4.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
4.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)

series200.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

64.0ms
(log (exp (- (/ 2 (+ 1 (exp (* -2 x)))) 1)))
48.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
45.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
44.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)

simplify718.0ms

Counts
26 → 67
Calls

26 calls. Slowest were:

99.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
79.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
67.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

prune1.1s

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize15.0ms

Local error

Found 4 expressions with local error:

3.6b
(log (sqrt (exp (- (/ 2 (+ 1 (exp (* -2 x)))) 1))))
3.6b
(log (sqrt (exp (- (/ 2 (+ 1 (exp (* -2 x)))) 1))))
3.6b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
3.6b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)

rewrite30.0ms

Algorithm
rewrite-expression-head
Counts
4 → 62
Calls

4 calls. Slowest were:

8.0ms
(log (sqrt (exp (- (/ 2 (+ 1 (exp (* -2 x)))) 1))))
8.0ms
(log (sqrt (exp (- (/ 2 (+ 1 (exp (* -2 x)))) 1))))
8.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)

series556.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

238.0ms
(log (sqrt (exp (- (/ 2 (+ 1 (exp (* -2 x)))) 1))))
211.0ms
(log (sqrt (exp (- (/ 2 (+ 1 (exp (* -2 x)))) 1))))
61.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
46.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)

simplify885.0ms

Counts
34 → 74
Calls

34 calls. Slowest were:

86.0ms
(- (+ (* 1/2 x) (* 1/15 (pow x 5))) (* 1/6 (pow x 3)))
80.0ms
(log (sqrt (exp (- (* 2 (/ 1 (+ (exp (* -2 x)) 1))) 1))))
74.0ms
(- (+ (* 1/2 x) (* 1/15 (pow x 5))) (* 1/6 (pow x 3)))

prune1.3s

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

regimes712.0ms

Accuracy

100% (0.0b remaining)

Error of 0.0b against oracle of 0.0b and baseline of 29.7b

bsearch193.0ms