Average Error: 30.7 → 0.2
Time: 23.4s
Precision: 64
Internal Precision: 128
\[\frac{1 - \cos x}{x \cdot x}\]
\[\frac{\frac{1}{x}}{\frac{\frac{x}{\sin x}}{\tan \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.7

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

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

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

    \[\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 clear-num15.0

    \[\leadsto \color{blue}{\frac{1}{\frac{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}{\sin x \cdot \sin x}}}\]
  8. Taylor expanded around -inf 15.0

    \[\leadsto \frac{1}{\color{blue}{\frac{{x}^{2} \cdot \left(\cos x + 1\right)}{{\left(\sin x\right)}^{2}}}}\]
  9. Simplified15.3

    \[\leadsto \frac{1}{\color{blue}{\frac{\frac{x \cdot x}{\sin x}}{\tan \left(\frac{x}{2}\right)}}}\]
  10. Using strategy rm
  11. Applied *-un-lft-identity15.3

    \[\leadsto \frac{1}{\frac{\frac{x \cdot x}{\sin x}}{\color{blue}{1 \cdot \tan \left(\frac{x}{2}\right)}}}\]
  12. Applied *-un-lft-identity15.3

    \[\leadsto \frac{1}{\frac{\frac{x \cdot x}{\color{blue}{1 \cdot \sin x}}}{1 \cdot \tan \left(\frac{x}{2}\right)}}\]
  13. Applied times-frac0.4

    \[\leadsto \frac{1}{\frac{\color{blue}{\frac{x}{1} \cdot \frac{x}{\sin x}}}{1 \cdot \tan \left(\frac{x}{2}\right)}}\]
  14. Applied times-frac0.5

    \[\leadsto \frac{1}{\color{blue}{\frac{\frac{x}{1}}{1} \cdot \frac{\frac{x}{\sin x}}{\tan \left(\frac{x}{2}\right)}}}\]
  15. Applied associate-/r*0.2

    \[\leadsto \color{blue}{\frac{\frac{1}{\frac{\frac{x}{1}}{1}}}{\frac{\frac{x}{\sin x}}{\tan \left(\frac{x}{2}\right)}}}\]
  16. Final simplification0.2

    \[\leadsto \frac{\frac{1}{x}}{\frac{\frac{x}{\sin x}}{\tan \left(\frac{x}{2}\right)}}\]

Reproduce

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

Details

Time bar (total: 22.8s)Debug log

sample160.0ms

Algorithm
intervals
Results
256×(pre true 80)
76×(body real 80)
47×(body real 2560)
45×(body real 640)
42×(body real 1280)
31×(body real 320)
15×(body real 160)

simplify14.0ms

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

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 30.4b

localize11.0ms

Local error

Found 2 expressions with local error:

14.4b
(/ (- 1 (cos x)) (* x x))
1.9b
(- 1 (cos x))

rewrite6.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
5.0ms
(/ (- 1 (cos x)) (* x x))
1.0ms
(- 1 (cos x))

series110.0ms

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

simplify745.0ms

Counts
19 → 39
Calls
19 calls:
Slowest
440.0ms
(/ (* (* (- 1 (cos x)) (- 1 (cos x))) (- 1 (cos x))) (* (* (* x x) (* x x)) (* x x)))
68.0ms
(- (+ (* 1/2 (pow x 2)) (* 1/720 (pow x 6))) (* 1/24 (pow x 4)))
67.0ms
(- (+ (* 1/720 (pow x 4)) 1/2) (* 1/24 (pow x 2)))
40.0ms
(- (log (- 1 (cos x))) (log (* x x)))
18.0ms
(- (pow 1 3) (pow (cos x) 3))

prune350.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0.0b

localize13.0ms

Local error

Found 4 expressions with local error:

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

rewrite19.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
8.0ms
(/ (* (sin x) (sin x)) (* (* x x) (+ 1 (cos x))))
6.0ms
(* (sin x) (sin x))
3.0ms
(* (* x x) (+ 1 (cos x)))
1.0ms
(+ 1 (cos x))

series104.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
46.0ms
(/ (* (sin x) (sin x)) (* (* x x) (+ 1 (cos x))))
30.0ms
(* (* x x) (+ 1 (cos x)))
19.0ms
(* (sin x) (sin x))
9.0ms
(+ 1 (cos x))

simplify5.0s

Counts
51 → 88
Calls
51 calls:
Slowest
1.2s
(* (* (* (* x x) (* x x)) (* x x)) (* (* (+ 1 (cos x)) (+ 1 (cos x))) (+ 1 (cos x))))
417.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)))))
391.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)))))
362.0ms
(- (+ (log (sin x)) (log (sin x))) (+ (log (* x x)) (log (+ 1 (cos x)))))
343.0ms
(- (log (* (sin x) (sin x))) (log (* (* x x) (+ 1 (cos x)))))

prune735.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 0.0b

localize9.0ms

Local error

Found 4 expressions with local error:

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

rewrite17.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-+
associate-/l/
sin-mult
*-commutative
pow-prod-down
associate-/l*
div-inv
sqr-sin
pow-prod-up
associate-/r/
pow-plus
times-frac
distribute-lft-in
frac-2neg
associate-/r*
clear-num
+-commutative
distribute-rgt-in
pow2
Counts
4 → 75
Calls
4 calls:
Slowest
8.0ms
(/ (* (* x x) (+ 1 (cos x))) (* (sin x) (sin x)))
3.0ms
(* (* x x) (+ 1 (cos x)))
3.0ms
(* (sin x) (sin x))
1.0ms
(+ 1 (cos x))

series120.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
60.0ms
(/ (* (* x x) (+ 1 (cos x))) (* (sin x) (sin x)))
30.0ms
(* (* x x) (+ 1 (cos x)))
22.0ms
(* (sin x) (sin x))
8.0ms
(+ 1 (cos x))

simplify5.4s

Counts
49 → 87
Calls
49 calls:
Slowest
856.0ms
(* (* (* (* x x) (* x x)) (* x x)) (* (* (+ 1 (cos x)) (+ 1 (cos x))) (+ 1 (cos x))))
571.0ms
(/ (* (pow x 2) (+ (cos x) 1)) (pow (sin x) 2))
470.0ms
(/ (* (pow x 2) (+ (cos x) 1)) (pow (sin x) 2))
422.0ms
(/ (* (* (* (* x x) (+ 1 (cos x))) (* (* x x) (+ 1 (cos x)))) (* (* x x) (+ 1 (cos x)))) (* (* (* (sin x) (sin x)) (* (sin x) (sin x))) (* (sin x) (sin x))))
398.0ms
(/ (* (* (* (* x x) (+ 1 (cos x))) (* (* x x) (+ 1 (cos x)))) (* (* x x) (+ 1 (cos x)))) (* (* (* (sin x) (sin x)) (sin x)) (* (* (sin x) (sin x)) (sin x))))

prune836.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 0b

localize13.0ms

Local error

Found 3 expressions with local error:

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

rewrite13.0ms

Algorithm
rewrite-expression-head
Rules
66×times-frac
35×add-cube-cbrt
35×*-un-lft-identity
35×add-sqr-sqrt
32×associate-/r*
16×add-exp-log
11×div-inv
10×add-cbrt-cube
associate-/l*
div-exp
cbrt-undiv
pow1
add-log-exp
associate-/r/
frac-2neg
clear-num
rec-exp
tan-quot
associate-/l/
inv-pow
pow-flip
Counts
3 → 108
Calls
3 calls:
Slowest
6.0ms
(/ (/ (* x x) (sin x)) (tan (/ x 2)))
3.0ms
(/ (* x x) (sin x))
3.0ms
(/ 1 (/ (/ (* x x) (sin x)) (tan (/ x 2))))

series146.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
62.0ms
(/ (/ (* x x) (sin x)) (tan (/ x 2)))
61.0ms
(/ 1 (/ (/ (* x x) (sin x)) (tan (/ x 2))))
23.0ms
(/ (* x x) (sin x))

simplify3.2s

Counts
105 → 117
Calls
105 calls:
Slowest
734.0ms
(/ (* (* (/ (* x x) (sin x)) (/ (* x x) (sin x))) (/ (* x x) (sin x))) (* (* (tan (/ x 2)) (tan (/ x 2))) (tan (/ x 2))))
455.0ms
(/ (/ (* (* (* x x) (* x x)) (* x x)) (* (* (sin x) (sin x)) (sin x))) (* (* (tan (/ x 2)) (tan (/ x 2))) (tan (/ x 2))))
193.0ms
(/ (* (* (* x x) (* x x)) (* x x)) (* (* (sin x) (sin x)) (sin x)))
172.0ms
(/ (* (cos (* 1/2 x)) (pow x 2)) (* (sin x) (sin (* 1/2 x))))
156.0ms
(- (- (log (* x x)) (log (sin x))) (log (tan (/ x 2))))

prune1.0s

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0b

regimes32.0ms

Accuracy

0% (0.1b remaining)

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

bsearch1.0ms

end0.0ms

sample4.6s

Algorithm
intervals
Results
8000×(pre true 80)
2314×(body real 80)
1586×(body real 2560)
1464×(body real 640)
1248×(body real 1280)
887×(body real 320)
501×(body real 160)