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)
\]
Simplified0.5
\[\leadsto \color{blue}{\frac{\cos th}{\sqrt{2}} \cdot \mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}
\]
Proof
(*.f64 (/.f64 (cos.f64 th) (sqrt.f64 2)) (fma.f64 a1 a1 (*.f64 a2 a2))): 0 points increase in error, 0 points decrease in error
(*.f64 (/.f64 (cos.f64 th) (sqrt.f64 2)) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 a1 a1) (*.f64 a2 a2)))): 1 points increase in error, 0 points decrease in error
(Rewrite<= distribute-lft-out_binary64 (+.f64 (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 2)) (*.f64 a1 a1)) (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 2)) (*.f64 a2 a2)))): 0 points increase in error, 1 points decrease in error
Taylor expanded in th around inf 0.5
\[\leadsto \color{blue}{\frac{\left({a2}^{2} + {a1}^{2}\right) \cdot \cos th}{\sqrt{2}}}
\]
Simplified0.5
\[\leadsto \color{blue}{\mathsf{fma}\left(a2, a2, a1 \cdot a1\right) \cdot \frac{\cos th}{\sqrt{2}}}
\]
Proof
(*.f64 (fma.f64 a2 a2 (*.f64 a1 a1)) (/.f64 (cos.f64 th) (sqrt.f64 2))): 0 points increase in error, 0 points decrease in error
(*.f64 (fma.f64 a2 a2 (Rewrite<= unpow2_binary64 (pow.f64 a1 2))) (/.f64 (cos.f64 th) (sqrt.f64 2))): 0 points increase in error, 0 points decrease in error
(*.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 a2 a2) (pow.f64 a1 2))) (/.f64 (cos.f64 th) (sqrt.f64 2))): 2 points increase in error, 0 points decrease in error
(*.f64 (+.f64 (Rewrite<= unpow2_binary64 (pow.f64 a2 2)) (pow.f64 a1 2)) (/.f64 (cos.f64 th) (sqrt.f64 2))): 0 points increase in error, 0 points decrease in error
(Rewrite<= *-commutative_binary64 (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 2)) (+.f64 (pow.f64 a2 2) (pow.f64 a1 2)))): 0 points increase in error, 0 points decrease in error
(Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 (cos.f64 th) (+.f64 (pow.f64 a2 2) (pow.f64 a1 2))) (sqrt.f64 2))): 24 points increase in error, 29 points decrease in error
(/.f64 (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 (pow.f64 a2 2) (pow.f64 a1 2)) (cos.f64 th))) (sqrt.f64 2)): 0 points increase in error, 0 points decrease in error
Final simplification0.5
\[\leadsto \mathsf{fma}\left(a2, a2, a1 \cdot a1\right) \cdot \frac{\cos th}{\sqrt{2}}
\]