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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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

Details

Time bar (total: 30.2s)Debug log

sample197.0ms

Algorithm
intervals
Results
256×(pre true 80)
74×(body real 80)
49×(body real 640)
49×(body real 2560)
45×(body real 1280)
27×(body real 320)
12×(body real 160)

simplify33.0ms

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

prune10.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 30.7b

localize53.0ms

Local error

Found 2 expressions with local error:

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

rewrite10.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
8.0ms
(/ (- 1 (cos x)) (* x x))
2.0ms
(- 1 (cos x))

series94.0ms

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

simplify967.0ms

Counts
19 → 39
Calls
19 calls:
Slowest
543.0ms
(/ (* (* (- 1 (cos x)) (- 1 (cos x))) (- 1 (cos x))) (* (* (* x x) (* x x)) (* x x)))
88.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)))
47.0ms
(- (log (- 1 (cos x))) (log (* x x)))
34.0ms
(/ (- 1 (cos x)) (pow x 2))

prune519.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 0.0b

localize39.0ms

Local error

Found 4 expressions with local error:

15.6b
(/ (* (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)))

rewrite38.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
18.0ms
(/ (* (sin x) (sin x)) (* (* x x) (+ 1 (cos x))))
8.0ms
(* (* x x) (+ 1 (cos x)))
8.0ms
(* (sin x) (sin x))
2.0ms
(+ 1 (cos x))

series172.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
79.0ms
(/ (* (sin x) (sin x)) (* (* x x) (+ 1 (cos x))))
42.0ms
(* (* x x) (+ 1 (cos x)))
30.0ms
(* (sin x) (sin x))
21.0ms
(+ 1 (cos x))

simplify7.2s

Counts
51 → 88
Calls
51 calls:
Slowest
1.4s
(* (* (* (* x x) (* x x)) (* x x)) (* (* (+ 1 (cos x)) (+ 1 (cos x))) (+ 1 (cos x))))
624.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)))))
542.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)))))
509.0ms
(- (+ (log (sin x)) (log (sin x))) (log (* (* x x) (+ 1 (cos x)))))
493.0ms
(- (+ (log (sin x)) (log (sin x))) (+ (log (* x x)) (log (+ 1 (cos x)))))

prune1.3s

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 0b

localize31.0ms

Local error

Found 2 expressions with local error:

15.1b
(/ (* x x) (sin x))
0.2b
(/ (tan (/ x 2)) (/ (* x x) (sin x)))

rewrite21.0ms

Algorithm
rewrite-expression-head
Rules
36×times-frac
20×add-cube-cbrt
20×*-un-lft-identity
20×add-sqr-sqrt
10×associate-/r*
add-exp-log
add-cbrt-cube
div-inv
associate-/l*
div-exp
cbrt-undiv
add-log-exp
frac-2neg
clear-num
pow1
associate-/l/
associate-/r/
tan-quot
Counts
2 → 66
Calls
2 calls:
Slowest
12.0ms
(/ (tan (/ x 2)) (/ (* x x) (sin x)))
7.0ms
(/ (* x x) (sin x))

series171.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
119.0ms
(/ (tan (/ x 2)) (/ (* x x) (sin x)))
52.0ms
(/ (* x x) (sin x))

simplify4.2s

Counts
74 → 72
Calls
74 calls:
Slowest
1.5s
(/ (* (* (tan (/ x 2)) (tan (/ x 2))) (tan (/ x 2))) (* (* (/ (* x x) (sin x)) (/ (* x x) (sin x))) (/ (* x x) (sin x))))
350.0ms
(/ (* (* (* x x) (* x x)) (* x x)) (* (* (sin x) (sin x)) (sin x)))
264.0ms
(/ (* (sin x) (sin (* 1/2 x))) (* (cos (* 1/2 x)) (pow x 2)))
246.0ms
(/ (* (sin x) (sin (* 1/2 x))) (* (cos (* 1/2 x)) (pow x 2)))
156.0ms
(- (log (tan (/ x 2))) (- (log (* x x)) (log (sin x))))

prune1.1s

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 0b

localize29.0ms

Local error

Found 3 expressions with local error:

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

rewrite25.0ms

Algorithm
rewrite-expression-head
Rules
24×times-frac
22×add-cube-cbrt
22×*-un-lft-identity
22×add-sqr-sqrt
17×associate-*r*
11×div-inv
10×add-exp-log
10×add-cbrt-cube
associate-/r*
pow1
associate-*l*
add-log-exp
associate-/l*
cbrt-unprod
associate-/r/
prod-exp
div-exp
frac-2neg
clear-num
cbrt-undiv
associate-/l/
*-commutative
associate-*r/
tan-quot
associate-*l/
pow-prod-down
frac-times
Counts
3 → 83
Calls
3 calls:
Slowest
12.0ms
(* (/ 1 x) (/ (tan (/ x 2)) (/ x (sin x))))
10.0ms
(/ (tan (/ x 2)) (/ x (sin x)))
1.0ms
(/ x (sin x))

series289.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
127.0ms
(/ (tan (/ x 2)) (/ x (sin x)))
118.0ms
(* (/ 1 x) (/ (tan (/ x 2)) (/ x (sin x))))
44.0ms
(/ x (sin x))

simplify3.8s

Counts
74 → 92
Calls
74 calls:
Slowest
612.0ms
(* (/ 1 x) (/ (tan (/ x 2)) (/ x (sin x))))
518.0ms
(+ (log (/ 1 x)) (log (/ (tan (/ x 2)) (/ x (sin x)))))
343.0ms
(+ (log (/ 1 x)) (- (log (tan (/ x 2))) (log (/ x (sin x)))))
310.0ms
(/ (* (* (tan (/ x 2)) (tan (/ x 2))) (tan (/ x 2))) (* (* (/ x (sin x)) (/ x (sin x))) (/ x (sin x))))
251.0ms
(/ (* (sin x) (sin (* 1/2 x))) (* (cos (* 1/2 x)) (pow x 2)))

prune1.5s

Pruning

7 alts after pruning (4 fresh and 3 done)

Merged error: 0b

regimes78.0ms

Accuracy

0% (0.2b remaining)

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

bsearch3.0ms

end0.0ms

sample8.4s

Algorithm
intervals
Results
8000×(pre true 80)
2258×(body real 80)
1611×(body real 2560)
1476×(body real 640)
1236×(body real 1280)
940×(body real 320)
479×(body real 160)