
(FPCore (a1 a2 th) :precision binary64 (let* ((t_1 (/ (cos th) (sqrt 2.0)))) (+ (* t_1 (* a1 a1)) (* t_1 (* a2 a2)))))
double code(double a1, double a2, double th) {
double t_1 = cos(th) / sqrt(2.0);
return (t_1 * (a1 * a1)) + (t_1 * (a2 * a2));
}
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
real(8) :: t_1
t_1 = cos(th) / sqrt(2.0d0)
code = (t_1 * (a1 * a1)) + (t_1 * (a2 * a2))
end function
public static double code(double a1, double a2, double th) {
double t_1 = Math.cos(th) / Math.sqrt(2.0);
return (t_1 * (a1 * a1)) + (t_1 * (a2 * a2));
}
def code(a1, a2, th): t_1 = math.cos(th) / math.sqrt(2.0) return (t_1 * (a1 * a1)) + (t_1 * (a2 * a2))
function code(a1, a2, th) t_1 = Float64(cos(th) / sqrt(2.0)) return Float64(Float64(t_1 * Float64(a1 * a1)) + Float64(t_1 * Float64(a2 * a2))) end
function tmp = code(a1, a2, th) t_1 = cos(th) / sqrt(2.0); tmp = (t_1 * (a1 * a1)) + (t_1 * (a2 * a2)); end
code[a1_, a2_, th_] := Block[{t$95$1 = N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$1 * N[(a1 * a1), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[(a2 * a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\cos th}{\sqrt{2}}\\
t\_1 \cdot \left(a1 \cdot a1\right) + t\_1 \cdot \left(a2 \cdot a2\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a1 a2 th) :precision binary64 (let* ((t_1 (/ (cos th) (sqrt 2.0)))) (+ (* t_1 (* a1 a1)) (* t_1 (* a2 a2)))))
double code(double a1, double a2, double th) {
double t_1 = cos(th) / sqrt(2.0);
return (t_1 * (a1 * a1)) + (t_1 * (a2 * a2));
}
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
real(8) :: t_1
t_1 = cos(th) / sqrt(2.0d0)
code = (t_1 * (a1 * a1)) + (t_1 * (a2 * a2))
end function
public static double code(double a1, double a2, double th) {
double t_1 = Math.cos(th) / Math.sqrt(2.0);
return (t_1 * (a1 * a1)) + (t_1 * (a2 * a2));
}
def code(a1, a2, th): t_1 = math.cos(th) / math.sqrt(2.0) return (t_1 * (a1 * a1)) + (t_1 * (a2 * a2))
function code(a1, a2, th) t_1 = Float64(cos(th) / sqrt(2.0)) return Float64(Float64(t_1 * Float64(a1 * a1)) + Float64(t_1 * Float64(a2 * a2))) end
function tmp = code(a1, a2, th) t_1 = cos(th) / sqrt(2.0); tmp = (t_1 * (a1 * a1)) + (t_1 * (a2 * a2)); end
code[a1_, a2_, th_] := Block[{t$95$1 = N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$1 * N[(a1 * a1), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[(a2 * a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\cos th}{\sqrt{2}}\\
t\_1 \cdot \left(a1 \cdot a1\right) + t\_1 \cdot \left(a2 \cdot a2\right)
\end{array}
\end{array}
(FPCore (a1 a2 th) :precision binary64 (* (fma a1 a1 (* a2 a2)) (/ (cos th) (sqrt 2.0))))
double code(double a1, double a2, double th) {
return fma(a1, a1, (a2 * a2)) * (cos(th) / sqrt(2.0));
}
function code(a1, a2, th) return Float64(fma(a1, a1, Float64(a2 * a2)) * Float64(cos(th) / sqrt(2.0))) end
code[a1_, a2_, th_] := N[(N[(a1 * a1 + N[(a2 * a2), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a1, a1, a2 \cdot a2\right) \cdot \frac{\cos th}{\sqrt{2}}
\end{array}
Initial program 99.7%
distribute-lft-outN/A
*-commutativeN/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
sqrt-lowering-sqrt.f6499.7
Applied egg-rr99.7%
(FPCore (a1 a2 th)
:precision binary64
(let* ((t_1 (/ (cos th) (sqrt 2.0))))
(if (<= (+ (* t_1 (* a1 a1)) (* (* a2 a2) t_1)) -4e-314)
(* (sqrt 2.0) (* (fma a1 a1 (* a2 a2)) -0.5))
(/ (fma a2 a2 (* a1 a1)) (sqrt 2.0)))))
double code(double a1, double a2, double th) {
double t_1 = cos(th) / sqrt(2.0);
double tmp;
if (((t_1 * (a1 * a1)) + ((a2 * a2) * t_1)) <= -4e-314) {
tmp = sqrt(2.0) * (fma(a1, a1, (a2 * a2)) * -0.5);
} else {
tmp = fma(a2, a2, (a1 * a1)) / sqrt(2.0);
}
return tmp;
}
function code(a1, a2, th) t_1 = Float64(cos(th) / sqrt(2.0)) tmp = 0.0 if (Float64(Float64(t_1 * Float64(a1 * a1)) + Float64(Float64(a2 * a2) * t_1)) <= -4e-314) tmp = Float64(sqrt(2.0) * Float64(fma(a1, a1, Float64(a2 * a2)) * -0.5)); else tmp = Float64(fma(a2, a2, Float64(a1 * a1)) / sqrt(2.0)); end return tmp end
code[a1_, a2_, th_] := Block[{t$95$1 = N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$1 * N[(a1 * a1), $MachinePrecision]), $MachinePrecision] + N[(N[(a2 * a2), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], -4e-314], N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[(a1 * a1 + N[(a2 * a2), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(a2 * a2 + N[(a1 * a1), $MachinePrecision]), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\cos th}{\sqrt{2}}\\
\mathbf{if}\;t\_1 \cdot \left(a1 \cdot a1\right) + \left(a2 \cdot a2\right) \cdot t\_1 \leq -4 \cdot 10^{-314}:\\
\;\;\;\;\sqrt{2} \cdot \left(\mathsf{fma}\left(a1, a1, a2 \cdot a2\right) \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a2, a2, a1 \cdot a1\right)}{\sqrt{2}}\\
\end{array}
\end{array}
if (+.f64 (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a1 a1)) (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a2 a2))) < -3.9999999999e-314Initial program 99.7%
Taylor expanded in th around 0
unpow2N/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f641.3
Simplified1.3%
+-commutativeN/A
associate-*r/N/A
frac-addN/A
rem-square-sqrtN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f641.3
Applied egg-rr1.3%
Applied egg-rr70.8%
associate-/r/N/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6470.9
Applied egg-rr70.9%
if -3.9999999999e-314 < (+.f64 (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a1 a1)) (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a2 a2))) Initial program 99.7%
distribute-lft-outN/A
*-commutativeN/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
sqrt-lowering-sqrt.f6499.7
Applied egg-rr99.7%
Taylor expanded in th around 0
/-lowering-/.f64N/A
+-commutativeN/A
unpow2N/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6486.1
Simplified86.1%
Final simplification82.5%
(FPCore (a1 a2 th)
:precision binary64
(let* ((t_1 (fma a1 a1 (* a2 a2))) (t_2 (/ (cos th) (sqrt 2.0))))
(if (<= (+ (* t_2 (* a1 a1)) (* (* a2 a2) t_2)) -4e-314)
(* (sqrt 2.0) (* t_1 -0.5))
(* (* t_1 (sqrt 2.0)) 0.5))))
double code(double a1, double a2, double th) {
double t_1 = fma(a1, a1, (a2 * a2));
double t_2 = cos(th) / sqrt(2.0);
double tmp;
if (((t_2 * (a1 * a1)) + ((a2 * a2) * t_2)) <= -4e-314) {
tmp = sqrt(2.0) * (t_1 * -0.5);
} else {
tmp = (t_1 * sqrt(2.0)) * 0.5;
}
return tmp;
}
function code(a1, a2, th) t_1 = fma(a1, a1, Float64(a2 * a2)) t_2 = Float64(cos(th) / sqrt(2.0)) tmp = 0.0 if (Float64(Float64(t_2 * Float64(a1 * a1)) + Float64(Float64(a2 * a2) * t_2)) <= -4e-314) tmp = Float64(sqrt(2.0) * Float64(t_1 * -0.5)); else tmp = Float64(Float64(t_1 * sqrt(2.0)) * 0.5); end return tmp end
code[a1_, a2_, th_] := Block[{t$95$1 = N[(a1 * a1 + N[(a2 * a2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$2 * N[(a1 * a1), $MachinePrecision]), $MachinePrecision] + N[(N[(a2 * a2), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], -4e-314], N[(N[Sqrt[2.0], $MachinePrecision] * N[(t$95$1 * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a1, a1, a2 \cdot a2\right)\\
t_2 := \frac{\cos th}{\sqrt{2}}\\
\mathbf{if}\;t\_2 \cdot \left(a1 \cdot a1\right) + \left(a2 \cdot a2\right) \cdot t\_2 \leq -4 \cdot 10^{-314}:\\
\;\;\;\;\sqrt{2} \cdot \left(t\_1 \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_1 \cdot \sqrt{2}\right) \cdot 0.5\\
\end{array}
\end{array}
if (+.f64 (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a1 a1)) (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a2 a2))) < -3.9999999999e-314Initial program 99.7%
Taylor expanded in th around 0
unpow2N/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f641.3
Simplified1.3%
+-commutativeN/A
associate-*r/N/A
frac-addN/A
rem-square-sqrtN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f641.3
Applied egg-rr1.3%
Applied egg-rr70.8%
associate-/r/N/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6470.9
Applied egg-rr70.9%
if -3.9999999999e-314 < (+.f64 (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a1 a1)) (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a2 a2))) Initial program 99.7%
Taylor expanded in th around 0
unpow2N/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6486.1
Simplified86.1%
+-commutativeN/A
associate-*r/N/A
frac-addN/A
rem-square-sqrtN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f6486.0
Applied egg-rr86.0%
div-invN/A
metadata-evalN/A
*-lowering-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
+-commutativeN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f6486.0
Applied egg-rr86.0%
Final simplification82.4%
(FPCore (a1 a2 th)
:precision binary64
(let* ((t_1 (/ (cos th) (sqrt 2.0))))
(if (<= (+ (* t_1 (* a1 a1)) (* (* a2 a2) t_1)) -4e-314)
(* -0.5 (* a2 (* a2 (sqrt 2.0))))
(/ (* a2 a2) (sqrt 2.0)))))
double code(double a1, double a2, double th) {
double t_1 = cos(th) / sqrt(2.0);
double tmp;
if (((t_1 * (a1 * a1)) + ((a2 * a2) * t_1)) <= -4e-314) {
tmp = -0.5 * (a2 * (a2 * sqrt(2.0)));
} else {
tmp = (a2 * a2) / sqrt(2.0);
}
return tmp;
}
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = cos(th) / sqrt(2.0d0)
if (((t_1 * (a1 * a1)) + ((a2 * a2) * t_1)) <= (-4d-314)) then
tmp = (-0.5d0) * (a2 * (a2 * sqrt(2.0d0)))
else
tmp = (a2 * a2) / sqrt(2.0d0)
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double t_1 = Math.cos(th) / Math.sqrt(2.0);
double tmp;
if (((t_1 * (a1 * a1)) + ((a2 * a2) * t_1)) <= -4e-314) {
tmp = -0.5 * (a2 * (a2 * Math.sqrt(2.0)));
} else {
tmp = (a2 * a2) / Math.sqrt(2.0);
}
return tmp;
}
def code(a1, a2, th): t_1 = math.cos(th) / math.sqrt(2.0) tmp = 0 if ((t_1 * (a1 * a1)) + ((a2 * a2) * t_1)) <= -4e-314: tmp = -0.5 * (a2 * (a2 * math.sqrt(2.0))) else: tmp = (a2 * a2) / math.sqrt(2.0) return tmp
function code(a1, a2, th) t_1 = Float64(cos(th) / sqrt(2.0)) tmp = 0.0 if (Float64(Float64(t_1 * Float64(a1 * a1)) + Float64(Float64(a2 * a2) * t_1)) <= -4e-314) tmp = Float64(-0.5 * Float64(a2 * Float64(a2 * sqrt(2.0)))); else tmp = Float64(Float64(a2 * a2) / sqrt(2.0)); end return tmp end
function tmp_2 = code(a1, a2, th) t_1 = cos(th) / sqrt(2.0); tmp = 0.0; if (((t_1 * (a1 * a1)) + ((a2 * a2) * t_1)) <= -4e-314) tmp = -0.5 * (a2 * (a2 * sqrt(2.0))); else tmp = (a2 * a2) / sqrt(2.0); end tmp_2 = tmp; end
code[a1_, a2_, th_] := Block[{t$95$1 = N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$1 * N[(a1 * a1), $MachinePrecision]), $MachinePrecision] + N[(N[(a2 * a2), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], -4e-314], N[(-0.5 * N[(a2 * N[(a2 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a2 * a2), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\cos th}{\sqrt{2}}\\
\mathbf{if}\;t\_1 \cdot \left(a1 \cdot a1\right) + \left(a2 \cdot a2\right) \cdot t\_1 \leq -4 \cdot 10^{-314}:\\
\;\;\;\;-0.5 \cdot \left(a2 \cdot \left(a2 \cdot \sqrt{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a2 \cdot a2}{\sqrt{2}}\\
\end{array}
\end{array}
if (+.f64 (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a1 a1)) (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a2 a2))) < -3.9999999999e-314Initial program 99.7%
Taylor expanded in th around 0
unpow2N/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f641.3
Simplified1.3%
+-commutativeN/A
associate-*r/N/A
frac-addN/A
rem-square-sqrtN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f641.3
Applied egg-rr1.3%
Applied egg-rr70.8%
Taylor expanded in a1 around 0
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6437.8
Simplified37.8%
if -3.9999999999e-314 < (+.f64 (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a1 a1)) (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a2 a2))) Initial program 99.7%
Taylor expanded in th around 0
unpow2N/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6486.1
Simplified86.1%
Taylor expanded in a1 around 0
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6456.4
Simplified56.4%
Final simplification51.9%
(FPCore (a1 a2 th)
:precision binary64
(let* ((t_1 (/ (cos th) (sqrt 2.0))))
(if (<= (+ (* t_1 (* a1 a1)) (* (* a2 a2) t_1)) -4e-314)
(* -0.5 (* a2 (* a2 (sqrt 2.0))))
(* a2 (/ a2 (sqrt 2.0))))))
double code(double a1, double a2, double th) {
double t_1 = cos(th) / sqrt(2.0);
double tmp;
if (((t_1 * (a1 * a1)) + ((a2 * a2) * t_1)) <= -4e-314) {
tmp = -0.5 * (a2 * (a2 * sqrt(2.0)));
} else {
tmp = a2 * (a2 / sqrt(2.0));
}
return tmp;
}
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = cos(th) / sqrt(2.0d0)
if (((t_1 * (a1 * a1)) + ((a2 * a2) * t_1)) <= (-4d-314)) then
tmp = (-0.5d0) * (a2 * (a2 * sqrt(2.0d0)))
else
tmp = a2 * (a2 / sqrt(2.0d0))
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double t_1 = Math.cos(th) / Math.sqrt(2.0);
double tmp;
if (((t_1 * (a1 * a1)) + ((a2 * a2) * t_1)) <= -4e-314) {
tmp = -0.5 * (a2 * (a2 * Math.sqrt(2.0)));
} else {
tmp = a2 * (a2 / Math.sqrt(2.0));
}
return tmp;
}
def code(a1, a2, th): t_1 = math.cos(th) / math.sqrt(2.0) tmp = 0 if ((t_1 * (a1 * a1)) + ((a2 * a2) * t_1)) <= -4e-314: tmp = -0.5 * (a2 * (a2 * math.sqrt(2.0))) else: tmp = a2 * (a2 / math.sqrt(2.0)) return tmp
function code(a1, a2, th) t_1 = Float64(cos(th) / sqrt(2.0)) tmp = 0.0 if (Float64(Float64(t_1 * Float64(a1 * a1)) + Float64(Float64(a2 * a2) * t_1)) <= -4e-314) tmp = Float64(-0.5 * Float64(a2 * Float64(a2 * sqrt(2.0)))); else tmp = Float64(a2 * Float64(a2 / sqrt(2.0))); end return tmp end
function tmp_2 = code(a1, a2, th) t_1 = cos(th) / sqrt(2.0); tmp = 0.0; if (((t_1 * (a1 * a1)) + ((a2 * a2) * t_1)) <= -4e-314) tmp = -0.5 * (a2 * (a2 * sqrt(2.0))); else tmp = a2 * (a2 / sqrt(2.0)); end tmp_2 = tmp; end
code[a1_, a2_, th_] := Block[{t$95$1 = N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$1 * N[(a1 * a1), $MachinePrecision]), $MachinePrecision] + N[(N[(a2 * a2), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], -4e-314], N[(-0.5 * N[(a2 * N[(a2 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a2 * N[(a2 / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\cos th}{\sqrt{2}}\\
\mathbf{if}\;t\_1 \cdot \left(a1 \cdot a1\right) + \left(a2 \cdot a2\right) \cdot t\_1 \leq -4 \cdot 10^{-314}:\\
\;\;\;\;-0.5 \cdot \left(a2 \cdot \left(a2 \cdot \sqrt{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \frac{a2}{\sqrt{2}}\\
\end{array}
\end{array}
if (+.f64 (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a1 a1)) (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a2 a2))) < -3.9999999999e-314Initial program 99.7%
Taylor expanded in th around 0
unpow2N/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f641.3
Simplified1.3%
+-commutativeN/A
associate-*r/N/A
frac-addN/A
rem-square-sqrtN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f641.3
Applied egg-rr1.3%
Applied egg-rr70.8%
Taylor expanded in a1 around 0
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6437.8
Simplified37.8%
if -3.9999999999e-314 < (+.f64 (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a1 a1)) (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a2 a2))) Initial program 99.7%
Taylor expanded in th around 0
unpow2N/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6486.1
Simplified86.1%
+-commutativeN/A
frac-2negN/A
associate-*r/N/A
frac-addN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6486.0
Applied egg-rr86.0%
Taylor expanded in a2 around inf
unpow2N/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f6456.4
Simplified56.4%
Final simplification52.0%
(FPCore (a1 a2 th)
:precision binary64
(let* ((t_1 (* a2 (* a2 (sqrt 2.0)))) (t_2 (/ (cos th) (sqrt 2.0))))
(if (<= (+ (* t_2 (* a1 a1)) (* (* a2 a2) t_2)) -4e-314)
(* -0.5 t_1)
(* 0.5 t_1))))
double code(double a1, double a2, double th) {
double t_1 = a2 * (a2 * sqrt(2.0));
double t_2 = cos(th) / sqrt(2.0);
double tmp;
if (((t_2 * (a1 * a1)) + ((a2 * a2) * t_2)) <= -4e-314) {
tmp = -0.5 * t_1;
} else {
tmp = 0.5 * t_1;
}
return tmp;
}
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = a2 * (a2 * sqrt(2.0d0))
t_2 = cos(th) / sqrt(2.0d0)
if (((t_2 * (a1 * a1)) + ((a2 * a2) * t_2)) <= (-4d-314)) then
tmp = (-0.5d0) * t_1
else
tmp = 0.5d0 * t_1
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double t_1 = a2 * (a2 * Math.sqrt(2.0));
double t_2 = Math.cos(th) / Math.sqrt(2.0);
double tmp;
if (((t_2 * (a1 * a1)) + ((a2 * a2) * t_2)) <= -4e-314) {
tmp = -0.5 * t_1;
} else {
tmp = 0.5 * t_1;
}
return tmp;
}
def code(a1, a2, th): t_1 = a2 * (a2 * math.sqrt(2.0)) t_2 = math.cos(th) / math.sqrt(2.0) tmp = 0 if ((t_2 * (a1 * a1)) + ((a2 * a2) * t_2)) <= -4e-314: tmp = -0.5 * t_1 else: tmp = 0.5 * t_1 return tmp
function code(a1, a2, th) t_1 = Float64(a2 * Float64(a2 * sqrt(2.0))) t_2 = Float64(cos(th) / sqrt(2.0)) tmp = 0.0 if (Float64(Float64(t_2 * Float64(a1 * a1)) + Float64(Float64(a2 * a2) * t_2)) <= -4e-314) tmp = Float64(-0.5 * t_1); else tmp = Float64(0.5 * t_1); end return tmp end
function tmp_2 = code(a1, a2, th) t_1 = a2 * (a2 * sqrt(2.0)); t_2 = cos(th) / sqrt(2.0); tmp = 0.0; if (((t_2 * (a1 * a1)) + ((a2 * a2) * t_2)) <= -4e-314) tmp = -0.5 * t_1; else tmp = 0.5 * t_1; end tmp_2 = tmp; end
code[a1_, a2_, th_] := Block[{t$95$1 = N[(a2 * N[(a2 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$2 * N[(a1 * a1), $MachinePrecision]), $MachinePrecision] + N[(N[(a2 * a2), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], -4e-314], N[(-0.5 * t$95$1), $MachinePrecision], N[(0.5 * t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a2 \cdot \left(a2 \cdot \sqrt{2}\right)\\
t_2 := \frac{\cos th}{\sqrt{2}}\\
\mathbf{if}\;t\_2 \cdot \left(a1 \cdot a1\right) + \left(a2 \cdot a2\right) \cdot t\_2 \leq -4 \cdot 10^{-314}:\\
\;\;\;\;-0.5 \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a1 a1)) (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a2 a2))) < -3.9999999999e-314Initial program 99.7%
Taylor expanded in th around 0
unpow2N/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f641.3
Simplified1.3%
+-commutativeN/A
associate-*r/N/A
frac-addN/A
rem-square-sqrtN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f641.3
Applied egg-rr1.3%
Applied egg-rr70.8%
Taylor expanded in a1 around 0
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6437.8
Simplified37.8%
if -3.9999999999e-314 < (+.f64 (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a1 a1)) (*.f64 (/.f64 (cos.f64 th) (sqrt.f64 #s(literal 2 binary64))) (*.f64 a2 a2))) Initial program 99.7%
Taylor expanded in th around 0
unpow2N/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6486.1
Simplified86.1%
+-commutativeN/A
associate-*r/N/A
frac-addN/A
rem-square-sqrtN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f6486.0
Applied egg-rr86.0%
Taylor expanded in a2 around inf
*-lowering-*.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6456.4
Simplified56.4%
Final simplification51.9%
(FPCore (a1 a2 th) :precision binary64 (if (<= (cos th) -0.01) (* (sqrt 2.0) (* (fma a1 a1 (* a2 a2)) -0.5)) (/ (* a2 a2) (sqrt 2.0))))
double code(double a1, double a2, double th) {
double tmp;
if (cos(th) <= -0.01) {
tmp = sqrt(2.0) * (fma(a1, a1, (a2 * a2)) * -0.5);
} else {
tmp = (a2 * a2) / sqrt(2.0);
}
return tmp;
}
function code(a1, a2, th) tmp = 0.0 if (cos(th) <= -0.01) tmp = Float64(sqrt(2.0) * Float64(fma(a1, a1, Float64(a2 * a2)) * -0.5)); else tmp = Float64(Float64(a2 * a2) / sqrt(2.0)); end return tmp end
code[a1_, a2_, th_] := If[LessEqual[N[Cos[th], $MachinePrecision], -0.01], N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[(a1 * a1 + N[(a2 * a2), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(a2 * a2), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos th \leq -0.01:\\
\;\;\;\;\sqrt{2} \cdot \left(\mathsf{fma}\left(a1, a1, a2 \cdot a2\right) \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a2 \cdot a2}{\sqrt{2}}\\
\end{array}
\end{array}
if (cos.f64 th) < -0.0100000000000000002Initial program 99.7%
Taylor expanded in th around 0
unpow2N/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f645.9
Simplified5.9%
+-commutativeN/A
associate-*r/N/A
frac-addN/A
rem-square-sqrtN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f645.9
Applied egg-rr5.9%
Applied egg-rr72.2%
associate-/r/N/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6472.3
Applied egg-rr72.3%
if -0.0100000000000000002 < (cos.f64 th) Initial program 99.7%
Taylor expanded in th around 0
unpow2N/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6485.9
Simplified85.9%
Taylor expanded in a1 around 0
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6455.7
Simplified55.7%
Final simplification59.8%
(FPCore (a1 a2 th) :precision binary64 (* (cos th) (/ (fma a1 a1 (* a2 a2)) (sqrt 2.0))))
double code(double a1, double a2, double th) {
return cos(th) * (fma(a1, a1, (a2 * a2)) / sqrt(2.0));
}
function code(a1, a2, th) return Float64(cos(th) * Float64(fma(a1, a1, Float64(a2 * a2)) / sqrt(2.0))) end
code[a1_, a2_, th_] := N[(N[Cos[th], $MachinePrecision] * N[(N[(a1 * a1 + N[(a2 * a2), $MachinePrecision]), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos th \cdot \frac{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt{2}}
\end{array}
Initial program 99.7%
distribute-lft-outN/A
div-invN/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
cos-lowering-cos.f6499.7
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (a1 a2 th) :precision binary64 (if (<= (cos th) -0.01) (/ (* a2 a2) (- (sqrt 2.0))) (/ (* a2 a2) (sqrt 2.0))))
double code(double a1, double a2, double th) {
double tmp;
if (cos(th) <= -0.01) {
tmp = (a2 * a2) / -sqrt(2.0);
} else {
tmp = (a2 * a2) / sqrt(2.0);
}
return tmp;
}
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 (cos(th) <= (-0.01d0)) then
tmp = (a2 * a2) / -sqrt(2.0d0)
else
tmp = (a2 * a2) / sqrt(2.0d0)
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double tmp;
if (Math.cos(th) <= -0.01) {
tmp = (a2 * a2) / -Math.sqrt(2.0);
} else {
tmp = (a2 * a2) / Math.sqrt(2.0);
}
return tmp;
}
def code(a1, a2, th): tmp = 0 if math.cos(th) <= -0.01: tmp = (a2 * a2) / -math.sqrt(2.0) else: tmp = (a2 * a2) / math.sqrt(2.0) return tmp
function code(a1, a2, th) tmp = 0.0 if (cos(th) <= -0.01) tmp = Float64(Float64(a2 * a2) / Float64(-sqrt(2.0))); else tmp = Float64(Float64(a2 * a2) / sqrt(2.0)); end return tmp end
function tmp_2 = code(a1, a2, th) tmp = 0.0; if (cos(th) <= -0.01) tmp = (a2 * a2) / -sqrt(2.0); else tmp = (a2 * a2) / sqrt(2.0); end tmp_2 = tmp; end
code[a1_, a2_, th_] := If[LessEqual[N[Cos[th], $MachinePrecision], -0.01], N[(N[(a2 * a2), $MachinePrecision] / (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], N[(N[(a2 * a2), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos th \leq -0.01:\\
\;\;\;\;\frac{a2 \cdot a2}{-\sqrt{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a2 \cdot a2}{\sqrt{2}}\\
\end{array}
\end{array}
if (cos.f64 th) < -0.0100000000000000002Initial program 99.7%
Taylor expanded in th around 0
unpow2N/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f645.9
Simplified5.9%
+-commutativeN/A
frac-2negN/A
associate-*r/N/A
frac-addN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f645.9
Applied egg-rr5.9%
Applied egg-rr72.3%
Taylor expanded in a2 around inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
sqrt-lowering-sqrt.f6440.7
Simplified40.7%
if -0.0100000000000000002 < (cos.f64 th) Initial program 99.7%
Taylor expanded in th around 0
unpow2N/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6485.9
Simplified85.9%
Taylor expanded in a1 around 0
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6455.7
Simplified55.7%
(FPCore (a1 a2 th) :precision binary64 (* (* a2 a2) (/ (cos th) (sqrt 2.0))))
double code(double a1, double a2, double th) {
return (a2 * a2) * (cos(th) / sqrt(2.0));
}
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
code = (a2 * a2) * (cos(th) / sqrt(2.0d0))
end function
public static double code(double a1, double a2, double th) {
return (a2 * a2) * (Math.cos(th) / Math.sqrt(2.0));
}
def code(a1, a2, th): return (a2 * a2) * (math.cos(th) / math.sqrt(2.0))
function code(a1, a2, th) return Float64(Float64(a2 * a2) * Float64(cos(th) / sqrt(2.0))) end
function tmp = code(a1, a2, th) tmp = (a2 * a2) * (cos(th) / sqrt(2.0)); end
code[a1_, a2_, th_] := N[(N[(a2 * a2), $MachinePrecision] * N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a2 \cdot a2\right) \cdot \frac{\cos th}{\sqrt{2}}
\end{array}
Initial program 99.7%
distribute-lft-outN/A
*-commutativeN/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
sqrt-lowering-sqrt.f6499.7
Applied egg-rr99.7%
Taylor expanded in a1 around 0
unpow2N/A
*-lowering-*.f6460.7
Simplified60.7%
(FPCore (a1 a2 th) :precision binary64 (* 0.5 (* a2 (* a2 (sqrt 2.0)))))
double code(double a1, double a2, double th) {
return 0.5 * (a2 * (a2 * sqrt(2.0)));
}
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
code = 0.5d0 * (a2 * (a2 * sqrt(2.0d0)))
end function
public static double code(double a1, double a2, double th) {
return 0.5 * (a2 * (a2 * Math.sqrt(2.0)));
}
def code(a1, a2, th): return 0.5 * (a2 * (a2 * math.sqrt(2.0)))
function code(a1, a2, th) return Float64(0.5 * Float64(a2 * Float64(a2 * sqrt(2.0)))) end
function tmp = code(a1, a2, th) tmp = 0.5 * (a2 * (a2 * sqrt(2.0))); end
code[a1_, a2_, th_] := N[(0.5 * N[(a2 * N[(a2 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(a2 \cdot \left(a2 \cdot \sqrt{2}\right)\right)
\end{array}
Initial program 99.7%
Taylor expanded in th around 0
unpow2N/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6465.9
Simplified65.9%
+-commutativeN/A
associate-*r/N/A
frac-addN/A
rem-square-sqrtN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f6465.8
Applied egg-rr65.8%
Taylor expanded in a2 around inf
*-lowering-*.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6443.4
Simplified43.4%
(FPCore (a1 a2 th) :precision binary64 (* 0.5 (* a1 (* a1 (sqrt 2.0)))))
double code(double a1, double a2, double th) {
return 0.5 * (a1 * (a1 * sqrt(2.0)));
}
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
code = 0.5d0 * (a1 * (a1 * sqrt(2.0d0)))
end function
public static double code(double a1, double a2, double th) {
return 0.5 * (a1 * (a1 * Math.sqrt(2.0)));
}
def code(a1, a2, th): return 0.5 * (a1 * (a1 * math.sqrt(2.0)))
function code(a1, a2, th) return Float64(0.5 * Float64(a1 * Float64(a1 * sqrt(2.0)))) end
function tmp = code(a1, a2, th) tmp = 0.5 * (a1 * (a1 * sqrt(2.0))); end
code[a1_, a2_, th_] := N[(0.5 * N[(a1 * N[(a1 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(a1 \cdot \left(a1 \cdot \sqrt{2}\right)\right)
\end{array}
Initial program 99.7%
Taylor expanded in th around 0
unpow2N/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6465.9
Simplified65.9%
+-commutativeN/A
associate-*r/N/A
frac-addN/A
rem-square-sqrtN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f6465.8
Applied egg-rr65.8%
Taylor expanded in a2 around 0
*-lowering-*.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6438.5
Simplified38.5%
herbie shell --seed 2024198
(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))))