Average Error: 29.6 → 0.0
Time: 8.4s
Precision: 64
Internal Precision: 128
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.007379778048640885:\\ \;\;\;\;\sqrt[3]{\left(\frac{2}{e^{-2 \cdot x} + 1} - 1\right) \cdot \left(\log \left(e^{\frac{2}{e^{-2 \cdot x} + 1} - 1}\right) \cdot \log \left(e^{\frac{2}{e^{-2 \cdot x} + 1} - 1}\right)\right)}\\ \mathbf{elif}\;x \le 0.006295141041971404:\\ \;\;\;\;\left(x + {x}^{5} \cdot \frac{2}{15}\right) - {x}^{3} \cdot \frac{1}{3}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\left(\log \left(e^{\frac{\frac{2}{e^{-2 \cdot x} + 1} \cdot \frac{2}{e^{-2 \cdot x} + 1} - 1}{1 + \frac{2}{e^{-2 \cdot x} + 1}}}\right) \cdot \log \left(e^{\frac{2}{e^{-2 \cdot x} + 1} - 1}\right)\right) \cdot \left(\sqrt[3]{\log \left(e^{\frac{2}{e^{-2 \cdot x} + 1} - 1}\right)} \cdot \left(\sqrt[3]{\log \left(e^{\frac{2}{e^{-2 \cdot x} + 1} - 1}\right)} \cdot \sqrt[3]{\log \left(e^{\frac{2}{e^{-2 \cdot x} + 1} - 1}\right)}\right)\right)}\\ \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 3 regimes
  2. if x < -0.007379778048640885

    1. Initial program 0.0

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

      \[\leadsto \color{blue}{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\]
    4. Using strategy rm
    5. Applied add-cbrt-cube0.0

      \[\leadsto \color{blue}{\sqrt[3]{\left(\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right) \cdot \log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)\right) \cdot \log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}}\]
    6. Taylor expanded around inf 0.0

      \[\leadsto \sqrt[3]{\left(\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right) \cdot \log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)\right) \cdot \color{blue}{\left(2 \cdot \frac{1}{e^{-2 \cdot x} + 1} - 1\right)}}\]
    7. Simplified0.0

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

    if -0.007379778048640885 < x < 0.006295141041971404

    1. Initial program 58.9

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Using strategy rm
    3. Applied add-log-exp58.9

      \[\leadsto \color{blue}{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\]
    4. Taylor expanded around 0 0.0

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

    if 0.006295141041971404 < x

    1. Initial program 0.0

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

      \[\leadsto \color{blue}{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\]
    4. Using strategy rm
    5. Applied add-cbrt-cube0.0

      \[\leadsto \color{blue}{\sqrt[3]{\left(\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right) \cdot \log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)\right) \cdot \log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt0.0

      \[\leadsto \sqrt[3]{\left(\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right) \cdot \log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)\right) \cdot \color{blue}{\left(\left(\sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\right) \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\right)}}\]
    8. Using strategy rm
    9. Applied flip--0.0

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

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

Reproduce

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

Details

Time bar (total: 7.9s)Debug log

sample92.0ms

Algorithm
intervals

simplify29.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

29.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)

prune10.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.4b

localize26.0ms

Local error

Found 2 expressions with local error:

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

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
2 → 22
Calls

2 calls. Slowest were:

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

series52.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

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

simplify282.0ms

Counts
7 → 28
Calls

7 calls. Slowest were:

165.0ms
(- (+ (* 2 (pow x 2)) 2) (* 2 x))
53.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
32.0ms
(- (* 2 (/ 1 (+ (exp (* -2 x)) 1))) 1)

prune242.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize6.0ms

Local error

Found 3 expressions with local error:

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

rewrite14.0ms

Algorithm
rewrite-expression-head
Counts
3 → 41
Calls

3 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)))

series84.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify387.0ms

Counts
21 → 50
Calls

21 calls. Slowest were:

127.0ms
(- (+ (* 2 (pow x 2)) 2) (* 2 x))
45.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
45.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

prune395.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.0b

localize9.0ms

Local error

Found 4 expressions with local error:

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

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

series231.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

60.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
58.0ms
(log (exp (- (/ 2 (+ 1 (exp (* -2 x)))) 1)))
57.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
55.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)

simplify545.0ms

Counts
26 → 67
Calls

26 calls. Slowest were:

70.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
61.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
60.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

prune934.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize19.0ms

Local error

Found 4 expressions with local error:

2.8b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
2.8b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
2.8b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
2.8b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)

rewrite16.0ms

Algorithm
rewrite-expression-head
Counts
4 → 48
Calls

4 calls. Slowest were:

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

series212.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

60.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
57.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
57.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
38.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)

simplify373.0ms

Counts
16 → 60
Calls

16 calls. Slowest were:

46.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
45.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
45.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

prune874.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

regimes425.0ms

Accuracy

100% (0.0b remaining)

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

bsearch248.0ms

end0.0ms

sample2.3s

Algorithm
intervals