
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
(FPCore (kx ky th) :precision binary64 (* (sin th) (/ (sin ky) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
return sin(th) * (sin(ky) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th): return math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th) return Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), sin(kx)))) end
function tmp = code(kx, ky, th) tmp = sin(th) * (sin(ky) / hypot(sin(ky), sin(kx))); end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Initial program 94.0%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (pow (sin kx) 2.0))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) t_1))))
(t_3
(/
(sin ky)
(/
(*
(hypot (sin kx) (sin ky))
(fma (* th th) 0.16666666666666666 1.0))
th))))
(if (<= t_2 -0.996)
(* (/ (sin ky) (sqrt (fma (cos (* 2.0 ky)) -0.5 0.5))) (sin th))
(if (<= t_2 -0.05)
t_3
(if (<= t_2 0.15)
(* (/ (sin ky) (sqrt (+ (* ky ky) t_1))) (sin th))
(if (<= t_2 0.995) t_3 (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = pow(sin(kx), 2.0);
double t_2 = sin(ky) / sqrt((pow(sin(ky), 2.0) + t_1));
double t_3 = sin(ky) / ((hypot(sin(kx), sin(ky)) * fma((th * th), 0.16666666666666666, 1.0)) / th);
double tmp;
if (t_2 <= -0.996) {
tmp = (sin(ky) / sqrt(fma(cos((2.0 * ky)), -0.5, 0.5))) * sin(th);
} else if (t_2 <= -0.05) {
tmp = t_3;
} else if (t_2 <= 0.15) {
tmp = (sin(ky) / sqrt(((ky * ky) + t_1))) * sin(th);
} else if (t_2 <= 0.995) {
tmp = t_3;
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = sin(kx) ^ 2.0 t_2 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + t_1))) t_3 = Float64(sin(ky) / Float64(Float64(hypot(sin(kx), sin(ky)) * fma(Float64(th * th), 0.16666666666666666, 1.0)) / th)) tmp = 0.0 if (t_2 <= -0.996) tmp = Float64(Float64(sin(ky) / sqrt(fma(cos(Float64(2.0 * ky)), -0.5, 0.5))) * sin(th)); elseif (t_2 <= -0.05) tmp = t_3; elseif (t_2 <= 0.15) tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(ky * ky) + t_1))) * sin(th)); elseif (t_2 <= 0.995) tmp = t_3; else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[ky], $MachinePrecision] / N[(N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(N[(th * th), $MachinePrecision] * 0.16666666666666666 + 1.0), $MachinePrecision]), $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -0.996], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -0.05], t$95$3, If[LessEqual[t$95$2, 0.15], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(ky * ky), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.995], t$95$3, N[Sin[th], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\sin kx}^{2}\\
t_2 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + t\_1}}\\
t_3 := \frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \mathsf{fma}\left(th \cdot th, 0.16666666666666666, 1\right)}{th}}\\
\mathbf{if}\;t\_2 \leq -0.996:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(2 \cdot ky\right), -0.5, 0.5\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq -0.05:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 0.15:\\
\;\;\;\;\frac{\sin ky}{\sqrt{ky \cdot ky + t\_1}} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq 0.995:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.996Initial program 87.4%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
*-commutativeN/A
lower-*.f6461.1
Applied rewrites61.1%
Taylor expanded in kx around 0
lower-sqrt.f64N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f6459.5
Applied rewrites59.5%
if -0.996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.050000000000000003 or 0.149999999999999994 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.994999999999999996Initial program 99.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.3
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.3
Applied rewrites99.3%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
Applied rewrites99.4%
Taylor expanded in th around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-/.f64N/A
Applied rewrites49.9%
if -0.050000000000000003 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.149999999999999994Initial program 99.2%
Taylor expanded in ky around 0
unpow2N/A
lower-*.f6498.1
Applied rewrites98.1%
if 0.994999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 87.8%
Taylor expanded in kx around 0
lower-sin.f6492.0
Applied rewrites92.0%
Final simplification77.0%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (pow (sin kx) 2.0))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) t_1))))
(t_3 (/ (sin ky) (/ (hypot (sin kx) (sin ky)) th))))
(if (<= t_2 -0.996)
(* (/ (sin ky) (sqrt (fma (cos (* 2.0 ky)) -0.5 0.5))) (sin th))
(if (<= t_2 -0.05)
t_3
(if (<= t_2 0.15)
(* (/ (sin ky) (sqrt (+ (* ky ky) t_1))) (sin th))
(if (<= t_2 0.995) t_3 (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = pow(sin(kx), 2.0);
double t_2 = sin(ky) / sqrt((pow(sin(ky), 2.0) + t_1));
double t_3 = sin(ky) / (hypot(sin(kx), sin(ky)) / th);
double tmp;
if (t_2 <= -0.996) {
tmp = (sin(ky) / sqrt(fma(cos((2.0 * ky)), -0.5, 0.5))) * sin(th);
} else if (t_2 <= -0.05) {
tmp = t_3;
} else if (t_2 <= 0.15) {
tmp = (sin(ky) / sqrt(((ky * ky) + t_1))) * sin(th);
} else if (t_2 <= 0.995) {
tmp = t_3;
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = sin(kx) ^ 2.0 t_2 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + t_1))) t_3 = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) / th)) tmp = 0.0 if (t_2 <= -0.996) tmp = Float64(Float64(sin(ky) / sqrt(fma(cos(Float64(2.0 * ky)), -0.5, 0.5))) * sin(th)); elseif (t_2 <= -0.05) tmp = t_3; elseif (t_2 <= 0.15) tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(ky * ky) + t_1))) * sin(th)); elseif (t_2 <= 0.995) tmp = t_3; else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -0.996], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -0.05], t$95$3, If[LessEqual[t$95$2, 0.15], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(ky * ky), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.995], t$95$3, N[Sin[th], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\sin kx}^{2}\\
t_2 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + t\_1}}\\
t_3 := \frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\
\mathbf{if}\;t\_2 \leq -0.996:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(2 \cdot ky\right), -0.5, 0.5\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq -0.05:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 0.15:\\
\;\;\;\;\frac{\sin ky}{\sqrt{ky \cdot ky + t\_1}} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq 0.995:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.996Initial program 87.4%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
*-commutativeN/A
lower-*.f6461.1
Applied rewrites61.1%
Taylor expanded in kx around 0
lower-sqrt.f64N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f6459.5
Applied rewrites59.5%
if -0.996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.050000000000000003 or 0.149999999999999994 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.994999999999999996Initial program 99.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.3
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.3
Applied rewrites99.3%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
Applied rewrites99.4%
Taylor expanded in th around 0
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-sin.f64N/A
lower-sin.f6448.8
Applied rewrites48.8%
if -0.050000000000000003 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.149999999999999994Initial program 99.2%
Taylor expanded in ky around 0
unpow2N/A
lower-*.f6498.1
Applied rewrites98.1%
if 0.994999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 87.8%
Taylor expanded in kx around 0
lower-sin.f6492.0
Applied rewrites92.0%
Final simplification76.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (pow (sin kx) 2.0))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) t_1))))
(t_3 (/ (sin ky) (/ (hypot (sin kx) (sin ky)) th))))
(if (<= t_2 -0.996)
(* (/ (sin ky) (sqrt (fma (cos (* 2.0 ky)) -0.5 0.5))) (sin th))
(if (<= t_2 -0.05)
t_3
(if (<= t_2 0.15)
(/ (sin th) (/ (sqrt t_1) (sin ky)))
(if (<= t_2 0.995) t_3 (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = pow(sin(kx), 2.0);
double t_2 = sin(ky) / sqrt((pow(sin(ky), 2.0) + t_1));
double t_3 = sin(ky) / (hypot(sin(kx), sin(ky)) / th);
double tmp;
if (t_2 <= -0.996) {
tmp = (sin(ky) / sqrt(fma(cos((2.0 * ky)), -0.5, 0.5))) * sin(th);
} else if (t_2 <= -0.05) {
tmp = t_3;
} else if (t_2 <= 0.15) {
tmp = sin(th) / (sqrt(t_1) / sin(ky));
} else if (t_2 <= 0.995) {
tmp = t_3;
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = sin(kx) ^ 2.0 t_2 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + t_1))) t_3 = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) / th)) tmp = 0.0 if (t_2 <= -0.996) tmp = Float64(Float64(sin(ky) / sqrt(fma(cos(Float64(2.0 * ky)), -0.5, 0.5))) * sin(th)); elseif (t_2 <= -0.05) tmp = t_3; elseif (t_2 <= 0.15) tmp = Float64(sin(th) / Float64(sqrt(t_1) / sin(ky))); elseif (t_2 <= 0.995) tmp = t_3; else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -0.996], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -0.05], t$95$3, If[LessEqual[t$95$2, 0.15], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[t$95$1], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.995], t$95$3, N[Sin[th], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\sin kx}^{2}\\
t_2 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + t\_1}}\\
t_3 := \frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\
\mathbf{if}\;t\_2 \leq -0.996:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(2 \cdot ky\right), -0.5, 0.5\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq -0.05:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 0.15:\\
\;\;\;\;\frac{\sin th}{\frac{\sqrt{t\_1}}{\sin ky}}\\
\mathbf{elif}\;t\_2 \leq 0.995:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.996Initial program 87.4%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
*-commutativeN/A
lower-*.f6461.1
Applied rewrites61.1%
Taylor expanded in kx around 0
lower-sqrt.f64N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f6459.5
Applied rewrites59.5%
if -0.996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.050000000000000003 or 0.149999999999999994 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.994999999999999996Initial program 99.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.3
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.3
Applied rewrites99.3%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
Applied rewrites99.4%
Taylor expanded in th around 0
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-sin.f64N/A
lower-sin.f6448.8
Applied rewrites48.8%
if -0.050000000000000003 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.149999999999999994Initial program 99.2%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.3
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
Taylor expanded in ky around 0
lower-sin.f6463.8
Applied rewrites63.8%
Applied rewrites98.1%
if 0.994999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 87.8%
Taylor expanded in kx around 0
lower-sin.f6492.0
Applied rewrites92.0%
Final simplification76.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))))
(t_2 (/ (sin ky) (/ (hypot (sin kx) (sin ky)) th))))
(if (<= t_1 -0.996)
(* (/ (sin ky) (sqrt (fma (cos (* 2.0 ky)) -0.5 0.5))) (sin th))
(if (<= t_1 -0.05)
t_2
(if (<= t_1 5e-24)
(* (/ (sin th) (sin kx)) (sin ky))
(if (<= t_1 0.995) t_2 (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
double t_2 = sin(ky) / (hypot(sin(kx), sin(ky)) / th);
double tmp;
if (t_1 <= -0.996) {
tmp = (sin(ky) / sqrt(fma(cos((2.0 * ky)), -0.5, 0.5))) * sin(th);
} else if (t_1 <= -0.05) {
tmp = t_2;
} else if (t_1 <= 5e-24) {
tmp = (sin(th) / sin(kx)) * sin(ky);
} else if (t_1 <= 0.995) {
tmp = t_2;
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) t_2 = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) / th)) tmp = 0.0 if (t_1 <= -0.996) tmp = Float64(Float64(sin(ky) / sqrt(fma(cos(Float64(2.0 * ky)), -0.5, 0.5))) * sin(th)); elseif (t_1 <= -0.05) tmp = t_2; elseif (t_1 <= 5e-24) tmp = Float64(Float64(sin(th) / sin(kx)) * sin(ky)); elseif (t_1 <= 0.995) tmp = t_2; else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.996], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.05], t$95$2, If[LessEqual[t$95$1, 5e-24], N[(N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.995], t$95$2, N[Sin[th], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
t_2 := \frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\
\mathbf{if}\;t\_1 \leq -0.996:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(2 \cdot ky\right), -0.5, 0.5\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq -0.05:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-24}:\\
\;\;\;\;\frac{\sin th}{\sin kx} \cdot \sin ky\\
\mathbf{elif}\;t\_1 \leq 0.995:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.996Initial program 87.4%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
*-commutativeN/A
lower-*.f6461.1
Applied rewrites61.1%
Taylor expanded in kx around 0
lower-sqrt.f64N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f6459.5
Applied rewrites59.5%
if -0.996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.050000000000000003 or 4.9999999999999998e-24 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.994999999999999996Initial program 99.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.3
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.3
Applied rewrites99.3%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
Applied rewrites99.4%
Taylor expanded in th around 0
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-sin.f64N/A
lower-sin.f6452.1
Applied rewrites52.1%
if -0.050000000000000003 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 4.9999999999999998e-24Initial program 99.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.2
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
Taylor expanded in ky around 0
lower-sin.f6463.6
Applied rewrites63.6%
if 0.994999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 87.8%
Taylor expanded in kx around 0
lower-sin.f6492.0
Applied rewrites92.0%
Final simplification66.0%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0))))))
(if (<= t_1 -0.246)
(* (/ (sin ky) (sqrt (fma (cos (* 2.0 ky)) -0.5 0.5))) (sin th))
(if (<= t_1 0.17) (/ (sin th) (/ (sin kx) (sin ky))) (sin th)))))
double code(double kx, double ky, double th) {
double t_1 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
double tmp;
if (t_1 <= -0.246) {
tmp = (sin(ky) / sqrt(fma(cos((2.0 * ky)), -0.5, 0.5))) * sin(th);
} else if (t_1 <= 0.17) {
tmp = sin(th) / (sin(kx) / sin(ky));
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) tmp = 0.0 if (t_1 <= -0.246) tmp = Float64(Float64(sin(ky) / sqrt(fma(cos(Float64(2.0 * ky)), -0.5, 0.5))) * sin(th)); elseif (t_1 <= 0.17) tmp = Float64(sin(th) / Float64(sin(kx) / sin(ky))); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.246], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.17], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
\mathbf{if}\;t\_1 \leq -0.246:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(2 \cdot ky\right), -0.5, 0.5\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 0.17:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.246Initial program 91.3%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
*-commutativeN/A
lower-*.f6473.8
Applied rewrites73.8%
Taylor expanded in kx around 0
lower-sqrt.f64N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f6446.6
Applied rewrites46.6%
if -0.246 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.170000000000000012Initial program 99.2%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.3
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
Taylor expanded in ky around 0
lower-sin.f6461.4
Applied rewrites61.4%
if 0.170000000000000012 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.1%
Taylor expanded in kx around 0
lower-sin.f6471.9
Applied rewrites71.9%
Final simplification59.4%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 0.17) (/ (sin th) (/ (sin kx) (sin ky))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) <= 0.17) {
tmp = sin(th) / (sin(kx) / sin(ky));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))) <= 0.17d0) then
tmp = sin(th) / (sin(kx) / sin(ky))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)))) <= 0.17) {
tmp = Math.sin(th) / (Math.sin(kx) / Math.sin(ky));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))) <= 0.17: tmp = math.sin(th) / (math.sin(kx) / math.sin(ky)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 0.17) tmp = Float64(sin(th) / Float64(sin(kx) / sin(ky))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 0.17) tmp = sin(th) / (sin(kx) / sin(ky)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.17], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 0.17:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.170000000000000012Initial program 95.2%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6495.3
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
lower-sin.f6435.1
Applied rewrites35.1%
if 0.170000000000000012 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.1%
Taylor expanded in kx around 0
lower-sin.f6471.9
Applied rewrites71.9%
Final simplification46.3%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 0.17) (* (/ (sin th) (sin kx)) (sin ky)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) <= 0.17) {
tmp = (sin(th) / sin(kx)) * sin(ky);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))) <= 0.17d0) then
tmp = (sin(th) / sin(kx)) * sin(ky)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)))) <= 0.17) {
tmp = (Math.sin(th) / Math.sin(kx)) * Math.sin(ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))) <= 0.17: tmp = (math.sin(th) / math.sin(kx)) * math.sin(ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 0.17) tmp = Float64(Float64(sin(th) / sin(kx)) * sin(ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 0.17) tmp = (sin(th) / sin(kx)) * sin(ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.17], N[(N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 0.17:\\
\;\;\;\;\frac{\sin th}{\sin kx} \cdot \sin ky\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.170000000000000012Initial program 95.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.2
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
Taylor expanded in ky around 0
lower-sin.f6435.1
Applied rewrites35.1%
if 0.170000000000000012 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.1%
Taylor expanded in kx around 0
lower-sin.f6471.9
Applied rewrites71.9%
Final simplification46.3%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 0.17) (* (/ (sin ky) (sin kx)) (sin th)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) <= 0.17) {
tmp = (sin(ky) / sin(kx)) * sin(th);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))) <= 0.17d0) then
tmp = (sin(ky) / sin(kx)) * sin(th)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)))) <= 0.17) {
tmp = (Math.sin(ky) / Math.sin(kx)) * Math.sin(th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))) <= 0.17: tmp = (math.sin(ky) / math.sin(kx)) * math.sin(th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 0.17) tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 0.17) tmp = (sin(ky) / sin(kx)) * sin(th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.17], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 0.17:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.170000000000000012Initial program 95.2%
Taylor expanded in ky around 0
lower-sin.f6435.1
Applied rewrites35.1%
if 0.170000000000000012 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.1%
Taylor expanded in kx around 0
lower-sin.f6471.9
Applied rewrites71.9%
Final simplification46.3%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 4e-7) (/ (sin th) (/ (sin kx) ky)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) <= 4e-7) {
tmp = sin(th) / (sin(kx) / ky);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))) <= 4d-7) then
tmp = sin(th) / (sin(kx) / ky)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)))) <= 4e-7) {
tmp = Math.sin(th) / (Math.sin(kx) / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))) <= 4e-7: tmp = math.sin(th) / (math.sin(kx) / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 4e-7) tmp = Float64(sin(th) / Float64(sin(kx) / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 4e-7) tmp = sin(th) / (sin(kx) / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 4e-7], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 4 \cdot 10^{-7}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 3.9999999999999998e-7Initial program 95.2%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6495.3
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sin.f6433.4
Applied rewrites33.4%
if 3.9999999999999998e-7 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.3%
Taylor expanded in kx around 0
lower-sin.f6470.5
Applied rewrites70.5%
Final simplification45.0%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 4e-7) (* (/ ky (sin kx)) (sin th)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) <= 4e-7) {
tmp = (ky / sin(kx)) * sin(th);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))) <= 4d-7) then
tmp = (ky / sin(kx)) * sin(th)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)))) <= 4e-7) {
tmp = (ky / Math.sin(kx)) * Math.sin(th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))) <= 4e-7: tmp = (ky / math.sin(kx)) * math.sin(th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 4e-7) tmp = Float64(Float64(ky / sin(kx)) * sin(th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 4e-7) tmp = (ky / sin(kx)) * sin(th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 4e-7], N[(N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 4 \cdot 10^{-7}:\\
\;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 3.9999999999999998e-7Initial program 95.2%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sin.f6433.4
Applied rewrites33.4%
if 3.9999999999999998e-7 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.3%
Taylor expanded in kx around 0
lower-sin.f6470.5
Applied rewrites70.5%
Final simplification45.0%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 4e-74) (* (pow th 3.0) -0.16666666666666666) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) <= 4e-74) {
tmp = pow(th, 3.0) * -0.16666666666666666;
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))) <= 4d-74) then
tmp = (th ** 3.0d0) * (-0.16666666666666666d0)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)))) <= 4e-74) {
tmp = Math.pow(th, 3.0) * -0.16666666666666666;
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))) <= 4e-74: tmp = math.pow(th, 3.0) * -0.16666666666666666 else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 4e-74) tmp = Float64((th ^ 3.0) * -0.16666666666666666); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 4e-74) tmp = (th ^ 3.0) * -0.16666666666666666; else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 4e-74], N[(N[Power[th, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 4 \cdot 10^{-74}:\\
\;\;\;\;{th}^{3} \cdot -0.16666666666666666\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 3.99999999999999983e-74Initial program 94.9%
Taylor expanded in kx around 0
lower-sin.f643.8
Applied rewrites3.8%
Taylor expanded in th around 0
Applied rewrites4.0%
Taylor expanded in th around inf
Applied rewrites17.0%
if 3.99999999999999983e-74 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 92.4%
Taylor expanded in kx around 0
lower-sin.f6460.7
Applied rewrites60.7%
Final simplification33.2%
(FPCore (kx ky th)
:precision binary64
(if (<= ky 1.6e-224)
(/
(sin th)
(/
(fma
(* (fma 0.16666666666666666 (sin kx) (/ 0.5 (sin kx))) ky)
ky
(sin kx))
ky))
(if (<= ky 6.6e-5)
(* (/ (sin ky) (sqrt (+ (* ky ky) (pow (sin kx) 2.0)))) (sin th))
(*
(/
(sin ky)
(sqrt
(+ (- 0.5 (* (cos (* 2.0 ky)) 0.5)) (- 0.5 (* (cos (* 2.0 kx)) 0.5)))))
(sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.6e-224) {
tmp = sin(th) / (fma((fma(0.16666666666666666, sin(kx), (0.5 / sin(kx))) * ky), ky, sin(kx)) / ky);
} else if (ky <= 6.6e-5) {
tmp = (sin(ky) / sqrt(((ky * ky) + pow(sin(kx), 2.0)))) * sin(th);
} else {
tmp = (sin(ky) / sqrt(((0.5 - (cos((2.0 * ky)) * 0.5)) + (0.5 - (cos((2.0 * kx)) * 0.5))))) * sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.6e-224) tmp = Float64(sin(th) / Float64(fma(Float64(fma(0.16666666666666666, sin(kx), Float64(0.5 / sin(kx))) * ky), ky, sin(kx)) / ky)); elseif (ky <= 6.6e-5) tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(ky * ky) + (sin(kx) ^ 2.0)))) * sin(th)); else tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(0.5 - Float64(cos(Float64(2.0 * ky)) * 0.5)) + Float64(0.5 - Float64(cos(Float64(2.0 * kx)) * 0.5))))) * sin(th)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.6e-224], N[(N[Sin[th], $MachinePrecision] / N[(N[(N[(N[(0.16666666666666666 * N[Sin[kx], $MachinePrecision] + N[(0.5 / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * ky), $MachinePrecision] * ky + N[Sin[kx], $MachinePrecision]), $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 6.6e-5], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(ky * ky), $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(0.5 - N[(N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.6 \cdot 10^{-224}:\\
\;\;\;\;\frac{\sin th}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, \sin kx, \frac{0.5}{\sin kx}\right) \cdot ky, ky, \sin kx\right)}{ky}}\\
\mathbf{elif}\;ky \leq 6.6 \cdot 10^{-5}:\\
\;\;\;\;\frac{\sin ky}{\sqrt{ky \cdot ky + {\sin kx}^{2}}} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\left(0.5 - \cos \left(2 \cdot ky\right) \cdot 0.5\right) + \left(0.5 - \cos \left(2 \cdot kx\right) \cdot 0.5\right)}} \cdot \sin th\\
\end{array}
\end{array}
if ky < 1.5999999999999999e-224Initial program 90.7%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6490.6
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
lower-/.f64N/A
Applied rewrites30.0%
if 1.5999999999999999e-224 < ky < 6.6000000000000005e-5Initial program 96.7%
Taylor expanded in ky around 0
unpow2N/A
lower-*.f6496.7
Applied rewrites96.7%
if 6.6000000000000005e-5 < ky Initial program 99.6%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
*-commutativeN/A
lower-*.f6498.9
Applied rewrites98.9%
lift-pow.f64N/A
pow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
lower-*.f6499.0
Applied rewrites99.0%
Final simplification58.5%
(FPCore (kx ky th)
:precision binary64
(if (<= ky 1.35e-177)
(* (/ (sin th) (fma (* (/ ky kx) 0.5) ky (sin kx))) (sin ky))
(if (<= ky 0.022)
(*
(/ (sin ky) (sqrt (+ (- 0.5 (* (cos (* 2.0 kx)) 0.5)) (* ky ky))))
(sin th))
(* (/ (sin ky) (sqrt (fma (cos (* 2.0 ky)) -0.5 0.5))) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.35e-177) {
tmp = (sin(th) / fma(((ky / kx) * 0.5), ky, sin(kx))) * sin(ky);
} else if (ky <= 0.022) {
tmp = (sin(ky) / sqrt(((0.5 - (cos((2.0 * kx)) * 0.5)) + (ky * ky)))) * sin(th);
} else {
tmp = (sin(ky) / sqrt(fma(cos((2.0 * ky)), -0.5, 0.5))) * sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.35e-177) tmp = Float64(Float64(sin(th) / fma(Float64(Float64(ky / kx) * 0.5), ky, sin(kx))) * sin(ky)); elseif (ky <= 0.022) tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(0.5 - Float64(cos(Float64(2.0 * kx)) * 0.5)) + Float64(ky * ky)))) * sin(th)); else tmp = Float64(Float64(sin(ky) / sqrt(fma(cos(Float64(2.0 * ky)), -0.5, 0.5))) * sin(th)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.35e-177], N[(N[(N[Sin[th], $MachinePrecision] / N[(N[(N[(ky / kx), $MachinePrecision] * 0.5), $MachinePrecision] * ky + N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 0.022], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(0.5 - N[(N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] + N[(ky * ky), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.35 \cdot 10^{-177}:\\
\;\;\;\;\frac{\sin th}{\mathsf{fma}\left(\frac{ky}{kx} \cdot 0.5, ky, \sin kx\right)} \cdot \sin ky\\
\mathbf{elif}\;ky \leq 0.022:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\left(0.5 - \cos \left(2 \cdot kx\right) \cdot 0.5\right) + ky \cdot ky}} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\mathsf{fma}\left(\cos \left(2 \cdot ky\right), -0.5, 0.5\right)}} \cdot \sin th\\
\end{array}
\end{array}
if ky < 1.3500000000000001e-177Initial program 90.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6490.2
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
Taylor expanded in ky around 0
+-commutativeN/A
associate-*r/N/A
associate-*l/N/A
metadata-evalN/A
associate-*r/N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-sin.f64N/A
lower-sin.f6431.3
Applied rewrites31.3%
Taylor expanded in kx around 0
Applied rewrites31.4%
if 1.3500000000000001e-177 < ky < 0.021999999999999999Initial program 99.7%
Taylor expanded in ky around 0
unpow2N/A
lower-*.f6499.7
Applied rewrites99.7%
lift-pow.f64N/A
pow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
count-2N/A
flip-+N/A
+-inversesN/A
+-inversesN/A
lift-*.f64N/A
lift-*.f64N/A
+-inversesN/A
+-inversesN/A
flip-+N/A
count-2N/A
lower-*.f64N/A
Applied rewrites88.1%
if 0.021999999999999999 < ky Initial program 99.6%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
*-commutativeN/A
lower-*.f6498.9
Applied rewrites98.9%
Taylor expanded in kx around 0
lower-sqrt.f64N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f6465.5
Applied rewrites65.5%
(FPCore (kx ky th) :precision binary64 (sin th))
double code(double kx, double ky, double th) {
return sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = sin(th)
end function
public static double code(double kx, double ky, double th) {
return Math.sin(th);
}
def code(kx, ky, th): return math.sin(th)
function code(kx, ky, th) return sin(th) end
function tmp = code(kx, ky, th) tmp = sin(th); end
code[kx_, ky_, th_] := N[Sin[th], $MachinePrecision]
\begin{array}{l}
\\
\sin th
\end{array}
Initial program 94.0%
Taylor expanded in kx around 0
lower-sin.f6425.0
Applied rewrites25.0%
(FPCore (kx ky th) :precision binary64 (fma (* -0.16666666666666666 (* th th)) th th))
double code(double kx, double ky, double th) {
return fma((-0.16666666666666666 * (th * th)), th, th);
}
function code(kx, ky, th) return fma(Float64(-0.16666666666666666 * Float64(th * th)), th, th) end
code[kx_, ky_, th_] := N[(N[(-0.16666666666666666 * N[(th * th), $MachinePrecision]), $MachinePrecision] * th + th), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666 \cdot \left(th \cdot th\right), th, th\right)
\end{array}
Initial program 94.0%
Taylor expanded in kx around 0
lower-sin.f6425.0
Applied rewrites25.0%
Taylor expanded in th around 0
Applied rewrites13.8%
Applied rewrites13.8%
herbie shell --seed 2024276
(FPCore (kx ky th)
:name "Toniolo and Linder, Equation (3b), real"
:precision binary64
(* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))