Average Error: 0.5 → 0.5
Time: 36.0s
Precision: binary64
Cost: 26692
\[\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right) \]
\[\begin{array}{l} \mathbf{if}\;a1 \ne 0:\\ \;\;\;\;\frac{\cos th \cdot a1}{\frac{\sqrt{2}}{a1}}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(a1 \cdot a1\right) \cdot \cos th\right) \cdot \sqrt{0.5}\\ \end{array} + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right) \]
(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
 (+
  (if (!= a1 0.0)
    (/ (* (cos th) a1) (/ (sqrt 2.0) a1))
    (* (* (* a1 a1) (cos th)) (sqrt 0.5)))
  (* (/ (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) / sqrt(2.0)) * (a2 * a2));
}
double code(double a1, double a2, double th) {
	double tmp;
	if (a1 != 0.0) {
		tmp = (cos(th) * a1) / (sqrt(2.0) / a1);
	} else {
		tmp = ((a1 * a1) * cos(th)) * sqrt(0.5);
	}
	return tmp + ((cos(th) / sqrt(2.0)) * (a2 * a2));
}
real(8) function code(a1, a2, th)
    real(8), intent (in) :: a1
    real(8), intent (in) :: a2
    real(8), intent (in) :: th
    code = ((cos(th) / sqrt(2.0d0)) * (a1 * a1)) + ((cos(th) / sqrt(2.0d0)) * (a2 * a2))
end function
real(8) function code(a1, a2, th)
    real(8), intent (in) :: a1
    real(8), intent (in) :: a2
    real(8), intent (in) :: th
    real(8) :: tmp
    if (a1 /= 0.0d0) then
        tmp = (cos(th) * a1) / (sqrt(2.0d0) / a1)
    else
        tmp = ((a1 * a1) * cos(th)) * sqrt(0.5d0)
    end if
    code = tmp + ((cos(th) / sqrt(2.0d0)) * (a2 * a2))
end function
public static double code(double a1, double a2, double th) {
	return ((Math.cos(th) / Math.sqrt(2.0)) * (a1 * a1)) + ((Math.cos(th) / Math.sqrt(2.0)) * (a2 * a2));
}
public static double code(double a1, double a2, double th) {
	double tmp;
	if (a1 != 0.0) {
		tmp = (Math.cos(th) * a1) / (Math.sqrt(2.0) / a1);
	} else {
		tmp = ((a1 * a1) * Math.cos(th)) * Math.sqrt(0.5);
	}
	return tmp + ((Math.cos(th) / Math.sqrt(2.0)) * (a2 * a2));
}
def code(a1, a2, th):
	return ((math.cos(th) / math.sqrt(2.0)) * (a1 * a1)) + ((math.cos(th) / math.sqrt(2.0)) * (a2 * a2))
def code(a1, a2, th):
	tmp = 0
	if a1 != 0.0:
		tmp = (math.cos(th) * a1) / (math.sqrt(2.0) / a1)
	else:
		tmp = ((a1 * a1) * math.cos(th)) * math.sqrt(0.5)
	return tmp + ((math.cos(th) / math.sqrt(2.0)) * (a2 * a2))
function code(a1, a2, th)
	return Float64(Float64(Float64(cos(th) / sqrt(2.0)) * Float64(a1 * a1)) + Float64(Float64(cos(th) / sqrt(2.0)) * Float64(a2 * a2)))
end
function code(a1, a2, th)
	tmp = 0.0
	if (a1 != 0.0)
		tmp = Float64(Float64(cos(th) * a1) / Float64(sqrt(2.0) / a1));
	else
		tmp = Float64(Float64(Float64(a1 * a1) * cos(th)) * sqrt(0.5));
	end
	return Float64(tmp + Float64(Float64(cos(th) / sqrt(2.0)) * Float64(a2 * a2)))
end
function tmp = code(a1, a2, th)
	tmp = ((cos(th) / sqrt(2.0)) * (a1 * a1)) + ((cos(th) / sqrt(2.0)) * (a2 * a2));
end
function tmp_2 = code(a1, a2, th)
	tmp = 0.0;
	if (a1 ~= 0.0)
		tmp = (cos(th) * a1) / (sqrt(2.0) / a1);
	else
		tmp = ((a1 * a1) * cos(th)) * sqrt(0.5);
	end
	tmp_2 = tmp + ((cos(th) / sqrt(2.0)) * (a2 * a2));
end
code[a1_, a2_, th_] := N[(N[(N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(a1 * a1), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(a2 * a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[a1_, a2_, th_] := N[(If[Unequal[a1, 0.0], N[(N[(N[Cos[th], $MachinePrecision] * a1), $MachinePrecision] / N[(N[Sqrt[2.0], $MachinePrecision] / a1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a1 * a1), $MachinePrecision] * N[Cos[th], $MachinePrecision]), $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]] + N[(N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(a2 * a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)
\begin{array}{l}
\mathbf{if}\;a1 \ne 0:\\
\;\;\;\;\frac{\cos th \cdot a1}{\frac{\sqrt{2}}{a1}}\\

\mathbf{else}:\\
\;\;\;\;\left(\left(a1 \cdot a1\right) \cdot \cos th\right) \cdot \sqrt{0.5}\\


\end{array} + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)

Error

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. Applied egg-rr0.5

    \[\leadsto \color{blue}{\begin{array}{l} \color{blue}{\mathbf{if}\;a1 \ne 0:\\ \;\;\;\;\frac{\cos th \cdot a1}{\frac{\sqrt{2}}{a1}}\\ \mathbf{else}:\\ \;\;\;\;\left(\cos th \cdot \left(a1 \cdot a1\right)\right) \cdot \sqrt{0.5}\\ } \end{array}} + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right) \]
  3. Simplified0.5

    \[\leadsto \color{blue}{\begin{array}{l} \color{blue}{\mathbf{if}\;a1 \ne 0:\\ \;\;\;\;\frac{\cos th \cdot a1}{\frac{\sqrt{2}}{a1}}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(a1 \cdot a1\right) \cdot \cos th\right) \cdot \sqrt{0.5}\\ } \end{array}} + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right) \]
    Proof

Alternatives

Alternative 1
Error0.5
Cost26560
\[\left(\left(\cos th \cdot a1\right) \cdot \sqrt{0.5}\right) \cdot a1 + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right) \]
Alternative 2
Error0.5
Cost19776
\[\sqrt{0.5} \cdot \left(\cos th \cdot \mathsf{fma}\left(a1, a1, a2 \cdot a2\right)\right) \]
Alternative 3
Error0.5
Cost19776
\[\frac{\mathsf{fma}\left(a2, a2, a1 \cdot a1\right) \cdot \cos th}{\sqrt{2}} \]
Alternative 4
Error14.1
Cost14368
\[\begin{array}{l} t_1 := \left(\sqrt{0.5} \cdot a1\right) \cdot \left(a1 \cdot \cos th\right)\\ t_2 := a2 \cdot \cos th\\ \mathbf{if}\;th \leq -2.2 \cdot 10^{+215}:\\ \;\;\;\;\left(\sqrt{0.5} \cdot a2\right) \cdot t_2\\ \mathbf{elif}\;th \leq -4.7 \cdot 10^{+170}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq -2 \cdot 10^{+131}:\\ \;\;\;\;\left(\left(\cos th \cdot \sqrt{0.5}\right) \cdot a2\right) \cdot a2\\ \mathbf{elif}\;th \leq -0.14:\\ \;\;\;\;a1 \cdot \left(a1 \cdot \frac{\cos th}{\sqrt{2}}\right)\\ \mathbf{elif}\;th \leq 0.00049:\\ \;\;\;\;\frac{\mathsf{fma}\left(a2, a2, a1 \cdot a1\right)}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 7.4 \cdot 10^{+99}:\\ \;\;\;\;\left(a2 \cdot t_2\right) \cdot \sqrt{0.5}\\ \mathbf{elif}\;th \leq 1.55 \cdot 10^{+134}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq 2 \cdot 10^{+204}:\\ \;\;\;\;\frac{\left(a2 \cdot a2\right) \cdot \cos th}{{0.125}^{-0.16666666666666666}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\left(a1 \cdot a1\right) \cdot \cos th\right)\\ \end{array} \]
Alternative 5
Error14.1
Cost14304
\[\begin{array}{l} t_1 := \sqrt{0.5} \cdot \left(\left(a2 \cdot a2\right) \cdot \cos th\right)\\ t_2 := \sqrt{0.5} \cdot \left(\left(a1 \cdot a1\right) \cdot \cos th\right)\\ \mathbf{if}\;th \leq -9.6 \cdot 10^{+215}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq -5.3 \cdot 10^{+169}:\\ \;\;\;\;a1 \cdot \left(a1 \cdot \left(\sqrt{0.5} \cdot \cos th\right)\right)\\ \mathbf{elif}\;th \leq -1.2 \cdot 10^{+131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq -0.14:\\ \;\;\;\;a1 \cdot \left(a1 \cdot \frac{\cos th}{\sqrt{2}}\right)\\ \mathbf{elif}\;th \leq 0.00044:\\ \;\;\;\;\sqrt{0.5} \cdot \mathsf{fma}\left(a2, a2, a1 \cdot a1\right)\\ \mathbf{elif}\;th \leq 1.26 \cdot 10^{+100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq 8.6 \cdot 10^{+133}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;th \leq 1.95 \cdot 10^{+205}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error14.2
Cost14304
\[\begin{array}{l} t_1 := \left(a2 \cdot \left(a2 \cdot \cos th\right)\right) \cdot \sqrt{0.5}\\ t_2 := \sqrt{0.5} \cdot \left(\left(a1 \cdot a1\right) \cdot \cos th\right)\\ \mathbf{if}\;th \leq -6 \cdot 10^{+214}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq -3.8 \cdot 10^{+172}:\\ \;\;\;\;a1 \cdot \left(a1 \cdot \left(\sqrt{0.5} \cdot \cos th\right)\right)\\ \mathbf{elif}\;th \leq -1.2 \cdot 10^{+131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq -0.14:\\ \;\;\;\;a1 \cdot \left(a1 \cdot \frac{\cos th}{\sqrt{2}}\right)\\ \mathbf{elif}\;th \leq 0.0048:\\ \;\;\;\;\sqrt{0.5} \cdot \mathsf{fma}\left(a2, a2, a1 \cdot a1\right)\\ \mathbf{elif}\;th \leq 3.4 \cdot 10^{+99}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq 1.3 \cdot 10^{+134}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;th \leq 5.4 \cdot 10^{+203}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\left(a2 \cdot a2\right) \cdot \cos th\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error14.2
Cost14304
\[\begin{array}{l} t_1 := \left(\sqrt{0.5} \cdot a1\right) \cdot \left(a1 \cdot \cos th\right)\\ t_2 := \left(a2 \cdot \left(a2 \cdot \cos th\right)\right) \cdot \sqrt{0.5}\\ \mathbf{if}\;th \leq -5.6 \cdot 10^{+215}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;th \leq -7 \cdot 10^{+171}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq -9.2 \cdot 10^{+130}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;th \leq -0.14:\\ \;\;\;\;a1 \cdot \left(a1 \cdot \frac{\cos th}{\sqrt{2}}\right)\\ \mathbf{elif}\;th \leq 0.005:\\ \;\;\;\;\sqrt{0.5} \cdot \mathsf{fma}\left(a2, a2, a1 \cdot a1\right)\\ \mathbf{elif}\;th \leq 1.7 \cdot 10^{+100}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;th \leq 1.15 \cdot 10^{+134}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq 4.8 \cdot 10^{+203}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\left(a2 \cdot a2\right) \cdot \cos th\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\left(a1 \cdot a1\right) \cdot \cos th\right)\\ \end{array} \]
Alternative 8
Error14.2
Cost14304
\[\begin{array}{l} t_1 := \left(\sqrt{0.5} \cdot a1\right) \cdot \left(a1 \cdot \cos th\right)\\ t_2 := a2 \cdot \cos th\\ t_3 := \left(a2 \cdot t_2\right) \cdot \sqrt{0.5}\\ \mathbf{if}\;th \leq -7.5 \cdot 10^{+216}:\\ \;\;\;\;\left(\sqrt{0.5} \cdot a2\right) \cdot t_2\\ \mathbf{elif}\;th \leq -4.5 \cdot 10^{+172}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq -1.38 \cdot 10^{+131}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;th \leq -0.29:\\ \;\;\;\;a1 \cdot \left(a1 \cdot \frac{\cos th}{\sqrt{2}}\right)\\ \mathbf{elif}\;th \leq 0.00037:\\ \;\;\;\;\sqrt{0.5} \cdot \mathsf{fma}\left(a2, a2, a1 \cdot a1\right)\\ \mathbf{elif}\;th \leq 1.9 \cdot 10^{+100}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;th \leq 1.25 \cdot 10^{+134}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq 2.2 \cdot 10^{+205}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\left(a2 \cdot a2\right) \cdot \cos th\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\left(a1 \cdot a1\right) \cdot \cos th\right)\\ \end{array} \]
Alternative 9
Error14.2
Cost14304
\[\begin{array}{l} t_1 := \left(\sqrt{0.5} \cdot a1\right) \cdot \left(a1 \cdot \cos th\right)\\ t_2 := a2 \cdot \cos th\\ \mathbf{if}\;th \leq -2.8 \cdot 10^{+216}:\\ \;\;\;\;\left(\sqrt{0.5} \cdot a2\right) \cdot t_2\\ \mathbf{elif}\;th \leq -6.2 \cdot 10^{+171}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq -2.25 \cdot 10^{+131}:\\ \;\;\;\;\left(t_2 \cdot \sqrt{0.5}\right) \cdot a2\\ \mathbf{elif}\;th \leq -0.14:\\ \;\;\;\;a1 \cdot \left(a1 \cdot \frac{\cos th}{\sqrt{2}}\right)\\ \mathbf{elif}\;th \leq 0.0125:\\ \;\;\;\;\sqrt{0.5} \cdot \mathsf{fma}\left(a2, a2, a1 \cdot a1\right)\\ \mathbf{elif}\;th \leq 2.9 \cdot 10^{+99}:\\ \;\;\;\;\left(a2 \cdot t_2\right) \cdot \sqrt{0.5}\\ \mathbf{elif}\;th \leq 1.6 \cdot 10^{+134}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq 5.8 \cdot 10^{+204}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\left(a2 \cdot a2\right) \cdot \cos th\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\left(a1 \cdot a1\right) \cdot \cos th\right)\\ \end{array} \]
Alternative 10
Error14.2
Cost14304
\[\begin{array}{l} t_1 := \left(\sqrt{0.5} \cdot a1\right) \cdot \left(a1 \cdot \cos th\right)\\ t_2 := a2 \cdot \cos th\\ \mathbf{if}\;th \leq -4.4 \cdot 10^{+214}:\\ \;\;\;\;\left(\sqrt{0.5} \cdot a2\right) \cdot t_2\\ \mathbf{elif}\;th \leq -7 \cdot 10^{+171}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq -1.85 \cdot 10^{+131}:\\ \;\;\;\;\left(\left(\cos th \cdot \sqrt{0.5}\right) \cdot a2\right) \cdot a2\\ \mathbf{elif}\;th \leq -0.155:\\ \;\;\;\;a1 \cdot \left(a1 \cdot \frac{\cos th}{\sqrt{2}}\right)\\ \mathbf{elif}\;th \leq 8 \cdot 10^{-5}:\\ \;\;\;\;\sqrt{0.5} \cdot \mathsf{fma}\left(a2, a2, a1 \cdot a1\right)\\ \mathbf{elif}\;th \leq 4.6 \cdot 10^{+99}:\\ \;\;\;\;\left(a2 \cdot t_2\right) \cdot \sqrt{0.5}\\ \mathbf{elif}\;th \leq 1.25 \cdot 10^{+134}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq 1.25 \cdot 10^{+204}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\left(a2 \cdot a2\right) \cdot \cos th\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\left(a1 \cdot a1\right) \cdot \cos th\right)\\ \end{array} \]
Alternative 11
Error14.1
Cost14304
\[\begin{array}{l} t_1 := \left(\sqrt{0.5} \cdot a1\right) \cdot \left(a1 \cdot \cos th\right)\\ t_2 := a2 \cdot \cos th\\ \mathbf{if}\;th \leq -1.7 \cdot 10^{+213}:\\ \;\;\;\;\left(\sqrt{0.5} \cdot a2\right) \cdot t_2\\ \mathbf{elif}\;th \leq -1.55 \cdot 10^{+172}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq -7.4 \cdot 10^{+130}:\\ \;\;\;\;\left(\left(\cos th \cdot \sqrt{0.5}\right) \cdot a2\right) \cdot a2\\ \mathbf{elif}\;th \leq -0.14:\\ \;\;\;\;a1 \cdot \left(a1 \cdot \frac{\cos th}{\sqrt{2}}\right)\\ \mathbf{elif}\;th \leq 0.0006:\\ \;\;\;\;\frac{\mathsf{fma}\left(a2, a2, a1 \cdot a1\right)}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 3 \cdot 10^{+99}:\\ \;\;\;\;\left(a2 \cdot t_2\right) \cdot \sqrt{0.5}\\ \mathbf{elif}\;th \leq 7.4 \cdot 10^{+133}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq 3.2 \cdot 10^{+204}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\left(a2 \cdot a2\right) \cdot \cos th\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\left(a1 \cdot a1\right) \cdot \cos th\right)\\ \end{array} \]
Alternative 12
Error12.7
Cost13776
\[\begin{array}{l} t_1 := \sqrt{0.5} \cdot \left(\left(a2 \cdot a2\right) \cdot \cos th\right)\\ \mathbf{if}\;a2 \leq -8.8 \cdot 10^{-41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a2 \leq -1.6 \cdot 10^{-68}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\left(a1 \cdot a1\right) \cdot \cos th\right)\\ \mathbf{elif}\;a2 \leq -1.9 \cdot 10^{-104}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a2 \leq 2 \cdot 10^{-42}:\\ \;\;\;\;a1 \cdot \left(a1 \cdot \left(\sqrt{0.5} \cdot \cos th\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error20.9
Cost13512
\[\begin{array}{l} t_1 := a1 \cdot \left(a1 \cdot \left(\sqrt{0.5} \cdot \cos th\right)\right)\\ \mathbf{if}\;a1 \leq -3.9 \cdot 10^{-165}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a1 \leq 4.9 \cdot 10^{-118}:\\ \;\;\;\;\left(\sqrt{0.5} \cdot a2\right) \cdot a2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 14
Error20.9
Cost13512
\[\begin{array}{l} \mathbf{if}\;a1 \leq -3.9 \cdot 10^{-165}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\left(a1 \cdot a1\right) \cdot \cos th\right)\\ \mathbf{elif}\;a1 \leq 2.2 \cdot 10^{-115}:\\ \;\;\;\;\left(\sqrt{0.5} \cdot a2\right) \cdot a2\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \left(a1 \cdot \left(\sqrt{0.5} \cdot \cos th\right)\right)\\ \end{array} \]
Alternative 15
Error33.7
Cost7500
\[\begin{array}{l} t_1 := \left(\sqrt{0.5} \cdot a2\right) \cdot a2\\ \mathbf{if}\;a1 \cdot a1 \leq 10^{-293}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a1 \cdot a1 \leq 2 \cdot 10^{-198}:\\ \;\;\;\;\frac{a1 \cdot a1}{\sqrt{2}}\\ \mathbf{elif}\;a1 \cdot a1 \leq 2 \cdot 10^{-90}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(a1 \cdot a1\right)\\ \end{array} \]
Alternative 16
Error33.7
Cost7500
\[\begin{array}{l} \mathbf{if}\;a1 \cdot a1 \leq 10^{-293}:\\ \;\;\;\;\frac{a2 \cdot a2}{\sqrt{2}}\\ \mathbf{elif}\;a1 \cdot a1 \leq 2 \cdot 10^{-198}:\\ \;\;\;\;\frac{a1 \cdot a1}{\sqrt{2}}\\ \mathbf{elif}\;a1 \cdot a1 \leq 2 \cdot 10^{-90}:\\ \;\;\;\;\left(\sqrt{0.5} \cdot a2\right) \cdot a2\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(a1 \cdot a1\right)\\ \end{array} \]
Alternative 17
Error33.1
Cost6984
\[\begin{array}{l} t_1 := \sqrt{0.5} \cdot \left(a1 \cdot a1\right)\\ \mathbf{if}\;a1 \leq -1.38 \cdot 10^{-148}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a1 \leq 8.4 \cdot 10^{-116}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(a2 \cdot a2\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 18
Error33.1
Cost6984
\[\begin{array}{l} \mathbf{if}\;a1 \leq -1.12 \cdot 10^{-146}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(a1 \cdot a1\right)\\ \mathbf{elif}\;a1 \leq 2.1 \cdot 10^{-116}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(a2 \cdot a2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{0.5} \cdot a1\right) \cdot a1\\ \end{array} \]
Alternative 19
Error33.1
Cost6984
\[\begin{array}{l} \mathbf{if}\;a1 \leq -5.2 \cdot 10^{-146}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(a1 \cdot a1\right)\\ \mathbf{elif}\;a1 \leq 6.5 \cdot 10^{-117}:\\ \;\;\;\;\left(\sqrt{0.5} \cdot a2\right) \cdot a2\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{0.5} \cdot a1\right) \cdot a1\\ \end{array} \]
Alternative 20
Error40.8
Cost6720
\[\sqrt{0.5} \cdot \left(a1 \cdot a1\right) \]

Error

Reproduce

herbie shell --seed 2023010 
(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))))