
(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 22 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 96.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.7
Applied rewrites99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (pow (sin ky) 2.0))
(t_2 (/ (sin ky) (sqrt (+ t_1 (pow (sin kx) 2.0))))))
(if (<= t_2 -0.98)
(/ (* (sin th) (sin ky)) (sqrt t_1))
(if (<= t_2 -0.001)
(*
(* th (sin ky))
(sqrt (/ 2.0 (- 1.0 (- (cos (* 2.0 ky)) (- 1.0 (cos (* 2.0 kx))))))))
(if (<= t_2 0.05)
(*
(/
(*
(fma
(fma (* ky ky) 0.008333333333333333 -0.16666666666666666)
(* ky ky)
1.0)
ky)
(hypot (* (fma -0.16666666666666666 (* ky ky) 1.0) ky) (sin kx)))
(sin th))
(if (<= t_2 0.99)
(/
(*
(fma
(fma
(fma (* th th) -0.0001984126984126984 0.008333333333333333)
(* th th)
-0.16666666666666666)
(* th th)
1.0)
th)
(/
(sqrt
(fma
(- 1.0 (cos (+ ky ky)))
0.5
(* (- 1.0 (cos (+ kx kx))) 0.5)))
(sin ky)))
(*
(/
(sin ky)
(hypot (sin ky) (* (fma -0.16666666666666666 (* kx kx) 1.0) kx)))
(sin th))))))))
double code(double kx, double ky, double th) {
double t_1 = pow(sin(ky), 2.0);
double t_2 = sin(ky) / sqrt((t_1 + pow(sin(kx), 2.0)));
double tmp;
if (t_2 <= -0.98) {
tmp = (sin(th) * sin(ky)) / sqrt(t_1);
} else if (t_2 <= -0.001) {
tmp = (th * sin(ky)) * sqrt((2.0 / (1.0 - (cos((2.0 * ky)) - (1.0 - cos((2.0 * kx)))))));
} else if (t_2 <= 0.05) {
tmp = ((fma(fma((ky * ky), 0.008333333333333333, -0.16666666666666666), (ky * ky), 1.0) * ky) / hypot((fma(-0.16666666666666666, (ky * ky), 1.0) * ky), sin(kx))) * sin(th);
} else if (t_2 <= 0.99) {
tmp = (fma(fma(fma((th * th), -0.0001984126984126984, 0.008333333333333333), (th * th), -0.16666666666666666), (th * th), 1.0) * th) / (sqrt(fma((1.0 - cos((ky + ky))), 0.5, ((1.0 - cos((kx + kx))) * 0.5))) / sin(ky));
} else {
tmp = (sin(ky) / hypot(sin(ky), (fma(-0.16666666666666666, (kx * kx), 1.0) * kx))) * sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = sin(ky) ^ 2.0 t_2 = Float64(sin(ky) / sqrt(Float64(t_1 + (sin(kx) ^ 2.0)))) tmp = 0.0 if (t_2 <= -0.98) tmp = Float64(Float64(sin(th) * sin(ky)) / sqrt(t_1)); elseif (t_2 <= -0.001) tmp = Float64(Float64(th * sin(ky)) * sqrt(Float64(2.0 / Float64(1.0 - Float64(cos(Float64(2.0 * ky)) - Float64(1.0 - cos(Float64(2.0 * kx)))))))); elseif (t_2 <= 0.05) tmp = Float64(Float64(Float64(fma(fma(Float64(ky * ky), 0.008333333333333333, -0.16666666666666666), Float64(ky * ky), 1.0) * ky) / hypot(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * ky), sin(kx))) * sin(th)); elseif (t_2 <= 0.99) tmp = Float64(Float64(fma(fma(fma(Float64(th * th), -0.0001984126984126984, 0.008333333333333333), Float64(th * th), -0.16666666666666666), Float64(th * th), 1.0) * th) / Float64(sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))) / sin(ky))); else tmp = Float64(Float64(sin(ky) / hypot(sin(ky), Float64(fma(-0.16666666666666666, Float64(kx * kx), 1.0) * kx))) * sin(th)); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -0.98], N[(N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -0.001], N[(N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 / N[(1.0 - N[(N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision] - N[(1.0 - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.05], N[(N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * ky), $MachinePrecision] / N[Sqrt[N[(N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * ky), $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.99], N[(N[(N[(N[(N[(N[(th * th), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(th * th), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * N[(th * th), $MachinePrecision] + 1.0), $MachinePrecision] * th), $MachinePrecision] / N[(N[Sqrt[N[(N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[(N[(-0.16666666666666666 * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision] * kx), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\sin ky}^{2}\\
t_2 := \frac{\sin ky}{\sqrt{t\_1 + {\sin kx}^{2}}}\\
\mathbf{if}\;t\_2 \leq -0.98:\\
\;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{t\_1}}\\
\mathbf{elif}\;t\_2 \leq -0.001:\\
\;\;\;\;\left(th \cdot \sin ky\right) \cdot \sqrt{\frac{2}{1 - \left(\cos \left(2 \cdot ky\right) - \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}\\
\mathbf{elif}\;t\_2 \leq 0.05:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), ky \cdot ky, 1\right) \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq 0.99:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(th \cdot th, -0.0001984126984126984, 0.008333333333333333\right), th \cdot th, -0.16666666666666666\right), th \cdot th, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right) \cdot kx\right)} \cdot \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.97999999999999998Initial program 89.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6488.9
Applied rewrites67.4%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6463.4
Applied rewrites63.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.2
Applied rewrites3.2%
Applied rewrites80.2%
if -0.97999999999999998 < (/.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))))) < -1e-3Initial program 99.3%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.3
Applied rewrites99.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6419.9
Applied rewrites19.9%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
associate-+l-N/A
lower--.f64N/A
Applied rewrites45.8%
if -1e-3 < (/.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.050000000000000003Initial program 99.5%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6498.2
Applied rewrites98.2%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.2
Applied rewrites98.2%
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.98999999999999999Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.2
Applied rewrites99.1%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites55.1%
if 0.98999999999999999 < (/.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 95.4%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f64100.0
Applied rewrites100.0%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Final simplification81.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (pow (sin ky) 2.0))
(t_2 (/ (sin ky) (sqrt (+ t_1 (pow (sin kx) 2.0))))))
(if (<= t_2 -0.98)
(/ (* (sin th) (sin ky)) (sqrt t_1))
(if (<= t_2 -0.001)
(*
(* th (sin ky))
(sqrt (/ 2.0 (- 1.0 (- (cos (* 2.0 ky)) (- 1.0 (cos (* 2.0 kx))))))))
(if (<= t_2 0.05)
(*
(/
(*
(fma
(fma (* ky ky) 0.008333333333333333 -0.16666666666666666)
(* ky ky)
1.0)
ky)
(hypot (* (fma -0.16666666666666666 (* ky ky) 1.0) ky) (sin kx)))
(sin th))
(if (<= t_2 0.9999996186923419)
(/
(*
(fma
(fma (* th th) 0.008333333333333333 -0.16666666666666666)
(* th th)
1.0)
th)
(/
(sqrt
(fma
(- 1.0 (cos (+ ky ky)))
0.5
(* (- 1.0 (cos (+ kx kx))) 0.5)))
(sin ky)))
(* (/ (sin ky) (fma (* 0.5 kx) (/ kx ky) (sin ky))) (sin th))))))))
double code(double kx, double ky, double th) {
double t_1 = pow(sin(ky), 2.0);
double t_2 = sin(ky) / sqrt((t_1 + pow(sin(kx), 2.0)));
double tmp;
if (t_2 <= -0.98) {
tmp = (sin(th) * sin(ky)) / sqrt(t_1);
} else if (t_2 <= -0.001) {
tmp = (th * sin(ky)) * sqrt((2.0 / (1.0 - (cos((2.0 * ky)) - (1.0 - cos((2.0 * kx)))))));
} else if (t_2 <= 0.05) {
tmp = ((fma(fma((ky * ky), 0.008333333333333333, -0.16666666666666666), (ky * ky), 1.0) * ky) / hypot((fma(-0.16666666666666666, (ky * ky), 1.0) * ky), sin(kx))) * sin(th);
} else if (t_2 <= 0.9999996186923419) {
tmp = (fma(fma((th * th), 0.008333333333333333, -0.16666666666666666), (th * th), 1.0) * th) / (sqrt(fma((1.0 - cos((ky + ky))), 0.5, ((1.0 - cos((kx + kx))) * 0.5))) / sin(ky));
} else {
tmp = (sin(ky) / fma((0.5 * kx), (kx / ky), sin(ky))) * sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = sin(ky) ^ 2.0 t_2 = Float64(sin(ky) / sqrt(Float64(t_1 + (sin(kx) ^ 2.0)))) tmp = 0.0 if (t_2 <= -0.98) tmp = Float64(Float64(sin(th) * sin(ky)) / sqrt(t_1)); elseif (t_2 <= -0.001) tmp = Float64(Float64(th * sin(ky)) * sqrt(Float64(2.0 / Float64(1.0 - Float64(cos(Float64(2.0 * ky)) - Float64(1.0 - cos(Float64(2.0 * kx)))))))); elseif (t_2 <= 0.05) tmp = Float64(Float64(Float64(fma(fma(Float64(ky * ky), 0.008333333333333333, -0.16666666666666666), Float64(ky * ky), 1.0) * ky) / hypot(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * ky), sin(kx))) * sin(th)); elseif (t_2 <= 0.9999996186923419) tmp = Float64(Float64(fma(fma(Float64(th * th), 0.008333333333333333, -0.16666666666666666), Float64(th * th), 1.0) * th) / Float64(sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))) / sin(ky))); else tmp = Float64(Float64(sin(ky) / fma(Float64(0.5 * kx), Float64(kx / ky), sin(ky))) * sin(th)); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -0.98], N[(N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -0.001], N[(N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 / N[(1.0 - N[(N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision] - N[(1.0 - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.05], N[(N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * ky), $MachinePrecision] / N[Sqrt[N[(N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * ky), $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.9999996186923419], N[(N[(N[(N[(N[(th * th), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(th * th), $MachinePrecision] + 1.0), $MachinePrecision] * th), $MachinePrecision] / N[(N[Sqrt[N[(N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[(0.5 * kx), $MachinePrecision] * N[(kx / ky), $MachinePrecision] + N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\sin ky}^{2}\\
t_2 := \frac{\sin ky}{\sqrt{t\_1 + {\sin kx}^{2}}}\\
\mathbf{if}\;t\_2 \leq -0.98:\\
\;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{t\_1}}\\
\mathbf{elif}\;t\_2 \leq -0.001:\\
\;\;\;\;\left(th \cdot \sin ky\right) \cdot \sqrt{\frac{2}{1 - \left(\cos \left(2 \cdot ky\right) - \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}\\
\mathbf{elif}\;t\_2 \leq 0.05:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), ky \cdot ky, 1\right) \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq 0.9999996186923419:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(th \cdot th, 0.008333333333333333, -0.16666666666666666\right), th \cdot th, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \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.97999999999999998Initial program 89.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6488.9
Applied rewrites67.4%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6463.4
Applied rewrites63.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.2
Applied rewrites3.2%
Applied rewrites80.2%
if -0.97999999999999998 < (/.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))))) < -1e-3Initial program 99.3%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.3
Applied rewrites99.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6419.9
Applied rewrites19.9%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
associate-+l-N/A
lower--.f64N/A
Applied rewrites45.8%
if -1e-3 < (/.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.050000000000000003Initial program 99.5%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6498.2
Applied rewrites98.2%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.2
Applied rewrites98.2%
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.99999961869234189Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.2
Applied rewrites99.1%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6455.6
Applied rewrites55.6%
if 0.99999961869234189 < (/.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 95.4%
Taylor expanded in kx around 0
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
associate-/l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-sin.f64100.0
Applied rewrites100.0%
Taylor expanded in ky around 0
Applied rewrites100.0%
Final simplification81.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))))
(t_2 (cos (* 2.0 ky))))
(if (<= t_1 -0.98)
(/ (* (sin th) (sin ky)) (sqrt (* (- 1.0 t_2) 0.5)))
(if (<= t_1 -0.001)
(*
(* th (sin ky))
(sqrt (/ 2.0 (- 1.0 (- t_2 (- 1.0 (cos (* 2.0 kx))))))))
(if (<= t_1 0.05)
(*
(/
(*
(fma
(fma (* ky ky) 0.008333333333333333 -0.16666666666666666)
(* ky ky)
1.0)
ky)
(hypot (* (fma -0.16666666666666666 (* ky ky) 1.0) ky) (sin kx)))
(sin th))
(if (<= t_1 0.9999996186923419)
(/
(*
(fma
(fma (* th th) 0.008333333333333333 -0.16666666666666666)
(* th th)
1.0)
th)
(/
(sqrt
(fma
(- 1.0 (cos (+ ky ky)))
0.5
(* (- 1.0 (cos (+ kx kx))) 0.5)))
(sin ky)))
(* (/ (sin ky) (fma (* 0.5 kx) (/ kx ky) (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 t_2 = cos((2.0 * ky));
double tmp;
if (t_1 <= -0.98) {
tmp = (sin(th) * sin(ky)) / sqrt(((1.0 - t_2) * 0.5));
} else if (t_1 <= -0.001) {
tmp = (th * sin(ky)) * sqrt((2.0 / (1.0 - (t_2 - (1.0 - cos((2.0 * kx)))))));
} else if (t_1 <= 0.05) {
tmp = ((fma(fma((ky * ky), 0.008333333333333333, -0.16666666666666666), (ky * ky), 1.0) * ky) / hypot((fma(-0.16666666666666666, (ky * ky), 1.0) * ky), sin(kx))) * sin(th);
} else if (t_1 <= 0.9999996186923419) {
tmp = (fma(fma((th * th), 0.008333333333333333, -0.16666666666666666), (th * th), 1.0) * th) / (sqrt(fma((1.0 - cos((ky + ky))), 0.5, ((1.0 - cos((kx + kx))) * 0.5))) / sin(ky));
} else {
tmp = (sin(ky) / fma((0.5 * kx), (kx / ky), sin(ky))) * 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 = cos(Float64(2.0 * ky)) tmp = 0.0 if (t_1 <= -0.98) tmp = Float64(Float64(sin(th) * sin(ky)) / sqrt(Float64(Float64(1.0 - t_2) * 0.5))); elseif (t_1 <= -0.001) tmp = Float64(Float64(th * sin(ky)) * sqrt(Float64(2.0 / Float64(1.0 - Float64(t_2 - Float64(1.0 - cos(Float64(2.0 * kx)))))))); elseif (t_1 <= 0.05) tmp = Float64(Float64(Float64(fma(fma(Float64(ky * ky), 0.008333333333333333, -0.16666666666666666), Float64(ky * ky), 1.0) * ky) / hypot(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * ky), sin(kx))) * sin(th)); elseif (t_1 <= 0.9999996186923419) tmp = Float64(Float64(fma(fma(Float64(th * th), 0.008333333333333333, -0.16666666666666666), Float64(th * th), 1.0) * th) / Float64(sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))) / sin(ky))); else tmp = Float64(Float64(sin(ky) / fma(Float64(0.5 * kx), Float64(kx / ky), sin(ky))) * 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[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -0.98], N[(N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.001], N[(N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 / N[(1.0 - N[(t$95$2 - N[(1.0 - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.05], N[(N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * ky), $MachinePrecision] / N[Sqrt[N[(N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * ky), $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.9999996186923419], N[(N[(N[(N[(N[(th * th), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(th * th), $MachinePrecision] + 1.0), $MachinePrecision] * th), $MachinePrecision] / N[(N[Sqrt[N[(N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[(0.5 * kx), $MachinePrecision] * N[(kx / ky), $MachinePrecision] + N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
t_2 := \cos \left(2 \cdot ky\right)\\
\mathbf{if}\;t\_1 \leq -0.98:\\
\;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - t\_2\right) \cdot 0.5}}\\
\mathbf{elif}\;t\_1 \leq -0.001:\\
\;\;\;\;\left(th \cdot \sin ky\right) \cdot \sqrt{\frac{2}{1 - \left(t\_2 - \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}\\
\mathbf{elif}\;t\_1 \leq 0.05:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), ky \cdot ky, 1\right) \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 0.9999996186923419:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(th \cdot th, 0.008333333333333333, -0.16666666666666666\right), th \cdot th, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \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.97999999999999998Initial program 89.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6488.9
Applied rewrites67.4%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6463.4
Applied rewrites63.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.2
Applied rewrites3.2%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6463.2
Applied rewrites63.2%
if -0.97999999999999998 < (/.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))))) < -1e-3Initial program 99.3%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.3
Applied rewrites99.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6419.9
Applied rewrites19.9%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
associate-+l-N/A
lower--.f64N/A
Applied rewrites45.8%
if -1e-3 < (/.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.050000000000000003Initial program 99.5%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6498.2
Applied rewrites98.2%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.2
Applied rewrites98.2%
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.99999961869234189Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.2
Applied rewrites99.1%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6455.6
Applied rewrites55.6%
if 0.99999961869234189 < (/.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 95.4%
Taylor expanded in kx around 0
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
associate-/l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-sin.f64100.0
Applied rewrites100.0%
Taylor expanded in ky around 0
Applied rewrites100.0%
Final simplification77.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (cos (* 2.0 ky)))
(t_2 (- 1.0 t_1))
(t_3 (* th (sin ky)))
(t_4 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))))
(t_5 (cos (* 2.0 kx))))
(if (<= t_4 -0.98)
(/ (* (sin th) (sin ky)) (sqrt (* t_2 0.5)))
(if (<= t_4 -0.001)
(* t_3 (sqrt (/ 2.0 (- 1.0 (- t_1 (- 1.0 t_5))))))
(if (<= t_4 0.05)
(*
(/
(*
(fma
(fma (* ky ky) 0.008333333333333333 -0.16666666666666666)
(* ky ky)
1.0)
ky)
(hypot (* (fma -0.16666666666666666 (* ky ky) 1.0) ky) (sin kx)))
(sin th))
(if (<= t_4 0.9999996186923419)
(* (sqrt (/ 2.0 (- 1.0 (- t_5 t_2)))) t_3)
(* (/ (sin ky) (fma (* 0.5 kx) (/ kx ky) (sin ky))) (sin th))))))))
double code(double kx, double ky, double th) {
double t_1 = cos((2.0 * ky));
double t_2 = 1.0 - t_1;
double t_3 = th * sin(ky);
double t_4 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
double t_5 = cos((2.0 * kx));
double tmp;
if (t_4 <= -0.98) {
tmp = (sin(th) * sin(ky)) / sqrt((t_2 * 0.5));
} else if (t_4 <= -0.001) {
tmp = t_3 * sqrt((2.0 / (1.0 - (t_1 - (1.0 - t_5)))));
} else if (t_4 <= 0.05) {
tmp = ((fma(fma((ky * ky), 0.008333333333333333, -0.16666666666666666), (ky * ky), 1.0) * ky) / hypot((fma(-0.16666666666666666, (ky * ky), 1.0) * ky), sin(kx))) * sin(th);
} else if (t_4 <= 0.9999996186923419) {
tmp = sqrt((2.0 / (1.0 - (t_5 - t_2)))) * t_3;
} else {
tmp = (sin(ky) / fma((0.5 * kx), (kx / ky), sin(ky))) * sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = cos(Float64(2.0 * ky)) t_2 = Float64(1.0 - t_1) t_3 = Float64(th * sin(ky)) t_4 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) t_5 = cos(Float64(2.0 * kx)) tmp = 0.0 if (t_4 <= -0.98) tmp = Float64(Float64(sin(th) * sin(ky)) / sqrt(Float64(t_2 * 0.5))); elseif (t_4 <= -0.001) tmp = Float64(t_3 * sqrt(Float64(2.0 / Float64(1.0 - Float64(t_1 - Float64(1.0 - t_5)))))); elseif (t_4 <= 0.05) tmp = Float64(Float64(Float64(fma(fma(Float64(ky * ky), 0.008333333333333333, -0.16666666666666666), Float64(ky * ky), 1.0) * ky) / hypot(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * ky), sin(kx))) * sin(th)); elseif (t_4 <= 0.9999996186923419) tmp = Float64(sqrt(Float64(2.0 / Float64(1.0 - Float64(t_5 - t_2)))) * t_3); else tmp = Float64(Float64(sin(ky) / fma(Float64(0.5 * kx), Float64(kx / ky), sin(ky))) * sin(th)); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = 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$5 = N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$4, -0.98], N[(N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(t$95$2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, -0.001], N[(t$95$3 * N[Sqrt[N[(2.0 / N[(1.0 - N[(t$95$1 - N[(1.0 - t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 0.05], N[(N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * ky), $MachinePrecision] / N[Sqrt[N[(N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * ky), $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 0.9999996186923419], N[(N[Sqrt[N[(2.0 / N[(1.0 - N[(t$95$5 - t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$3), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[(0.5 * kx), $MachinePrecision] * N[(kx / ky), $MachinePrecision] + N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \cos \left(2 \cdot ky\right)\\
t_2 := 1 - t\_1\\
t_3 := th \cdot \sin ky\\
t_4 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
t_5 := \cos \left(2 \cdot kx\right)\\
\mathbf{if}\;t\_4 \leq -0.98:\\
\;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{t\_2 \cdot 0.5}}\\
\mathbf{elif}\;t\_4 \leq -0.001:\\
\;\;\;\;t\_3 \cdot \sqrt{\frac{2}{1 - \left(t\_1 - \left(1 - t\_5\right)\right)}}\\
\mathbf{elif}\;t\_4 \leq 0.05:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(ky \cdot ky, 0.008333333333333333, -0.16666666666666666\right), ky \cdot ky, 1\right) \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th\\
\mathbf{elif}\;t\_4 \leq 0.9999996186923419:\\
\;\;\;\;\sqrt{\frac{2}{1 - \left(t\_5 - t\_2\right)}} \cdot t\_3\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \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.97999999999999998Initial program 89.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6488.9
Applied rewrites67.4%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6463.4
Applied rewrites63.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.2
Applied rewrites3.2%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6463.2
Applied rewrites63.2%
if -0.97999999999999998 < (/.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))))) < -1e-3Initial program 99.3%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.3
Applied rewrites99.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6419.9
Applied rewrites19.9%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
associate-+l-N/A
lower--.f64N/A
Applied rewrites45.8%
if -1e-3 < (/.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.050000000000000003Initial program 99.5%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6498.2
Applied rewrites98.2%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.2
Applied rewrites98.2%
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.99999961869234189Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.2
Applied rewrites99.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6420.2
Applied rewrites20.2%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6420.2
Applied rewrites21.4%
Taylor expanded in th around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
associate-+l-N/A
lower--.f64N/A
Applied rewrites56.2%
if 0.99999961869234189 < (/.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 95.4%
Taylor expanded in kx around 0
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
associate-/l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-sin.f64100.0
Applied rewrites100.0%
Taylor expanded in ky around 0
Applied rewrites100.0%
Final simplification77.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (cos (* 2.0 ky)))
(t_2 (- 1.0 t_1))
(t_3 (* th (sin ky)))
(t_4 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))))
(t_5 (cos (* 2.0 kx))))
(if (<= t_4 -0.98)
(/ (* (sin th) (sin ky)) (sqrt (* t_2 0.5)))
(if (<= t_4 -0.001)
(* t_3 (sqrt (/ 2.0 (- 1.0 (- t_1 (- 1.0 t_5))))))
(if (<= t_4 0.05)
(*
(/
(* (fma (* ky ky) -0.16666666666666666 1.0) ky)
(hypot (* (fma -0.16666666666666666 (* ky ky) 1.0) ky) (sin kx)))
(sin th))
(if (<= t_4 0.9999996186923419)
(* (sqrt (/ 2.0 (- 1.0 (- t_5 t_2)))) t_3)
(* (/ (sin ky) (fma (* 0.5 kx) (/ kx ky) (sin ky))) (sin th))))))))
double code(double kx, double ky, double th) {
double t_1 = cos((2.0 * ky));
double t_2 = 1.0 - t_1;
double t_3 = th * sin(ky);
double t_4 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
double t_5 = cos((2.0 * kx));
double tmp;
if (t_4 <= -0.98) {
tmp = (sin(th) * sin(ky)) / sqrt((t_2 * 0.5));
} else if (t_4 <= -0.001) {
tmp = t_3 * sqrt((2.0 / (1.0 - (t_1 - (1.0 - t_5)))));
} else if (t_4 <= 0.05) {
tmp = ((fma((ky * ky), -0.16666666666666666, 1.0) * ky) / hypot((fma(-0.16666666666666666, (ky * ky), 1.0) * ky), sin(kx))) * sin(th);
} else if (t_4 <= 0.9999996186923419) {
tmp = sqrt((2.0 / (1.0 - (t_5 - t_2)))) * t_3;
} else {
tmp = (sin(ky) / fma((0.5 * kx), (kx / ky), sin(ky))) * sin(th);
}
return tmp;
}
function code(kx, ky, th) t_1 = cos(Float64(2.0 * ky)) t_2 = Float64(1.0 - t_1) t_3 = Float64(th * sin(ky)) t_4 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) t_5 = cos(Float64(2.0 * kx)) tmp = 0.0 if (t_4 <= -0.98) tmp = Float64(Float64(sin(th) * sin(ky)) / sqrt(Float64(t_2 * 0.5))); elseif (t_4 <= -0.001) tmp = Float64(t_3 * sqrt(Float64(2.0 / Float64(1.0 - Float64(t_1 - Float64(1.0 - t_5)))))); elseif (t_4 <= 0.05) tmp = Float64(Float64(Float64(fma(Float64(ky * ky), -0.16666666666666666, 1.0) * ky) / hypot(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * ky), sin(kx))) * sin(th)); elseif (t_4 <= 0.9999996186923419) tmp = Float64(sqrt(Float64(2.0 / Float64(1.0 - Float64(t_5 - t_2)))) * t_3); else tmp = Float64(Float64(sin(ky) / fma(Float64(0.5 * kx), Float64(kx / ky), sin(ky))) * sin(th)); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = 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$5 = N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$4, -0.98], N[(N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(t$95$2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, -0.001], N[(t$95$3 * N[Sqrt[N[(2.0 / N[(1.0 - N[(t$95$1 - N[(1.0 - t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 0.05], N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * ky), $MachinePrecision] / N[Sqrt[N[(N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * ky), $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 0.9999996186923419], N[(N[Sqrt[N[(2.0 / N[(1.0 - N[(t$95$5 - t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$3), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[(0.5 * kx), $MachinePrecision] * N[(kx / ky), $MachinePrecision] + N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \cos \left(2 \cdot ky\right)\\
t_2 := 1 - t\_1\\
t_3 := th \cdot \sin ky\\
t_4 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
t_5 := \cos \left(2 \cdot kx\right)\\
\mathbf{if}\;t\_4 \leq -0.98:\\
\;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{t\_2 \cdot 0.5}}\\
\mathbf{elif}\;t\_4 \leq -0.001:\\
\;\;\;\;t\_3 \cdot \sqrt{\frac{2}{1 - \left(t\_1 - \left(1 - t\_5\right)\right)}}\\
\mathbf{elif}\;t\_4 \leq 0.05:\\
\;\;\;\;\frac{\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th\\
\mathbf{elif}\;t\_4 \leq 0.9999996186923419:\\
\;\;\;\;\sqrt{\frac{2}{1 - \left(t\_5 - t\_2\right)}} \cdot t\_3\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \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.97999999999999998Initial program 89.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6488.9
Applied rewrites67.4%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6463.4
Applied rewrites63.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.2
Applied rewrites3.2%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6463.2
Applied rewrites63.2%
if -0.97999999999999998 < (/.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))))) < -1e-3Initial program 99.3%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.3
Applied rewrites99.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6419.9
Applied rewrites19.9%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
associate-+l-N/A
lower--.f64N/A
Applied rewrites45.8%
if -1e-3 < (/.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.050000000000000003Initial program 99.5%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6498.2
Applied rewrites98.2%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6497.9
Applied rewrites97.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.99999961869234189Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.2
Applied rewrites99.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6420.2
Applied rewrites20.2%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6420.2
Applied rewrites21.4%
Taylor expanded in th around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
associate-+l-N/A
lower--.f64N/A
Applied rewrites56.2%
if 0.99999961869234189 < (/.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 95.4%
Taylor expanded in kx around 0
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
associate-/l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-sin.f64100.0
Applied rewrites100.0%
Taylor expanded in ky around 0
Applied rewrites100.0%
Final simplification77.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 (cos (* 2.0 ky)))
(t_3
(*
(* th (sin ky))
(sqrt (/ 2.0 (- 1.0 (- t_2 (- 1.0 (cos (* 2.0 kx))))))))))
(if (<= t_1 -0.98)
(/ (* (sin th) (sin ky)) (sqrt (* (- 1.0 t_2) 0.5)))
(if (<= t_1 -0.001)
t_3
(if (<= t_1 0.05)
(*
(/
(* (fma (* ky ky) -0.16666666666666666 1.0) ky)
(hypot (* (fma -0.16666666666666666 (* ky ky) 1.0) ky) (sin kx)))
(sin th))
(if (<= t_1 0.9999996186923419)
t_3
(* (/ (sin ky) (fma (* 0.5 kx) (/ kx ky) (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 t_2 = cos((2.0 * ky));
double t_3 = (th * sin(ky)) * sqrt((2.0 / (1.0 - (t_2 - (1.0 - cos((2.0 * kx)))))));
double tmp;
if (t_1 <= -0.98) {
tmp = (sin(th) * sin(ky)) / sqrt(((1.0 - t_2) * 0.5));
} else if (t_1 <= -0.001) {
tmp = t_3;
} else if (t_1 <= 0.05) {
tmp = ((fma((ky * ky), -0.16666666666666666, 1.0) * ky) / hypot((fma(-0.16666666666666666, (ky * ky), 1.0) * ky), sin(kx))) * sin(th);
} else if (t_1 <= 0.9999996186923419) {
tmp = t_3;
} else {
tmp = (sin(ky) / fma((0.5 * kx), (kx / ky), sin(ky))) * 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 = cos(Float64(2.0 * ky)) t_3 = Float64(Float64(th * sin(ky)) * sqrt(Float64(2.0 / Float64(1.0 - Float64(t_2 - Float64(1.0 - cos(Float64(2.0 * kx)))))))) tmp = 0.0 if (t_1 <= -0.98) tmp = Float64(Float64(sin(th) * sin(ky)) / sqrt(Float64(Float64(1.0 - t_2) * 0.5))); elseif (t_1 <= -0.001) tmp = t_3; elseif (t_1 <= 0.05) tmp = Float64(Float64(Float64(fma(Float64(ky * ky), -0.16666666666666666, 1.0) * ky) / hypot(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * ky), sin(kx))) * sin(th)); elseif (t_1 <= 0.9999996186923419) tmp = t_3; else tmp = Float64(Float64(sin(ky) / fma(Float64(0.5 * kx), Float64(kx / ky), sin(ky))) * 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[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 / N[(1.0 - N[(t$95$2 - N[(1.0 - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.98], N[(N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.001], t$95$3, If[LessEqual[t$95$1, 0.05], N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * ky), $MachinePrecision] / N[Sqrt[N[(N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * ky), $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.9999996186923419], t$95$3, N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[(0.5 * kx), $MachinePrecision] * N[(kx / ky), $MachinePrecision] + N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
t_2 := \cos \left(2 \cdot ky\right)\\
t_3 := \left(th \cdot \sin ky\right) \cdot \sqrt{\frac{2}{1 - \left(t\_2 - \left(1 - \cos \left(2 \cdot kx\right)\right)\right)}}\\
\mathbf{if}\;t\_1 \leq -0.98:\\
\;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - t\_2\right) \cdot 0.5}}\\
\mathbf{elif}\;t\_1 \leq -0.001:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_1 \leq 0.05:\\
\;\;\;\;\frac{\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 0.9999996186923419:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \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.97999999999999998Initial program 89.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6488.9
Applied rewrites67.4%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6463.4
Applied rewrites63.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.2
Applied rewrites3.2%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6463.2
Applied rewrites63.2%
if -0.97999999999999998 < (/.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))))) < -1e-3 or 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.99999961869234189Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.3
Applied rewrites99.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6420.0
Applied rewrites20.0%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
associate-+l-N/A
lower--.f64N/A
Applied rewrites50.7%
if -1e-3 < (/.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.050000000000000003Initial program 99.5%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6498.2
Applied rewrites98.2%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6497.9
Applied rewrites97.9%
if 0.99999961869234189 < (/.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 95.4%
Taylor expanded in kx around 0
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
associate-/l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-sin.f64100.0
Applied rewrites100.0%
Taylor expanded in ky around 0
Applied rewrites100.0%
Final simplification77.7%
(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.708)
(/ (* (sin th) (sin ky)) (sqrt (* (- 1.0 (cos (* 2.0 ky))) 0.5)))
(if (<= t_1 0.999)
(* (/ (sin th) (sqrt (* (- 1.0 (cos (+ kx kx))) 0.5))) (sin ky))
(* (/ (sin ky) (fma (* 0.5 kx) (/ kx ky) (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.708) {
tmp = (sin(th) * sin(ky)) / sqrt(((1.0 - cos((2.0 * ky))) * 0.5));
} else if (t_1 <= 0.999) {
tmp = (sin(th) / sqrt(((1.0 - cos((kx + kx))) * 0.5))) * sin(ky);
} else {
tmp = (sin(ky) / fma((0.5 * kx), (kx / ky), sin(ky))) * 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.708) tmp = Float64(Float64(sin(th) * sin(ky)) / sqrt(Float64(Float64(1.0 - cos(Float64(2.0 * ky))) * 0.5))); elseif (t_1 <= 0.999) tmp = Float64(Float64(sin(th) / sqrt(Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))) * sin(ky)); else tmp = Float64(Float64(sin(ky) / fma(Float64(0.5 * kx), Float64(kx / ky), sin(ky))) * 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.708], N[(N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.999], N[(N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[(0.5 * kx), $MachinePrecision] * N[(kx / ky), $MachinePrecision] + N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $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.708:\\
\;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot 0.5}}\\
\mathbf{elif}\;t\_1 \leq 0.999:\\
\;\;\;\;\frac{\sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \cdot \sin ky\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \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.70799999999999996Initial program 90.9%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6490.8
Applied rewrites73.2%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6455.8
Applied rewrites55.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6455.7
Applied rewrites6.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6455.7
Applied rewrites55.7%
if -0.70799999999999996 < (/.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.998999999999999999Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.4
Applied rewrites85.4%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f649.0
Applied rewrites9.0%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites54.9%
if 0.998999999999999999 < (/.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 95.4%
Taylor expanded in kx around 0
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
associate-/l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-sin.f64100.0
Applied rewrites100.0%
Taylor expanded in ky around 0
Applied rewrites100.0%
Final simplification62.7%
(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.88)
(/
(* (fma (* th th) -0.16666666666666666 1.0) th)
(/
(sqrt
(fma
(- 1.0 (cos (* 2.0 ky)))
0.5
(*
(fma
(fma 0.044444444444444446 (* kx kx) -0.3333333333333333)
(* kx kx)
1.0)
(* kx kx))))
(sin ky)))
(if (<= t_1 0.999)
(* (/ (sin th) (sqrt (* (- 1.0 (cos (+ kx kx))) 0.5))) (sin ky))
(* (/ (sin ky) (fma (* 0.5 kx) (/ kx ky) (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.88) {
tmp = (fma((th * th), -0.16666666666666666, 1.0) * th) / (sqrt(fma((1.0 - cos((2.0 * ky))), 0.5, (fma(fma(0.044444444444444446, (kx * kx), -0.3333333333333333), (kx * kx), 1.0) * (kx * kx)))) / sin(ky));
} else if (t_1 <= 0.999) {
tmp = (sin(th) / sqrt(((1.0 - cos((kx + kx))) * 0.5))) * sin(ky);
} else {
tmp = (sin(ky) / fma((0.5 * kx), (kx / ky), sin(ky))) * 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.88) tmp = Float64(Float64(fma(Float64(th * th), -0.16666666666666666, 1.0) * th) / Float64(sqrt(fma(Float64(1.0 - cos(Float64(2.0 * ky))), 0.5, Float64(fma(fma(0.044444444444444446, Float64(kx * kx), -0.3333333333333333), Float64(kx * kx), 1.0) * Float64(kx * kx)))) / sin(ky))); elseif (t_1 <= 0.999) tmp = Float64(Float64(sin(th) / sqrt(Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))) * sin(ky)); else tmp = Float64(Float64(sin(ky) / fma(Float64(0.5 * kx), Float64(kx / ky), sin(ky))) * 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.88], N[(N[(N[(N[(th * th), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * th), $MachinePrecision] / N[(N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(N[(0.044444444444444446 * N[(kx * kx), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision] * N[(kx * kx), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.999], N[(N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[(N[(0.5 * kx), $MachinePrecision] * N[(kx / ky), $MachinePrecision] + N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $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.88:\\
\;\;\;\;\frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(2 \cdot ky\right), 0.5, \mathsf{fma}\left(\mathsf{fma}\left(0.044444444444444446, kx \cdot kx, -0.3333333333333333\right), kx \cdot kx, 1\right) \cdot \left(kx \cdot kx\right)\right)}}{\sin ky}}\\
\mathbf{elif}\;t\_1 \leq 0.999:\\
\;\;\;\;\frac{\sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \cdot \sin ky\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{fma}\left(0.5 \cdot kx, \frac{kx}{ky}, \sin ky\right)} \cdot \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.880000000000000004Initial program 89.9%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6489.8
Applied rewrites70.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6459.9
Applied rewrites59.9%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6433.1
Applied rewrites33.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites34.3%
if -0.880000000000000004 < (/.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.998999999999999999Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.4
Applied rewrites86.2%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f649.6
Applied rewrites9.6%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites53.0%
if 0.998999999999999999 < (/.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 95.4%
Taylor expanded in kx around 0
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
associate-/l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-sin.f64100.0
Applied rewrites100.0%
Taylor expanded in ky around 0
Applied rewrites100.0%
Final simplification55.9%
(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.88)
(/
(* (fma (* th th) -0.16666666666666666 1.0) th)
(/
(sqrt
(fma
(- 1.0 (cos (* 2.0 ky)))
0.5
(*
(fma
(fma 0.044444444444444446 (* kx kx) -0.3333333333333333)
(* kx kx)
1.0)
(* kx kx))))
(sin ky)))
(if (<= t_1 0.71)
(* (/ (sin th) (sqrt (* (- 1.0 (cos (+ kx kx))) 0.5))) (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.88) {
tmp = (fma((th * th), -0.16666666666666666, 1.0) * th) / (sqrt(fma((1.0 - cos((2.0 * ky))), 0.5, (fma(fma(0.044444444444444446, (kx * kx), -0.3333333333333333), (kx * kx), 1.0) * (kx * kx)))) / sin(ky));
} else if (t_1 <= 0.71) {
tmp = (sin(th) / sqrt(((1.0 - cos((kx + kx))) * 0.5))) * 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.88) tmp = Float64(Float64(fma(Float64(th * th), -0.16666666666666666, 1.0) * th) / Float64(sqrt(fma(Float64(1.0 - cos(Float64(2.0 * ky))), 0.5, Float64(fma(fma(0.044444444444444446, Float64(kx * kx), -0.3333333333333333), Float64(kx * kx), 1.0) * Float64(kx * kx)))) / sin(ky))); elseif (t_1 <= 0.71) tmp = Float64(Float64(sin(th) / sqrt(Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))) * 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.88], N[(N[(N[(N[(th * th), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * th), $MachinePrecision] / N[(N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(N[(0.044444444444444446 * N[(kx * kx), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision] * N[(kx * kx), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.71], N[(N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $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.88:\\
\;\;\;\;\frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(2 \cdot ky\right), 0.5, \mathsf{fma}\left(\mathsf{fma}\left(0.044444444444444446, kx \cdot kx, -0.3333333333333333\right), kx \cdot kx, 1\right) \cdot \left(kx \cdot kx\right)\right)}}{\sin ky}}\\
\mathbf{elif}\;t\_1 \leq 0.71:\\
\;\;\;\;\frac{\sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \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.880000000000000004Initial program 89.9%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6489.8
Applied rewrites70.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6459.9
Applied rewrites59.9%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6433.1
Applied rewrites33.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites34.3%
if -0.880000000000000004 < (/.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.70999999999999996Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.5
Applied rewrites84.9%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f648.4
Applied rewrites8.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites56.3%
if 0.70999999999999996 < (/.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 96.4%
Taylor expanded in kx around 0
lower-sin.f6482.0
Applied rewrites82.0%
Final simplification56.1%
(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.88)
(/
(* (fma (* th th) -0.16666666666666666 1.0) th)
(/
(sqrt
(fma
(- 1.0 (cos (* 2.0 ky)))
0.5
(*
(fma
(fma 0.044444444444444446 (* kx kx) -0.3333333333333333)
(* kx kx)
1.0)
(* kx kx))))
(sin ky)))
(if (<= t_1 0.71)
(* (/ (sin ky) (sqrt (* (- 1.0 (cos (+ kx kx))) 0.5))) (sin th))
(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.88) {
tmp = (fma((th * th), -0.16666666666666666, 1.0) * th) / (sqrt(fma((1.0 - cos((2.0 * ky))), 0.5, (fma(fma(0.044444444444444446, (kx * kx), -0.3333333333333333), (kx * kx), 1.0) * (kx * kx)))) / sin(ky));
} else if (t_1 <= 0.71) {
tmp = (sin(ky) / sqrt(((1.0 - cos((kx + kx))) * 0.5))) * sin(th);
} 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.88) tmp = Float64(Float64(fma(Float64(th * th), -0.16666666666666666, 1.0) * th) / Float64(sqrt(fma(Float64(1.0 - cos(Float64(2.0 * ky))), 0.5, Float64(fma(fma(0.044444444444444446, Float64(kx * kx), -0.3333333333333333), Float64(kx * kx), 1.0) * Float64(kx * kx)))) / sin(ky))); elseif (t_1 <= 0.71) tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))) * sin(th)); 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.88], N[(N[(N[(N[(th * th), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * th), $MachinePrecision] / N[(N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(N[(0.044444444444444446 * N[(kx * kx), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision] * N[(kx * kx), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.71], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $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.88:\\
\;\;\;\;\frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(2 \cdot ky\right), 0.5, \mathsf{fma}\left(\mathsf{fma}\left(0.044444444444444446, kx \cdot kx, -0.3333333333333333\right), kx \cdot kx, 1\right) \cdot \left(kx \cdot kx\right)\right)}}{\sin ky}}\\
\mathbf{elif}\;t\_1 \leq 0.71:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \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.880000000000000004Initial program 89.9%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6489.8
Applied rewrites70.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6459.9
Applied rewrites59.9%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6433.1
Applied rewrites33.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites34.3%
if -0.880000000000000004 < (/.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.70999999999999996Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.5
Applied rewrites84.9%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f648.4
Applied rewrites8.4%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lift-/.f64N/A
clear-numN/A
lower-*.f64N/A
Applied rewrites56.3%
if 0.70999999999999996 < (/.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 96.4%
Taylor expanded in kx around 0
lower-sin.f6482.0
Applied rewrites82.0%
Final simplification56.1%
(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.02)
(/
(* (fma (* th th) -0.16666666666666666 1.0) th)
(/ (sqrt (* 0.5 (- 1.0 (cos (+ ky ky))))) (sin ky)))
(if (<= t_1 0.05)
(/
(* (* (fma (* ky ky) -0.16666666666666666 1.0) ky) (sin th))
(sqrt (* (- 1.0 (cos (+ kx kx))) 0.5)))
(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.02) {
tmp = (fma((th * th), -0.16666666666666666, 1.0) * th) / (sqrt((0.5 * (1.0 - cos((ky + ky))))) / sin(ky));
} else if (t_1 <= 0.05) {
tmp = ((fma((ky * ky), -0.16666666666666666, 1.0) * ky) * sin(th)) / sqrt(((1.0 - cos((kx + kx))) * 0.5));
} 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.02) tmp = Float64(Float64(fma(Float64(th * th), -0.16666666666666666, 1.0) * th) / Float64(sqrt(Float64(0.5 * Float64(1.0 - cos(Float64(ky + ky))))) / sin(ky))); elseif (t_1 <= 0.05) tmp = Float64(Float64(Float64(fma(Float64(ky * ky), -0.16666666666666666, 1.0) * ky) * sin(th)) / sqrt(Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))); 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.02], N[(N[(N[(N[(th * th), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * th), $MachinePrecision] / N[(N[Sqrt[N[(0.5 * N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.05], N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * ky), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $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.02:\\
\;\;\;\;\frac{\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th}{\frac{\sqrt{0.5 \cdot \left(1 - \cos \left(ky + ky\right)\right)}}{\sin ky}}\\
\mathbf{elif}\;t\_1 \leq 0.05:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky\right) \cdot \sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}\\
\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.0200000000000000004Initial program 92.7%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6492.7
Applied rewrites78.8%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6447.7
Applied rewrites47.7%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6426.4
Applied rewrites26.4%
Applied rewrites26.4%
if -0.0200000000000000004 < (/.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.050000000000000003Initial program 99.5%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.5
Applied rewrites77.0%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f642.6
Applied rewrites2.6%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f642.3
Applied rewrites74.5%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6474.0
Applied rewrites74.0%
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))))) Initial program 97.1%
Taylor expanded in kx around 0
lower-sin.f6466.6
Applied rewrites66.6%
Final simplification53.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sqrt (* (- 1.0 (cos (+ kx kx))) 0.5)))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0))))))
(if (<= t_2 -0.001)
(/ (* th (sin ky)) t_1)
(if (<= t_2 0.05) (/ (* (sin th) ky) t_1) (sin th)))))
double code(double kx, double ky, double th) {
double t_1 = sqrt(((1.0 - cos((kx + kx))) * 0.5));
double t_2 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
double tmp;
if (t_2 <= -0.001) {
tmp = (th * sin(ky)) / t_1;
} else if (t_2 <= 0.05) {
tmp = (sin(th) * ky) / t_1;
} 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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = sqrt(((1.0d0 - cos((kx + kx))) * 0.5d0))
t_2 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
if (t_2 <= (-0.001d0)) then
tmp = (th * sin(ky)) / t_1
else if (t_2 <= 0.05d0) then
tmp = (sin(th) * ky) / t_1
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sqrt(((1.0 - Math.cos((kx + kx))) * 0.5));
double t_2 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
double tmp;
if (t_2 <= -0.001) {
tmp = (th * Math.sin(ky)) / t_1;
} else if (t_2 <= 0.05) {
tmp = (Math.sin(th) * ky) / t_1;
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sqrt(((1.0 - math.cos((kx + kx))) * 0.5)) t_2 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0))) tmp = 0 if t_2 <= -0.001: tmp = (th * math.sin(ky)) / t_1 elif t_2 <= 0.05: tmp = (math.sin(th) * ky) / t_1 else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = sqrt(Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5)) t_2 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) tmp = 0.0 if (t_2 <= -0.001) tmp = Float64(Float64(th * sin(ky)) / t_1); elseif (t_2 <= 0.05) tmp = Float64(Float64(sin(th) * ky) / t_1); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sqrt(((1.0 - cos((kx + kx))) * 0.5)); t_2 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))); tmp = 0.0; if (t_2 <= -0.001) tmp = (th * sin(ky)) / t_1; elseif (t_2 <= 0.05) tmp = (sin(th) * ky) / t_1; else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = 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$2, -0.001], N[(N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 0.05], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / t$95$1), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}\\
t_2 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
\mathbf{if}\;t\_2 \leq -0.001:\\
\;\;\;\;\frac{th \cdot \sin ky}{t\_1}\\
\mathbf{elif}\;t\_2 \leq 0.05:\\
\;\;\;\;\frac{\sin th \cdot ky}{t\_1}\\
\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))))) < -1e-3Initial program 92.7%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6492.7
Applied rewrites78.8%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6447.7
Applied rewrites47.7%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6447.6
Applied rewrites10.0%
Taylor expanded in th around 0
lower-*.f64N/A
lower-sin.f646.2
Applied rewrites6.2%
if -1e-3 < (/.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.050000000000000003Initial program 99.5%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.5
Applied rewrites77.0%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f642.6
Applied rewrites2.6%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f642.3
Applied rewrites74.5%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6473.9
Applied rewrites73.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))))) Initial program 97.1%
Taylor expanded in kx around 0
lower-sin.f6466.6
Applied rewrites66.6%
Final simplification46.1%
(FPCore (kx ky th)
:precision binary64
(if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 0.05)
(/
(* (* (fma (* ky ky) -0.16666666666666666 1.0) ky) (sin th))
(sqrt (* (- 1.0 (cos (+ kx kx))) 0.5)))
(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.05) {
tmp = ((fma((ky * ky), -0.16666666666666666, 1.0) * ky) * sin(th)) / sqrt(((1.0 - cos((kx + kx))) * 0.5));
} else {
tmp = 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.05) tmp = Float64(Float64(Float64(fma(Float64(ky * ky), -0.16666666666666666, 1.0) * ky) * sin(th)) / sqrt(Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))); else tmp = sin(th); end return 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.05], N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * ky), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $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.05:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky\right) \cdot \sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}}\\
\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.050000000000000003Initial program 95.9%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6495.9
Applied rewrites78.0%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6426.6
Applied rewrites26.6%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6426.4
Applied rewrites40.1%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6435.6
Applied rewrites35.6%
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))))) Initial program 97.1%
Taylor expanded in kx around 0
lower-sin.f6466.6
Applied rewrites66.6%
Final simplification44.6%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 2e-8) (* (/ (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)))) <= 2e-8) {
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)))) <= 2d-8) 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)))) <= 2e-8) {
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)))) <= 2e-8: 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)))) <= 2e-8) tmp = Float64(Float64(sin(th) / 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)))) <= 2e-8) 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], 2e-8], N[(N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * ky), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\sin th}{\sin kx} \cdot 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))))) < 2e-8Initial program 95.8%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites23.1%
Taylor expanded in ky around 0
Applied rewrites25.7%
if 2e-8 < (/.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 97.2%
Taylor expanded in kx around 0
lower-sin.f6464.5
Applied rewrites64.5%
Final simplification37.4%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 1e-71) (* (* (/ (* (* ky ky) (sin th)) (* (* kx kx) kx)) -0.5) 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)))) <= 1e-71) {
tmp = ((((ky * ky) * sin(th)) / ((kx * kx) * kx)) * -0.5) * 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)))) <= 1d-71) then
tmp = ((((ky * ky) * sin(th)) / ((kx * kx) * kx)) * (-0.5d0)) * 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)))) <= 1e-71) {
tmp = ((((ky * ky) * Math.sin(th)) / ((kx * kx) * kx)) * -0.5) * 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)))) <= 1e-71: tmp = ((((ky * ky) * math.sin(th)) / ((kx * kx) * kx)) * -0.5) * 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)))) <= 1e-71) tmp = Float64(Float64(Float64(Float64(Float64(ky * ky) * sin(th)) / Float64(Float64(kx * kx) * kx)) * -0.5) * 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)))) <= 1e-71) tmp = ((((ky * ky) * sin(th)) / ((kx * kx) * kx)) * -0.5) * 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], 1e-71], N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[(N[(kx * kx), $MachinePrecision] * kx), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision] * ky), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-71}:\\
\;\;\;\;\left(\frac{\left(ky \cdot ky\right) \cdot \sin th}{\left(kx \cdot kx\right) \cdot kx} \cdot -0.5\right) \cdot 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))))) < 9.9999999999999992e-72Initial program 95.7%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites22.6%
Taylor expanded in kx around 0
Applied rewrites9.1%
if 9.9999999999999992e-72 < (/.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 97.4%
Taylor expanded in kx around 0
lower-sin.f6461.1
Applied rewrites61.1%
Final simplification25.8%
(FPCore (kx ky th)
:precision binary64
(if (<= (pow (sin kx) 2.0) 5e-9)
(*
(/
(sin ky)
(hypot (sin ky) (* (fma -0.16666666666666666 (* kx kx) 1.0) kx)))
(sin th))
(*
(/
(sin th)
(sqrt (fma (- 1.0 (cos (+ ky ky))) 0.5 (* (- 1.0 (cos (+ kx kx))) 0.5))))
(sin ky))))
double code(double kx, double ky, double th) {
double tmp;
if (pow(sin(kx), 2.0) <= 5e-9) {
tmp = (sin(ky) / hypot(sin(ky), (fma(-0.16666666666666666, (kx * kx), 1.0) * kx))) * sin(th);
} else {
tmp = (sin(th) / sqrt(fma((1.0 - cos((ky + ky))), 0.5, ((1.0 - cos((kx + kx))) * 0.5)))) * sin(ky);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if ((sin(kx) ^ 2.0) <= 5e-9) tmp = Float64(Float64(sin(ky) / hypot(sin(ky), Float64(fma(-0.16666666666666666, Float64(kx * kx), 1.0) * kx))) * sin(th)); else tmp = Float64(Float64(sin(th) / sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5)))) * sin(ky)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision], 5e-9], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[(N[(-0.16666666666666666 * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision] * kx), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\sin kx}^{2} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right) \cdot kx\right)} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}} \cdot \sin ky\\
\end{array}
\end{array}
if (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 5.0000000000000001e-9Initial program 92.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.9
Applied rewrites99.9%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.9
Applied rewrites99.9%
if 5.0000000000000001e-9 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) Initial program 99.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.0%
(FPCore (kx ky th)
:precision binary64
(if (<= (pow (sin kx) 2.0) 5e-9)
(*
(/
(sin ky)
(hypot (sin ky) (* (fma -0.16666666666666666 (* kx kx) 1.0) kx)))
(sin th))
(*
(/
(sin ky)
(sqrt (fma (- 1.0 (cos (+ ky ky))) 0.5 (* (- 1.0 (cos (+ kx kx))) 0.5))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (pow(sin(kx), 2.0) <= 5e-9) {
tmp = (sin(ky) / hypot(sin(ky), (fma(-0.16666666666666666, (kx * kx), 1.0) * kx))) * sin(th);
} else {
tmp = (sin(ky) / sqrt(fma((1.0 - cos((ky + ky))), 0.5, ((1.0 - cos((kx + kx))) * 0.5)))) * sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if ((sin(kx) ^ 2.0) <= 5e-9) tmp = Float64(Float64(sin(ky) / hypot(sin(ky), Float64(fma(-0.16666666666666666, Float64(kx * kx), 1.0) * kx))) * sin(th)); else tmp = Float64(Float64(sin(ky) / sqrt(fma(Float64(1.0 - cos(Float64(ky + ky))), 0.5, Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5)))) * sin(th)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision], 5e-9], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[(N[(-0.16666666666666666 * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision] * kx), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\sin kx}^{2} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right) \cdot kx\right)} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - \cos \left(ky + ky\right), 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}} \cdot \sin th\\
\end{array}
\end{array}
if (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 5.0000000000000001e-9Initial program 92.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.9
Applied rewrites99.9%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.9
Applied rewrites99.9%
if 5.0000000000000001e-9 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) Initial program 99.4%
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
div-invN/A
metadata-evalN/A
lower-fma.f64N/A
count-2N/A
cos-diffN/A
cos-sin-sumN/A
lower--.f64N/A
count-2N/A
lower-cos.f64N/A
lower-+.f6499.4
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites98.9%
(FPCore (kx ky th)
:precision binary64
(if (<=
(*
(/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0))))
(sin th))
8e-297)
(* (* (* th th) th) -0.16666666666666666)
(* 1.0 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)))) * sin(th)) <= 8e-297) {
tmp = ((th * th) * th) * -0.16666666666666666;
} else {
tmp = 1.0 * 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)))) * sin(th)) <= 8d-297) then
tmp = ((th * th) * th) * (-0.16666666666666666d0)
else
tmp = 1.0d0 * 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)))) * Math.sin(th)) <= 8e-297) {
tmp = ((th * th) * th) * -0.16666666666666666;
} else {
tmp = 1.0 * 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)))) * math.sin(th)) <= 8e-297: tmp = ((th * th) * th) * -0.16666666666666666 else: tmp = 1.0 * th return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) * sin(th)) <= 8e-297) tmp = Float64(Float64(Float64(th * th) * th) * -0.16666666666666666); else tmp = Float64(1.0 * 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)))) * sin(th)) <= 8e-297) tmp = ((th * th) * th) * -0.16666666666666666; else tmp = 1.0 * th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[(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] * N[Sin[th], $MachinePrecision]), $MachinePrecision], 8e-297], N[(N[(N[(th * th), $MachinePrecision] * th), $MachinePrecision] * -0.16666666666666666), $MachinePrecision], N[(1.0 * th), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \cdot \sin th \leq 8 \cdot 10^{-297}:\\
\;\;\;\;\left(\left(th \cdot th\right) \cdot th\right) \cdot -0.16666666666666666\\
\mathbf{else}:\\
\;\;\;\;1 \cdot th\\
\end{array}
\end{array}
if (*.f64 (/.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))))) (sin.f64 th)) < 8.00000000000000032e-297Initial program 96.7%
Taylor expanded in kx around 0
lower-sin.f6421.1
Applied rewrites21.1%
Taylor expanded in th around 0
Applied rewrites11.3%
Taylor expanded in th around inf
Applied rewrites11.7%
if 8.00000000000000032e-297 < (*.f64 (/.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))))) (sin.f64 th)) Initial program 95.8%
Taylor expanded in kx around 0
lower-sin.f6422.5
Applied rewrites22.5%
Taylor expanded in th around 0
Applied rewrites15.5%
Taylor expanded in th around 0
Applied rewrites15.6%
Final simplification13.6%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 1e-61) (* (* (* th th) th) -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)))) <= 1e-61) {
tmp = ((th * th) * th) * -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)))) <= 1d-61) then
tmp = ((th * th) * th) * (-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)))) <= 1e-61) {
tmp = ((th * th) * th) * -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)))) <= 1e-61: tmp = ((th * th) * th) * -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)))) <= 1e-61) tmp = Float64(Float64(Float64(th * th) * th) * -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)))) <= 1e-61) tmp = ((th * th) * th) * -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], 1e-61], N[(N[(N[(th * th), $MachinePrecision] * th), $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 10^{-61}:\\
\;\;\;\;\left(\left(th \cdot th\right) \cdot th\right) \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))))) < 1e-61Initial program 95.7%
Taylor expanded in kx around 0
lower-sin.f643.3
Applied rewrites3.3%
Taylor expanded in th around 0
Applied rewrites3.1%
Taylor expanded in th around inf
Applied rewrites10.5%
if 1e-61 < (/.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 97.4%
Taylor expanded in kx around 0
lower-sin.f6461.1
Applied rewrites61.1%
Final simplification26.7%
(FPCore (kx ky th)
:precision binary64
(if (<= ky 170000000000.0)
(*
(/
(* (fma (* ky ky) -0.16666666666666666 1.0) ky)
(hypot (* (fma -0.16666666666666666 (* ky ky) 1.0) ky) (sin kx)))
(sin th))
(/ (* (sin th) (sin ky)) (sqrt (* (- 1.0 (cos (* 2.0 ky))) 0.5)))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 170000000000.0) {
tmp = ((fma((ky * ky), -0.16666666666666666, 1.0) * ky) / hypot((fma(-0.16666666666666666, (ky * ky), 1.0) * ky), sin(kx))) * sin(th);
} else {
tmp = (sin(th) * sin(ky)) / sqrt(((1.0 - cos((2.0 * ky))) * 0.5));
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (ky <= 170000000000.0) tmp = Float64(Float64(Float64(fma(Float64(ky * ky), -0.16666666666666666, 1.0) * ky) / hypot(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * ky), sin(kx))) * sin(th)); else tmp = Float64(Float64(sin(th) * sin(ky)) / sqrt(Float64(Float64(1.0 - cos(Float64(2.0 * ky))) * 0.5))); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[ky, 170000000000.0], N[(N[(N[(N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * ky), $MachinePrecision] / N[Sqrt[N[(N[(-0.16666666666666666 * N[(ky * ky), $MachinePrecision] + 1.0), $MachinePrecision] * ky), $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 170000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(ky \cdot ky, -0.16666666666666666, 1\right) \cdot ky}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th \cdot \sin ky}{\sqrt{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot 0.5}}\\
\end{array}
\end{array}
if ky < 1.7e11Initial program 95.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
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6461.5
Applied rewrites61.5%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6462.1
Applied rewrites62.1%
if 1.7e11 < ky Initial program 99.8%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.7
Applied rewrites99.0%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6465.0
Applied rewrites65.0%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6465.1
Applied rewrites11.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower--.f64N/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6465.1
Applied rewrites65.1%
Final simplification62.8%
(FPCore (kx ky th) :precision binary64 (* 1.0 th))
double code(double kx, double ky, double th) {
return 1.0 * th;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = 1.0d0 * th
end function
public static double code(double kx, double ky, double th) {
return 1.0 * th;
}
def code(kx, ky, th): return 1.0 * th
function code(kx, ky, th) return Float64(1.0 * th) end
function tmp = code(kx, ky, th) tmp = 1.0 * th; end
code[kx_, ky_, th_] := N[(1.0 * th), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot th
\end{array}
Initial program 96.2%
Taylor expanded in kx around 0
lower-sin.f6421.8
Applied rewrites21.8%
Taylor expanded in th around 0
Applied rewrites13.3%
Taylor expanded in th around 0
Applied rewrites13.7%
herbie shell --seed 2024235
(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)))