
(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 21 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 (* (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.6%
distribute-lft-out99.6%
associate-*l/99.6%
associate-*r/99.7%
fma-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (a1 a2 th) :precision binary64 (* (+ (* a2 a2) (* a1 a1)) (* (cos th) (sqrt 0.5))))
double code(double a1, double a2, double th) {
return ((a2 * a2) + (a1 * a1)) * (cos(th) * sqrt(0.5));
}
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) + (a1 * a1)) * (cos(th) * sqrt(0.5d0))
end function
public static double code(double a1, double a2, double th) {
return ((a2 * a2) + (a1 * a1)) * (Math.cos(th) * Math.sqrt(0.5));
}
def code(a1, a2, th): return ((a2 * a2) + (a1 * a1)) * (math.cos(th) * math.sqrt(0.5))
function code(a1, a2, th) return Float64(Float64(Float64(a2 * a2) + Float64(a1 * a1)) * Float64(cos(th) * sqrt(0.5))) end
function tmp = code(a1, a2, th) tmp = ((a2 * a2) + (a1 * a1)) * (cos(th) * sqrt(0.5)); end
code[a1_, a2_, th_] := N[(N[(N[(a2 * a2), $MachinePrecision] + N[(a1 * a1), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[th], $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a2 \cdot a2 + a1 \cdot a1\right) \cdot \left(\cos th \cdot \sqrt{0.5}\right)
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
clear-num99.6%
associate-/r/99.6%
pow1/299.6%
pow-flip99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in th around inf 99.6%
Final simplification99.6%
(FPCore (a1 a2 th) :precision binary64 (* (/ (cos th) (sqrt 2.0)) (+ (* a2 a2) (* a1 a1))))
double code(double a1, double a2, double th) {
return (cos(th) / sqrt(2.0)) * ((a2 * a2) + (a1 * a1));
}
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
code = (cos(th) / sqrt(2.0d0)) * ((a2 * a2) + (a1 * a1))
end function
public static double code(double a1, double a2, double th) {
return (Math.cos(th) / Math.sqrt(2.0)) * ((a2 * a2) + (a1 * a1));
}
def code(a1, a2, th): return (math.cos(th) / math.sqrt(2.0)) * ((a2 * a2) + (a1 * a1))
function code(a1, a2, th) return Float64(Float64(cos(th) / sqrt(2.0)) * Float64(Float64(a2 * a2) + Float64(a1 * a1))) end
function tmp = code(a1, a2, th) tmp = (cos(th) / sqrt(2.0)) * ((a2 * a2) + (a1 * a1)); end
code[a1_, a2_, th_] := N[(N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(N[(a2 * a2), $MachinePrecision] + N[(a1 * a1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2 + a1 \cdot a1\right)
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (a1 a2 th) :precision binary64 (* (cos th) (* a2 (/ a2 (sqrt 2.0)))))
double code(double a1, double a2, double th) {
return cos(th) * (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 = cos(th) * (a2 * (a2 / sqrt(2.0d0)))
end function
public static double code(double a1, double a2, double th) {
return Math.cos(th) * (a2 * (a2 / Math.sqrt(2.0)));
}
def code(a1, a2, th): return math.cos(th) * (a2 * (a2 / math.sqrt(2.0)))
function code(a1, a2, th) return Float64(cos(th) * Float64(a2 * Float64(a2 / sqrt(2.0)))) end
function tmp = code(a1, a2, th) tmp = cos(th) * (a2 * (a2 / sqrt(2.0))); end
code[a1_, a2_, th_] := N[(N[Cos[th], $MachinePrecision] * N[(a2 * N[(a2 / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos th \cdot \left(a2 \cdot \frac{a2}{\sqrt{2}}\right)
\end{array}
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 60.6%
unpow260.6%
associate-/l*60.6%
associate-/r/60.6%
Simplified60.6%
Final simplification60.6%
(FPCore (a1 a2 th) :precision binary64 (* (cos th) (/ (* a2 a2) (sqrt 2.0))))
double code(double a1, double a2, double th) {
return cos(th) * ((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 = cos(th) * ((a2 * a2) / sqrt(2.0d0))
end function
public static double code(double a1, double a2, double th) {
return Math.cos(th) * ((a2 * a2) / Math.sqrt(2.0));
}
def code(a1, a2, th): return math.cos(th) * ((a2 * a2) / math.sqrt(2.0))
function code(a1, a2, th) return Float64(cos(th) * Float64(Float64(a2 * a2) / sqrt(2.0))) end
function tmp = code(a1, a2, th) tmp = cos(th) * ((a2 * a2) / sqrt(2.0)); end
code[a1_, a2_, th_] := N[(N[Cos[th], $MachinePrecision] * N[(N[(a2 * a2), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos th \cdot \frac{a2 \cdot a2}{\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%
Taylor expanded in a1 around 0 60.6%
unpow260.6%
Simplified60.6%
Final simplification60.6%
(FPCore (a1 a2 th)
:precision binary64
(if (<= a2 8e+171)
(* (+ (* a2 a2) (* a1 a1)) (sqrt 0.5))
(if (or (<= a2 7.6e+261) (and (not (<= a2 2e+279)) (<= a2 1e+297)))
(* (sqrt 0.5) (* (* a2 a2) (+ (* -0.5 (* th th)) 1.0)))
(* a2 (/ a2 (sqrt 2.0))))))
double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 8e+171) {
tmp = ((a2 * a2) + (a1 * a1)) * sqrt(0.5);
} else if ((a2 <= 7.6e+261) || (!(a2 <= 2e+279) && (a2 <= 1e+297))) {
tmp = sqrt(0.5) * ((a2 * a2) * ((-0.5 * (th * th)) + 1.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 (a2 <= 8d+171) then
tmp = ((a2 * a2) + (a1 * a1)) * sqrt(0.5d0)
else if ((a2 <= 7.6d+261) .or. (.not. (a2 <= 2d+279)) .and. (a2 <= 1d+297)) then
tmp = sqrt(0.5d0) * ((a2 * a2) * (((-0.5d0) * (th * th)) + 1.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 (a2 <= 8e+171) {
tmp = ((a2 * a2) + (a1 * a1)) * Math.sqrt(0.5);
} else if ((a2 <= 7.6e+261) || (!(a2 <= 2e+279) && (a2 <= 1e+297))) {
tmp = Math.sqrt(0.5) * ((a2 * a2) * ((-0.5 * (th * th)) + 1.0));
} else {
tmp = a2 * (a2 / Math.sqrt(2.0));
}
return tmp;
}
def code(a1, a2, th): tmp = 0 if a2 <= 8e+171: tmp = ((a2 * a2) + (a1 * a1)) * math.sqrt(0.5) elif (a2 <= 7.6e+261) or (not (a2 <= 2e+279) and (a2 <= 1e+297)): tmp = math.sqrt(0.5) * ((a2 * a2) * ((-0.5 * (th * th)) + 1.0)) else: tmp = a2 * (a2 / math.sqrt(2.0)) return tmp
function code(a1, a2, th) tmp = 0.0 if (a2 <= 8e+171) tmp = Float64(Float64(Float64(a2 * a2) + Float64(a1 * a1)) * sqrt(0.5)); elseif ((a2 <= 7.6e+261) || (!(a2 <= 2e+279) && (a2 <= 1e+297))) tmp = Float64(sqrt(0.5) * Float64(Float64(a2 * a2) * Float64(Float64(-0.5 * Float64(th * th)) + 1.0))); else tmp = Float64(a2 * Float64(a2 / sqrt(2.0))); end return tmp end
function tmp_2 = code(a1, a2, th) tmp = 0.0; if (a2 <= 8e+171) tmp = ((a2 * a2) + (a1 * a1)) * sqrt(0.5); elseif ((a2 <= 7.6e+261) || (~((a2 <= 2e+279)) && (a2 <= 1e+297))) tmp = sqrt(0.5) * ((a2 * a2) * ((-0.5 * (th * th)) + 1.0)); else tmp = a2 * (a2 / sqrt(2.0)); end tmp_2 = tmp; end
code[a1_, a2_, th_] := If[LessEqual[a2, 8e+171], N[(N[(N[(a2 * a2), $MachinePrecision] + N[(a1 * a1), $MachinePrecision]), $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[a2, 7.6e+261], And[N[Not[LessEqual[a2, 2e+279]], $MachinePrecision], LessEqual[a2, 1e+297]]], N[(N[Sqrt[0.5], $MachinePrecision] * N[(N[(a2 * a2), $MachinePrecision] * N[(N[(-0.5 * N[(th * th), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a2 * N[(a2 / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 8 \cdot 10^{+171}:\\
\;\;\;\;\left(a2 \cdot a2 + a1 \cdot a1\right) \cdot \sqrt{0.5}\\
\mathbf{elif}\;a2 \leq 7.6 \cdot 10^{+261} \lor \neg \left(a2 \leq 2 \cdot 10^{+279}\right) \land a2 \leq 10^{+297}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(\left(a2 \cdot a2\right) \cdot \left(-0.5 \cdot \left(th \cdot th\right) + 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \frac{a2}{\sqrt{2}}\\
\end{array}
\end{array}
if a2 < 7.99999999999999963e171Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
clear-num99.5%
associate-/r/99.5%
pow1/299.5%
pow-flip99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 64.0%
*-commutative64.0%
unpow264.0%
unpow264.0%
+-commutative64.0%
Simplified64.0%
if 7.99999999999999963e171 < a2 < 7.6000000000000003e261 or 2.00000000000000012e279 < a2 < 1e297Initial program 100.0%
distribute-lft-out100.0%
Simplified100.0%
clear-num100.0%
associate-/r/100.0%
pow1/2100.0%
pow-flip100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in th around inf 100.0%
Taylor expanded in a1 around 0 100.0%
unpow2100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in th around 0 0.0%
unpow20.0%
unpow20.0%
associate-*r*0.0%
distribute-rgt1-in90.9%
unpow290.9%
Simplified90.9%
if 7.6000000000000003e261 < a2 < 2.00000000000000012e279 or 1e297 < a2 Initial program 100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in th around 0 83.3%
Taylor expanded in a1 around 0 83.3%
unpow283.3%
associate-*r/83.3%
Simplified83.3%
Final simplification66.8%
(FPCore (a1 a2 th) :precision binary64 (* (+ (* a2 a2) (* a1 a1)) (sqrt 0.5)))
double code(double a1, double a2, double th) {
return ((a2 * a2) + (a1 * a1)) * sqrt(0.5);
}
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) + (a1 * a1)) * sqrt(0.5d0)
end function
public static double code(double a1, double a2, double th) {
return ((a2 * a2) + (a1 * a1)) * Math.sqrt(0.5);
}
def code(a1, a2, th): return ((a2 * a2) + (a1 * a1)) * math.sqrt(0.5)
function code(a1, a2, th) return Float64(Float64(Float64(a2 * a2) + Float64(a1 * a1)) * sqrt(0.5)) end
function tmp = code(a1, a2, th) tmp = ((a2 * a2) + (a1 * a1)) * sqrt(0.5); end
code[a1_, a2_, th_] := N[(N[(N[(a2 * a2), $MachinePrecision] + N[(a1 * a1), $MachinePrecision]), $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a2 \cdot a2 + a1 \cdot a1\right) \cdot \sqrt{0.5}
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
clear-num99.6%
associate-/r/99.6%
pow1/299.6%
pow-flip99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 65.2%
*-commutative65.2%
unpow265.2%
unpow265.2%
+-commutative65.2%
Simplified65.2%
Final simplification65.2%
(FPCore (a1 a2 th) :precision binary64 (* a2 (/ a2 (sqrt 2.0))))
double code(double a1, double a2, double th) {
return 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 = a2 * (a2 / sqrt(2.0d0))
end function
public static double code(double a1, double a2, double th) {
return a2 * (a2 / Math.sqrt(2.0));
}
def code(a1, a2, th): return a2 * (a2 / math.sqrt(2.0))
function code(a1, a2, th) return Float64(a2 * Float64(a2 / sqrt(2.0))) end
function tmp = code(a1, a2, th) tmp = a2 * (a2 / sqrt(2.0)); end
code[a1_, a2_, th_] := N[(a2 * N[(a2 / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a2 \cdot \frac{a2}{\sqrt{2}}
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 65.2%
Taylor expanded in a1 around 0 40.4%
unpow240.4%
associate-*r/40.3%
Simplified40.3%
Final simplification40.3%
(FPCore (a1 a2 th) :precision binary64 (* (* a2 a2) (sqrt 0.5)))
double code(double a1, double a2, double th) {
return (a2 * a2) * sqrt(0.5);
}
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
public static double code(double a1, double a2, double th) {
return (a2 * a2) * Math.sqrt(0.5);
}
def code(a1, a2, th): return (a2 * a2) * math.sqrt(0.5)
function code(a1, a2, th) return Float64(Float64(a2 * a2) * sqrt(0.5)) end
function tmp = code(a1, a2, th) tmp = (a2 * a2) * sqrt(0.5); end
code[a1_, a2_, th_] := N[(N[(a2 * a2), $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a2 \cdot a2\right) \cdot \sqrt{0.5}
\end{array}
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 60.6%
unpow260.6%
*-commutative60.6%
Simplified60.6%
Taylor expanded in th around 0 40.4%
unpow240.4%
Simplified40.4%
div-inv40.3%
add-sqr-sqrt40.3%
sqrt-unprod40.3%
frac-times40.3%
metadata-eval40.3%
add-sqr-sqrt40.4%
metadata-eval40.4%
Applied egg-rr40.4%
Final simplification40.4%
(FPCore (a1 a2 th) :precision binary64 (/ a2 (/ (sqrt 2.0) a2)))
double code(double a1, double a2, double th) {
return a2 / (sqrt(2.0) / a2);
}
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
public static double code(double a1, double a2, double th) {
return a2 / (Math.sqrt(2.0) / a2);
}
def code(a1, a2, th): return a2 / (math.sqrt(2.0) / a2)
function code(a1, a2, th) return Float64(a2 / Float64(sqrt(2.0) / a2)) end
function tmp = code(a1, a2, th) tmp = a2 / (sqrt(2.0) / a2); end
code[a1_, a2_, th_] := N[(a2 / N[(N[Sqrt[2.0], $MachinePrecision] / a2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a2}{\frac{\sqrt{2}}{a2}}
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 65.2%
Taylor expanded in a1 around 0 40.4%
unpow240.4%
associate-*r/40.3%
Simplified40.3%
clear-num40.3%
un-div-inv40.4%
Applied egg-rr40.4%
Final simplification40.4%
(FPCore (a1 a2 th) :precision binary64 (/ (* a2 a2) (sqrt 2.0)))
double code(double a1, double a2, double th) {
return (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 = (a2 * a2) / sqrt(2.0d0)
end function
public static double code(double a1, double a2, double th) {
return (a2 * a2) / Math.sqrt(2.0);
}
def code(a1, a2, th): return (a2 * a2) / math.sqrt(2.0)
function code(a1, a2, th) return Float64(Float64(a2 * a2) / sqrt(2.0)) end
function tmp = code(a1, a2, th) tmp = (a2 * a2) / sqrt(2.0); end
code[a1_, a2_, th_] := N[(N[(a2 * a2), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a2 \cdot a2}{\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%
Taylor expanded in a1 around 0 60.6%
unpow260.6%
*-commutative60.6%
Simplified60.6%
Taylor expanded in th around 0 40.4%
unpow240.4%
Simplified40.4%
Final simplification40.4%
(FPCore (a1 a2 th)
:precision binary64
(if (<= th 4.8e+24)
(* a1 a1)
(if (or (<= th 1.3e+110) (and (not (<= th 3.2e+155)) (<= th 3.6e+212)))
(* th a2)
(* th (- a2)))))
double code(double a1, double a2, double th) {
double tmp;
if (th <= 4.8e+24) {
tmp = a1 * a1;
} else if ((th <= 1.3e+110) || (!(th <= 3.2e+155) && (th <= 3.6e+212))) {
tmp = th * a2;
} else {
tmp = th * -a2;
}
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 (th <= 4.8d+24) then
tmp = a1 * a1
else if ((th <= 1.3d+110) .or. (.not. (th <= 3.2d+155)) .and. (th <= 3.6d+212)) then
tmp = th * a2
else
tmp = th * -a2
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double tmp;
if (th <= 4.8e+24) {
tmp = a1 * a1;
} else if ((th <= 1.3e+110) || (!(th <= 3.2e+155) && (th <= 3.6e+212))) {
tmp = th * a2;
} else {
tmp = th * -a2;
}
return tmp;
}
def code(a1, a2, th): tmp = 0 if th <= 4.8e+24: tmp = a1 * a1 elif (th <= 1.3e+110) or (not (th <= 3.2e+155) and (th <= 3.6e+212)): tmp = th * a2 else: tmp = th * -a2 return tmp
function code(a1, a2, th) tmp = 0.0 if (th <= 4.8e+24) tmp = Float64(a1 * a1); elseif ((th <= 1.3e+110) || (!(th <= 3.2e+155) && (th <= 3.6e+212))) tmp = Float64(th * a2); else tmp = Float64(th * Float64(-a2)); end return tmp end
function tmp_2 = code(a1, a2, th) tmp = 0.0; if (th <= 4.8e+24) tmp = a1 * a1; elseif ((th <= 1.3e+110) || (~((th <= 3.2e+155)) && (th <= 3.6e+212))) tmp = th * a2; else tmp = th * -a2; end tmp_2 = tmp; end
code[a1_, a2_, th_] := If[LessEqual[th, 4.8e+24], N[(a1 * a1), $MachinePrecision], If[Or[LessEqual[th, 1.3e+110], And[N[Not[LessEqual[th, 3.2e+155]], $MachinePrecision], LessEqual[th, 3.6e+212]]], N[(th * a2), $MachinePrecision], N[(th * (-a2)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 4.8 \cdot 10^{+24}:\\
\;\;\;\;a1 \cdot a1\\
\mathbf{elif}\;th \leq 1.3 \cdot 10^{+110} \lor \neg \left(th \leq 3.2 \cdot 10^{+155}\right) \land th \leq 3.6 \cdot 10^{+212}:\\
\;\;\;\;th \cdot a2\\
\mathbf{else}:\\
\;\;\;\;th \cdot \left(-a2\right)\\
\end{array}
\end{array}
if th < 4.8000000000000001e24Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 73.4%
Taylor expanded in a1 around inf 42.1%
unpow242.1%
Simplified42.1%
Applied egg-rr34.5%
if 4.8000000000000001e24 < th < 1.3e110 or 3.20000000000000012e155 < th < 3.6e212Initial program 99.7%
distribute-lft-out99.6%
associate-*l/99.5%
associate-*r/99.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in a1 around 0 69.2%
unpow269.2%
*-commutative69.2%
Simplified69.2%
Taylor expanded in th around 0 1.7%
unpow21.7%
unpow21.7%
associate-*r*1.7%
distribute-rgt1-in10.4%
unpow210.4%
Simplified10.4%
Taylor expanded in th around inf 10.4%
unpow210.4%
unpow210.4%
Simplified10.4%
Applied egg-rr3.8%
if 1.3e110 < th < 3.20000000000000012e155 or 3.6e212 < th Initial program 99.7%
distribute-lft-out99.7%
associate-*l/99.5%
associate-*r/99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in a1 around 0 49.5%
unpow249.5%
*-commutative49.5%
Simplified49.5%
Taylor expanded in th around 0 14.6%
unpow214.6%
unpow214.6%
associate-*r*14.6%
distribute-rgt1-in32.0%
unpow232.0%
Simplified32.0%
Taylor expanded in th around inf 32.0%
unpow232.0%
unpow232.0%
Simplified32.0%
Applied egg-rr11.8%
Final simplification29.7%
(FPCore (a1 a2 th) :precision binary64 (if (or (<= th 7.8e+76) (and (not (<= th 3.2e+155)) (<= th 3.6e+212))) (* a2 a2) (* a2 (/ a2 -2.0))))
double code(double a1, double a2, double th) {
double tmp;
if ((th <= 7.8e+76) || (!(th <= 3.2e+155) && (th <= 3.6e+212))) {
tmp = a2 * a2;
} else {
tmp = a2 * (a2 / -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 ((th <= 7.8d+76) .or. (.not. (th <= 3.2d+155)) .and. (th <= 3.6d+212)) then
tmp = a2 * a2
else
tmp = a2 * (a2 / (-2.0d0))
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double tmp;
if ((th <= 7.8e+76) || (!(th <= 3.2e+155) && (th <= 3.6e+212))) {
tmp = a2 * a2;
} else {
tmp = a2 * (a2 / -2.0);
}
return tmp;
}
def code(a1, a2, th): tmp = 0 if (th <= 7.8e+76) or (not (th <= 3.2e+155) and (th <= 3.6e+212)): tmp = a2 * a2 else: tmp = a2 * (a2 / -2.0) return tmp
function code(a1, a2, th) tmp = 0.0 if ((th <= 7.8e+76) || (!(th <= 3.2e+155) && (th <= 3.6e+212))) tmp = Float64(a2 * a2); else tmp = Float64(a2 * Float64(a2 / -2.0)); end return tmp end
function tmp_2 = code(a1, a2, th) tmp = 0.0; if ((th <= 7.8e+76) || (~((th <= 3.2e+155)) && (th <= 3.6e+212))) tmp = a2 * a2; else tmp = a2 * (a2 / -2.0); end tmp_2 = tmp; end
code[a1_, a2_, th_] := If[Or[LessEqual[th, 7.8e+76], And[N[Not[LessEqual[th, 3.2e+155]], $MachinePrecision], LessEqual[th, 3.6e+212]]], N[(a2 * a2), $MachinePrecision], N[(a2 * N[(a2 / -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 7.8 \cdot 10^{+76} \lor \neg \left(th \leq 3.2 \cdot 10^{+155}\right) \land th \leq 3.6 \cdot 10^{+212}:\\
\;\;\;\;a2 \cdot a2\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \frac{a2}{-2}\\
\end{array}
\end{array}
if th < 7.79999999999999979e76 or 3.20000000000000012e155 < th < 3.6e212Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 70.0%
Taylor expanded in a1 around 0 43.2%
unpow243.2%
associate-*r/43.2%
Simplified43.2%
frac-2neg43.2%
div-inv43.1%
Applied egg-rr43.1%
Applied egg-rr29.1%
if 7.79999999999999979e76 < th < 3.20000000000000012e155 or 3.6e212 < th Initial program 99.7%
distribute-lft-out99.7%
associate-*l/99.5%
associate-*r/99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in a1 around 0 53.4%
unpow253.4%
*-commutative53.4%
Simplified53.4%
Taylor expanded in th around 0 16.5%
unpow216.5%
Simplified16.5%
div-inv16.5%
add-sqr-sqrt16.5%
sqrt-unprod16.5%
frac-times16.5%
metadata-eval16.5%
add-sqr-sqrt16.5%
metadata-eval16.5%
Applied egg-rr16.5%
Applied egg-rr26.8%
associate-/r/26.8%
Simplified26.8%
Final simplification28.9%
(FPCore (a1 a2 th) :precision binary64 (if (<= th 7.8e+76) (* a2 (* th a2)) (* a2 (/ a2 -2.0))))
double code(double a1, double a2, double th) {
double tmp;
if (th <= 7.8e+76) {
tmp = a2 * (th * a2);
} else {
tmp = a2 * (a2 / -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 (th <= 7.8d+76) then
tmp = a2 * (th * a2)
else
tmp = a2 * (a2 / (-2.0d0))
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double tmp;
if (th <= 7.8e+76) {
tmp = a2 * (th * a2);
} else {
tmp = a2 * (a2 / -2.0);
}
return tmp;
}
def code(a1, a2, th): tmp = 0 if th <= 7.8e+76: tmp = a2 * (th * a2) else: tmp = a2 * (a2 / -2.0) return tmp
function code(a1, a2, th) tmp = 0.0 if (th <= 7.8e+76) tmp = Float64(a2 * Float64(th * a2)); else tmp = Float64(a2 * Float64(a2 / -2.0)); end return tmp end
function tmp_2 = code(a1, a2, th) tmp = 0.0; if (th <= 7.8e+76) tmp = a2 * (th * a2); else tmp = a2 * (a2 / -2.0); end tmp_2 = tmp; end
code[a1_, a2_, th_] := If[LessEqual[th, 7.8e+76], N[(a2 * N[(th * a2), $MachinePrecision]), $MachinePrecision], N[(a2 * N[(a2 / -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 7.8 \cdot 10^{+76}:\\
\;\;\;\;a2 \cdot \left(th \cdot a2\right)\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \frac{a2}{-2}\\
\end{array}
\end{array}
if th < 7.79999999999999979e76Initial 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 0 61.5%
unpow261.5%
*-commutative61.5%
Simplified61.5%
Taylor expanded in th around 0 25.7%
unpow225.7%
unpow225.7%
associate-*r*25.7%
distribute-rgt1-in47.6%
unpow247.6%
Simplified47.6%
Taylor expanded in th around inf 14.6%
unpow214.6%
unpow214.6%
Simplified14.6%
Applied egg-rr18.3%
if 7.79999999999999979e76 < th Initial program 99.7%
distribute-lft-out99.7%
associate-*l/99.5%
associate-*r/99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in a1 around 0 54.6%
unpow254.6%
*-commutative54.6%
Simplified54.6%
Taylor expanded in th around 0 17.3%
unpow217.3%
Simplified17.3%
div-inv17.3%
add-sqr-sqrt17.3%
sqrt-unprod17.3%
frac-times17.3%
metadata-eval17.3%
add-sqr-sqrt17.3%
metadata-eval17.3%
Applied egg-rr17.3%
Applied egg-rr27.0%
associate-/r/27.0%
Simplified27.0%
Final simplification19.4%
(FPCore (a1 a2 th) :precision binary64 (* a2 (* a2 (- -0.5))))
double code(double a1, double a2, double th) {
return a2 * (a2 * -(-0.5));
}
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 * -(-0.5d0))
end function
public static double code(double a1, double a2, double th) {
return a2 * (a2 * -(-0.5));
}
def code(a1, a2, th): return a2 * (a2 * -(-0.5))
function code(a1, a2, th) return Float64(a2 * Float64(a2 * Float64(-(-0.5)))) end
function tmp = code(a1, a2, th) tmp = a2 * (a2 * -(-0.5)); end
code[a1_, a2_, th_] := N[(a2 * N[(a2 * (--0.5)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a2 \cdot \left(a2 \cdot \left(--0.5\right)\right)
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 65.2%
Taylor expanded in a1 around 0 40.4%
unpow240.4%
associate-*r/40.3%
Simplified40.3%
frac-2neg40.3%
div-inv40.3%
Applied egg-rr40.3%
Applied egg-rr28.0%
Final simplification28.0%
(FPCore (a1 a2 th) :precision binary64 (if (<= th 3.2e+24) (* a1 a1) (* th a2)))
double code(double a1, double a2, double th) {
double tmp;
if (th <= 3.2e+24) {
tmp = a1 * a1;
} else {
tmp = th * a2;
}
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 (th <= 3.2d+24) then
tmp = a1 * a1
else
tmp = th * a2
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double tmp;
if (th <= 3.2e+24) {
tmp = a1 * a1;
} else {
tmp = th * a2;
}
return tmp;
}
def code(a1, a2, th): tmp = 0 if th <= 3.2e+24: tmp = a1 * a1 else: tmp = th * a2 return tmp
function code(a1, a2, th) tmp = 0.0 if (th <= 3.2e+24) tmp = Float64(a1 * a1); else tmp = Float64(th * a2); end return tmp end
function tmp_2 = code(a1, a2, th) tmp = 0.0; if (th <= 3.2e+24) tmp = a1 * a1; else tmp = th * a2; end tmp_2 = tmp; end
code[a1_, a2_, th_] := If[LessEqual[th, 3.2e+24], N[(a1 * a1), $MachinePrecision], N[(th * a2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 3.2 \cdot 10^{+24}:\\
\;\;\;\;a1 \cdot a1\\
\mathbf{else}:\\
\;\;\;\;th \cdot a2\\
\end{array}
\end{array}
if th < 3.1999999999999997e24Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 73.4%
Taylor expanded in a1 around inf 42.1%
unpow242.1%
Simplified42.1%
Applied egg-rr34.5%
if 3.1999999999999997e24 < th Initial program 99.7%
distribute-lft-out99.6%
associate-*l/99.5%
associate-*r/99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in a1 around 0 59.3%
unpow259.3%
*-commutative59.3%
Simplified59.3%
Taylor expanded in th around 0 8.1%
unpow28.1%
unpow28.1%
associate-*r*8.1%
distribute-rgt1-in21.2%
unpow221.2%
Simplified21.2%
Taylor expanded in th around inf 21.2%
unpow221.2%
unpow221.2%
Simplified21.2%
Applied egg-rr13.5%
Final simplification30.7%
(FPCore (a1 a2 th) :precision binary64 (* a2 (* th a2)))
double code(double a1, double a2, double th) {
return a2 * (th * a2);
}
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 * a2)
end function
public static double code(double a1, double a2, double th) {
return a2 * (th * a2);
}
def code(a1, a2, th): return a2 * (th * a2)
function code(a1, a2, th) return Float64(a2 * Float64(th * a2)) end
function tmp = code(a1, a2, th) tmp = a2 * (th * a2); end
code[a1_, a2_, th_] := N[(a2 * N[(th * a2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a2 \cdot \left(th \cdot a2\right)
\end{array}
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 60.6%
unpow260.6%
*-commutative60.6%
Simplified60.6%
Taylor expanded in th around 0 23.9%
unpow223.9%
unpow223.9%
associate-*r*23.9%
distribute-rgt1-in45.0%
unpow245.0%
Simplified45.0%
Taylor expanded in th around inf 16.1%
unpow216.1%
unpow216.1%
Simplified16.1%
Applied egg-rr17.7%
Final simplification17.7%
(FPCore (a1 a2 th) :precision binary64 (* a1 a1))
double code(double a1, double a2, double th) {
return a1 * a1;
}
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
end function
public static double code(double a1, double a2, double th) {
return a1 * a1;
}
def code(a1, a2, th): return a1 * a1
function code(a1, a2, th) return Float64(a1 * a1) end
function tmp = code(a1, a2, th) tmp = a1 * a1; end
code[a1_, a2_, th_] := N[(a1 * a1), $MachinePrecision]
\begin{array}{l}
\\
a1 \cdot a1
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 65.2%
Taylor expanded in a1 around inf 38.0%
unpow238.0%
Simplified38.0%
Applied egg-rr31.7%
Final simplification31.7%
(FPCore (a1 a2 th) :precision binary64 1.0)
double code(double a1, double a2, double th) {
return 1.0;
}
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
public static double code(double a1, double a2, double th) {
return 1.0;
}
def code(a1, a2, th): return 1.0
function code(a1, a2, th) return 1.0 end
function tmp = code(a1, a2, th) tmp = 1.0; end
code[a1_, a2_, th_] := 1.0
\begin{array}{l}
\\
1
\end{array}
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 60.6%
unpow260.6%
*-commutative60.6%
Simplified60.6%
Taylor expanded in th around 0 40.4%
unpow240.4%
Simplified40.4%
div-inv40.3%
add-sqr-sqrt40.3%
sqrt-unprod40.3%
frac-times40.3%
metadata-eval40.3%
add-sqr-sqrt40.4%
metadata-eval40.4%
Applied egg-rr40.4%
Applied egg-rr3.4%
*-inverses3.4%
Simplified3.4%
Final simplification3.4%
(FPCore (a1 a2 th) :precision binary64 a1)
double code(double a1, double a2, double th) {
return a1;
}
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
public static double code(double a1, double a2, double th) {
return a1;
}
def code(a1, a2, th): return a1
function code(a1, a2, th) return a1 end
function tmp = code(a1, a2, th) tmp = a1; end
code[a1_, a2_, th_] := a1
\begin{array}{l}
\\
a1
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 65.2%
Taylor expanded in a1 around inf 38.0%
unpow238.0%
Simplified38.0%
Applied egg-rr4.7%
unpow14.7%
*-inverses4.7%
sqr-pow2.3%
fabs-sqr2.3%
sqr-pow3.5%
*-inverses3.5%
unpow13.5%
Simplified3.5%
Final simplification3.5%
(FPCore (a1 a2 th) :precision binary64 a2)
double code(double a1, double a2, double th) {
return a2;
}
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
public static double code(double a1, double a2, double th) {
return a2;
}
def code(a1, a2, th): return a2
function code(a1, a2, th) return a2 end
function tmp = code(a1, a2, th) tmp = a2; end
code[a1_, a2_, th_] := a2
\begin{array}{l}
\\
a2
\end{array}
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 60.6%
unpow260.6%
*-commutative60.6%
Simplified60.6%
Taylor expanded in th around 0 40.4%
unpow240.4%
Simplified40.4%
div-inv40.3%
add-sqr-sqrt40.3%
sqrt-unprod40.3%
frac-times40.3%
metadata-eval40.3%
add-sqr-sqrt40.4%
metadata-eval40.4%
Applied egg-rr40.4%
Applied egg-rr3.5%
+-lft-identity3.5%
Simplified3.5%
Final simplification3.5%
herbie shell --seed 2023192
(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))))