Average Error: 30.9 → 0.1
Time: 19.4s
Precision: 64
Internal Precision: 128
\[\frac{1 - \cos x}{x \cdot x}\]
\[\frac{\sin x}{x} \cdot \frac{\tan \left(\frac{x}{2}\right)}{x}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 30.9

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

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

    \[\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.4

    \[\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-*l*15.5

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

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

    \[\leadsto \frac{\sin x}{x} \cdot \color{blue}{\frac{\sin x}{(\left(\cos x\right) \cdot x + x)_*}}\]
  11. Using strategy rm
  12. Applied *-un-lft-identity0.3

    \[\leadsto \frac{\sin x}{x} \cdot \color{blue}{\left(1 \cdot \frac{\sin x}{(\left(\cos x\right) \cdot x + x)_*}\right)}\]
  13. Applied associate-*r*0.3

    \[\leadsto \color{blue}{\left(\frac{\sin x}{x} \cdot 1\right) \cdot \frac{\sin x}{(\left(\cos x\right) \cdot x + x)_*}}\]
  14. Simplified0.1

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

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

Reproduce

herbie shell --seed 2019005 +o rules:numerics
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))

Details

Time bar (total: 18.9s)Debug log

sample155.0ms

Algorithm
intervals

simplify30.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

29.0ms
(/ (- 1 (cos x)) (* x x))

prune8.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 30.8b

localize14.0ms

Local error

Found 2 expressions with local error:

15.5b
(/ (- 1 (cos x)) (* x x))
1.6b
(- 1 (cos x))

rewrite6.0ms

Algorithm
rewrite-expression-head
Counts
2 → 37
Calls

2 calls. Slowest were:

4.0ms
(/ (- 1 (cos x)) (* x x))
1.0ms
(- 1 (cos x))

series102.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

74.0ms
(/ (- 1 (cos x)) (* x x))
28.0ms
(- 1 (cos x))

simplify765.0ms

Counts
19 → 43
Calls

19 calls. Slowest were:

445.0ms
(/ (* (* (- 1 (cos x)) (- 1 (cos x))) (- 1 (cos x))) (* (* (* x x) (* x x)) (* x x)))
91.0ms
(- (+ (* 1/720 (pow x 4)) 1/2) (* 1/24 (pow x 2)))
77.0ms
(- (+ (* 1/2 (pow x 2)) (* 1/720 (pow x 6))) (* 1/24 (pow x 4)))

prune377.0ms

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 0.0b

localize25.0ms

Local error

Found 4 expressions with local error:

15.3b
(/ (* (sin x) (sin x)) (* (* x x) (+ 1 (cos x))))
0.4b
(+ 1 (cos x))
0.2b
(* (sin x) (sin x))
0.1b
(* (* x x) (+ 1 (cos x)))

rewrite35.0ms

Algorithm
rewrite-expression-head
Counts
4 → 84
Calls

4 calls. Slowest were:

17.0ms
(/ (* (sin x) (sin x)) (* (* x x) (+ 1 (cos x))))
7.0ms
(* (* x x) (+ 1 (cos x)))
7.0ms
(* (sin x) (sin x))

series97.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

49.0ms
(/ (* (sin x) (sin x)) (* (* x x) (+ 1 (cos x))))
22.0ms
(* (* x x) (+ 1 (cos x)))
17.0ms
(* (sin x) (sin x))
8.0ms
(+ 1 (cos x))

simplify4.6s

Counts
51 → 96
Calls

51 calls. Slowest were:

696.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)))))
480.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)))))
442.0ms
(- (+ (log (sin x)) (log (sin x))) (+ (log (* x x)) (log (+ 1 (cos x)))))

prune1.0s

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 0b

localize8.0ms

Local error

Found 4 expressions with local error:

15.3b
(/ (* (sin x) (sin x)) (* x (* x (+ 1 (cos x)))))
0.4b
(+ 1 (cos x))
0.2b
(* (sin x) (sin x))
0.1b
(* x (+ 1 (cos x)))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 76
Calls

4 calls. Slowest were:

7.0ms
(/ (* (sin x) (sin x)) (* x (* x (+ 1 (cos x)))))
3.0ms
(* (sin x) (sin x))
1.0ms
(* x (+ 1 (cos x)))

series120.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

51.0ms
(/ (* (sin x) (sin x)) (* x (* x (+ 1 (cos x)))))
36.0ms
(* x (+ 1 (cos x)))
24.0ms
(* (sin x) (sin x))
9.0ms
(+ 1 (cos x))

simplify2.4s

Counts
44 → 88
Calls

44 calls. Slowest were:

359.0ms
(- (+ (log (sin x)) (log (sin x))) (log (* x (* x (+ 1 (cos x))))))
359.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))))))
316.0ms
(- (log (* (sin x) (sin x))) (log (* x (* x (+ 1 (cos x))))))

prune821.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0b

localize21.0ms

Local error

Found 4 expressions with local error:

0.3b
(fma (cos x) x x)
0.2b
(/ (sin x) (fma (cos x) x x))
0.1b
(* (/ (sin x) x) (/ (sin x) (fma (cos x) x x)))
0.1b
(/ (sin x) x)

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 89
Calls

4 calls. Slowest were:

6.0ms
(* (/ (sin x) x) (/ (sin x) (fma (cos x) x x)))
3.0ms
(/ (sin x) (fma (cos x) x x))
2.0ms
(/ (sin x) x)

series160.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

67.0ms
(* (/ (sin x) x) (/ (sin x) (fma (cos x) x x)))
37.0ms
(/ (sin x) (fma (cos x) x x))
32.0ms
(/ (sin x) x)
24.0ms
(fma (cos x) x x)

simplify2.5s

Counts
64 → 101
Calls

64 calls. Slowest were:

483.0ms
(* (* (* (/ (sin x) x) (/ (sin x) x)) (/ (sin x) x)) (* (* (/ (sin x) (fma (cos x) x x)) (/ (sin x) (fma (cos x) x x))) (/ (sin x) (fma (cos x) x x))))
308.0ms
(+ (log (/ (sin x) x)) (- (log (sin x)) (log (fma (cos x) x x))))
212.0ms
(+ (log (/ (sin x) x)) (log (/ (sin x) (fma (cos x) x x))))

prune888.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0b

regimes38.0ms

Accuracy

0% (0.1b remaining)

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

bsearch1.0ms

end0.0ms

sample4.6s

Algorithm
intervals