Average Error: 29.2 → 0.0
Time: 25.4s
Precision: 64
Internal Precision: 128
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.007795368062903516 \lor \neg \left(x \le 0.006166302486698174\right):\\ \;\;\;\;\sqrt[3]{\left(\frac{2}{e^{-2 \cdot x} + 1} - 1\right) \cdot \left(\left(\frac{2}{e^{-2 \cdot x} + 1} - 1\right) \cdot \left(\frac{2}{e^{-2 \cdot x} + 1} - 1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(x + \frac{2}{15} \cdot {x}^{5}\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.007795368062903516 or 0.006166302486698174 < 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-cbrt-cube0.0

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

    if -0.007795368062903516 < x < 0.006166302486698174

    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.007795368062903516 \lor \neg \left(x \le 0.006166302486698174\right):\\ \;\;\;\;\sqrt[3]{\left(\frac{2}{e^{-2 \cdot x} + 1} - 1\right) \cdot \left(\left(\frac{2}{e^{-2 \cdot x} + 1} - 1\right) \cdot \left(\frac{2}{e^{-2 \cdot x} + 1} - 1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(x + \frac{2}{15} \cdot {x}^{5}\right) - {x}^{3} \cdot \frac{1}{3}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 20.0s)Debug log

start181.0ms

Algorithm
intervals

setup40.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 33.1b

localize29.0ms

Local error

Found 3 expressions with local error:

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

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
3 → 50
Calls

3 calls. Slowest were:

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

series101.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

63.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
26.0ms
(/ 2 (+ 1 (exp (* -2 x))))
12.0ms
(+ 1 (exp (* -2 x)))

simplify684.0ms

Counts
20 → 59
Calls

20 calls. Slowest were:

158.0ms
(- (+ (* 2 (pow x 2)) 2) (* 2 x))
134.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
132.0ms
(+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x)))))

prune754.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize22.0ms

Local error

Found 3 expressions with local error:

14.5b
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
0.2b
(* 1/3 (pow x 3))
0.1b
(* 2/15 (pow x 5))

rewrite8.0ms

Algorithm
rewrite-expression-head
Counts
3 → 49
Calls

3 calls. Slowest were:

5.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
1.0ms
(* 1/3 (pow x 3))
1.0ms
(* 2/15 (pow x 5))

series95.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

33.0ms
(* 2/15 (pow x 5))
31.0ms
(* 1/3 (pow x 3))
31.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

simplify1.1s

Counts
25 → 58
Calls

25 calls. Slowest were:

198.0ms
(fma 1 (+ x (* 2/15 (pow x 5))) (- (* (pow x 3) 1/3)))
159.0ms
(/ (exp (+ x (* 2/15 (pow x 5)))) (exp (* 1/3 (pow x 3))))
130.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

prune917.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize10.0ms

Local error

Found 4 expressions with local error:

4.1b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
4.1b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
4.1b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
0.1b
(cbrt (* (* (- (/ 2 (+ 1 (exp (* -2 x)))) 1) (- (/ 2 (+ 1 (exp (* -2 x)))) 1)) (- (/ 2 (+ 1 (exp (* -2 x)))) 1)))

rewrite40.0ms

Algorithm
rewrite-expression-head
Counts
4 → 101
Calls

4 calls. Slowest were:

20.0ms
(cbrt (* (* (- (/ 2 (+ 1 (exp (* -2 x)))) 1) (- (/ 2 (+ 1 (exp (* -2 x)))) 1)) (- (/ 2 (+ 1 (exp (* -2 x)))) 1)))
7.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
7.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)

series169.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

58.0ms
(cbrt (* (* (- (/ 2 (+ 1 (exp (* -2 x)))) 1) (- (/ 2 (+ 1 (exp (* -2 x)))) 1)) (- (/ 2 (+ 1 (exp (* -2 x)))) 1)))
39.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
37.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
36.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)

simplify10.1s

Counts
58 → 113
Calls

58 calls. Slowest were:

957.0ms
(cbrt (* (* (- (pow (/ 2 (+ 1 (exp (* -2 x)))) 3) (pow 1 3)) (- (* (/ 2 (+ 1 (exp (* -2 x)))) (/ 2 (+ 1 (exp (* -2 x))))) (* 1 1))) (- (pow (/ 2 (+ 1 (exp (* -2 x)))) 3) (pow 1 3))))
946.0ms
(cbrt (* (* (- (pow (/ 2 (+ 1 (exp (* -2 x)))) 3) (pow 1 3)) (- (/ 2 (+ 1 (exp (* -2 x)))) 1)) (- (pow (/ 2 (+ 1 (exp (* -2 x)))) 3) (pow 1 3))))
943.0ms
(cbrt (* (* (- (pow (/ 2 (+ 1 (exp (* -2 x)))) 3) (pow 1 3)) (- (* (/ 2 (+ 1 (exp (* -2 x)))) (/ 2 (+ 1 (exp (* -2 x))))) (* 1 1))) (- (* (/ 2 (+ 1 (exp (* -2 x)))) (/ 2 (+ 1 (exp (* -2 x))))) (* 1 1))))

prune1.6s

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0.0b

localize53.0ms

Local error

Found 4 expressions with local error:

4.3b
(fma (/ 2 (+ 1 (exp (* x -6)))) (+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))) (- 1))
4.2b
(- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))
0.0b
(* (exp (* -2 x)) (exp (* -2 x)))
0.0b
(/ 2 (+ 1 (exp (* x -6))))

rewrite31.0ms

Algorithm
rewrite-expression-head
Counts
4 → 68
Calls

4 calls. Slowest were:

16.0ms
(- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))
12.0ms
(* (exp (* -2 x)) (exp (* -2 x)))
1.0ms
(/ 2 (+ 1 (exp (* x -6))))

series196.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

143.0ms
(fma (/ 2 (+ 1 (exp (* x -6)))) (+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))) (- 1))
26.0ms
(- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))
17.0ms
(/ 2 (+ 1 (exp (* x -6))))
10.0ms
(* (exp (* -2 x)) (exp (* -2 x)))

simplify1.9s

Counts
37 → 80
Calls

37 calls. Slowest were:

343.0ms
(- (+ (* 2 (/ (pow (exp (* -2 x)) 2) (+ (exp (* -6 x)) 1))) (* 2 (/ 1 (+ (exp (* -6 x)) 1)))) (+ (* 2 (/ (exp (* -2 x)) (+ (exp (* -6 x)) 1))) 1))
319.0ms
(- (* 6 (pow x 2)) (+ (* 2 x) (* 28/3 (pow x 3))))
290.0ms
(- (+ (* 2 (/ (pow (exp (* -2 x)) 2) (+ (exp (* -6 x)) 1))) (* 2 (/ 1 (+ (exp (* -6 x)) 1)))) (+ (* 2 (/ (exp (* -2 x)) (+ (exp (* -6 x)) 1))) 1))

prune1.4s

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0.0b

regimes363.0ms

Accuracy

100% (0.0b remaining)

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

bsearch181.0ms