
(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}
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 (cos th)) (* a2 (sqrt 0.5))))
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
return (a2 * cos(th)) * (a2 * sqrt(0.5));
}
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 * cos(th)) * (a2 * sqrt(0.5d0))
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.cos(th)) * (a2 * Math.sqrt(0.5));
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): return (a2 * math.cos(th)) * (a2 * math.sqrt(0.5))
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) return Float64(Float64(a2 * cos(th)) * Float64(a2 * sqrt(0.5))) end
a1 = abs(a1)
a2 = abs(a2)
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = (a2 * cos(th)) * (a2 * sqrt(0.5));
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[Cos[th], $MachinePrecision]), $MachinePrecision] * N[(a2 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\left(a2 \cdot \cos th\right) \cdot \left(a2 \cdot \sqrt{0.5}\right)
\end{array}
Initial program 98.9%
distribute-lft-out98.9%
cos-neg98.9%
associate-*l/99.0%
cos-neg99.0%
fma-def99.0%
Simplified99.0%
Taylor expanded in a1 around 0 59.2%
unpow259.2%
associate-*l*59.5%
Simplified59.5%
div-inv59.5%
pow1/259.5%
pow-flip59.5%
metadata-eval59.5%
*-commutative59.5%
associate-*l*59.5%
add-sqr-sqrt59.2%
sqrt-unprod59.5%
pow-prod-up59.5%
metadata-eval59.5%
metadata-eval59.5%
Applied egg-rr59.5%
Final simplification59.5%
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 (* a2 (/ (cos th) (sqrt 2.0)))))
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
return a2 * (a2 * (cos(th) / sqrt(2.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.
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
a1 = Math.abs(a1);
a2 = Math.abs(a2);
assert a1 < a2;
public static double code(double a1, double a2, double th) {
return a2 * (a2 * (Math.cos(th) / Math.sqrt(2.0)));
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): return a2 * (a2 * (math.cos(th) / math.sqrt(2.0)))
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) return Float64(a2 * Float64(a2 * Float64(cos(th) / sqrt(2.0)))) end
a1 = abs(a1)
a2 = abs(a2)
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = a2 * (a2 * (cos(th) / sqrt(2.0)));
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[(a2 * N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
a2 \cdot \left(a2 \cdot \frac{\cos th}{\sqrt{2}}\right)
\end{array}
Initial program 98.9%
+-commutative98.9%
distribute-lft-out98.9%
Simplified98.9%
Taylor expanded in a2 around inf 59.2%
unpow259.2%
associate-*r/59.1%
associate-*r*59.5%
Simplified59.5%
Final simplification59.5%
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 2.35e+72) (* (* a2 (sqrt 0.5)) (+ a2 (* -0.5 (* a2 (* th th))))) (* a2 (/ a2 (sqrt 2.0)))))
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
double tmp;
if (th <= 2.35e+72) {
tmp = (a2 * sqrt(0.5)) * (a2 + (-0.5 * (a2 * (th * th))));
} else {
tmp = a2 * (a2 / sqrt(2.0));
}
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 <= 2.35d+72) then
tmp = (a2 * sqrt(0.5d0)) * (a2 + ((-0.5d0) * (a2 * (th * th))))
else
tmp = a2 * (a2 / sqrt(2.0d0))
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 <= 2.35e+72) {
tmp = (a2 * Math.sqrt(0.5)) * (a2 + (-0.5 * (a2 * (th * th))));
} else {
tmp = a2 * (a2 / Math.sqrt(2.0));
}
return tmp;
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): tmp = 0 if th <= 2.35e+72: tmp = (a2 * math.sqrt(0.5)) * (a2 + (-0.5 * (a2 * (th * th)))) else: tmp = a2 * (a2 / math.sqrt(2.0)) return tmp
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) tmp = 0.0 if (th <= 2.35e+72) tmp = Float64(Float64(a2 * sqrt(0.5)) * Float64(a2 + Float64(-0.5 * Float64(a2 * Float64(th * th))))); else tmp = Float64(a2 * Float64(a2 / sqrt(2.0))); 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 <= 2.35e+72)
tmp = (a2 * sqrt(0.5)) * (a2 + (-0.5 * (a2 * (th * th))));
else
tmp = a2 * (a2 / sqrt(2.0));
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, 2.35e+72], N[(N[(a2 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] * N[(a2 + N[(-0.5 * N[(a2 * N[(th * th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a2 * N[(a2 / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\begin{array}{l}
\mathbf{if}\;th \leq 2.35 \cdot 10^{+72}:\\
\;\;\;\;\left(a2 \cdot \sqrt{0.5}\right) \cdot \left(a2 + -0.5 \cdot \left(a2 \cdot \left(th \cdot th\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \frac{a2}{\sqrt{2}}\\
\end{array}
\end{array}
if th < 2.35000000000000017e72Initial program 99.2%
distribute-lft-out99.2%
cos-neg99.2%
associate-*l/99.3%
cos-neg99.3%
fma-def99.3%
Simplified99.3%
Taylor expanded in a1 around 0 58.5%
unpow258.5%
associate-*l*58.9%
Simplified58.9%
div-inv58.9%
pow1/258.9%
pow-flip58.9%
metadata-eval58.9%
*-commutative58.9%
associate-*l*58.9%
add-sqr-sqrt58.6%
sqrt-unprod58.9%
pow-prod-up58.9%
metadata-eval58.9%
metadata-eval58.9%
Applied egg-rr58.9%
Taylor expanded in th around 0 40.5%
unpow240.5%
Simplified40.5%
if 2.35000000000000017e72 < th Initial program 97.9%
+-commutative97.9%
distribute-lft-out97.9%
Simplified97.9%
Taylor expanded in a2 around inf 61.7%
unpow261.7%
associate-*r/61.7%
associate-*r*61.8%
Simplified61.8%
Taylor expanded in th around 0 25.2%
Final simplification37.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 (* a2 (* a2 (sqrt 0.5))))
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
return a2 * (a2 * sqrt(0.5));
}
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 * (a2 * sqrt(0.5d0))
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 * (a2 * Math.sqrt(0.5));
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): return a2 * (a2 * math.sqrt(0.5))
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) return Float64(a2 * Float64(a2 * sqrt(0.5))) end
a1 = abs(a1)
a2 = abs(a2)
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = a2 * (a2 * sqrt(0.5));
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[(a2 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
a2 \cdot \left(a2 \cdot \sqrt{0.5}\right)
\end{array}
Initial program 98.9%
distribute-lft-out98.9%
cos-neg98.9%
associate-*l/99.0%
cos-neg99.0%
fma-def99.0%
Simplified99.0%
Taylor expanded in a1 around 0 59.2%
unpow259.2%
associate-*l*59.5%
Simplified59.5%
div-inv59.5%
pow1/259.5%
pow-flip59.5%
metadata-eval59.5%
*-commutative59.5%
associate-*l*59.5%
add-sqr-sqrt59.2%
sqrt-unprod59.5%
pow-prod-up59.5%
metadata-eval59.5%
metadata-eval59.5%
Applied egg-rr59.5%
Taylor expanded in th around 0 39.6%
unpow239.6%
associate-*l*39.6%
Simplified39.6%
Final simplification39.6%
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 a2) 5e-233) (* (* a1 a1) (- 64.0)) (* a2 (* a2 th))))
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
double tmp;
if ((a2 * a2) <= 5e-233) {
tmp = (a1 * a1) * -64.0;
} else {
tmp = a2 * (a2 * th);
}
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 * a2) <= 5d-233) then
tmp = (a1 * a1) * -64.0d0
else
tmp = a2 * (a2 * th)
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 * a2) <= 5e-233) {
tmp = (a1 * a1) * -64.0;
} else {
tmp = a2 * (a2 * th);
}
return tmp;
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): tmp = 0 if (a2 * a2) <= 5e-233: tmp = (a1 * a1) * -64.0 else: tmp = a2 * (a2 * th) return tmp
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) tmp = 0.0 if (Float64(a2 * a2) <= 5e-233) tmp = Float64(Float64(a1 * a1) * Float64(-64.0)); else tmp = Float64(a2 * Float64(a2 * th)); 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 * a2) <= 5e-233)
tmp = (a1 * a1) * -64.0;
else
tmp = a2 * (a2 * th);
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[N[(a2 * a2), $MachinePrecision], 5e-233], N[(N[(a1 * a1), $MachinePrecision] * (-64.0)), $MachinePrecision], N[(a2 * N[(a2 * th), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\begin{array}{l}
\mathbf{if}\;a2 \cdot a2 \leq 5 \cdot 10^{-233}:\\
\;\;\;\;\left(a1 \cdot a1\right) \cdot \left(-64\right)\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \left(a2 \cdot th\right)\\
\end{array}
\end{array}
if (*.f64 a2 a2) < 5.00000000000000012e-233Initial program 99.4%
+-commutative99.4%
distribute-lft-out99.4%
Simplified99.4%
Taylor expanded in th around 0 66.7%
unpow266.7%
unpow266.7%
+-commutative66.7%
Simplified66.7%
Taylor expanded in a2 around 0 64.3%
unpow264.3%
Simplified64.3%
frac-2neg64.3%
div-inv64.2%
Applied egg-rr64.2%
Applied egg-rr25.1%
if 5.00000000000000012e-233 < (*.f64 a2 a2) Initial program 98.7%
distribute-lft-out98.7%
cos-neg98.7%
associate-*l/98.7%
cos-neg98.7%
fma-def98.7%
Simplified98.7%
Taylor expanded in a1 around 0 75.7%
unpow275.7%
associate-*l*76.2%
Simplified76.2%
Taylor expanded in th around 0 45.8%
unpow245.8%
Simplified45.8%
Taylor expanded in th around inf 12.7%
unpow212.7%
unpow212.7%
associate-*l*12.8%
associate-*l*12.8%
*-commutative12.8%
associate-*l*12.8%
*-commutative12.8%
Simplified12.8%
Applied egg-rr20.9%
Final simplification22.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 (if (<= a2 2.1e+29) (* (* a1 a1) (- -2.0)) (* a2 (* a2 th))))
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 2.1e+29) {
tmp = (a1 * a1) * -(-2.0);
} else {
tmp = a2 * (a2 * th);
}
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 <= 2.1d+29) then
tmp = (a1 * a1) * -(-2.0d0)
else
tmp = a2 * (a2 * th)
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 <= 2.1e+29) {
tmp = (a1 * a1) * -(-2.0);
} else {
tmp = a2 * (a2 * th);
}
return tmp;
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): tmp = 0 if a2 <= 2.1e+29: tmp = (a1 * a1) * -(-2.0) else: tmp = a2 * (a2 * th) return tmp
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) tmp = 0.0 if (a2 <= 2.1e+29) tmp = Float64(Float64(a1 * a1) * Float64(-(-2.0))); else tmp = Float64(a2 * Float64(a2 * th)); 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 <= 2.1e+29)
tmp = (a1 * a1) * -(-2.0);
else
tmp = a2 * (a2 * th);
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, 2.1e+29], N[(N[(a1 * a1), $MachinePrecision] * (--2.0)), $MachinePrecision], N[(a2 * N[(a2 * th), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 2.1 \cdot 10^{+29}:\\
\;\;\;\;\left(a1 \cdot a1\right) \cdot \left(--2\right)\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \left(a2 \cdot th\right)\\
\end{array}
\end{array}
if a2 < 2.1000000000000002e29Initial program 98.7%
+-commutative98.7%
distribute-lft-out98.7%
Simplified98.7%
Taylor expanded in th around 0 63.9%
unpow263.9%
unpow263.9%
+-commutative63.9%
Simplified63.9%
Taylor expanded in a2 around 0 46.0%
unpow246.0%
Simplified46.0%
frac-2neg46.0%
div-inv45.9%
Applied egg-rr45.9%
Applied egg-rr33.9%
if 2.1000000000000002e29 < a2 Initial program 99.7%
distribute-lft-out99.7%
cos-neg99.7%
associate-*l/99.8%
cos-neg99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in a1 around 0 90.4%
unpow290.4%
associate-*l*90.3%
Simplified90.3%
Taylor expanded in th around 0 50.9%
unpow250.9%
Simplified50.9%
Taylor expanded in th around inf 10.9%
unpow210.9%
unpow210.9%
associate-*l*11.1%
associate-*l*11.1%
*-commutative11.1%
associate-*l*11.1%
*-commutative11.1%
Simplified11.1%
Applied egg-rr30.0%
Final simplification33.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 5.1e-113) (/ (* a1 a1) -2.0) (* a2 (* a2 th))))
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 5.1e-113) {
tmp = (a1 * a1) / -2.0;
} else {
tmp = a2 * (a2 * th);
}
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 <= 5.1d-113) then
tmp = (a1 * a1) / (-2.0d0)
else
tmp = a2 * (a2 * th)
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 <= 5.1e-113) {
tmp = (a1 * a1) / -2.0;
} else {
tmp = a2 * (a2 * th);
}
return tmp;
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): tmp = 0 if a2 <= 5.1e-113: tmp = (a1 * a1) / -2.0 else: tmp = a2 * (a2 * th) return tmp
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) tmp = 0.0 if (a2 <= 5.1e-113) tmp = Float64(Float64(a1 * a1) / -2.0); else tmp = Float64(a2 * Float64(a2 * th)); 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 <= 5.1e-113)
tmp = (a1 * a1) / -2.0;
else
tmp = a2 * (a2 * th);
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, 5.1e-113], N[(N[(a1 * a1), $MachinePrecision] / -2.0), $MachinePrecision], N[(a2 * N[(a2 * th), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 5.1 \cdot 10^{-113}:\\
\;\;\;\;\frac{a1 \cdot a1}{-2}\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \left(a2 \cdot th\right)\\
\end{array}
\end{array}
if a2 < 5.09999999999999979e-113Initial program 98.6%
+-commutative98.6%
distribute-lft-out98.6%
Simplified98.6%
Taylor expanded in th around 0 66.5%
unpow266.5%
unpow266.5%
+-commutative66.5%
Simplified66.5%
Taylor expanded in a2 around 0 49.1%
unpow249.1%
Simplified49.1%
frac-2neg49.1%
div-inv49.1%
Applied egg-rr49.1%
Applied egg-rr16.3%
associate-/l*16.3%
Simplified16.3%
if 5.09999999999999979e-113 < a2 Initial program 99.6%
distribute-lft-out99.6%
cos-neg99.6%
associate-*l/99.6%
cos-neg99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in a1 around 0 85.4%
unpow285.4%
associate-*l*85.4%
Simplified85.4%
Taylor expanded in th around 0 43.7%
unpow243.7%
Simplified43.7%
Taylor expanded in th around inf 8.9%
unpow28.9%
unpow28.9%
associate-*l*9.1%
associate-*l*9.1%
*-commutative9.1%
associate-*l*9.1%
*-commutative9.1%
Simplified9.1%
Applied egg-rr23.2%
Final simplification18.5%
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 (* a2 th)))
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
return a2 * (a2 * 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 * (a2 * 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 * (a2 * th);
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): return a2 * (a2 * th)
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) return Float64(a2 * Float64(a2 * th)) end
a1 = abs(a1)
a2 = abs(a2)
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = a2 * (a2 * 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[(a2 * N[(a2 * th), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
a2 \cdot \left(a2 \cdot th\right)
\end{array}
Initial program 98.9%
distribute-lft-out98.9%
cos-neg98.9%
associate-*l/99.0%
cos-neg99.0%
fma-def99.0%
Simplified99.0%
Taylor expanded in a1 around 0 59.2%
unpow259.2%
associate-*l*59.5%
Simplified59.5%
Taylor expanded in th around 0 35.8%
unpow235.8%
Simplified35.8%
Taylor expanded in th around inf 12.8%
unpow212.8%
unpow212.8%
associate-*l*12.5%
associate-*l*12.5%
*-commutative12.5%
associate-*l*12.5%
*-commutative12.5%
Simplified12.5%
Applied egg-rr19.0%
Final simplification19.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 (* a2 th))
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
return a2 * 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 * 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 * th;
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): return a2 * th
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) return Float64(a2 * th) end
a1 = abs(a1)
a2 = abs(a2)
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = a2 * 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[(a2 * th), $MachinePrecision]
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
a2 \cdot th
\end{array}
Initial program 98.9%
distribute-lft-out98.9%
cos-neg98.9%
associate-*l/99.0%
cos-neg99.0%
fma-def99.0%
Simplified99.0%
Taylor expanded in a1 around 0 59.2%
unpow259.2%
associate-*l*59.5%
Simplified59.5%
Taylor expanded in th around 0 35.8%
unpow235.8%
Simplified35.8%
Taylor expanded in th around inf 12.8%
unpow212.8%
unpow212.8%
associate-*l*12.5%
associate-*l*12.5%
*-commutative12.5%
associate-*l*12.5%
*-commutative12.5%
Simplified12.5%
Applied egg-rr11.3%
Final simplification11.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 1.0)
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
return 1.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.
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
code = 1.0d0
end function
a1 = Math.abs(a1);
a2 = Math.abs(a2);
assert a1 < a2;
public static double code(double a1, double a2, double th) {
return 1.0;
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): return 1.0
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) return 1.0 end
a1 = abs(a1)
a2 = abs(a2)
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = 1.0;
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_] := 1.0
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
1
\end{array}
Initial program 98.9%
distribute-lft-out98.9%
cos-neg98.9%
associate-*l/99.0%
cos-neg99.0%
fma-def99.0%
Simplified99.0%
Taylor expanded in a1 around 0 59.2%
unpow259.2%
associate-*l*59.5%
Simplified59.5%
div-inv59.5%
pow1/259.5%
pow-flip59.5%
metadata-eval59.5%
*-commutative59.5%
associate-*l*59.5%
add-sqr-sqrt59.2%
sqrt-unprod59.5%
pow-prod-up59.5%
metadata-eval59.5%
metadata-eval59.5%
Applied egg-rr59.5%
Taylor expanded in th around 0 39.6%
unpow239.6%
associate-*l*39.6%
Simplified39.6%
Applied egg-rr3.3%
*-inverses3.3%
Simplified3.3%
Final simplification3.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 a1)
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
return a1;
}
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 = a1
end function
a1 = Math.abs(a1);
a2 = Math.abs(a2);
assert a1 < a2;
public static double code(double a1, double a2, double th) {
return a1;
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): return a1
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) return a1 end
a1 = abs(a1)
a2 = abs(a2)
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = a1;
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_] := a1
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
a1
\end{array}
Initial program 98.9%
+-commutative98.9%
distribute-lft-out98.9%
Simplified98.9%
Taylor expanded in th around 0 65.4%
unpow265.4%
unpow265.4%
+-commutative65.4%
Simplified65.4%
Taylor expanded in a2 around 0 41.1%
unpow241.1%
Simplified41.1%
frac-2neg41.1%
div-inv41.1%
Applied egg-rr41.1%
Applied egg-rr3.4%
+-lft-identity3.4%
Simplified3.4%
Final simplification3.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)
a1 = abs(a1);
a2 = abs(a2);
assert(a1 < a2);
double code(double a1, double a2, double th) {
return 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
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;
}
a1 = abs(a1) a2 = abs(a2) [a1, a2] = sort([a1, a2]) def code(a1, a2, th): return a2
a1 = abs(a1) a2 = abs(a2) a1, a2 = sort([a1, a2]) function code(a1, a2, th) return a2 end
a1 = abs(a1)
a2 = abs(a2)
a1, a2 = num2cell(sort([a1, a2])){:}
function tmp = code(a1, a2, th)
tmp = 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_] := a2
\begin{array}{l}
a1 = |a1|\\
a2 = |a2|\\
[a1, a2] = \mathsf{sort}([a1, a2])\\
\\
a2
\end{array}
Initial program 98.9%
distribute-lft-out98.9%
cos-neg98.9%
associate-*l/99.0%
cos-neg99.0%
fma-def99.0%
Simplified99.0%
Taylor expanded in a1 around 0 59.2%
unpow259.2%
associate-*l*59.5%
Simplified59.5%
div-inv59.5%
pow1/259.5%
pow-flip59.5%
metadata-eval59.5%
*-commutative59.5%
associate-*l*59.5%
add-sqr-sqrt59.2%
sqrt-unprod59.5%
pow-prod-up59.5%
metadata-eval59.5%
metadata-eval59.5%
Applied egg-rr59.5%
Taylor expanded in th around 0 39.6%
unpow239.6%
associate-*l*39.6%
Simplified39.6%
Applied egg-rr4.8%
unpow14.8%
*-inverses4.8%
sqr-pow2.4%
fabs-sqr2.4%
sqr-pow3.6%
*-inverses3.6%
unpow13.6%
Simplified3.6%
Final simplification3.6%
herbie shell --seed 2023285
(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))))