
(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 7 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) (+ (* a1 a1) (* a2 a2))) (sqrt 2.0)))
double code(double a1, double a2, double th) {
return (cos(th) * ((a1 * a1) + (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) * ((a1 * a1) + (a2 * a2))) / sqrt(2.0d0)
end function
public static double code(double a1, double a2, double th) {
return (Math.cos(th) * ((a1 * a1) + (a2 * a2))) / Math.sqrt(2.0);
}
def code(a1, a2, th): return (math.cos(th) * ((a1 * a1) + (a2 * a2))) / math.sqrt(2.0)
function code(a1, a2, th) return Float64(Float64(cos(th) * Float64(Float64(a1 * a1) + Float64(a2 * a2))) / sqrt(2.0)) end
function tmp = code(a1, a2, th) tmp = (cos(th) * ((a1 * a1) + (a2 * a2))) / sqrt(2.0); end
code[a1_, a2_, th_] := N[(N[(N[Cos[th], $MachinePrecision] * N[(N[(a1 * a1), $MachinePrecision] + N[(a2 * a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos th \cdot \left(a1 \cdot a1 + a2 \cdot a2\right)}{\sqrt{2}}
\end{array}
Initial program 99.6%
distribute-lft-outN/A
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6499.6%
Simplified99.6%
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6499.7%
Applied egg-rr99.7%
(FPCore (a1 a2 th) :precision binary64 (* (cos th) (/ (+ (* a1 a1) (* a2 a2)) (sqrt 2.0))))
double code(double a1, double a2, double th) {
return cos(th) * (((a1 * a1) + (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) * (((a1 * a1) + (a2 * a2)) / sqrt(2.0d0))
end function
public static double code(double a1, double a2, double th) {
return Math.cos(th) * (((a1 * a1) + (a2 * a2)) / Math.sqrt(2.0));
}
def code(a1, a2, th): return math.cos(th) * (((a1 * a1) + (a2 * a2)) / math.sqrt(2.0))
function code(a1, a2, th) return Float64(cos(th) * Float64(Float64(Float64(a1 * a1) + Float64(a2 * a2)) / sqrt(2.0))) end
function tmp = code(a1, a2, th) tmp = cos(th) * (((a1 * a1) + (a2 * a2)) / sqrt(2.0)); end
code[a1_, a2_, th_] := N[(N[Cos[th], $MachinePrecision] * N[(N[(N[(a1 * a1), $MachinePrecision] + N[(a2 * a2), $MachinePrecision]), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos th \cdot \frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt{2}}
\end{array}
Initial program 99.6%
distribute-lft-outN/A
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6499.6%
Simplified99.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-outN/A
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6499.6%
Simplified99.6%
Taylor expanded in a1 around 0
/-lowering-/.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
sqrt-lowering-sqrt.f6458.5%
Simplified58.5%
associate-/l*N/A
*-commutativeN/A
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f6458.5%
Applied egg-rr58.5%
Final simplification58.5%
(FPCore (a1 a2 th)
:precision binary64
(if (<= th 4.8e+66)
(/ (+ (* a1 a1) (* a2 a2)) (sqrt 2.0))
(if (<= th 3.6e+176)
(/ (* a2 a2) (- 0.0 (sqrt 2.0)))
(/ (* a2 a2) (sqrt 2.0)))))
double code(double a1, double a2, double th) {
double tmp;
if (th <= 4.8e+66) {
tmp = ((a1 * a1) + (a2 * a2)) / sqrt(2.0);
} else if (th <= 3.6e+176) {
tmp = (a2 * a2) / (0.0 - sqrt(2.0));
} else {
tmp = (a2 * a2) / sqrt(2.0);
}
return tmp;
}
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
real(8) :: tmp
if (th <= 4.8d+66) then
tmp = ((a1 * a1) + (a2 * a2)) / sqrt(2.0d0)
else if (th <= 3.6d+176) then
tmp = (a2 * a2) / (0.0d0 - sqrt(2.0d0))
else
tmp = (a2 * a2) / sqrt(2.0d0)
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double tmp;
if (th <= 4.8e+66) {
tmp = ((a1 * a1) + (a2 * a2)) / Math.sqrt(2.0);
} else if (th <= 3.6e+176) {
tmp = (a2 * a2) / (0.0 - Math.sqrt(2.0));
} else {
tmp = (a2 * a2) / Math.sqrt(2.0);
}
return tmp;
}
def code(a1, a2, th): tmp = 0 if th <= 4.8e+66: tmp = ((a1 * a1) + (a2 * a2)) / math.sqrt(2.0) elif th <= 3.6e+176: tmp = (a2 * a2) / (0.0 - math.sqrt(2.0)) else: tmp = (a2 * a2) / math.sqrt(2.0) return tmp
function code(a1, a2, th) tmp = 0.0 if (th <= 4.8e+66) tmp = Float64(Float64(Float64(a1 * a1) + Float64(a2 * a2)) / sqrt(2.0)); elseif (th <= 3.6e+176) tmp = Float64(Float64(a2 * a2) / Float64(0.0 - sqrt(2.0))); else tmp = Float64(Float64(a2 * a2) / sqrt(2.0)); end return tmp end
function tmp_2 = code(a1, a2, th) tmp = 0.0; if (th <= 4.8e+66) tmp = ((a1 * a1) + (a2 * a2)) / sqrt(2.0); elseif (th <= 3.6e+176) tmp = (a2 * a2) / (0.0 - sqrt(2.0)); else tmp = (a2 * a2) / sqrt(2.0); end tmp_2 = tmp; end
code[a1_, a2_, th_] := If[LessEqual[th, 4.8e+66], N[(N[(N[(a1 * a1), $MachinePrecision] + N[(a2 * a2), $MachinePrecision]), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[th, 3.6e+176], N[(N[(a2 * a2), $MachinePrecision] / N[(0.0 - N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a2 * a2), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 4.8 \cdot 10^{+66}:\\
\;\;\;\;\frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt{2}}\\
\mathbf{elif}\;th \leq 3.6 \cdot 10^{+176}:\\
\;\;\;\;\frac{a2 \cdot a2}{0 - \sqrt{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a2 \cdot a2}{\sqrt{2}}\\
\end{array}
\end{array}
if th < 4.8000000000000003e66Initial program 99.6%
distribute-lft-outN/A
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6499.7%
Simplified99.7%
Taylor expanded in th around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6476.8%
Simplified76.8%
if 4.8000000000000003e66 < th < 3.59999999999999991e176Initial program 99.5%
distribute-lft-outN/A
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6499.4%
Simplified99.4%
Taylor expanded in th around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6423.6%
Simplified23.6%
flip-+N/A
clear-numN/A
associate-/r/N/A
*-lowering-*.f64N/A
difference-of-squaresN/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
difference-of-squaresN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f644.0%
Applied egg-rr4.0%
Taylor expanded in a1 around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
unpow2N/A
*-lowering-*.f641.9%
Simplified1.9%
Taylor expanded in a1 around inf
associate-*r/N/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6435.6%
Simplified35.6%
if 3.59999999999999991e176 < th Initial program 99.6%
distribute-lft-outN/A
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6499.6%
Simplified99.6%
Taylor expanded in th around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6448.8%
Simplified48.8%
Taylor expanded in a1 around 0
unpow2N/A
*-lowering-*.f6416.4%
Simplified16.4%
Final simplification66.2%
(FPCore (a1 a2 th)
:precision binary64
(let* ((t_1 (/ (* a2 a2) (sqrt 2.0))))
(if (<= th 4.8e+66)
t_1
(if (<= th 3.6e+176) (/ (* a2 a2) (- 0.0 (sqrt 2.0))) t_1))))
double code(double a1, double a2, double th) {
double t_1 = (a2 * a2) / sqrt(2.0);
double tmp;
if (th <= 4.8e+66) {
tmp = t_1;
} else if (th <= 3.6e+176) {
tmp = (a2 * a2) / (0.0 - sqrt(2.0));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = (a2 * a2) / sqrt(2.0d0)
if (th <= 4.8d+66) then
tmp = t_1
else if (th <= 3.6d+176) then
tmp = (a2 * a2) / (0.0d0 - sqrt(2.0d0))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double t_1 = (a2 * a2) / Math.sqrt(2.0);
double tmp;
if (th <= 4.8e+66) {
tmp = t_1;
} else if (th <= 3.6e+176) {
tmp = (a2 * a2) / (0.0 - Math.sqrt(2.0));
} else {
tmp = t_1;
}
return tmp;
}
def code(a1, a2, th): t_1 = (a2 * a2) / math.sqrt(2.0) tmp = 0 if th <= 4.8e+66: tmp = t_1 elif th <= 3.6e+176: tmp = (a2 * a2) / (0.0 - math.sqrt(2.0)) else: tmp = t_1 return tmp
function code(a1, a2, th) t_1 = Float64(Float64(a2 * a2) / sqrt(2.0)) tmp = 0.0 if (th <= 4.8e+66) tmp = t_1; elseif (th <= 3.6e+176) tmp = Float64(Float64(a2 * a2) / Float64(0.0 - sqrt(2.0))); else tmp = t_1; end return tmp end
function tmp_2 = code(a1, a2, th) t_1 = (a2 * a2) / sqrt(2.0); tmp = 0.0; if (th <= 4.8e+66) tmp = t_1; elseif (th <= 3.6e+176) tmp = (a2 * a2) / (0.0 - sqrt(2.0)); else tmp = t_1; end tmp_2 = tmp; end
code[a1_, a2_, th_] := Block[{t$95$1 = N[(N[(a2 * a2), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[th, 4.8e+66], t$95$1, If[LessEqual[th, 3.6e+176], N[(N[(a2 * a2), $MachinePrecision] / N[(0.0 - N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{a2 \cdot a2}{\sqrt{2}}\\
\mathbf{if}\;th \leq 4.8 \cdot 10^{+66}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;th \leq 3.6 \cdot 10^{+176}:\\
\;\;\;\;\frac{a2 \cdot a2}{0 - \sqrt{2}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if th < 4.8000000000000003e66 or 3.59999999999999991e176 < th Initial program 99.6%
distribute-lft-outN/A
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6499.7%
Simplified99.7%
Taylor expanded in th around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6473.2%
Simplified73.2%
Taylor expanded in a1 around 0
unpow2N/A
*-lowering-*.f6441.8%
Simplified41.8%
if 4.8000000000000003e66 < th < 3.59999999999999991e176Initial program 99.5%
distribute-lft-outN/A
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6499.4%
Simplified99.4%
Taylor expanded in th around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6423.6%
Simplified23.6%
flip-+N/A
clear-numN/A
associate-/r/N/A
*-lowering-*.f64N/A
difference-of-squaresN/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
difference-of-squaresN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f644.0%
Applied egg-rr4.0%
Taylor expanded in a1 around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
unpow2N/A
*-lowering-*.f641.9%
Simplified1.9%
Taylor expanded in a1 around inf
associate-*r/N/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6435.6%
Simplified35.6%
Final simplification41.3%
(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-outN/A
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6499.6%
Simplified99.6%
Taylor expanded in th around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6468.9%
Simplified68.9%
Taylor expanded in a1 around 0
unpow2N/A
*-lowering-*.f6439.6%
Simplified39.6%
(FPCore (a1 a2 th) :precision binary64 (* a1 (/ a1 (sqrt 2.0))))
double code(double a1, double a2, double th) {
return a1 * (a1 / sqrt(2.0));
}
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
code = a1 * (a1 / sqrt(2.0d0))
end function
public static double code(double a1, double a2, double th) {
return a1 * (a1 / Math.sqrt(2.0));
}
def code(a1, a2, th): return a1 * (a1 / math.sqrt(2.0))
function code(a1, a2, th) return Float64(a1 * Float64(a1 / sqrt(2.0))) end
function tmp = code(a1, a2, th) tmp = a1 * (a1 / sqrt(2.0)); end
code[a1_, a2_, th_] := N[(a1 * N[(a1 / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a1 \cdot \frac{a1}{\sqrt{2}}
\end{array}
Initial program 99.6%
distribute-lft-outN/A
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6499.6%
Simplified99.6%
Taylor expanded in th around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6468.9%
Simplified68.9%
Taylor expanded in a1 around inf
unpow2N/A
*-lowering-*.f6440.7%
Simplified40.7%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f6440.7%
Applied egg-rr40.7%
Final simplification40.7%
herbie shell --seed 2024158
(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))))