\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\cos th \cdot \frac{\sqrt{a1 \cdot a1 + a2 \cdot a2} \cdot \left(\sqrt{a1 \cdot a1 + a2 \cdot a2} \cdot {2}^{-0.25}\right)}{\sqrt{\sqrt{2}}}(FPCore (a1 a2 th) :precision binary64 (+ (* (/ (cos th) (sqrt 2.0)) (* a1 a1)) (* (/ (cos th) (sqrt 2.0)) (* a2 a2))))
(FPCore (a1 a2 th)
:precision binary64
(*
(cos th)
(/
(*
(sqrt (+ (* a1 a1) (* a2 a2)))
(* (sqrt (+ (* a1 a1) (* a2 a2))) (pow 2.0 -0.25)))
(sqrt (sqrt 2.0)))))double code(double a1, double a2, double th) {
return ((cos(th) / sqrt(2.0)) * (a1 * a1)) + ((cos(th) / sqrt(2.0)) * (a2 * a2));
}
double code(double a1, double a2, double th) {
return cos(th) * ((sqrt((a1 * a1) + (a2 * a2)) * (sqrt((a1 * a1) + (a2 * a2)) * pow(2.0, -0.25))) / sqrt(sqrt(2.0)));
}

















Bits error versus a1

















Bits error versus a2

















Bits error versus th
Results
| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 26496 |
| Alternative 2 | |
|---|---|
| Error | 0.5 |
| Cost | 13504 |
| Alternative 3 | |
|---|---|
| Error | 0.5 |
| Cost | 13504 |
| Alternative 4 | |
|---|---|
| Error | 13.5 |
| Cost | 15493 |
| Alternative 5 | |
|---|---|
| Error | 13.5 |
| Cost | 15493 |
| Alternative 6 | |
|---|---|
| Error | 13.5 |
| Cost | 15493 |
| Alternative 7 | |
|---|---|
| Error | 14.6 |
| Cost | 19969 |
| Alternative 8 | |
|---|---|
| Error | 26.0 |
| Cost | 6976 |
| Alternative 9 | |
|---|---|
| Error | 33.6 |
| Cost | 7048 |
| Alternative 10 | |
|---|---|
| Error | 33.6 |
| Cost | 7048 |
| Alternative 11 | |
|---|---|
| Error | 40.4 |
| Cost | 6720 |
| Alternative 12 | |
|---|---|
| Error | 40.4 |
| Cost | 6720 |
| Alternative 13 | |
|---|---|
| Error | 55.6 |
| Cost | 64 |
| Alternative 14 | |
|---|---|
| Error | 62.4 |
| Cost | 64 |

Initial program 0.5
Simplified0.5
rmApplied add-sqr-sqrt_binary64_4410.5
Applied associate-/r*_binary64_3630.5
Taylor expanded around 0 0.4
Simplified0.4
rmApplied add-sqr-sqrt_binary64_4410.4
Applied associate-*l*_binary64_3600.4
Simplified0.4
rmApplied pow1/2_binary64_4990.4
Applied pow-flip_binary64_4930.7
Applied sqrt-pow1_binary64_4370.4
Simplified0.4
Simplified0.4
Final simplification0.4
herbie shell --seed 2021014
(FPCore (a1 a2 th)
:name "Migdal et al, Equation (64)"
:precision binary64
(+ (* (/ (cos th) (sqrt 2.0)) (* a1 a1)) (* (/ (cos th) (sqrt 2.0)) (* a2 a2))))