Average Error: 30.5 → 0.2
Time: 29.1s
Precision: 64
Internal Precision: 128
\[\frac{1 - \cos x}{x \cdot x}\]
\[\frac{\sin x}{x} \cdot \frac{\sin \left(\frac{x}{2}\right)}{x \cdot \cos \left(\frac{x}{2}\right)}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 30.5

    \[\frac{1 - \cos x}{x \cdot x}\]
  2. Using strategy rm
  3. Applied flip--30.6

    \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}}{x \cdot x}\]
  4. Applied associate-/l/30.6

    \[\leadsto \color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}}\]
  5. Simplified14.9

    \[\leadsto \frac{\color{blue}{\sin x \cdot \sin x}}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}\]
  6. Using strategy rm
  7. Applied associate-/r*14.9

    \[\leadsto \color{blue}{\frac{\frac{\sin x \cdot \sin x}{x \cdot x}}{1 + \cos x}}\]
  8. Using strategy rm
  9. Applied *-un-lft-identity14.9

    \[\leadsto \frac{\frac{\sin x \cdot \sin x}{x \cdot x}}{\color{blue}{1 \cdot \left(1 + \cos x\right)}}\]
  10. Applied times-frac0.3

    \[\leadsto \frac{\color{blue}{\frac{\sin x}{x} \cdot \frac{\sin x}{x}}}{1 \cdot \left(1 + \cos x\right)}\]
  11. Applied times-frac0.3

    \[\leadsto \color{blue}{\frac{\frac{\sin x}{x}}{1} \cdot \frac{\frac{\sin x}{x}}{1 + \cos x}}\]
  12. Simplified0.3

    \[\leadsto \color{blue}{\frac{\sin x}{x}} \cdot \frac{\frac{\sin x}{x}}{1 + \cos x}\]
  13. Simplified0.1

    \[\leadsto \frac{\sin x}{x} \cdot \color{blue}{\frac{\tan \left(\frac{x}{2}\right)}{x}}\]
  14. Using strategy rm
  15. Applied tan-quot0.1

    \[\leadsto \frac{\sin x}{x} \cdot \frac{\color{blue}{\frac{\sin \left(\frac{x}{2}\right)}{\cos \left(\frac{x}{2}\right)}}}{x}\]
  16. Applied associate-/l/0.2

    \[\leadsto \frac{\sin x}{x} \cdot \color{blue}{\frac{\sin \left(\frac{x}{2}\right)}{x \cdot \cos \left(\frac{x}{2}\right)}}\]
  17. Final simplification0.2

    \[\leadsto \frac{\sin x}{x} \cdot \frac{\sin \left(\frac{x}{2}\right)}{x \cdot \cos \left(\frac{x}{2}\right)}\]

Reproduce

herbie shell --seed 1137770271 
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))

Details

Time bar (total: 28.1s)Debug log

sample207.0ms

Algorithm
intervals
Results
58×88.0ms(body real 2560)
35×34.0ms(body real 1280)
46×34.0ms(body real 640)
36×19.0ms(body real 320)
69×12.0ms(body real 80)
256×6.0ms(pre true 80)
12×4.0ms(body real 160)

simplify30.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
30.0ms
(/ (- 1 (cos x)) (* x x))

prune11.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 34.0b

localize31.0ms

Local error

Found 2 expressions with local error:

16.8b
(/ (- 1 (cos x)) (* x x))
1.2b
(- 1 (cos x))

rewrite33.0ms

Algorithm
rewrite-expression-head
Rules
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
add-sqr-sqrt
associate-/l*
times-frac
associate-/l/
add-log-exp
flip--
flip3--
pow1
div-inv
div-exp
div-sub
frac-2neg
sub-neg
associate-/r*
clear-num
cbrt-undiv
Counts
2 → 33
Calls
2 calls:
Slowest
30.0ms
(/ (- 1 (cos x)) (* x x))
2.0ms
(- 1 (cos x))

series99.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
62.0ms
(/ (- 1 (cos x)) (* x x))
36.0ms
(- 1 (cos x))

simplify947.0ms

Counts
19 → 39
Calls
19 calls:
Slowest
548.0ms
(/ (* (* (- 1 (cos x)) (- 1 (cos x))) (- 1 (cos x))) (* (* (* x x) (* x x)) (* x x)))
84.0ms
(- (+ (* 1/2 (pow x 2)) (* 1/720 (pow x 6))) (* 1/24 (pow x 4)))
84.0ms
(- (+ (* 1/720 (pow x 4)) 1/2) (* 1/24 (pow x 2)))
43.0ms
(- (log (- 1 (cos x))) (log (* x x)))
32.0ms
(/ (- 1 (cos x)) (pow x 2))

prune539.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.0b

localize42.0ms

Local error

Found 4 expressions with local error:

16.5b
(/ (* (sin x) (sin x)) (* (* x x) (+ 1 (cos x))))
0.3b
(+ 1 (cos x))
0.3b
(* (* x x) (+ 1 (cos x)))
0.3b
(* (sin x) (sin x))

rewrite42.0ms

Algorithm
rewrite-expression-head
Rules
20×add-exp-log
20×add-cbrt-cube
11×pow1
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
cbrt-unprod
prod-exp
associate-*r*
add-log-exp
associate-*r/
associate-*l*
div-exp
cbrt-undiv
flip-+
flip3-+
sin-mult
sqr-sin
*-commutative
associate-/r/
pow-prod-down
associate-/l/
associate-/l*
div-inv
pow-prod-up
div-sub
pow-plus
times-frac
distribute-lft-in
frac-2neg
associate-/r*
clear-num
+-commutative
distribute-rgt-in
pow2
Counts
4 → 76
Calls
4 calls:
Slowest
20.0ms
(/ (* (sin x) (sin x)) (* (* x x) (+ 1 (cos x))))
9.0ms
(* (* x x) (+ 1 (cos x)))
9.0ms
(* (sin x) (sin x))
2.0ms
(+ 1 (cos x))

series185.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
84.0ms
(/ (* (sin x) (sin x)) (* (* x x) (+ 1 (cos x))))
49.0ms
(* (* x x) (+ 1 (cos x)))
34.0ms
(* (sin x) (sin x))
18.0ms
(+ 1 (cos x))

simplify7.4s

Counts
51 → 88
Calls
51 calls:
Slowest
1.4s
(* (* (* (* x x) (* x x)) (* x x)) (* (* (+ 1 (cos x)) (+ 1 (cos x))) (+ 1 (cos x))))
609.0ms
(/ (* (* (* (sin x) (sin x)) (sin x)) (* (* (sin x) (sin x)) (sin x))) (* (* (* (* x x) (+ 1 (cos x))) (* (* x x) (+ 1 (cos x)))) (* (* x x) (+ 1 (cos x)))))
524.0ms
(/ (* (* (* (sin x) (sin x)) (* (sin x) (sin x))) (* (sin x) (sin x))) (* (* (* (* x x) (+ 1 (cos x))) (* (* x x) (+ 1 (cos x)))) (* (* x x) (+ 1 (cos x)))))
501.0ms
(- (+ (log (sin x)) (log (sin x))) (log (* (* x x) (+ 1 (cos x)))))
488.0ms
(- (+ (log (sin x)) (log (sin x))) (+ (log (* x x)) (log (+ 1 (cos x)))))

prune1.5s

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 0b

localize16.0ms

Local error

Found 4 expressions with local error:

16.6b
(/ (* (sin x) (sin x)) (* x x))
0.3b
(+ 1 (cos x))
0.3b
(* (sin x) (sin x))
0.1b
(/ (/ (* (sin x) (sin x)) (* x x)) (+ 1 (cos x)))

rewrite46.0ms

Algorithm
rewrite-expression-head
Rules
20×add-exp-log
20×add-cbrt-cube
20×times-frac
16×add-cube-cbrt
16×*-un-lft-identity
16×add-sqr-sqrt
pow1
div-exp
cbrt-undiv
associate-/l*
div-inv
add-log-exp
associate-/r*
sqr-sin
cbrt-unprod
prod-exp
associate-*l*
associate-*r*
div-sub
associate-/l/
sin-mult
flip-+
associate-/r/
flip3-+
frac-2neg
clear-num
pow-prod-up
*-commutative
pow-prod-down
pow-plus
+-commutative
pow2
Counts
4 → 94
Calls
4 calls:
Slowest
18.0ms
(/ (/ (* (sin x) (sin x)) (* x x)) (+ 1 (cos x)))
15.0ms
(/ (* (sin x) (sin x)) (* x x))
9.0ms
(* (sin x) (sin x))
2.0ms
(+ 1 (cos x))

series189.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
83.0ms
(/ (/ (* (sin x) (sin x)) (* x x)) (+ 1 (cos x)))
57.0ms
(/ (* (sin x) (sin x)) (* x x))
31.0ms
(* (sin x) (sin x))
17.0ms
(+ 1 (cos x))

simplify5.1s

Counts
81 → 106
Calls
81 calls:
Slowest
503.0ms
(- (log (/ (* (sin x) (sin x)) (* x x))) (log (+ 1 (cos x))))
322.0ms
(/ (pow (sin x) 2) (* (pow x 2) (+ (cos x) 1)))
321.0ms
(/ (pow (sin x) 2) (* (pow x 2) (+ (cos x) 1)))
311.0ms
(/ (/ (* (* (* (sin x) (sin x)) (* (sin x) (sin x))) (* (sin x) (sin x))) (* (* (* x x) (* x x)) (* x x))) (* (* (+ 1 (cos x)) (+ 1 (cos x))) (+ 1 (cos x))))
301.0ms
(/ (/ (* (* (* (sin x) (sin x)) (sin x)) (* (* (sin x) (sin x)) (sin x))) (* (* (* x x) (* x x)) (* x x))) (* (* (+ 1 (cos x)) (+ 1 (cos x))) (+ 1 (cos x))))

prune1.6s

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0b

localize39.0ms

Local error

Found 3 expressions with local error:

0.1b
(/ (sin x) x)
0.1b
(/ (tan (/ x 2)) x)
0.1b
(* (/ (sin x) x) (/ (tan (/ x 2)) x))

rewrite32.0ms

Algorithm
rewrite-expression-head
Rules
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
associate-/l*
add-exp-log
add-cbrt-cube
pow1
div-inv
associate-*l*
associate-*r*
add-log-exp
frac-2neg
clear-num
associate-/l/
cbrt-unprod
*-commutative
associate-*r/
tan-quot
prod-exp
associate-*l/
pow-prod-down
frac-times
Counts
3 → 49
Calls
3 calls:
Slowest
17.0ms
(* (/ (sin x) x) (/ (tan (/ x 2)) x))
8.0ms
(/ (tan (/ x 2)) x)
6.0ms
(/ (sin x) x)

series234.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
121.0ms
(* (/ (sin x) x) (/ (tan (/ x 2)) x))
70.0ms
(/ (tan (/ x 2)) x)
42.0ms
(/ (sin x) x)

simplify1.6s

Counts
27 → 58
Calls
27 calls:
Slowest
708.0ms
(* (* (* (/ (sin x) x) (/ (sin x) x)) (/ (sin x) x)) (* (* (/ (tan (/ x 2)) x) (/ (tan (/ x 2)) x)) (/ (tan (/ x 2)) x)))
255.0ms
(/ (* (sin x) (sin (* 1/2 x))) (* (cos (* 1/2 x)) (pow x 2)))
235.0ms
(/ (* (sin x) (sin (* 1/2 x))) (* (cos (* 1/2 x)) (pow x 2)))
128.0ms
(+ (log (/ (sin x) x)) (log (/ (tan (/ x 2)) x)))
84.0ms
(- (+ (* 1/120 (pow x 4)) 1) (* 1/6 (pow x 2)))

prune864.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0b

regimes58.0ms

Accuracy

0% (0.1b remaining)

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

bsearch3.0ms

end0.0ms

sample7.1s

Algorithm
intervals
Results
1573×2.6s(body real 2560)
1470×1.6s(body real 640)
1203×1.3s(body real 1280)
991×652.0ms(body real 320)
2267×454.0ms(body real 80)
496×215.0ms(body real 160)
8000×207.0ms(pre true 80)