
(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 14 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}
NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (* (cos th) (/ (fma a1 a1 (* a2 a2)) (sqrt 2.0))))
assert(a1 < a2);
double code(double a1, double a2, double th) {
return cos(th) * (fma(a1, a1, (a2 * a2)) / sqrt(2.0));
}
a1, a2 = sort([a1, a2]) function code(a1, a2, th) return Float64(cos(th) * Float64(fma(a1, a1, Float64(a2 * a2)) / sqrt(2.0))) end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. 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}
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\cos th \cdot \frac{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt{2}}
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
associate-*l/99.6%
associate-*r/99.7%
fma-def99.7%
Simplified99.7%
Final simplification99.7%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (if (<= (cos th) 0.115) (* a2 (/ a2 (/ (sqrt 2.0) (cos th)))) (* (sqrt 0.5) (+ (* a2 a2) (* a1 a1)))))
assert(a1 < a2);
double code(double a1, double a2, double th) {
double tmp;
if (cos(th) <= 0.115) {
tmp = a2 * (a2 / (sqrt(2.0) / cos(th)));
} else {
tmp = sqrt(0.5) * ((a2 * a2) + (a1 * a1));
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this 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 (cos(th) <= 0.115d0) then
tmp = a2 * (a2 / (sqrt(2.0d0) / cos(th)))
else
tmp = sqrt(0.5d0) * ((a2 * a2) + (a1 * a1))
end if
code = tmp
end function
assert a1 < a2;
public static double code(double a1, double a2, double th) {
double tmp;
if (Math.cos(th) <= 0.115) {
tmp = a2 * (a2 / (Math.sqrt(2.0) / Math.cos(th)));
} else {
tmp = Math.sqrt(0.5) * ((a2 * a2) + (a1 * a1));
}
return tmp;
}
[a1, a2] = sort([a1, a2]) def code(a1, a2, th): tmp = 0 if math.cos(th) <= 0.115: tmp = a2 * (a2 / (math.sqrt(2.0) / math.cos(th))) else: tmp = math.sqrt(0.5) * ((a2 * a2) + (a1 * a1)) return tmp
a1, a2 = sort([a1, a2]) function code(a1, a2, th) tmp = 0.0 if (cos(th) <= 0.115) tmp = Float64(a2 * Float64(a2 / Float64(sqrt(2.0) / cos(th)))); else tmp = Float64(sqrt(0.5) * Float64(Float64(a2 * a2) + Float64(a1 * a1))); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp_2 = code(a1, a2, th)
tmp = 0.0;
if (cos(th) <= 0.115)
tmp = a2 * (a2 / (sqrt(2.0) / cos(th)));
else
tmp = sqrt(0.5) * ((a2 * a2) + (a1 * a1));
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := If[LessEqual[N[Cos[th], $MachinePrecision], 0.115], N[(a2 * N[(a2 / N[(N[Sqrt[2.0], $MachinePrecision] / N[Cos[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[0.5], $MachinePrecision] * N[(N[(a2 * a2), $MachinePrecision] + N[(a1 * a1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\begin{array}{l}
\mathbf{if}\;\cos th \leq 0.115:\\
\;\;\;\;a2 \cdot \frac{a2}{\frac{\sqrt{2}}{\cos th}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(a2 \cdot a2 + a1 \cdot a1\right)\\
\end{array}
\end{array}
if (cos.f64 th) < 0.115000000000000005Initial program 99.6%
distribute-lft-out99.6%
associate-*l/99.6%
associate-*r/99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in a1 around 0 61.2%
unpow261.2%
associate-*l*61.3%
associate-*r/61.2%
associate-/l*61.2%
Simplified61.2%
if 0.115000000000000005 < (cos.f64 th) Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
clear-num99.6%
associate-/r/99.5%
pow1/299.5%
pow-flip99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 83.7%
unpow283.7%
unpow283.7%
Simplified83.7%
Final simplification78.0%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (* (* (cos th) (pow 2.0 -0.5)) (+ (* a2 a2) (* a1 a1))))
assert(a1 < a2);
double code(double a1, double a2, double th) {
return (cos(th) * pow(2.0, -0.5)) * ((a2 * a2) + (a1 * a1));
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
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) * (2.0d0 ** (-0.5d0))) * ((a2 * a2) + (a1 * a1))
end function
assert a1 < a2;
public static double code(double a1, double a2, double th) {
return (Math.cos(th) * Math.pow(2.0, -0.5)) * ((a2 * a2) + (a1 * a1));
}
[a1, a2] = sort([a1, a2]) def code(a1, a2, th): return (math.cos(th) * math.pow(2.0, -0.5)) * ((a2 * a2) + (a1 * a1))
a1, a2 = sort([a1, a2]) function code(a1, a2, th) return Float64(Float64(cos(th) * (2.0 ^ -0.5)) * Float64(Float64(a2 * a2) + Float64(a1 * a1))) end
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = (cos(th) * (2.0 ^ -0.5)) * ((a2 * a2) + (a1 * a1));
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := N[(N[(N[Cos[th], $MachinePrecision] * N[Power[2.0, -0.5], $MachinePrecision]), $MachinePrecision] * N[(N[(a2 * a2), $MachinePrecision] + N[(a1 * a1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\left(\cos th \cdot {2}^{-0.5}\right) \cdot \left(a2 \cdot a2 + a1 \cdot a1\right)
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
clear-num99.6%
associate-/r/99.5%
pow1/299.5%
pow-flip99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Final simplification99.6%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (* (sqrt 0.5) (* (cos th) (+ (* a2 a2) (* a1 a1)))))
assert(a1 < a2);
double code(double a1, double a2, double th) {
return sqrt(0.5) * (cos(th) * ((a2 * a2) + (a1 * a1)));
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
code = sqrt(0.5d0) * (cos(th) * ((a2 * a2) + (a1 * a1)))
end function
assert a1 < a2;
public static double code(double a1, double a2, double th) {
return Math.sqrt(0.5) * (Math.cos(th) * ((a2 * a2) + (a1 * a1)));
}
[a1, a2] = sort([a1, a2]) def code(a1, a2, th): return math.sqrt(0.5) * (math.cos(th) * ((a2 * a2) + (a1 * a1)))
a1, a2 = sort([a1, a2]) function code(a1, a2, th) return Float64(sqrt(0.5) * Float64(cos(th) * Float64(Float64(a2 * a2) + Float64(a1 * a1)))) end
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = sqrt(0.5) * (cos(th) * ((a2 * a2) + (a1 * a1)));
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := N[(N[Sqrt[0.5], $MachinePrecision] * N[(N[Cos[th], $MachinePrecision] * N[(N[(a2 * a2), $MachinePrecision] + N[(a1 * a1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\sqrt{0.5} \cdot \left(\cos th \cdot \left(a2 \cdot a2 + a1 \cdot a1\right)\right)
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
clear-num99.6%
associate-/r/99.5%
pow1/299.5%
pow-flip99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in th around inf 99.6%
unpow299.6%
unpow299.6%
Simplified99.6%
Final simplification99.6%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (if (<= a2 3.3e-127) (* (cos th) (/ a1 (/ (sqrt 2.0) a1))) (* a2 (/ a2 (/ (sqrt 2.0) (cos th))))))
assert(a1 < a2);
double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 3.3e-127) {
tmp = cos(th) * (a1 / (sqrt(2.0) / a1));
} else {
tmp = a2 * (a2 / (sqrt(2.0) / cos(th)));
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this 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 (a2 <= 3.3d-127) then
tmp = cos(th) * (a1 / (sqrt(2.0d0) / a1))
else
tmp = a2 * (a2 / (sqrt(2.0d0) / cos(th)))
end if
code = tmp
end function
assert a1 < a2;
public static double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 3.3e-127) {
tmp = Math.cos(th) * (a1 / (Math.sqrt(2.0) / a1));
} else {
tmp = a2 * (a2 / (Math.sqrt(2.0) / Math.cos(th)));
}
return tmp;
}
[a1, a2] = sort([a1, a2]) def code(a1, a2, th): tmp = 0 if a2 <= 3.3e-127: tmp = math.cos(th) * (a1 / (math.sqrt(2.0) / a1)) else: tmp = a2 * (a2 / (math.sqrt(2.0) / math.cos(th))) return tmp
a1, a2 = sort([a1, a2]) function code(a1, a2, th) tmp = 0.0 if (a2 <= 3.3e-127) tmp = Float64(cos(th) * Float64(a1 / Float64(sqrt(2.0) / a1))); else tmp = Float64(a2 * Float64(a2 / Float64(sqrt(2.0) / cos(th)))); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp_2 = code(a1, a2, th)
tmp = 0.0;
if (a2 <= 3.3e-127)
tmp = cos(th) * (a1 / (sqrt(2.0) / a1));
else
tmp = a2 * (a2 / (sqrt(2.0) / cos(th)));
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := If[LessEqual[a2, 3.3e-127], N[(N[Cos[th], $MachinePrecision] * N[(a1 / N[(N[Sqrt[2.0], $MachinePrecision] / a1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a2 * N[(a2 / N[(N[Sqrt[2.0], $MachinePrecision] / N[Cos[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 3.3 \cdot 10^{-127}:\\
\;\;\;\;\cos th \cdot \frac{a1}{\frac{\sqrt{2}}{a1}}\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \frac{a2}{\frac{\sqrt{2}}{\cos th}}\\
\end{array}
\end{array}
if a2 < 3.29999999999999981e-127Initial program 99.6%
distribute-lft-out99.6%
associate-*l/99.7%
associate-*r/99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in a1 around inf 64.6%
unpow264.6%
associate-/l*64.6%
Simplified64.6%
if 3.29999999999999981e-127 < a2 Initial program 99.6%
distribute-lft-out99.6%
associate-*l/99.6%
associate-*r/99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in a1 around 0 75.9%
unpow275.9%
associate-*l*75.9%
associate-*r/75.8%
associate-/l*75.9%
Simplified75.9%
Final simplification68.3%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (if (<= a2 6e-130) (* (cos th) (/ (* a1 a1) (sqrt 2.0))) (* a2 (/ a2 (/ (sqrt 2.0) (cos th))))))
assert(a1 < a2);
double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 6e-130) {
tmp = cos(th) * ((a1 * a1) / sqrt(2.0));
} else {
tmp = a2 * (a2 / (sqrt(2.0) / cos(th)));
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this 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 (a2 <= 6d-130) then
tmp = cos(th) * ((a1 * a1) / sqrt(2.0d0))
else
tmp = a2 * (a2 / (sqrt(2.0d0) / cos(th)))
end if
code = tmp
end function
assert a1 < a2;
public static double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 6e-130) {
tmp = Math.cos(th) * ((a1 * a1) / Math.sqrt(2.0));
} else {
tmp = a2 * (a2 / (Math.sqrt(2.0) / Math.cos(th)));
}
return tmp;
}
[a1, a2] = sort([a1, a2]) def code(a1, a2, th): tmp = 0 if a2 <= 6e-130: tmp = math.cos(th) * ((a1 * a1) / math.sqrt(2.0)) else: tmp = a2 * (a2 / (math.sqrt(2.0) / math.cos(th))) return tmp
a1, a2 = sort([a1, a2]) function code(a1, a2, th) tmp = 0.0 if (a2 <= 6e-130) tmp = Float64(cos(th) * Float64(Float64(a1 * a1) / sqrt(2.0))); else tmp = Float64(a2 * Float64(a2 / Float64(sqrt(2.0) / cos(th)))); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp_2 = code(a1, a2, th)
tmp = 0.0;
if (a2 <= 6e-130)
tmp = cos(th) * ((a1 * a1) / sqrt(2.0));
else
tmp = a2 * (a2 / (sqrt(2.0) / cos(th)));
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := If[LessEqual[a2, 6e-130], N[(N[Cos[th], $MachinePrecision] * N[(N[(a1 * a1), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a2 * N[(a2 / N[(N[Sqrt[2.0], $MachinePrecision] / N[Cos[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 6 \cdot 10^{-130}:\\
\;\;\;\;\cos th \cdot \frac{a1 \cdot a1}{\sqrt{2}}\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \frac{a2}{\frac{\sqrt{2}}{\cos th}}\\
\end{array}
\end{array}
if a2 < 5.99999999999999972e-130Initial program 99.6%
distribute-lft-out99.6%
associate-*l/99.7%
associate-*r/99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in a1 around inf 64.4%
unpow264.4%
Simplified64.4%
if 5.99999999999999972e-130 < a2 Initial program 99.6%
distribute-lft-out99.6%
associate-*l/99.6%
associate-*r/99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in a1 around 0 75.0%
unpow275.0%
associate-*l*75.0%
associate-*r/75.0%
associate-/l*75.0%
Simplified75.0%
Final simplification67.9%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (if (<= a2 3.3e-127) (* (cos th) (/ (* a1 a1) (sqrt 2.0))) (* (cos th) (/ (* a2 a2) (sqrt 2.0)))))
assert(a1 < a2);
double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 3.3e-127) {
tmp = cos(th) * ((a1 * a1) / sqrt(2.0));
} else {
tmp = cos(th) * ((a2 * a2) / sqrt(2.0));
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this 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 (a2 <= 3.3d-127) then
tmp = cos(th) * ((a1 * a1) / sqrt(2.0d0))
else
tmp = cos(th) * ((a2 * a2) / sqrt(2.0d0))
end if
code = tmp
end function
assert a1 < a2;
public static double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 3.3e-127) {
tmp = Math.cos(th) * ((a1 * a1) / Math.sqrt(2.0));
} else {
tmp = Math.cos(th) * ((a2 * a2) / Math.sqrt(2.0));
}
return tmp;
}
[a1, a2] = sort([a1, a2]) def code(a1, a2, th): tmp = 0 if a2 <= 3.3e-127: tmp = math.cos(th) * ((a1 * a1) / math.sqrt(2.0)) else: tmp = math.cos(th) * ((a2 * a2) / math.sqrt(2.0)) return tmp
a1, a2 = sort([a1, a2]) function code(a1, a2, th) tmp = 0.0 if (a2 <= 3.3e-127) tmp = Float64(cos(th) * Float64(Float64(a1 * a1) / sqrt(2.0))); else tmp = Float64(cos(th) * Float64(Float64(a2 * a2) / sqrt(2.0))); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp_2 = code(a1, a2, th)
tmp = 0.0;
if (a2 <= 3.3e-127)
tmp = cos(th) * ((a1 * a1) / sqrt(2.0));
else
tmp = cos(th) * ((a2 * a2) / sqrt(2.0));
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := If[LessEqual[a2, 3.3e-127], N[(N[Cos[th], $MachinePrecision] * N[(N[(a1 * a1), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[th], $MachinePrecision] * N[(N[(a2 * a2), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 3.3 \cdot 10^{-127}:\\
\;\;\;\;\cos th \cdot \frac{a1 \cdot a1}{\sqrt{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos th \cdot \frac{a2 \cdot a2}{\sqrt{2}}\\
\end{array}
\end{array}
if a2 < 3.29999999999999981e-127Initial program 99.6%
distribute-lft-out99.6%
associate-*l/99.7%
associate-*r/99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in a1 around inf 64.6%
unpow264.6%
Simplified64.6%
if 3.29999999999999981e-127 < a2 Initial program 99.6%
distribute-lft-out99.6%
associate-*l/99.6%
associate-*r/99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in a1 around 0 75.9%
unpow275.9%
Simplified75.9%
Final simplification68.3%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (if (<= a2 3.3e-127) (* (cos th) (/ (* a1 a1) (sqrt 2.0))) (* a2 (* a2 (* (cos th) (sqrt 0.5))))))
assert(a1 < a2);
double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 3.3e-127) {
tmp = cos(th) * ((a1 * a1) / sqrt(2.0));
} else {
tmp = a2 * (a2 * (cos(th) * sqrt(0.5)));
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this 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 (a2 <= 3.3d-127) then
tmp = cos(th) * ((a1 * a1) / sqrt(2.0d0))
else
tmp = a2 * (a2 * (cos(th) * sqrt(0.5d0)))
end if
code = tmp
end function
assert a1 < a2;
public static double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 3.3e-127) {
tmp = Math.cos(th) * ((a1 * a1) / Math.sqrt(2.0));
} else {
tmp = a2 * (a2 * (Math.cos(th) * Math.sqrt(0.5)));
}
return tmp;
}
[a1, a2] = sort([a1, a2]) def code(a1, a2, th): tmp = 0 if a2 <= 3.3e-127: tmp = math.cos(th) * ((a1 * a1) / math.sqrt(2.0)) else: tmp = a2 * (a2 * (math.cos(th) * math.sqrt(0.5))) return tmp
a1, a2 = sort([a1, a2]) function code(a1, a2, th) tmp = 0.0 if (a2 <= 3.3e-127) tmp = Float64(cos(th) * Float64(Float64(a1 * a1) / sqrt(2.0))); else tmp = Float64(a2 * Float64(a2 * Float64(cos(th) * sqrt(0.5)))); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp_2 = code(a1, a2, th)
tmp = 0.0;
if (a2 <= 3.3e-127)
tmp = cos(th) * ((a1 * a1) / sqrt(2.0));
else
tmp = a2 * (a2 * (cos(th) * sqrt(0.5)));
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := If[LessEqual[a2, 3.3e-127], N[(N[Cos[th], $MachinePrecision] * N[(N[(a1 * a1), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a2 * N[(a2 * N[(N[Cos[th], $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 3.3 \cdot 10^{-127}:\\
\;\;\;\;\cos th \cdot \frac{a1 \cdot a1}{\sqrt{2}}\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \left(a2 \cdot \left(\cos th \cdot \sqrt{0.5}\right)\right)\\
\end{array}
\end{array}
if a2 < 3.29999999999999981e-127Initial program 99.6%
distribute-lft-out99.6%
associate-*l/99.7%
associate-*r/99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in a1 around inf 64.6%
unpow264.6%
Simplified64.6%
if 3.29999999999999981e-127 < a2 Initial program 99.6%
distribute-lft-out99.6%
associate-*l/99.6%
associate-*r/99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in a1 around 0 75.9%
unpow275.9%
*-commutative75.9%
associate-/l*75.9%
Simplified75.9%
associate-/r/75.9%
div-inv75.8%
*-commutative75.8%
pow1/275.8%
pow-flip75.9%
metadata-eval75.9%
associate-*r*75.9%
*-commutative75.9%
metadata-eval75.9%
pow-flip75.8%
pow1/275.8%
add-sqr-sqrt75.8%
sqrt-unprod75.8%
frac-times75.8%
metadata-eval75.8%
add-sqr-sqrt75.9%
metadata-eval75.9%
Applied egg-rr75.9%
Final simplification68.3%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (if (<= a2 8.8e-91) (* a1 (* a1 (sqrt 0.5))) (/ 1.0 (/ (sqrt 2.0) (* a2 a2)))))
assert(a1 < a2);
double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 8.8e-91) {
tmp = a1 * (a1 * sqrt(0.5));
} else {
tmp = 1.0 / (sqrt(2.0) / (a2 * a2));
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this 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 (a2 <= 8.8d-91) then
tmp = a1 * (a1 * sqrt(0.5d0))
else
tmp = 1.0d0 / (sqrt(2.0d0) / (a2 * a2))
end if
code = tmp
end function
assert a1 < a2;
public static double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 8.8e-91) {
tmp = a1 * (a1 * Math.sqrt(0.5));
} else {
tmp = 1.0 / (Math.sqrt(2.0) / (a2 * a2));
}
return tmp;
}
[a1, a2] = sort([a1, a2]) def code(a1, a2, th): tmp = 0 if a2 <= 8.8e-91: tmp = a1 * (a1 * math.sqrt(0.5)) else: tmp = 1.0 / (math.sqrt(2.0) / (a2 * a2)) return tmp
a1, a2 = sort([a1, a2]) function code(a1, a2, th) tmp = 0.0 if (a2 <= 8.8e-91) tmp = Float64(a1 * Float64(a1 * sqrt(0.5))); else tmp = Float64(1.0 / Float64(sqrt(2.0) / Float64(a2 * a2))); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp_2 = code(a1, a2, th)
tmp = 0.0;
if (a2 <= 8.8e-91)
tmp = a1 * (a1 * sqrt(0.5));
else
tmp = 1.0 / (sqrt(2.0) / (a2 * a2));
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := If[LessEqual[a2, 8.8e-91], N[(a1 * N[(a1 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sqrt[2.0], $MachinePrecision] / N[(a2 * a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 8.8 \cdot 10^{-91}:\\
\;\;\;\;a1 \cdot \left(a1 \cdot \sqrt{0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\sqrt{2}}{a2 \cdot a2}}\\
\end{array}
\end{array}
if a2 < 8.8000000000000003e-91Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 66.8%
Taylor expanded in a1 around inf 45.3%
unpow245.3%
associate-*r/45.2%
Simplified45.2%
clear-num45.2%
associate-/r/45.2%
add-sqr-sqrt45.2%
sqrt-unprod45.2%
frac-times45.2%
metadata-eval45.2%
add-sqr-sqrt45.3%
metadata-eval45.3%
Applied egg-rr45.3%
if 8.8000000000000003e-91 < a2 Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 61.6%
Taylor expanded in a1 around 0 47.4%
unpow247.4%
Simplified47.4%
associate-*l/47.5%
associate-/l*47.5%
Applied egg-rr47.5%
Final simplification45.9%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (* (sqrt 0.5) (+ (* a2 a2) (* a1 a1))))
assert(a1 < a2);
double code(double a1, double a2, double th) {
return sqrt(0.5) * ((a2 * a2) + (a1 * a1));
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
code = sqrt(0.5d0) * ((a2 * a2) + (a1 * a1))
end function
assert a1 < a2;
public static double code(double a1, double a2, double th) {
return Math.sqrt(0.5) * ((a2 * a2) + (a1 * a1));
}
[a1, a2] = sort([a1, a2]) def code(a1, a2, th): return math.sqrt(0.5) * ((a2 * a2) + (a1 * a1))
a1, a2 = sort([a1, a2]) function code(a1, a2, th) return Float64(sqrt(0.5) * Float64(Float64(a2 * a2) + Float64(a1 * a1))) end
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = sqrt(0.5) * ((a2 * a2) + (a1 * a1));
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := N[(N[Sqrt[0.5], $MachinePrecision] * N[(N[(a2 * a2), $MachinePrecision] + N[(a1 * a1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\sqrt{0.5} \cdot \left(a2 \cdot a2 + a1 \cdot a1\right)
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
clear-num99.6%
associate-/r/99.5%
pow1/299.5%
pow-flip99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 65.3%
unpow265.3%
unpow265.3%
Simplified65.3%
Final simplification65.3%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (if (<= a2 8.5e-92) (* a1 (* a1 (sqrt 0.5))) (* a2 (/ a2 (sqrt 2.0)))))
assert(a1 < a2);
double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 8.5e-92) {
tmp = a1 * (a1 * sqrt(0.5));
} else {
tmp = a2 * (a2 / sqrt(2.0));
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this 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 (a2 <= 8.5d-92) then
tmp = a1 * (a1 * sqrt(0.5d0))
else
tmp = a2 * (a2 / sqrt(2.0d0))
end if
code = tmp
end function
assert a1 < a2;
public static double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 8.5e-92) {
tmp = a1 * (a1 * Math.sqrt(0.5));
} else {
tmp = a2 * (a2 / Math.sqrt(2.0));
}
return tmp;
}
[a1, a2] = sort([a1, a2]) def code(a1, a2, th): tmp = 0 if a2 <= 8.5e-92: tmp = a1 * (a1 * math.sqrt(0.5)) else: tmp = a2 * (a2 / math.sqrt(2.0)) return tmp
a1, a2 = sort([a1, a2]) function code(a1, a2, th) tmp = 0.0 if (a2 <= 8.5e-92) tmp = Float64(a1 * Float64(a1 * sqrt(0.5))); else tmp = Float64(a2 * Float64(a2 / sqrt(2.0))); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp_2 = code(a1, a2, th)
tmp = 0.0;
if (a2 <= 8.5e-92)
tmp = a1 * (a1 * sqrt(0.5));
else
tmp = a2 * (a2 / sqrt(2.0));
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := If[LessEqual[a2, 8.5e-92], N[(a1 * N[(a1 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a2 * N[(a2 / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 8.5 \cdot 10^{-92}:\\
\;\;\;\;a1 \cdot \left(a1 \cdot \sqrt{0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \frac{a2}{\sqrt{2}}\\
\end{array}
\end{array}
if a2 < 8.50000000000000067e-92Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 66.8%
Taylor expanded in a1 around inf 45.3%
unpow245.3%
associate-*r/45.2%
Simplified45.2%
clear-num45.2%
associate-/r/45.2%
add-sqr-sqrt45.2%
sqrt-unprod45.2%
frac-times45.2%
metadata-eval45.2%
add-sqr-sqrt45.3%
metadata-eval45.3%
Applied egg-rr45.3%
if 8.50000000000000067e-92 < a2 Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 61.6%
Taylor expanded in a1 around 0 47.4%
unpow247.4%
Simplified47.4%
Taylor expanded in a2 around 0 47.5%
unpow247.5%
associate-*l/47.4%
*-commutative47.4%
Simplified47.4%
Final simplification45.9%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (if (<= a2 1.1e-90) (* a1 (* a1 (sqrt 0.5))) (* a2 (* a2 (sqrt 0.5)))))
assert(a1 < a2);
double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 1.1e-90) {
tmp = a1 * (a1 * sqrt(0.5));
} else {
tmp = a2 * (a2 * sqrt(0.5));
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this 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 (a2 <= 1.1d-90) then
tmp = a1 * (a1 * sqrt(0.5d0))
else
tmp = a2 * (a2 * sqrt(0.5d0))
end if
code = tmp
end function
assert a1 < a2;
public static double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 1.1e-90) {
tmp = a1 * (a1 * Math.sqrt(0.5));
} else {
tmp = a2 * (a2 * Math.sqrt(0.5));
}
return tmp;
}
[a1, a2] = sort([a1, a2]) def code(a1, a2, th): tmp = 0 if a2 <= 1.1e-90: tmp = a1 * (a1 * math.sqrt(0.5)) else: tmp = a2 * (a2 * math.sqrt(0.5)) return tmp
a1, a2 = sort([a1, a2]) function code(a1, a2, th) tmp = 0.0 if (a2 <= 1.1e-90) tmp = Float64(a1 * Float64(a1 * sqrt(0.5))); else tmp = Float64(a2 * Float64(a2 * sqrt(0.5))); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp_2 = code(a1, a2, th)
tmp = 0.0;
if (a2 <= 1.1e-90)
tmp = a1 * (a1 * sqrt(0.5));
else
tmp = a2 * (a2 * sqrt(0.5));
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := If[LessEqual[a2, 1.1e-90], N[(a1 * N[(a1 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a2 * N[(a2 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 1.1 \cdot 10^{-90}:\\
\;\;\;\;a1 \cdot \left(a1 \cdot \sqrt{0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \left(a2 \cdot \sqrt{0.5}\right)\\
\end{array}
\end{array}
if a2 < 1.09999999999999993e-90Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 66.8%
Taylor expanded in a1 around inf 45.3%
unpow245.3%
associate-*r/45.2%
Simplified45.2%
clear-num45.2%
associate-/r/45.2%
add-sqr-sqrt45.2%
sqrt-unprod45.2%
frac-times45.2%
metadata-eval45.2%
add-sqr-sqrt45.3%
metadata-eval45.3%
Applied egg-rr45.3%
if 1.09999999999999993e-90 < a2 Initial program 99.6%
distribute-lft-out99.6%
associate-*l/99.6%
associate-*r/99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in a1 around 0 78.2%
unpow278.2%
*-commutative78.2%
associate-/l*78.2%
Simplified78.2%
associate-/r/78.1%
div-inv78.1%
*-commutative78.1%
pow1/278.1%
pow-flip78.1%
metadata-eval78.1%
associate-*r*78.2%
*-commutative78.2%
metadata-eval78.2%
pow-flip78.1%
pow1/278.1%
add-sqr-sqrt78.1%
sqrt-unprod78.1%
frac-times78.1%
metadata-eval78.1%
add-sqr-sqrt78.2%
metadata-eval78.2%
Applied egg-rr78.2%
Taylor expanded in th around 0 47.4%
Final simplification45.9%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (if (<= a2 1.7e-90) (* a1 (* a1 (sqrt 0.5))) (/ a2 (/ (sqrt 2.0) a2))))
assert(a1 < a2);
double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 1.7e-90) {
tmp = a1 * (a1 * sqrt(0.5));
} else {
tmp = a2 / (sqrt(2.0) / a2);
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this 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 (a2 <= 1.7d-90) then
tmp = a1 * (a1 * sqrt(0.5d0))
else
tmp = a2 / (sqrt(2.0d0) / a2)
end if
code = tmp
end function
assert a1 < a2;
public static double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 1.7e-90) {
tmp = a1 * (a1 * Math.sqrt(0.5));
} else {
tmp = a2 / (Math.sqrt(2.0) / a2);
}
return tmp;
}
[a1, a2] = sort([a1, a2]) def code(a1, a2, th): tmp = 0 if a2 <= 1.7e-90: tmp = a1 * (a1 * math.sqrt(0.5)) else: tmp = a2 / (math.sqrt(2.0) / a2) return tmp
a1, a2 = sort([a1, a2]) function code(a1, a2, th) tmp = 0.0 if (a2 <= 1.7e-90) tmp = Float64(a1 * Float64(a1 * sqrt(0.5))); else tmp = Float64(a2 / Float64(sqrt(2.0) / a2)); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp_2 = code(a1, a2, th)
tmp = 0.0;
if (a2 <= 1.7e-90)
tmp = a1 * (a1 * sqrt(0.5));
else
tmp = a2 / (sqrt(2.0) / a2);
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := If[LessEqual[a2, 1.7e-90], N[(a1 * N[(a1 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a2 / N[(N[Sqrt[2.0], $MachinePrecision] / a2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 1.7 \cdot 10^{-90}:\\
\;\;\;\;a1 \cdot \left(a1 \cdot \sqrt{0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a2}{\frac{\sqrt{2}}{a2}}\\
\end{array}
\end{array}
if a2 < 1.69999999999999997e-90Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 66.8%
Taylor expanded in a1 around inf 45.3%
unpow245.3%
associate-*r/45.2%
Simplified45.2%
clear-num45.2%
associate-/r/45.2%
add-sqr-sqrt45.2%
sqrt-unprod45.2%
frac-times45.2%
metadata-eval45.2%
add-sqr-sqrt45.3%
metadata-eval45.3%
Applied egg-rr45.3%
if 1.69999999999999997e-90 < a2 Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 61.6%
Taylor expanded in a1 around 0 47.4%
unpow247.4%
Simplified47.4%
associate-*l/47.5%
*-un-lft-identity47.5%
associate-/l*47.5%
Applied egg-rr47.5%
Final simplification45.9%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (* a1 (* a1 (sqrt 0.5))))
assert(a1 < a2);
double code(double a1, double a2, double th) {
return a1 * (a1 * sqrt(0.5));
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
code = a1 * (a1 * sqrt(0.5d0))
end function
assert a1 < a2;
public static double code(double a1, double a2, double th) {
return a1 * (a1 * Math.sqrt(0.5));
}
[a1, a2] = sort([a1, a2]) def code(a1, a2, th): return a1 * (a1 * math.sqrt(0.5))
a1, a2 = sort([a1, a2]) function code(a1, a2, th) return Float64(a1 * Float64(a1 * sqrt(0.5))) end
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = a1 * (a1 * sqrt(0.5));
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := N[(a1 * N[(a1 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
a1 \cdot \left(a1 \cdot \sqrt{0.5}\right)
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 65.3%
Taylor expanded in a1 around inf 39.0%
unpow239.0%
associate-*r/39.0%
Simplified39.0%
clear-num39.0%
associate-/r/39.0%
add-sqr-sqrt39.0%
sqrt-unprod39.0%
frac-times39.0%
metadata-eval39.0%
add-sqr-sqrt39.0%
metadata-eval39.0%
Applied egg-rr39.0%
Final simplification39.0%
herbie shell --seed 2023181
(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))))