Average Error: 1.0 → 1.0
Time: 15.3s
Precision: 64
Internal Precision: 128
\[2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\]
\[2 \cdot \cos \left((\frac{2}{3} \cdot \pi + \left(\frac{\frac{\cos^{-1} \left(-\frac{g}{h}\right)}{\sqrt{3}}}{\sqrt{3}}\right))_*\right)\]

Error

Bits error versus g

Bits error versus h

Derivation

  1. Initial program 1.0

    \[2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)\]
  2. Simplified1.0

    \[\leadsto \color{blue}{\cos \left((\frac{2}{3} \cdot \pi + \left(\frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right))_*\right) \cdot 2}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt1.0

    \[\leadsto \cos \left((\frac{2}{3} \cdot \pi + \color{blue}{\left(\sqrt{\frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}} \cdot \sqrt{\frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}}\right)})_*\right) \cdot 2\]
  5. Using strategy rm
  6. Applied sqrt-div1.0

    \[\leadsto \cos \left((\frac{2}{3} \cdot \pi + \left(\sqrt{\frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}} \cdot \color{blue}{\frac{\sqrt{\cos^{-1} \left(\frac{-g}{h}\right)}}{\sqrt{3}}}\right))_*\right) \cdot 2\]
  7. Using strategy rm
  8. Applied sqrt-div1.0

    \[\leadsto \cos \left((\frac{2}{3} \cdot \pi + \left(\color{blue}{\frac{\sqrt{\cos^{-1} \left(\frac{-g}{h}\right)}}{\sqrt{3}}} \cdot \frac{\sqrt{\cos^{-1} \left(\frac{-g}{h}\right)}}{\sqrt{3}}\right))_*\right) \cdot 2\]
  9. Applied associate-*l/1.0

    \[\leadsto \cos \left((\frac{2}{3} \cdot \pi + \color{blue}{\left(\frac{\sqrt{\cos^{-1} \left(\frac{-g}{h}\right)} \cdot \frac{\sqrt{\cos^{-1} \left(\frac{-g}{h}\right)}}{\sqrt{3}}}{\sqrt{3}}\right)})_*\right) \cdot 2\]
  10. Simplified1.0

    \[\leadsto \cos \left((\frac{2}{3} \cdot \pi + \left(\frac{\color{blue}{\frac{\cos^{-1} \left(\frac{-g}{h}\right)}{\sqrt{3}}}}{\sqrt{3}}\right))_*\right) \cdot 2\]
  11. Final simplification1.0

    \[\leadsto 2 \cdot \cos \left((\frac{2}{3} \cdot \pi + \left(\frac{\frac{\cos^{-1} \left(-\frac{g}{h}\right)}{\sqrt{3}}}{\sqrt{3}}\right))_*\right)\]

Reproduce

herbie shell --seed 2019016 +o rules:numerics
(FPCore (g h)
  :name "2-ancestry mixing, negative discriminant"
  (* 2 (cos (+ (/ (* 2 PI) 3) (/ (acos (/ (- g) h)) 3)))))

Details

Time bar (total: 14.7s)Debug log

sample174.0ms

Algorithm
intervals
Results
544×(pre true 80)
288×(body nan 80)
256×(body real 80)

simplify13.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
13.0ms
(* 2 (cos (+ (/ (* 2 PI) 3) (/ (acos (/ (- g) h)) 3))))

prune12.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 1.0b

localize27.0ms

Local error

Found 3 expressions with local error:

1.0b
(cos (fma 2/3 PI (/ (acos (/ (- g) h)) 3)))
0.9b
(/ (acos (/ (- g) h)) 3)
0.0b
(fma 2/3 PI (/ (acos (/ (- g) h)) 3))

rewrite6.0ms

Algorithm
rewrite-expression-head
Rules
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-log-exp
associate-/l*
log1p-expm1-u
add-exp-log
add-cbrt-cube
pow1
expm1-log1p-u
fma-udef
div-sub
div-inv
distribute-frac-neg
frac-2neg
clear-num
cos-sum
acos-neg
acos-asin
Counts
3 → 37
Calls
3 calls:
Slowest
3.0ms
(/ (acos (/ (- g) h)) 3)
2.0ms
(cos (fma 2/3 PI (/ (acos (/ (- g) h)) 3)))
0.0ms
(fma 2/3 PI (/ (acos (/ (- g) h)) 3))

series139.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
89.0ms
(cos (fma 2/3 PI (/ (acos (/ (- g) h)) 3)))
38.0ms
(fma 2/3 PI (/ (acos (/ (- g) h)) 3))
12.0ms
(/ (acos (/ (- g) h)) 3)

simplify272.0ms

Counts
14 → 46
Calls
14 calls:
Slowest
37.0ms
(cos (+ (* 1/3 (acos (* -1 (/ g h)))) (* 2/3 PI)))
34.0ms
(+ (* 1/3 (acos (* -1 (/ g h)))) (* 2/3 PI))
28.0ms
(+ (* 1/3 (acos (* -1 (/ g h)))) (* 2/3 PI))
27.0ms
(* 1/3 (acos (* -1 (/ g h))))
26.0ms
(* 1/3 (acos (* -1 (/ g h))))

prune569.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.9b

localize21.0ms

Local error

Found 4 expressions with local error:

1.0b
(log1p (expm1 (cos (fma 2/3 PI (/ (acos (/ (- g) h)) 3)))))
1.0b
(cos (fma 2/3 PI (/ (acos (/ (- g) h)) 3)))
0.9b
(expm1 (cos (fma 2/3 PI (/ (acos (/ (- g) h)) 3))))
0.9b
(/ (acos (/ (- g) h)) 3)

rewrite13.0ms

Algorithm
rewrite-expression-head
Rules
log1p-expm1-u
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-log-exp
add-exp-log
add-cbrt-cube
pow1
expm1-log1p-u
associate-/l*
div-sub
expm1-udef
div-inv
fma-udef
distribute-frac-neg
log1p-expm1
frac-2neg
clear-num
expm1-log1p
log1p-udef
cos-sum
acos-neg
acos-asin
Counts
4 → 49
Calls
4 calls:
Slowest
7.0ms
(/ (acos (/ (- g) h)) 3)
4.0ms
(cos (fma 2/3 PI (/ (acos (/ (- g) h)) 3)))
1.0ms
(expm1 (cos (fma 2/3 PI (/ (acos (/ (- g) h)) 3))))
0.0ms
(log1p (expm1 (cos (fma 2/3 PI (/ (acos (/ (- g) h)) 3)))))

series451.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
174.0ms
(log1p (expm1 (cos (fma 2/3 PI (/ (acos (/ (- g) h)) 3)))))
158.0ms
(expm1 (cos (fma 2/3 PI (/ (acos (/ (- g) h)) 3))))
108.0ms
(cos (fma 2/3 PI (/ (acos (/ (- g) h)) 3)))
11.0ms
(/ (acos (/ (- g) h)) 3)

simplify394.0ms

Counts
19 → 61
Calls
19 calls:
Slowest
40.0ms
(cos (+ (* 1/3 (acos (* -1 (/ g h)))) (* 2/3 PI)))
39.0ms
(cos (+ (* 1/3 (acos (* -1 (/ g h)))) (* 2/3 PI)))
38.0ms
(cos (+ (* 1/3 (acos (* -1 (/ g h)))) (* 2/3 PI)))
29.0ms
(- (exp (cos (+ (* 1/3 (acos (* -1 (/ g h)))) (* 2/3 PI)))) 1)
28.0ms
(cos (+ (* 1/3 (acos (* -1 (/ g h)))) (* 2/3 PI)))

prune813.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0.9b

localize33.0ms

Local error

Found 4 expressions with local error:

1.0b
(cos (fma 2/3 PI (* (sqrt (/ (acos (/ (- g) h)) 3)) (sqrt (/ (acos (/ (- g) h)) 3)))))
1.0b
(* (sqrt (/ (acos (/ (- g) h)) 3)) (sqrt (/ (acos (/ (- g) h)) 3)))
0.9b
(sqrt (/ (acos (/ (- g) h)) 3))
0.9b
(sqrt (/ (acos (/ (- g) h)) 3))

rewrite19.0ms

Algorithm
rewrite-expression-head
Rules
16×sqrt-prod
12×add-sqr-sqrt
10×add-cube-cbrt
10×*-un-lft-identity
pow1
associate-*l*
associate-*r*
add-exp-log
sqrt-div
pow1/2
add-cbrt-cube
add-log-exp
div-inv
log1p-expm1-u
expm1-log1p-u
pow-prod-up
pow-prod-down
rem-sqrt-square
fma-udef
cbrt-unprod
*-commutative
associate-*r/
prod-exp
associate-*l/
sqrt-unprod
pow-plus
rem-square-sqrt
cos-sum
frac-times
pow2
Counts
4 → 79
Calls
4 calls:
Slowest
10.0ms
(* (sqrt (/ (acos (/ (- g) h)) 3)) (sqrt (/ (acos (/ (- g) h)) 3)))
4.0ms
(cos (fma 2/3 PI (* (sqrt (/ (acos (/ (- g) h)) 3)) (sqrt (/ (acos (/ (- g) h)) 3)))))
2.0ms
(sqrt (/ (acos (/ (- g) h)) 3))
2.0ms
(sqrt (/ (acos (/ (- g) h)) 3))

series256.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
146.0ms
(cos (fma 2/3 PI (* (sqrt (/ (acos (/ (- g) h)) 3)) (sqrt (/ (acos (/ (- g) h)) 3)))))
55.0ms
(* (sqrt (/ (acos (/ (- g) h)) 3)) (sqrt (/ (acos (/ (- g) h)) 3)))
31.0ms
(sqrt (/ (acos (/ (- g) h)) 3))
24.0ms
(sqrt (/ (acos (/ (- g) h)) 3))

simplify638.0ms

Counts
53 → 91
Calls
53 calls:
Slowest
127.0ms
(* (* (* (sqrt (/ (acos (/ (- g) h)) 3)) (sqrt (/ (acos (/ (- g) h)) 3))) (sqrt (/ (acos (/ (- g) h)) 3))) (* (* (sqrt (/ (acos (/ (- g) h)) 3)) (sqrt (/ (acos (/ (- g) h)) 3))) (sqrt (/ (acos (/ (- g) h)) 3))))
43.0ms
(cos (+ (* 2/3 PI) (* (acos (* -1 (/ g h))) (pow (sqrt 1/3) 2))))
37.0ms
(* (sqrt (acos (* -1 (/ g h)))) (sqrt 1/3))
35.0ms
(* (acos (* -1 (/ g h))) (pow (sqrt 1/3) 2))
33.0ms
(* (acos (* -1 (/ g h))) (pow (sqrt 1/3) 2))

prune1.2s

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.9b

localize45.0ms

Local error

Found 4 expressions with local error:

1.0b
(/ (sqrt (acos (/ (- g) h))) (sqrt 3))
1.0b
(cos (fma 2/3 PI (* (sqrt (/ (acos (/ (- g) h)) 3)) (/ (sqrt (acos (/ (- g) h))) (sqrt 3)))))
1.0b
(* (sqrt (/ (acos (/ (- g) h)) 3)) (/ (sqrt (acos (/ (- g) h))) (sqrt 3)))
0.9b
(sqrt (/ (acos (/ (- g) h)) 3))

rewrite29.0ms

Algorithm
rewrite-expression-head
Rules
36×times-frac
36×add-sqr-sqrt
35×add-cube-cbrt
35×*-un-lft-identity
29×sqrt-prod
22×associate-*r*
11×add-exp-log
11×add-cbrt-cube
associate-*l*
associate-/l*
pow1
add-log-exp
div-inv
log1p-expm1-u
expm1-log1p-u
sqrt-div
associate-/r*
sqrt-undiv
cbrt-unprod
prod-exp
div-exp
cbrt-undiv
fma-udef
*-commutative
associate-*r/
associate-*l/
pow-prod-down
sqrt-unprod
pow1/2
frac-2neg
rem-square-sqrt
clear-num
cos-sum
rem-sqrt-square
frac-times
Counts
4 → 117
Calls
4 calls:
Slowest
13.0ms
(* (sqrt (/ (acos (/ (- g) h)) 3)) (/ (sqrt (acos (/ (- g) h))) (sqrt 3)))
8.0ms
(/ (sqrt (acos (/ (- g) h))) (sqrt 3))
4.0ms
(cos (fma 2/3 PI (* (sqrt (/ (acos (/ (- g) h)) 3)) (/ (sqrt (acos (/ (- g) h))) (sqrt 3)))))
2.0ms
(sqrt (/ (acos (/ (- g) h)) 3))

series309.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
185.0ms
(cos (fma 2/3 PI (* (sqrt (/ (acos (/ (- g) h)) 3)) (/ (sqrt (acos (/ (- g) h))) (sqrt 3)))))
59.0ms
(* (sqrt (/ (acos (/ (- g) h)) 3)) (/ (sqrt (acos (/ (- g) h))) (sqrt 3)))
40.0ms
(/ (sqrt (acos (/ (- g) h))) (sqrt 3))
24.0ms
(sqrt (/ (acos (/ (- g) h)) 3))

simplify1.7s

Counts
105 → 129
Calls
105 calls:
Slowest
314.0ms
(/ (* (* (sqrt (acos (/ (- g) h))) (sqrt (acos (/ (- g) h)))) (sqrt (acos (/ (- g) h)))) (* (* (sqrt 3) (sqrt 3)) (sqrt 3)))
178.0ms
(* (* (* (sqrt (/ (acos (/ (- g) h)) 3)) (sqrt (/ (acos (/ (- g) h)) 3))) (sqrt (/ (acos (/ (- g) h)) 3))) (* (* (/ (sqrt (acos (/ (- g) h))) (sqrt 3)) (/ (sqrt (acos (/ (- g) h))) (sqrt 3))) (/ (sqrt (acos (/ (- g) h))) (sqrt 3))))
114.0ms
(* (* (* (sqrt (/ (acos (/ (- g) h)) 3)) (sqrt (/ (acos (/ (- g) h)) 3))) (sqrt (/ (acos (/ (- g) h)) 3))) (/ (* (* (sqrt (acos (/ (- g) h))) (sqrt (acos (/ (- g) h)))) (sqrt (acos (/ (- g) h)))) (* (* (sqrt 3) (sqrt 3)) (sqrt 3))))
54.0ms
(* (sqrt (acos (* -1 (/ g h)))) (/ 1 (sqrt 3)))
52.0ms
(* (sqrt (acos (* -1 (/ g h)))) (/ 1 (sqrt 3)))

prune2.4s

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.9b

regimes242.0ms

Accuracy

0% (0.0b remaining)

Error of 1.0b against oracle of 1.0b and baseline of 1.0b

bsearch4.0ms

end0.0ms

sample4.9s

Algorithm
intervals
Results
15971×(pre true 80)
8001×(body real 80)
7970×(body nan 80)