
(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 6 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 should be positive before calling this function NOTE: a2 should be positive before calling this function NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (* (* a2 (sqrt 0.5)) (* a2 (cos th))))
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
return (a2 * sqrt(0.5)) * (a2 * cos(th));
}
NOTE: a1 should be positive before calling this function
NOTE: a2 should be positive before calling this function
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 = (a2 * sqrt(0.5d0)) * (a2 * cos(th))
end function
a1 = Math.abs(a1);
a2 = Math.abs(a2);
assert a1 < a2;
public static double code(double a1, double a2, double th) {
return (a2 * Math.sqrt(0.5)) * (a2 * Math.cos(th));
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): return (a2 * math.sqrt(0.5)) * (a2 * math.cos(th))
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) return Float64(Float64(a2 * sqrt(0.5)) * Float64(a2 * cos(th))) end
a1 = abs(a1)
a2 = abs(a2)
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = (a2 * sqrt(0.5)) * (a2 * cos(th));
end
NOTE: a1 should be positive before calling this function NOTE: a2 should be positive before calling this function NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := N[(N[(a2 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] * N[(a2 * N[Cos[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\left(a2 \cdot \sqrt{0.5}\right) \cdot \left(a2 \cdot \cos th\right)
\end{array}
Initial program 99.6%
+-commutative99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in a2 around inf 56.0%
unpow256.0%
associate-/l*56.0%
Simplified56.0%
associate-/l*56.0%
div-inv56.0%
*-commutative56.0%
inv-pow56.0%
sqrt-pow256.0%
metadata-eval56.0%
associate-*l*56.0%
*-commutative56.0%
Applied egg-rr56.0%
associate-*r*56.0%
*-commutative56.0%
Simplified56.0%
Taylor expanded in a2 around 0 56.0%
Final simplification56.0%
NOTE: a1 should be positive before calling this function NOTE: a2 should be positive before calling this function NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (* (cos th) (/ a2 (/ (sqrt 2.0) a2))))
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
return cos(th) * (a2 / (sqrt(2.0) / a2));
}
NOTE: a1 should be positive before calling this function
NOTE: a2 should be positive before calling this function
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) * (a2 / (sqrt(2.0d0) / a2))
end function
a1 = Math.abs(a1);
a2 = Math.abs(a2);
assert a1 < a2;
public static double code(double a1, double a2, double th) {
return Math.cos(th) * (a2 / (Math.sqrt(2.0) / a2));
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): return math.cos(th) * (a2 / (math.sqrt(2.0) / a2))
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) return Float64(cos(th) * Float64(a2 / Float64(sqrt(2.0) / a2))) end
a1 = abs(a1)
a2 = abs(a2)
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = cos(th) * (a2 / (sqrt(2.0) / a2));
end
NOTE: a1 should be positive before calling this function NOTE: a2 should be positive before calling this function NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := N[(N[Cos[th], $MachinePrecision] * N[(a2 / N[(N[Sqrt[2.0], $MachinePrecision] / a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\cos th \cdot \frac{a2}{\frac{\sqrt{2}}{a2}}
\end{array}
Initial program 99.6%
+-commutative99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in a2 around inf 56.0%
unpow256.0%
*-commutative56.0%
associate-*r/56.0%
associate-/l*56.0%
Simplified56.0%
Final simplification56.0%
NOTE: a1 should be positive before calling this function
NOTE: a2 should be positive before calling this function
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
(FPCore (a1 a2 th)
:precision binary64
(if (<= a2 7e+167)
(/ a2 (/ (sqrt 2.0) a2))
(if (<= a2 2.4e+259)
(* (* (sqrt 0.5) (+ 1.0 (* -0.5 (* th th)))) (* a2 a2))
(* (sqrt 0.5) (* a2 a2)))))a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 7e+167) {
tmp = a2 / (sqrt(2.0) / a2);
} else if (a2 <= 2.4e+259) {
tmp = (sqrt(0.5) * (1.0 + (-0.5 * (th * th)))) * (a2 * a2);
} else {
tmp = sqrt(0.5) * (a2 * a2);
}
return tmp;
}
NOTE: a1 should be positive before calling this function
NOTE: a2 should be positive before calling this function
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 <= 7d+167) then
tmp = a2 / (sqrt(2.0d0) / a2)
else if (a2 <= 2.4d+259) then
tmp = (sqrt(0.5d0) * (1.0d0 + ((-0.5d0) * (th * th)))) * (a2 * a2)
else
tmp = sqrt(0.5d0) * (a2 * a2)
end if
code = tmp
end function
a1 = Math.abs(a1);
a2 = Math.abs(a2);
assert a1 < a2;
public static double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 7e+167) {
tmp = a2 / (Math.sqrt(2.0) / a2);
} else if (a2 <= 2.4e+259) {
tmp = (Math.sqrt(0.5) * (1.0 + (-0.5 * (th * th)))) * (a2 * a2);
} else {
tmp = Math.sqrt(0.5) * (a2 * a2);
}
return tmp;
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): tmp = 0 if a2 <= 7e+167: tmp = a2 / (math.sqrt(2.0) / a2) elif a2 <= 2.4e+259: tmp = (math.sqrt(0.5) * (1.0 + (-0.5 * (th * th)))) * (a2 * a2) else: tmp = math.sqrt(0.5) * (a2 * a2) return tmp
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) tmp = 0.0 if (a2 <= 7e+167) tmp = Float64(a2 / Float64(sqrt(2.0) / a2)); elseif (a2 <= 2.4e+259) tmp = Float64(Float64(sqrt(0.5) * Float64(1.0 + Float64(-0.5 * Float64(th * th)))) * Float64(a2 * a2)); else tmp = Float64(sqrt(0.5) * Float64(a2 * a2)); end return tmp end
a1 = abs(a1)
a2 = abs(a2)
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp_2 = code(a1, a2, th)
tmp = 0.0;
if (a2 <= 7e+167)
tmp = a2 / (sqrt(2.0) / a2);
elseif (a2 <= 2.4e+259)
tmp = (sqrt(0.5) * (1.0 + (-0.5 * (th * th)))) * (a2 * a2);
else
tmp = sqrt(0.5) * (a2 * a2);
end
tmp_2 = tmp;
end
NOTE: a1 should be positive before calling this function NOTE: a2 should be positive before calling this function NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := If[LessEqual[a2, 7e+167], N[(a2 / N[(N[Sqrt[2.0], $MachinePrecision] / a2), $MachinePrecision]), $MachinePrecision], If[LessEqual[a2, 2.4e+259], N[(N[(N[Sqrt[0.5], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(th * th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a2 * a2), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[0.5], $MachinePrecision] * N[(a2 * a2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 7 \cdot 10^{+167}:\\
\;\;\;\;\frac{a2}{\frac{\sqrt{2}}{a2}}\\
\mathbf{elif}\;a2 \leq 2.4 \cdot 10^{+259}:\\
\;\;\;\;\left(\sqrt{0.5} \cdot \left(1 + -0.5 \cdot \left(th \cdot th\right)\right)\right) \cdot \left(a2 \cdot a2\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(a2 \cdot a2\right)\\
\end{array}
\end{array}
if a2 < 6.99999999999999975e167Initial program 99.5%
+-commutative99.5%
distribute-lft-out99.5%
Simplified99.5%
Taylor expanded in th around 0 65.3%
Taylor expanded in a2 around inf 37.1%
unpow237.1%
Simplified37.1%
Taylor expanded in a2 around 0 37.1%
unpow237.1%
associate-/l*37.1%
Simplified37.1%
if 6.99999999999999975e167 < a2 < 2.4e259Initial program 100.0%
+-commutative100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in a2 around inf 100.0%
unpow2100.0%
associate-/l*100.0%
Simplified100.0%
associate-/l*100.0%
div-inv100.0%
*-commutative100.0%
inv-pow100.0%
sqrt-pow2100.0%
metadata-eval100.0%
associate-*l*100.0%
*-commutative100.0%
Applied egg-rr100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in th around 0 92.3%
associate-*r*92.3%
unpow292.3%
Simplified92.3%
Taylor expanded in a2 around 0 92.3%
unpow292.3%
*-commutative92.3%
unpow292.3%
Simplified92.3%
if 2.4e259 < a2 Initial program 100.0%
+-commutative100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in a2 around inf 100.0%
unpow2100.0%
associate-/l*100.0%
Simplified100.0%
associate-/l*100.0%
div-inv100.0%
*-commutative100.0%
inv-pow100.0%
sqrt-pow2100.0%
metadata-eval100.0%
associate-*l*100.0%
*-commutative100.0%
Applied egg-rr100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in th around 0 81.8%
unpow281.8%
*-commutative81.8%
Simplified81.8%
Final simplification41.8%
NOTE: a1 should be positive before calling this function NOTE: a2 should be positive before calling this function NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (if (<= th 1.02e+175) (/ a2 (/ (sqrt 2.0) a2)) (* -0.5 (* (sqrt 0.5) (* (* th th) (* a2 a2))))))
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
double tmp;
if (th <= 1.02e+175) {
tmp = a2 / (sqrt(2.0) / a2);
} else {
tmp = -0.5 * (sqrt(0.5) * ((th * th) * (a2 * a2)));
}
return tmp;
}
NOTE: a1 should be positive before calling this function
NOTE: a2 should be positive before calling this function
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 (th <= 1.02d+175) then
tmp = a2 / (sqrt(2.0d0) / a2)
else
tmp = (-0.5d0) * (sqrt(0.5d0) * ((th * th) * (a2 * a2)))
end if
code = tmp
end function
a1 = Math.abs(a1);
a2 = Math.abs(a2);
assert a1 < a2;
public static double code(double a1, double a2, double th) {
double tmp;
if (th <= 1.02e+175) {
tmp = a2 / (Math.sqrt(2.0) / a2);
} else {
tmp = -0.5 * (Math.sqrt(0.5) * ((th * th) * (a2 * a2)));
}
return tmp;
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): tmp = 0 if th <= 1.02e+175: tmp = a2 / (math.sqrt(2.0) / a2) else: tmp = -0.5 * (math.sqrt(0.5) * ((th * th) * (a2 * a2))) return tmp
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) tmp = 0.0 if (th <= 1.02e+175) tmp = Float64(a2 / Float64(sqrt(2.0) / a2)); else tmp = Float64(-0.5 * Float64(sqrt(0.5) * Float64(Float64(th * th) * Float64(a2 * a2)))); end return tmp end
a1 = abs(a1)
a2 = abs(a2)
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp_2 = code(a1, a2, th)
tmp = 0.0;
if (th <= 1.02e+175)
tmp = a2 / (sqrt(2.0) / a2);
else
tmp = -0.5 * (sqrt(0.5) * ((th * th) * (a2 * a2)));
end
tmp_2 = tmp;
end
NOTE: a1 should be positive before calling this function NOTE: a2 should be positive before calling this function NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := If[LessEqual[th, 1.02e+175], N[(a2 / N[(N[Sqrt[2.0], $MachinePrecision] / a2), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[Sqrt[0.5], $MachinePrecision] * N[(N[(th * th), $MachinePrecision] * N[(a2 * a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\begin{array}{l}
\mathbf{if}\;th \leq 1.02 \cdot 10^{+175}:\\
\;\;\;\;\frac{a2}{\frac{\sqrt{2}}{a2}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\sqrt{0.5} \cdot \left(\left(th \cdot th\right) \cdot \left(a2 \cdot a2\right)\right)\right)\\
\end{array}
\end{array}
if th < 1.0199999999999999e175Initial program 99.6%
+-commutative99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 70.6%
Taylor expanded in a2 around inf 42.0%
unpow242.0%
Simplified42.0%
Taylor expanded in a2 around 0 42.0%
unpow242.0%
associate-/l*42.0%
Simplified42.0%
if 1.0199999999999999e175 < th Initial program 99.4%
+-commutative99.4%
distribute-lft-out99.4%
Simplified99.4%
Taylor expanded in a2 around inf 48.0%
unpow248.0%
associate-/l*48.1%
Simplified48.1%
associate-/l*48.0%
div-inv48.0%
*-commutative48.0%
inv-pow48.0%
sqrt-pow248.1%
metadata-eval48.1%
associate-*l*48.1%
*-commutative48.1%
Applied egg-rr48.1%
associate-*r*48.2%
*-commutative48.2%
Simplified48.2%
Taylor expanded in th around 0 29.9%
associate-*r*29.9%
unpow229.9%
Simplified29.9%
Taylor expanded in th around inf 26.1%
unpow226.1%
unpow226.1%
associate-*r*26.1%
*-commutative26.1%
Simplified26.1%
Final simplification40.3%
NOTE: a1 should be positive before calling this function NOTE: a2 should be positive before calling this function 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 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
return sqrt(0.5) * (a2 * a2);
}
NOTE: a1 should be positive before calling this function
NOTE: a2 should be positive before calling this function
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)
end function
a1 = Math.abs(a1);
a2 = Math.abs(a2);
assert a1 < a2;
public static double code(double a1, double a2, double th) {
return Math.sqrt(0.5) * (a2 * a2);
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): return math.sqrt(0.5) * (a2 * a2)
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) return Float64(sqrt(0.5) * Float64(a2 * a2)) end
a1 = abs(a1)
a2 = abs(a2)
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = sqrt(0.5) * (a2 * a2);
end
NOTE: a1 should be positive before calling this function NOTE: a2 should be positive before calling this function 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[(a2 * a2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\sqrt{0.5} \cdot \left(a2 \cdot a2\right)
\end{array}
Initial program 99.6%
+-commutative99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in a2 around inf 56.0%
unpow256.0%
associate-/l*56.0%
Simplified56.0%
associate-/l*56.0%
div-inv56.0%
*-commutative56.0%
inv-pow56.0%
sqrt-pow256.0%
metadata-eval56.0%
associate-*l*56.0%
*-commutative56.0%
Applied egg-rr56.0%
associate-*r*56.0%
*-commutative56.0%
Simplified56.0%
Taylor expanded in th around 0 39.4%
unpow239.4%
*-commutative39.4%
Simplified39.4%
Final simplification39.4%
NOTE: a1 should be positive before calling this function NOTE: a2 should be positive before calling this function NOTE: a1 and a2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 th) :precision binary64 (/ a2 (/ (sqrt 2.0) a2)))
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
return a2 / (sqrt(2.0) / a2);
}
NOTE: a1 should be positive before calling this function
NOTE: a2 should be positive before calling this function
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 = a2 / (sqrt(2.0d0) / a2)
end function
a1 = Math.abs(a1);
a2 = Math.abs(a2);
assert a1 < a2;
public static double code(double a1, double a2, double th) {
return a2 / (Math.sqrt(2.0) / a2);
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): return a2 / (math.sqrt(2.0) / a2)
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) return Float64(a2 / Float64(sqrt(2.0) / a2)) end
a1 = abs(a1)
a2 = abs(a2)
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = a2 / (sqrt(2.0) / a2);
end
NOTE: a1 should be positive before calling this function NOTE: a2 should be positive before calling this function NOTE: a1 and a2 should be sorted in increasing order before calling this function. code[a1_, a2_, th_] := N[(a2 / N[(N[Sqrt[2.0], $MachinePrecision] / a2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\frac{a2}{\frac{\sqrt{2}}{a2}}
\end{array}
Initial program 99.6%
+-commutative99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 65.1%
Taylor expanded in a2 around inf 39.4%
unpow239.4%
Simplified39.4%
Taylor expanded in a2 around 0 39.4%
unpow239.4%
associate-/l*39.4%
Simplified39.4%
Final simplification39.4%
herbie shell --seed 2023297
(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))))