Average Error: 0.5 → 0.5
Time: 7.2s
Precision: 64
\[\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\]
\[\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \cos th \cdot \frac{a2}{\frac{\sqrt{2}}{a2}}\]
\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)
\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \cos th \cdot \frac{a2}{\frac{\sqrt{2}}{a2}}
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(2.0)) * (a1 * a1)) + (cos(th) * (a2 / (sqrt(2.0) / a2))));
}

Error

Bits error versus a1

Bits error versus a2

Bits error versus th

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.5

    \[\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\]
  2. Using strategy rm
  3. Applied div-inv0.5

    \[\leadsto \frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \color{blue}{\left(\cos th \cdot \frac{1}{\sqrt{2}}\right)} \cdot \left(a2 \cdot a2\right)\]
  4. Applied associate-*l*0.5

    \[\leadsto \frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \color{blue}{\cos th \cdot \left(\frac{1}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\right)}\]
  5. Simplified0.5

    \[\leadsto \frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \cos th \cdot \color{blue}{\frac{{a2}^{2}}{\sqrt{2}}}\]
  6. Using strategy rm
  7. Applied unpow20.5

    \[\leadsto \frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \cos th \cdot \frac{\color{blue}{a2 \cdot a2}}{\sqrt{2}}\]
  8. Applied associate-/l*0.5

    \[\leadsto \frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \cos th \cdot \color{blue}{\frac{a2}{\frac{\sqrt{2}}{a2}}}\]
  9. Final simplification0.5

    \[\leadsto \frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \cos th \cdot \frac{a2}{\frac{\sqrt{2}}{a2}}\]

Reproduce

herbie shell --seed 2020091 
(FPCore (a1 a2 th)
  :name "Migdal et al, Equation (64)"
  :precision binary64
  (+ (* (/ (cos th) (sqrt 2)) (* a1 a1)) (* (/ (cos th) (sqrt 2)) (* a2 a2))))