
(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 20 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 (* (* (pow 2.0 -0.5) (cos th)) (+ (* a1 a1) (* a2 a2))))
double code(double a1, double a2, double th) {
return (pow(2.0, -0.5) * cos(th)) * ((a1 * a1) + (a2 * a2));
}
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
code = ((2.0d0 ** (-0.5d0)) * cos(th)) * ((a1 * a1) + (a2 * a2))
end function
public static double code(double a1, double a2, double th) {
return (Math.pow(2.0, -0.5) * Math.cos(th)) * ((a1 * a1) + (a2 * a2));
}
def code(a1, a2, th): return (math.pow(2.0, -0.5) * math.cos(th)) * ((a1 * a1) + (a2 * a2))
function code(a1, a2, th) return Float64(Float64((2.0 ^ -0.5) * cos(th)) * Float64(Float64(a1 * a1) + Float64(a2 * a2))) end
function tmp = code(a1, a2, th) tmp = ((2.0 ^ -0.5) * cos(th)) * ((a1 * a1) + (a2 * a2)); end
code[a1_, a2_, th_] := N[(N[(N[Power[2.0, -0.5], $MachinePrecision] * N[Cos[th], $MachinePrecision]), $MachinePrecision] * N[(N[(a1 * a1), $MachinePrecision] + N[(a2 * a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({2}^{-0.5} \cdot \cos th\right) \cdot \left(a1 \cdot a1 + a2 \cdot a2\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%
Final simplification99.6%
(FPCore (a1 a2 th)
:precision binary64
(let* ((t_1 (+ (* a1 a1) (* a2 a2))))
(if (<= (cos th) -0.4)
(* -0.5 t_1)
(if (<= (cos th) 0.97)
(* a2 (* a2 (* (cos th) (sqrt 0.5))))
(* t_1 (sqrt 0.5))))))
double code(double a1, double a2, double th) {
double t_1 = (a1 * a1) + (a2 * a2);
double tmp;
if (cos(th) <= -0.4) {
tmp = -0.5 * t_1;
} else if (cos(th) <= 0.97) {
tmp = a2 * (a2 * (cos(th) * sqrt(0.5)));
} else {
tmp = t_1 * sqrt(0.5);
}
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 = (a1 * a1) + (a2 * a2)
if (cos(th) <= (-0.4d0)) then
tmp = (-0.5d0) * t_1
else if (cos(th) <= 0.97d0) then
tmp = a2 * (a2 * (cos(th) * sqrt(0.5d0)))
else
tmp = t_1 * sqrt(0.5d0)
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double t_1 = (a1 * a1) + (a2 * a2);
double tmp;
if (Math.cos(th) <= -0.4) {
tmp = -0.5 * t_1;
} else if (Math.cos(th) <= 0.97) {
tmp = a2 * (a2 * (Math.cos(th) * Math.sqrt(0.5)));
} else {
tmp = t_1 * Math.sqrt(0.5);
}
return tmp;
}
def code(a1, a2, th): t_1 = (a1 * a1) + (a2 * a2) tmp = 0 if math.cos(th) <= -0.4: tmp = -0.5 * t_1 elif math.cos(th) <= 0.97: tmp = a2 * (a2 * (math.cos(th) * math.sqrt(0.5))) else: tmp = t_1 * math.sqrt(0.5) return tmp
function code(a1, a2, th) t_1 = Float64(Float64(a1 * a1) + Float64(a2 * a2)) tmp = 0.0 if (cos(th) <= -0.4) tmp = Float64(-0.5 * t_1); elseif (cos(th) <= 0.97) tmp = Float64(a2 * Float64(a2 * Float64(cos(th) * sqrt(0.5)))); else tmp = Float64(t_1 * sqrt(0.5)); end return tmp end
function tmp_2 = code(a1, a2, th) t_1 = (a1 * a1) + (a2 * a2); tmp = 0.0; if (cos(th) <= -0.4) tmp = -0.5 * t_1; elseif (cos(th) <= 0.97) tmp = a2 * (a2 * (cos(th) * sqrt(0.5))); else tmp = t_1 * sqrt(0.5); end tmp_2 = tmp; end
code[a1_, a2_, th_] := Block[{t$95$1 = N[(N[(a1 * a1), $MachinePrecision] + N[(a2 * a2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[th], $MachinePrecision], -0.4], N[(-0.5 * t$95$1), $MachinePrecision], If[LessEqual[N[Cos[th], $MachinePrecision], 0.97], N[(a2 * N[(a2 * N[(N[Cos[th], $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a1 \cdot a1 + a2 \cdot a2\\
\mathbf{if}\;\cos th \leq -0.4:\\
\;\;\;\;-0.5 \cdot t_1\\
\mathbf{elif}\;\cos th \leq 0.97:\\
\;\;\;\;a2 \cdot \left(a2 \cdot \left(\cos th \cdot \sqrt{0.5}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \sqrt{0.5}\\
\end{array}
\end{array}
if (cos.f64 th) < -0.40000000000000002Initial program 99.9%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in th around 0 11.5%
Applied egg-rr75.7%
if -0.40000000000000002 < (cos.f64 th) < 0.96999999999999997Initial program 99.5%
distribute-lft-out99.5%
associate-*l/99.5%
associate-*r/99.4%
fma-def99.4%
Simplified99.4%
Taylor expanded in a1 around 0 54.3%
unpow254.3%
associate-*l*54.3%
associate-*r/54.3%
associate-/l*54.3%
Simplified54.3%
*-un-lft-identity54.3%
div-inv54.2%
times-frac54.2%
pow1/254.2%
pow-flip54.3%
metadata-eval54.3%
add-sqr-sqrt54.0%
sqrt-unprod54.3%
pow-prod-up54.3%
metadata-eval54.3%
metadata-eval54.3%
Applied egg-rr54.3%
associate-/r/54.3%
/-rgt-identity54.3%
*-commutative54.3%
associate-*l*54.3%
Simplified54.3%
if 0.96999999999999997 < (cos.f64 th) Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
clear-num99.6%
associate-/r/99.6%
pow1/299.6%
pow-flip99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Taylor expanded in th around 0 94.2%
Final simplification79.4%
(FPCore (a1 a2 th)
:precision binary64
(let* ((t_1 (+ (* a1 a1) (* a2 a2))))
(if (<= (cos th) -0.4)
(* -0.5 t_1)
(if (<= (cos th) 0.97)
(* (cos th) (* a2 (* a2 (sqrt 0.5))))
(* t_1 (sqrt 0.5))))))
double code(double a1, double a2, double th) {
double t_1 = (a1 * a1) + (a2 * a2);
double tmp;
if (cos(th) <= -0.4) {
tmp = -0.5 * t_1;
} else if (cos(th) <= 0.97) {
tmp = cos(th) * (a2 * (a2 * sqrt(0.5)));
} else {
tmp = t_1 * sqrt(0.5);
}
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 = (a1 * a1) + (a2 * a2)
if (cos(th) <= (-0.4d0)) then
tmp = (-0.5d0) * t_1
else if (cos(th) <= 0.97d0) then
tmp = cos(th) * (a2 * (a2 * sqrt(0.5d0)))
else
tmp = t_1 * sqrt(0.5d0)
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double t_1 = (a1 * a1) + (a2 * a2);
double tmp;
if (Math.cos(th) <= -0.4) {
tmp = -0.5 * t_1;
} else if (Math.cos(th) <= 0.97) {
tmp = Math.cos(th) * (a2 * (a2 * Math.sqrt(0.5)));
} else {
tmp = t_1 * Math.sqrt(0.5);
}
return tmp;
}
def code(a1, a2, th): t_1 = (a1 * a1) + (a2 * a2) tmp = 0 if math.cos(th) <= -0.4: tmp = -0.5 * t_1 elif math.cos(th) <= 0.97: tmp = math.cos(th) * (a2 * (a2 * math.sqrt(0.5))) else: tmp = t_1 * math.sqrt(0.5) return tmp
function code(a1, a2, th) t_1 = Float64(Float64(a1 * a1) + Float64(a2 * a2)) tmp = 0.0 if (cos(th) <= -0.4) tmp = Float64(-0.5 * t_1); elseif (cos(th) <= 0.97) tmp = Float64(cos(th) * Float64(a2 * Float64(a2 * sqrt(0.5)))); else tmp = Float64(t_1 * sqrt(0.5)); end return tmp end
function tmp_2 = code(a1, a2, th) t_1 = (a1 * a1) + (a2 * a2); tmp = 0.0; if (cos(th) <= -0.4) tmp = -0.5 * t_1; elseif (cos(th) <= 0.97) tmp = cos(th) * (a2 * (a2 * sqrt(0.5))); else tmp = t_1 * sqrt(0.5); end tmp_2 = tmp; end
code[a1_, a2_, th_] := Block[{t$95$1 = N[(N[(a1 * a1), $MachinePrecision] + N[(a2 * a2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[th], $MachinePrecision], -0.4], N[(-0.5 * t$95$1), $MachinePrecision], If[LessEqual[N[Cos[th], $MachinePrecision], 0.97], N[(N[Cos[th], $MachinePrecision] * N[(a2 * N[(a2 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a1 \cdot a1 + a2 \cdot a2\\
\mathbf{if}\;\cos th \leq -0.4:\\
\;\;\;\;-0.5 \cdot t_1\\
\mathbf{elif}\;\cos th \leq 0.97:\\
\;\;\;\;\cos th \cdot \left(a2 \cdot \left(a2 \cdot \sqrt{0.5}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \sqrt{0.5}\\
\end{array}
\end{array}
if (cos.f64 th) < -0.40000000000000002Initial program 99.9%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in th around 0 11.5%
Applied egg-rr75.7%
if -0.40000000000000002 < (cos.f64 th) < 0.96999999999999997Initial program 99.5%
distribute-lft-out99.5%
Simplified99.5%
clear-num99.4%
associate-/r/99.4%
pow1/299.4%
pow-flip99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in a1 around 0 54.4%
unpow254.4%
associate-*r*54.4%
*-commutative54.4%
*-commutative54.4%
associate-*l*54.4%
Simplified54.4%
if 0.96999999999999997 < (cos.f64 th) Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
clear-num99.6%
associate-/r/99.6%
pow1/299.6%
pow-flip99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Taylor expanded in th around 0 94.2%
Final simplification79.4%
(FPCore (a1 a2 th) :precision binary64 (let* ((t_1 (+ (* a1 a1) (* a2 a2)))) (if (<= (cos th) -0.02) (* -0.5 t_1) (* t_1 (sqrt 0.5)))))
double code(double a1, double a2, double th) {
double t_1 = (a1 * a1) + (a2 * a2);
double tmp;
if (cos(th) <= -0.02) {
tmp = -0.5 * t_1;
} else {
tmp = t_1 * sqrt(0.5);
}
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 = (a1 * a1) + (a2 * a2)
if (cos(th) <= (-0.02d0)) then
tmp = (-0.5d0) * t_1
else
tmp = t_1 * sqrt(0.5d0)
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double t_1 = (a1 * a1) + (a2 * a2);
double tmp;
if (Math.cos(th) <= -0.02) {
tmp = -0.5 * t_1;
} else {
tmp = t_1 * Math.sqrt(0.5);
}
return tmp;
}
def code(a1, a2, th): t_1 = (a1 * a1) + (a2 * a2) tmp = 0 if math.cos(th) <= -0.02: tmp = -0.5 * t_1 else: tmp = t_1 * math.sqrt(0.5) return tmp
function code(a1, a2, th) t_1 = Float64(Float64(a1 * a1) + Float64(a2 * a2)) tmp = 0.0 if (cos(th) <= -0.02) tmp = Float64(-0.5 * t_1); else tmp = Float64(t_1 * sqrt(0.5)); end return tmp end
function tmp_2 = code(a1, a2, th) t_1 = (a1 * a1) + (a2 * a2); tmp = 0.0; if (cos(th) <= -0.02) tmp = -0.5 * t_1; else tmp = t_1 * sqrt(0.5); end tmp_2 = tmp; end
code[a1_, a2_, th_] := Block[{t$95$1 = N[(N[(a1 * a1), $MachinePrecision] + N[(a2 * a2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[th], $MachinePrecision], -0.02], N[(-0.5 * t$95$1), $MachinePrecision], N[(t$95$1 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a1 \cdot a1 + a2 \cdot a2\\
\mathbf{if}\;\cos th \leq -0.02:\\
\;\;\;\;-0.5 \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \sqrt{0.5}\\
\end{array}
\end{array}
if (cos.f64 th) < -0.0200000000000000004Initial program 99.8%
distribute-lft-out99.8%
Simplified99.8%
Taylor expanded in th around 0 8.4%
Applied egg-rr70.0%
if -0.0200000000000000004 < (cos.f64 th) Initial program 99.5%
distribute-lft-out99.5%
Simplified99.5%
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 81.4%
Final simplification78.5%
(FPCore (a1 a2 th) :precision binary64 (* (+ (* a1 a1) (* a2 a2)) (/ (cos th) (sqrt 2.0))))
double code(double a1, double a2, double th) {
return ((a1 * a1) + (a2 * a2)) * (cos(th) / 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) + (a2 * a2)) * (cos(th) / sqrt(2.0d0))
end function
public static double code(double a1, double a2, double th) {
return ((a1 * a1) + (a2 * a2)) * (Math.cos(th) / Math.sqrt(2.0));
}
def code(a1, a2, th): return ((a1 * a1) + (a2 * a2)) * (math.cos(th) / math.sqrt(2.0))
function code(a1, a2, th) return Float64(Float64(Float64(a1 * a1) + Float64(a2 * a2)) * Float64(cos(th) / sqrt(2.0))) end
function tmp = code(a1, a2, th) tmp = ((a1 * a1) + (a2 * a2)) * (cos(th) / sqrt(2.0)); end
code[a1_, a2_, th_] := N[(N[(N[(a1 * a1), $MachinePrecision] + N[(a2 * a2), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a1 \cdot a1 + a2 \cdot a2\right) \cdot \frac{\cos th}{\sqrt{2}}
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (a1 a2 th) :precision binary64 (if (<= a1 -7.8e-59) (* (cos th) (/ a1 (/ (sqrt 2.0) a1))) (* (cos th) (* a2 (* a2 (sqrt 0.5))))))
double code(double a1, double a2, double th) {
double tmp;
if (a1 <= -7.8e-59) {
tmp = cos(th) * (a1 / (sqrt(2.0) / a1));
} else {
tmp = cos(th) * (a2 * (a2 * sqrt(0.5)));
}
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 (a1 <= (-7.8d-59)) then
tmp = cos(th) * (a1 / (sqrt(2.0d0) / a1))
else
tmp = cos(th) * (a2 * (a2 * sqrt(0.5d0)))
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double tmp;
if (a1 <= -7.8e-59) {
tmp = Math.cos(th) * (a1 / (Math.sqrt(2.0) / a1));
} else {
tmp = Math.cos(th) * (a2 * (a2 * Math.sqrt(0.5)));
}
return tmp;
}
def code(a1, a2, th): tmp = 0 if a1 <= -7.8e-59: tmp = math.cos(th) * (a1 / (math.sqrt(2.0) / a1)) else: tmp = math.cos(th) * (a2 * (a2 * math.sqrt(0.5))) return tmp
function code(a1, a2, th) tmp = 0.0 if (a1 <= -7.8e-59) tmp = Float64(cos(th) * Float64(a1 / Float64(sqrt(2.0) / a1))); else tmp = Float64(cos(th) * Float64(a2 * Float64(a2 * sqrt(0.5)))); end return tmp end
function tmp_2 = code(a1, a2, th) tmp = 0.0; if (a1 <= -7.8e-59) tmp = cos(th) * (a1 / (sqrt(2.0) / a1)); else tmp = cos(th) * (a2 * (a2 * sqrt(0.5))); end tmp_2 = tmp; end
code[a1_, a2_, th_] := If[LessEqual[a1, -7.8e-59], N[(N[Cos[th], $MachinePrecision] * N[(a1 / N[(N[Sqrt[2.0], $MachinePrecision] / a1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[th], $MachinePrecision] * N[(a2 * N[(a2 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a1 \leq -7.8 \cdot 10^{-59}:\\
\;\;\;\;\cos th \cdot \frac{a1}{\frac{\sqrt{2}}{a1}}\\
\mathbf{else}:\\
\;\;\;\;\cos th \cdot \left(a2 \cdot \left(a2 \cdot \sqrt{0.5}\right)\right)\\
\end{array}
\end{array}
if a1 < -7.80000000000000038e-59Initial program 99.7%
distribute-lft-out99.7%
associate-*l/99.8%
associate-*r/99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in a1 around inf 80.9%
unpow280.9%
associate-/l*81.0%
Simplified81.0%
if -7.80000000000000038e-59 < a1 Initial 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 a1 around 0 60.4%
unpow260.4%
associate-*r*60.4%
*-commutative60.4%
*-commutative60.4%
associate-*l*60.4%
Simplified60.4%
Final simplification65.6%
(FPCore (a1 a2 th) :precision binary64 (if (<= a1 -8.2e-59) (* (cos th) (/ a1 (/ (sqrt 2.0) a1))) (* (cos th) (/ a2 (/ (sqrt 2.0) a2)))))
double code(double a1, double a2, double th) {
double tmp;
if (a1 <= -8.2e-59) {
tmp = cos(th) * (a1 / (sqrt(2.0) / a1));
} else {
tmp = cos(th) * (a2 / (sqrt(2.0) / 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 (a1 <= (-8.2d-59)) then
tmp = cos(th) * (a1 / (sqrt(2.0d0) / a1))
else
tmp = cos(th) * (a2 / (sqrt(2.0d0) / a2))
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double tmp;
if (a1 <= -8.2e-59) {
tmp = Math.cos(th) * (a1 / (Math.sqrt(2.0) / a1));
} else {
tmp = Math.cos(th) * (a2 / (Math.sqrt(2.0) / a2));
}
return tmp;
}
def code(a1, a2, th): tmp = 0 if a1 <= -8.2e-59: tmp = math.cos(th) * (a1 / (math.sqrt(2.0) / a1)) else: tmp = math.cos(th) * (a2 / (math.sqrt(2.0) / a2)) return tmp
function code(a1, a2, th) tmp = 0.0 if (a1 <= -8.2e-59) tmp = Float64(cos(th) * Float64(a1 / Float64(sqrt(2.0) / a1))); else tmp = Float64(cos(th) * Float64(a2 / Float64(sqrt(2.0) / a2))); end return tmp end
function tmp_2 = code(a1, a2, th) tmp = 0.0; if (a1 <= -8.2e-59) tmp = cos(th) * (a1 / (sqrt(2.0) / a1)); else tmp = cos(th) * (a2 / (sqrt(2.0) / a2)); end tmp_2 = tmp; end
code[a1_, a2_, th_] := If[LessEqual[a1, -8.2e-59], N[(N[Cos[th], $MachinePrecision] * N[(a1 / N[(N[Sqrt[2.0], $MachinePrecision] / a1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[th], $MachinePrecision] * N[(a2 / N[(N[Sqrt[2.0], $MachinePrecision] / a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a1 \leq -8.2 \cdot 10^{-59}:\\
\;\;\;\;\cos th \cdot \frac{a1}{\frac{\sqrt{2}}{a1}}\\
\mathbf{else}:\\
\;\;\;\;\cos th \cdot \frac{a2}{\frac{\sqrt{2}}{a2}}\\
\end{array}
\end{array}
if a1 < -8.1999999999999991e-59Initial program 99.7%
distribute-lft-out99.7%
associate-*l/99.8%
associate-*r/99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in a1 around inf 80.9%
unpow280.9%
associate-/l*81.0%
Simplified81.0%
if -8.1999999999999991e-59 < a1 Initial program 99.6%
distribute-lft-out99.6%
associate-*l/99.6%
associate-*r/99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in a1 around 0 60.4%
unpow260.4%
associate-/l*60.4%
Simplified60.4%
Final simplification65.6%
(FPCore (a1 a2 th) :precision binary64 (if (<= a1 -1.1e-59) (/ (* a1 a1) (/ (sqrt 2.0) (cos th))) (* (cos th) (/ a2 (/ (sqrt 2.0) a2)))))
double code(double a1, double a2, double th) {
double tmp;
if (a1 <= -1.1e-59) {
tmp = (a1 * a1) / (sqrt(2.0) / cos(th));
} else {
tmp = cos(th) * (a2 / (sqrt(2.0) / 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 (a1 <= (-1.1d-59)) then
tmp = (a1 * a1) / (sqrt(2.0d0) / cos(th))
else
tmp = cos(th) * (a2 / (sqrt(2.0d0) / a2))
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double tmp;
if (a1 <= -1.1e-59) {
tmp = (a1 * a1) / (Math.sqrt(2.0) / Math.cos(th));
} else {
tmp = Math.cos(th) * (a2 / (Math.sqrt(2.0) / a2));
}
return tmp;
}
def code(a1, a2, th): tmp = 0 if a1 <= -1.1e-59: tmp = (a1 * a1) / (math.sqrt(2.0) / math.cos(th)) else: tmp = math.cos(th) * (a2 / (math.sqrt(2.0) / a2)) return tmp
function code(a1, a2, th) tmp = 0.0 if (a1 <= -1.1e-59) tmp = Float64(Float64(a1 * a1) / Float64(sqrt(2.0) / cos(th))); else tmp = Float64(cos(th) * Float64(a2 / Float64(sqrt(2.0) / a2))); end return tmp end
function tmp_2 = code(a1, a2, th) tmp = 0.0; if (a1 <= -1.1e-59) tmp = (a1 * a1) / (sqrt(2.0) / cos(th)); else tmp = cos(th) * (a2 / (sqrt(2.0) / a2)); end tmp_2 = tmp; end
code[a1_, a2_, th_] := If[LessEqual[a1, -1.1e-59], N[(N[(a1 * a1), $MachinePrecision] / N[(N[Sqrt[2.0], $MachinePrecision] / N[Cos[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[th], $MachinePrecision] * N[(a2 / N[(N[Sqrt[2.0], $MachinePrecision] / a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a1 \leq -1.1 \cdot 10^{-59}:\\
\;\;\;\;\frac{a1 \cdot a1}{\frac{\sqrt{2}}{\cos th}}\\
\mathbf{else}:\\
\;\;\;\;\cos th \cdot \frac{a2}{\frac{\sqrt{2}}{a2}}\\
\end{array}
\end{array}
if a1 < -1.0999999999999999e-59Initial program 99.7%
distribute-lft-out99.7%
associate-*l/99.8%
associate-*r/99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in a1 around inf 80.9%
unpow280.9%
associate-/l*80.9%
Simplified80.9%
if -1.0999999999999999e-59 < a1 Initial program 99.6%
distribute-lft-out99.6%
associate-*l/99.6%
associate-*r/99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in a1 around 0 60.4%
unpow260.4%
associate-/l*60.4%
Simplified60.4%
Final simplification65.6%
(FPCore (a1 a2 th)
:precision binary64
(if (<= a2 1.45)
(* (* a1 a1) (sqrt 0.5))
(if (<= a2 1.05e+150)
(* a2 (sqrt (/ (* a2 a2) 2.0)))
(* a2 (* (cos th) a2)))))
double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 1.45) {
tmp = (a1 * a1) * sqrt(0.5);
} else if (a2 <= 1.05e+150) {
tmp = a2 * sqrt(((a2 * a2) / 2.0));
} else {
tmp = a2 * (cos(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 (a2 <= 1.45d0) then
tmp = (a1 * a1) * sqrt(0.5d0)
else if (a2 <= 1.05d+150) then
tmp = a2 * sqrt(((a2 * a2) / 2.0d0))
else
tmp = a2 * (cos(th) * a2)
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 1.45) {
tmp = (a1 * a1) * Math.sqrt(0.5);
} else if (a2 <= 1.05e+150) {
tmp = a2 * Math.sqrt(((a2 * a2) / 2.0));
} else {
tmp = a2 * (Math.cos(th) * a2);
}
return tmp;
}
def code(a1, a2, th): tmp = 0 if a2 <= 1.45: tmp = (a1 * a1) * math.sqrt(0.5) elif a2 <= 1.05e+150: tmp = a2 * math.sqrt(((a2 * a2) / 2.0)) else: tmp = a2 * (math.cos(th) * a2) return tmp
function code(a1, a2, th) tmp = 0.0 if (a2 <= 1.45) tmp = Float64(Float64(a1 * a1) * sqrt(0.5)); elseif (a2 <= 1.05e+150) tmp = Float64(a2 * sqrt(Float64(Float64(a2 * a2) / 2.0))); else tmp = Float64(a2 * Float64(cos(th) * a2)); end return tmp end
function tmp_2 = code(a1, a2, th) tmp = 0.0; if (a2 <= 1.45) tmp = (a1 * a1) * sqrt(0.5); elseif (a2 <= 1.05e+150) tmp = a2 * sqrt(((a2 * a2) / 2.0)); else tmp = a2 * (cos(th) * a2); end tmp_2 = tmp; end
code[a1_, a2_, th_] := If[LessEqual[a2, 1.45], N[(N[(a1 * a1), $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[a2, 1.05e+150], N[(a2 * N[Sqrt[N[(N[(a2 * a2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(a2 * N[(N[Cos[th], $MachinePrecision] * a2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 1.45:\\
\;\;\;\;\left(a1 \cdot a1\right) \cdot \sqrt{0.5}\\
\mathbf{elif}\;a2 \leq 1.05 \cdot 10^{+150}:\\
\;\;\;\;a2 \cdot \sqrt{\frac{a2 \cdot a2}{2}}\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \left(\cos th \cdot a2\right)\\
\end{array}
\end{array}
if a2 < 1.44999999999999996Initial 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 65.5%
Taylor expanded in a1 around inf 46.3%
unpow246.3%
Simplified46.3%
if 1.44999999999999996 < a2 < 1.04999999999999999e150Initial program 99.5%
distribute-lft-out99.5%
associate-*l/99.6%
associate-*r/99.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in a1 around 0 55.2%
unpow255.2%
associate-*l*55.1%
associate-*r/55.1%
associate-/l*55.2%
Simplified55.2%
Taylor expanded in th around 0 28.7%
add-sqr-sqrt28.6%
sqrt-unprod28.7%
frac-times28.6%
add-sqr-sqrt28.6%
Applied egg-rr28.6%
if 1.04999999999999999e150 < a2 Initial program 100.0%
distribute-lft-out100.0%
associate-*l/100.0%
associate-*r/100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in a1 around 0 100.0%
unpow2100.0%
associate-*l*100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
*-un-lft-identity100.0%
div-inv100.0%
times-frac100.0%
pow1/2100.0%
pow-flip100.0%
metadata-eval100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
pow-prod-up100.0%
metadata-eval100.0%
metadata-eval100.0%
Applied egg-rr100.0%
associate-/r/100.0%
/-rgt-identity100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Applied egg-rr100.0%
rem-log-exp100.0%
Simplified100.0%
Final simplification49.0%
(FPCore (a1 a2 th) :precision binary64 (let* ((t_1 (+ (* a1 a1) (* a2 a2)))) (if (<= (cos th) -1e-309) (* -0.5 t_1) (* t_1 0.5))))
double code(double a1, double a2, double th) {
double t_1 = (a1 * a1) + (a2 * a2);
double tmp;
if (cos(th) <= -1e-309) {
tmp = -0.5 * t_1;
} else {
tmp = t_1 * 0.5;
}
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 = (a1 * a1) + (a2 * a2)
if (cos(th) <= (-1d-309)) then
tmp = (-0.5d0) * t_1
else
tmp = t_1 * 0.5d0
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double t_1 = (a1 * a1) + (a2 * a2);
double tmp;
if (Math.cos(th) <= -1e-309) {
tmp = -0.5 * t_1;
} else {
tmp = t_1 * 0.5;
}
return tmp;
}
def code(a1, a2, th): t_1 = (a1 * a1) + (a2 * a2) tmp = 0 if math.cos(th) <= -1e-309: tmp = -0.5 * t_1 else: tmp = t_1 * 0.5 return tmp
function code(a1, a2, th) t_1 = Float64(Float64(a1 * a1) + Float64(a2 * a2)) tmp = 0.0 if (cos(th) <= -1e-309) tmp = Float64(-0.5 * t_1); else tmp = Float64(t_1 * 0.5); end return tmp end
function tmp_2 = code(a1, a2, th) t_1 = (a1 * a1) + (a2 * a2); tmp = 0.0; if (cos(th) <= -1e-309) tmp = -0.5 * t_1; else tmp = t_1 * 0.5; end tmp_2 = tmp; end
code[a1_, a2_, th_] := Block[{t$95$1 = N[(N[(a1 * a1), $MachinePrecision] + N[(a2 * a2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[th], $MachinePrecision], -1e-309], N[(-0.5 * t$95$1), $MachinePrecision], N[(t$95$1 * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a1 \cdot a1 + a2 \cdot a2\\
\mathbf{if}\;\cos th \leq -1 \cdot 10^{-309}:\\
\;\;\;\;-0.5 \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot 0.5\\
\end{array}
\end{array}
if (cos.f64 th) < -1.000000000000002e-309Initial program 99.8%
distribute-lft-out99.8%
Simplified99.8%
Taylor expanded in th around 0 8.4%
Applied egg-rr70.0%
if -1.000000000000002e-309 < (cos.f64 th) Initial program 99.5%
distribute-lft-out99.5%
Simplified99.5%
Taylor expanded in th around 0 81.3%
Applied egg-rr56.8%
Final simplification60.1%
(FPCore (a1 a2 th) :precision binary64 (if (<= a2 0.00035) (* (* a1 a1) (sqrt 0.5)) (if (<= a2 1e+150) (* a2 (* a2 (sqrt 0.5))) (* a2 (* (cos th) a2)))))
double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 0.00035) {
tmp = (a1 * a1) * sqrt(0.5);
} else if (a2 <= 1e+150) {
tmp = a2 * (a2 * sqrt(0.5));
} else {
tmp = a2 * (cos(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 (a2 <= 0.00035d0) then
tmp = (a1 * a1) * sqrt(0.5d0)
else if (a2 <= 1d+150) then
tmp = a2 * (a2 * sqrt(0.5d0))
else
tmp = a2 * (cos(th) * a2)
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 0.00035) {
tmp = (a1 * a1) * Math.sqrt(0.5);
} else if (a2 <= 1e+150) {
tmp = a2 * (a2 * Math.sqrt(0.5));
} else {
tmp = a2 * (Math.cos(th) * a2);
}
return tmp;
}
def code(a1, a2, th): tmp = 0 if a2 <= 0.00035: tmp = (a1 * a1) * math.sqrt(0.5) elif a2 <= 1e+150: tmp = a2 * (a2 * math.sqrt(0.5)) else: tmp = a2 * (math.cos(th) * a2) return tmp
function code(a1, a2, th) tmp = 0.0 if (a2 <= 0.00035) tmp = Float64(Float64(a1 * a1) * sqrt(0.5)); elseif (a2 <= 1e+150) tmp = Float64(a2 * Float64(a2 * sqrt(0.5))); else tmp = Float64(a2 * Float64(cos(th) * a2)); end return tmp end
function tmp_2 = code(a1, a2, th) tmp = 0.0; if (a2 <= 0.00035) tmp = (a1 * a1) * sqrt(0.5); elseif (a2 <= 1e+150) tmp = a2 * (a2 * sqrt(0.5)); else tmp = a2 * (cos(th) * a2); end tmp_2 = tmp; end
code[a1_, a2_, th_] := If[LessEqual[a2, 0.00035], N[(N[(a1 * a1), $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[a2, 1e+150], N[(a2 * N[(a2 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a2 * N[(N[Cos[th], $MachinePrecision] * a2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 0.00035:\\
\;\;\;\;\left(a1 \cdot a1\right) \cdot \sqrt{0.5}\\
\mathbf{elif}\;a2 \leq 10^{+150}:\\
\;\;\;\;a2 \cdot \left(a2 \cdot \sqrt{0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \left(\cos th \cdot a2\right)\\
\end{array}
\end{array}
if a2 < 3.49999999999999996e-4Initial 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 65.5%
Taylor expanded in a1 around inf 46.3%
unpow246.3%
Simplified46.3%
if 3.49999999999999996e-4 < a2 < 9.99999999999999981e149Initial program 99.5%
distribute-lft-out99.5%
associate-*l/99.6%
associate-*r/99.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in a1 around 0 55.2%
unpow255.2%
associate-*l*55.1%
associate-*r/55.1%
associate-/l*55.2%
Simplified55.2%
*-un-lft-identity55.2%
div-inv55.2%
times-frac55.1%
pow1/255.1%
pow-flip55.2%
metadata-eval55.2%
add-sqr-sqrt54.6%
sqrt-unprod55.2%
pow-prod-up55.2%
metadata-eval55.2%
metadata-eval55.2%
Applied egg-rr55.2%
associate-/r/55.3%
/-rgt-identity55.3%
*-commutative55.3%
associate-*l*55.2%
Simplified55.2%
Taylor expanded in th around 0 28.6%
if 9.99999999999999981e149 < a2 Initial program 100.0%
distribute-lft-out100.0%
associate-*l/100.0%
associate-*r/100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in a1 around 0 100.0%
unpow2100.0%
associate-*l*100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
*-un-lft-identity100.0%
div-inv100.0%
times-frac100.0%
pow1/2100.0%
pow-flip100.0%
metadata-eval100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
pow-prod-up100.0%
metadata-eval100.0%
metadata-eval100.0%
Applied egg-rr100.0%
associate-/r/100.0%
/-rgt-identity100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Applied egg-rr100.0%
rem-log-exp100.0%
Simplified100.0%
Final simplification49.0%
(FPCore (a1 a2 th) :precision binary64 (if (or (<= th 1.5e+80) (and (not (<= th 2.6e+254)) (<= th 6.8e+289))) (* (+ a1 a2) (+ a1 a2)) (* -0.5 (+ (* a1 a1) (* a2 a2)))))
double code(double a1, double a2, double th) {
double tmp;
if ((th <= 1.5e+80) || (!(th <= 2.6e+254) && (th <= 6.8e+289))) {
tmp = (a1 + a2) * (a1 + a2);
} else {
tmp = -0.5 * ((a1 * a1) + (a2 * 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 <= 1.5d+80) .or. (.not. (th <= 2.6d+254)) .and. (th <= 6.8d+289)) then
tmp = (a1 + a2) * (a1 + a2)
else
tmp = (-0.5d0) * ((a1 * a1) + (a2 * a2))
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double tmp;
if ((th <= 1.5e+80) || (!(th <= 2.6e+254) && (th <= 6.8e+289))) {
tmp = (a1 + a2) * (a1 + a2);
} else {
tmp = -0.5 * ((a1 * a1) + (a2 * a2));
}
return tmp;
}
def code(a1, a2, th): tmp = 0 if (th <= 1.5e+80) or (not (th <= 2.6e+254) and (th <= 6.8e+289)): tmp = (a1 + a2) * (a1 + a2) else: tmp = -0.5 * ((a1 * a1) + (a2 * a2)) return tmp
function code(a1, a2, th) tmp = 0.0 if ((th <= 1.5e+80) || (!(th <= 2.6e+254) && (th <= 6.8e+289))) tmp = Float64(Float64(a1 + a2) * Float64(a1 + a2)); else tmp = Float64(-0.5 * Float64(Float64(a1 * a1) + Float64(a2 * a2))); end return tmp end
function tmp_2 = code(a1, a2, th) tmp = 0.0; if ((th <= 1.5e+80) || (~((th <= 2.6e+254)) && (th <= 6.8e+289))) tmp = (a1 + a2) * (a1 + a2); else tmp = -0.5 * ((a1 * a1) + (a2 * a2)); end tmp_2 = tmp; end
code[a1_, a2_, th_] := If[Or[LessEqual[th, 1.5e+80], And[N[Not[LessEqual[th, 2.6e+254]], $MachinePrecision], LessEqual[th, 6.8e+289]]], N[(N[(a1 + a2), $MachinePrecision] * N[(a1 + a2), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(a1 * a1), $MachinePrecision] + N[(a2 * a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 1.5 \cdot 10^{+80} \lor \neg \left(th \leq 2.6 \cdot 10^{+254}\right) \land th \leq 6.8 \cdot 10^{+289}:\\
\;\;\;\;\left(a1 + a2\right) \cdot \left(a1 + a2\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(a1 \cdot a1 + a2 \cdot a2\right)\\
\end{array}
\end{array}
if th < 1.49999999999999993e80 or 2.6000000000000001e254 < th < 6.7999999999999997e289Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 71.6%
Applied egg-rr45.7%
distribute-lft-out49.4%
+-commutative49.4%
+-commutative49.4%
Simplified49.4%
if 1.49999999999999993e80 < th < 2.6000000000000001e254 or 6.7999999999999997e289 < th Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 20.8%
Applied egg-rr57.2%
Final simplification50.7%
(FPCore (a1 a2 th)
:precision binary64
(let* ((t_1 (+ (* a1 a1) (* a2 a2))))
(if (<= th 1.5e+80)
(* (+ a1 a2) (+ a1 a2))
(if (or (<= th 2.6e+254) (not (<= th 6.8e+289)))
(* -0.5 t_1)
(* t_1 0.125)))))
double code(double a1, double a2, double th) {
double t_1 = (a1 * a1) + (a2 * a2);
double tmp;
if (th <= 1.5e+80) {
tmp = (a1 + a2) * (a1 + a2);
} else if ((th <= 2.6e+254) || !(th <= 6.8e+289)) {
tmp = -0.5 * t_1;
} else {
tmp = t_1 * 0.125;
}
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 = (a1 * a1) + (a2 * a2)
if (th <= 1.5d+80) then
tmp = (a1 + a2) * (a1 + a2)
else if ((th <= 2.6d+254) .or. (.not. (th <= 6.8d+289))) then
tmp = (-0.5d0) * t_1
else
tmp = t_1 * 0.125d0
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double t_1 = (a1 * a1) + (a2 * a2);
double tmp;
if (th <= 1.5e+80) {
tmp = (a1 + a2) * (a1 + a2);
} else if ((th <= 2.6e+254) || !(th <= 6.8e+289)) {
tmp = -0.5 * t_1;
} else {
tmp = t_1 * 0.125;
}
return tmp;
}
def code(a1, a2, th): t_1 = (a1 * a1) + (a2 * a2) tmp = 0 if th <= 1.5e+80: tmp = (a1 + a2) * (a1 + a2) elif (th <= 2.6e+254) or not (th <= 6.8e+289): tmp = -0.5 * t_1 else: tmp = t_1 * 0.125 return tmp
function code(a1, a2, th) t_1 = Float64(Float64(a1 * a1) + Float64(a2 * a2)) tmp = 0.0 if (th <= 1.5e+80) tmp = Float64(Float64(a1 + a2) * Float64(a1 + a2)); elseif ((th <= 2.6e+254) || !(th <= 6.8e+289)) tmp = Float64(-0.5 * t_1); else tmp = Float64(t_1 * 0.125); end return tmp end
function tmp_2 = code(a1, a2, th) t_1 = (a1 * a1) + (a2 * a2); tmp = 0.0; if (th <= 1.5e+80) tmp = (a1 + a2) * (a1 + a2); elseif ((th <= 2.6e+254) || ~((th <= 6.8e+289))) tmp = -0.5 * t_1; else tmp = t_1 * 0.125; end tmp_2 = tmp; end
code[a1_, a2_, th_] := Block[{t$95$1 = N[(N[(a1 * a1), $MachinePrecision] + N[(a2 * a2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[th, 1.5e+80], N[(N[(a1 + a2), $MachinePrecision] * N[(a1 + a2), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[th, 2.6e+254], N[Not[LessEqual[th, 6.8e+289]], $MachinePrecision]], N[(-0.5 * t$95$1), $MachinePrecision], N[(t$95$1 * 0.125), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a1 \cdot a1 + a2 \cdot a2\\
\mathbf{if}\;th \leq 1.5 \cdot 10^{+80}:\\
\;\;\;\;\left(a1 + a2\right) \cdot \left(a1 + a2\right)\\
\mathbf{elif}\;th \leq 2.6 \cdot 10^{+254} \lor \neg \left(th \leq 6.8 \cdot 10^{+289}\right):\\
\;\;\;\;-0.5 \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot 0.125\\
\end{array}
\end{array}
if th < 1.49999999999999993e80Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 72.9%
Applied egg-rr45.6%
distribute-lft-out49.5%
+-commutative49.5%
+-commutative49.5%
Simplified49.5%
if 1.49999999999999993e80 < th < 2.6000000000000001e254 or 6.7999999999999997e289 < th Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 20.8%
Applied egg-rr57.2%
if 2.6000000000000001e254 < th < 6.7999999999999997e289Initial program 99.1%
distribute-lft-out99.1%
Simplified99.1%
Taylor expanded in th around 0 49.4%
Applied egg-rr48.0%
Final simplification50.7%
(FPCore (a1 a2 th)
:precision binary64
(let* ((t_1 (+ (* a1 a1) (* a2 a2))))
(if (<= th 1.5e+80)
(* (+ a1 a2) (+ a1 a2))
(if (or (<= th 2.6e+254) (not (<= th 6.8e+289)))
(* -0.5 t_1)
(* t_1 0.25)))))
double code(double a1, double a2, double th) {
double t_1 = (a1 * a1) + (a2 * a2);
double tmp;
if (th <= 1.5e+80) {
tmp = (a1 + a2) * (a1 + a2);
} else if ((th <= 2.6e+254) || !(th <= 6.8e+289)) {
tmp = -0.5 * t_1;
} else {
tmp = t_1 * 0.25;
}
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 = (a1 * a1) + (a2 * a2)
if (th <= 1.5d+80) then
tmp = (a1 + a2) * (a1 + a2)
else if ((th <= 2.6d+254) .or. (.not. (th <= 6.8d+289))) then
tmp = (-0.5d0) * t_1
else
tmp = t_1 * 0.25d0
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double t_1 = (a1 * a1) + (a2 * a2);
double tmp;
if (th <= 1.5e+80) {
tmp = (a1 + a2) * (a1 + a2);
} else if ((th <= 2.6e+254) || !(th <= 6.8e+289)) {
tmp = -0.5 * t_1;
} else {
tmp = t_1 * 0.25;
}
return tmp;
}
def code(a1, a2, th): t_1 = (a1 * a1) + (a2 * a2) tmp = 0 if th <= 1.5e+80: tmp = (a1 + a2) * (a1 + a2) elif (th <= 2.6e+254) or not (th <= 6.8e+289): tmp = -0.5 * t_1 else: tmp = t_1 * 0.25 return tmp
function code(a1, a2, th) t_1 = Float64(Float64(a1 * a1) + Float64(a2 * a2)) tmp = 0.0 if (th <= 1.5e+80) tmp = Float64(Float64(a1 + a2) * Float64(a1 + a2)); elseif ((th <= 2.6e+254) || !(th <= 6.8e+289)) tmp = Float64(-0.5 * t_1); else tmp = Float64(t_1 * 0.25); end return tmp end
function tmp_2 = code(a1, a2, th) t_1 = (a1 * a1) + (a2 * a2); tmp = 0.0; if (th <= 1.5e+80) tmp = (a1 + a2) * (a1 + a2); elseif ((th <= 2.6e+254) || ~((th <= 6.8e+289))) tmp = -0.5 * t_1; else tmp = t_1 * 0.25; end tmp_2 = tmp; end
code[a1_, a2_, th_] := Block[{t$95$1 = N[(N[(a1 * a1), $MachinePrecision] + N[(a2 * a2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[th, 1.5e+80], N[(N[(a1 + a2), $MachinePrecision] * N[(a1 + a2), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[th, 2.6e+254], N[Not[LessEqual[th, 6.8e+289]], $MachinePrecision]], N[(-0.5 * t$95$1), $MachinePrecision], N[(t$95$1 * 0.25), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a1 \cdot a1 + a2 \cdot a2\\
\mathbf{if}\;th \leq 1.5 \cdot 10^{+80}:\\
\;\;\;\;\left(a1 + a2\right) \cdot \left(a1 + a2\right)\\
\mathbf{elif}\;th \leq 2.6 \cdot 10^{+254} \lor \neg \left(th \leq 6.8 \cdot 10^{+289}\right):\\
\;\;\;\;-0.5 \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot 0.25\\
\end{array}
\end{array}
if th < 1.49999999999999993e80Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 72.9%
Applied egg-rr45.6%
distribute-lft-out49.5%
+-commutative49.5%
+-commutative49.5%
Simplified49.5%
if 1.49999999999999993e80 < th < 2.6000000000000001e254 or 6.7999999999999997e289 < th Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 20.8%
Applied egg-rr57.2%
if 2.6000000000000001e254 < th < 6.7999999999999997e289Initial program 99.1%
distribute-lft-out99.1%
Simplified99.1%
Taylor expanded in th around 0 49.4%
Applied egg-rr48.6%
Final simplification50.8%
(FPCore (a1 a2 th) :precision binary64 (* (+ a1 a2) (+ a1 a2)))
double code(double a1, double a2, double th) {
return (a1 + a2) * (a1 + a2);
}
real(8) function code(a1, a2, th)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: th
code = (a1 + a2) * (a1 + a2)
end function
public static double code(double a1, double a2, double th) {
return (a1 + a2) * (a1 + a2);
}
def code(a1, a2, th): return (a1 + a2) * (a1 + a2)
function code(a1, a2, th) return Float64(Float64(a1 + a2) * Float64(a1 + a2)) end
function tmp = code(a1, a2, th) tmp = (a1 + a2) * (a1 + a2); end
code[a1_, a2_, th_] := N[(N[(a1 + a2), $MachinePrecision] * N[(a1 + a2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a1 + a2\right) \cdot \left(a1 + a2\right)
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in th around 0 63.1%
Applied egg-rr41.3%
distribute-lft-out44.4%
+-commutative44.4%
+-commutative44.4%
Simplified44.4%
Final simplification44.4%
(FPCore (a1 a2 th) :precision binary64 (if (<= a2 0.03) (* a1 a1) (* a2 a2)))
double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 0.03) {
tmp = a1 * a1;
} else {
tmp = a2 * 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 (a2 <= 0.03d0) then
tmp = a1 * a1
else
tmp = a2 * a2
end if
code = tmp
end function
public static double code(double a1, double a2, double th) {
double tmp;
if (a2 <= 0.03) {
tmp = a1 * a1;
} else {
tmp = a2 * a2;
}
return tmp;
}
def code(a1, a2, th): tmp = 0 if a2 <= 0.03: tmp = a1 * a1 else: tmp = a2 * a2 return tmp
function code(a1, a2, th) tmp = 0.0 if (a2 <= 0.03) tmp = Float64(a1 * a1); else tmp = Float64(a2 * a2); end return tmp end
function tmp_2 = code(a1, a2, th) tmp = 0.0; if (a2 <= 0.03) tmp = a1 * a1; else tmp = a2 * a2; end tmp_2 = tmp; end
code[a1_, a2_, th_] := If[LessEqual[a2, 0.03], N[(a1 * a1), $MachinePrecision], N[(a2 * a2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 0.03:\\
\;\;\;\;a1 \cdot a1\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot a2\\
\end{array}
\end{array}
if a2 < 0.029999999999999999Initial program 99.6%
distribute-lft-out99.6%
associate-*l/99.6%
associate-*r/99.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in th around 0 65.5%
unpow265.5%
unpow265.5%
+-commutative65.5%
Simplified65.5%
Taylor expanded in a1 around inf 46.3%
unpow246.3%
Simplified46.3%
Applied egg-rr35.1%
if 0.029999999999999999 < a2 Initial program 99.7%
distribute-lft-out99.7%
associate-*l/99.8%
associate-*r/99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in a1 around 0 74.3%
unpow274.3%
associate-*l*74.2%
associate-*r/74.2%
associate-/l*74.3%
Simplified74.3%
Taylor expanded in th around 0 42.4%
frac-2neg42.4%
div-inv42.4%
Applied egg-rr42.4%
Applied egg-rr31.2%
+-lft-identity31.2%
Simplified31.2%
Final simplification34.2%
(FPCore (a1 a2 th) :precision binary64 (* a1 -2.0))
double code(double a1, double a2, double th) {
return a1 * -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 * (-2.0d0)
end function
public static double code(double a1, double a2, double th) {
return a1 * -2.0;
}
def code(a1, a2, th): return a1 * -2.0
function code(a1, a2, th) return Float64(a1 * -2.0) end
function tmp = code(a1, a2, th) tmp = a1 * -2.0; end
code[a1_, a2_, th_] := N[(a1 * -2.0), $MachinePrecision]
\begin{array}{l}
\\
a1 \cdot -2
\end{array}
Initial program 99.6%
distribute-lft-out99.6%
associate-*l/99.6%
associate-*r/99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in th around 0 63.1%
unpow263.1%
unpow263.1%
+-commutative63.1%
Simplified63.1%
Taylor expanded in a1 around inf 40.2%
unpow240.2%
Simplified40.2%
Applied egg-rr3.3%
*-commutative3.3%
Simplified3.3%
Final simplification3.3%
(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%
associate-*l/99.6%
associate-*r/99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in th around 0 63.1%
unpow263.1%
unpow263.1%
+-commutative63.1%
Simplified63.1%
Taylor expanded in a1 around inf 40.2%
unpow240.2%
Simplified40.2%
Applied egg-rr31.0%
Final simplification31.0%
(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 Float64(-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%
associate-*l/99.6%
associate-*r/99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in th around 0 63.1%
unpow263.1%
unpow263.1%
+-commutative63.1%
Simplified63.1%
Taylor expanded in a1 around inf 40.2%
unpow240.2%
Simplified40.2%
Applied egg-rr3.3%
neg-sub03.3%
Simplified3.3%
Final simplification3.3%
(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%
associate-*l/99.6%
associate-*r/99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in th around 0 63.1%
unpow263.1%
unpow263.1%
+-commutative63.1%
Simplified63.1%
Taylor expanded in a1 around inf 40.2%
unpow240.2%
Simplified40.2%
Applied egg-rr4.7%
unpow14.7%
metadata-eval4.7%
sqr-pow2.9%
fabs-sqr2.9%
sqr-pow3.9%
metadata-eval3.9%
unpow13.9%
Simplified3.9%
Final simplification3.9%
herbie shell --seed 2023187
(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))))