
(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 94.4%
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 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))))
(t_2 (cos (+ ky ky)))
(t_3
(*
(/
(sin ky)
(hypot (* (fma -0.16666666666666666 (* ky ky) 1.0) ky) (sin kx)))
(sin th))))
(if (<= t_1 -0.945)
(* (* (/ 1.0 (sqrt (* (- 1.0 (cos (* 2.0 ky))) 0.5))) (sin ky)) (sin th))
(if (<= t_1 -0.1)
(*
(* (sqrt 2.0) (sqrt (/ 1.0 (- (- 2.0 t_2) (cos (* 2.0 kx))))))
(* th (sin ky)))
(if (<= t_1 1e-7)
t_3
(if (<= t_1 0.9972580999534978)
(*
(*
(fma
(fma
(fma (* th th) -0.0001984126984126984 0.008333333333333333)
(* th th)
-0.16666666666666666)
(* th th)
1.0)
th)
(/
(sin ky)
(sqrt (fma (- 1.0 t_2) 0.5 (* (- 1.0 (cos (+ kx kx))) 0.5)))))
(if (<= t_1 2.0) (sin th) t_3)))))))
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((ky + ky));
double t_3 = (sin(ky) / hypot((fma(-0.16666666666666666, (ky * ky), 1.0) * ky), sin(kx))) * sin(th);
double tmp;
if (t_1 <= -0.945) {
tmp = ((1.0 / sqrt(((1.0 - cos((2.0 * ky))) * 0.5))) * sin(ky)) * sin(th);
} else if (t_1 <= -0.1) {
tmp = (sqrt(2.0) * sqrt((1.0 / ((2.0 - t_2) - cos((2.0 * kx)))))) * (th * sin(ky));
} else if (t_1 <= 1e-7) {
tmp = t_3;
} else if (t_1 <= 0.9972580999534978) {
tmp = (fma(fma(fma((th * th), -0.0001984126984126984, 0.008333333333333333), (th * th), -0.16666666666666666), (th * th), 1.0) * th) * (sin(ky) / sqrt(fma((1.0 - t_2), 0.5, ((1.0 - cos((kx + kx))) * 0.5))));
} else if (t_1 <= 2.0) {
tmp = sin(th);
} else {
tmp = t_3;
}
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(ky + ky)) t_3 = Float64(Float64(sin(ky) / hypot(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * ky), sin(kx))) * sin(th)) tmp = 0.0 if (t_1 <= -0.945) tmp = Float64(Float64(Float64(1.0 / sqrt(Float64(Float64(1.0 - cos(Float64(2.0 * ky))) * 0.5))) * sin(ky)) * sin(th)); elseif (t_1 <= -0.1) tmp = Float64(Float64(sqrt(2.0) * sqrt(Float64(1.0 / Float64(Float64(2.0 - t_2) - cos(Float64(2.0 * kx)))))) * Float64(th * sin(ky))); elseif (t_1 <= 1e-7) tmp = t_3; elseif (t_1 <= 0.9972580999534978) 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(sin(ky) / sqrt(fma(Float64(1.0 - t_2), 0.5, Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))))); elseif (t_1 <= 2.0) tmp = sin(th); else tmp = t_3; 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[(ky + ky), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Sin[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.945], N[(N[(N[(1.0 / N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.1], N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[Sqrt[N[(1.0 / N[(N[(2.0 - t$95$2), $MachinePrecision] - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-7], t$95$3, If[LessEqual[t$95$1, 0.9972580999534978], 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[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] * 0.5 + N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[Sin[th], $MachinePrecision], t$95$3]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
t_2 := \cos \left(ky + ky\right)\\
t_3 := \frac{\sin ky}{\mathsf{hypot}\left(\mathsf{fma}\left(-0.16666666666666666, ky \cdot ky, 1\right) \cdot ky, \sin kx\right)} \cdot \sin th\\
\mathbf{if}\;t\_1 \leq -0.945:\\
\;\;\;\;\left(\frac{1}{\sqrt{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq -0.1:\\
\;\;\;\;\left(\sqrt{2} \cdot \sqrt{\frac{1}{\left(2 - t\_2\right) - \cos \left(2 \cdot kx\right)}}\right) \cdot \left(th \cdot \sin ky\right)\\
\mathbf{elif}\;t\_1 \leq 10^{-7}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_1 \leq 0.9972580999534978:\\
\;\;\;\;\left(\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\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - t\_2, 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\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.944999999999999951Initial program 90.6%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites73.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6462.2
Applied rewrites62.2%
if -0.944999999999999951 < (/.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.10000000000000001Initial 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.3
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites99.4%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites60.8%
Taylor expanded in kx around inf
Applied rewrites60.8%
Applied rewrites60.8%
if -0.10000000000000001 < (/.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.9999999999999995e-8 or 2 < (/.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 90.9%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.7
Applied rewrites99.7%
if 9.9999999999999995e-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))))) < 0.99725809995349779Initial 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.1
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites99.1%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites35.4%
if 0.99725809995349779 < (/.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))))) < 2Initial program 100.0%
Taylor expanded in kx around 0
lower-sin.f6498.5
Applied rewrites98.5%
Final simplification79.0%
(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 (+ ky ky))))
(if (<= t_1 -0.945)
(* (* (/ 1.0 (sqrt (* (- 1.0 (cos (* 2.0 ky))) 0.5))) (sin ky)) (sin th))
(if (<= t_1 -0.1)
(*
(* (sqrt 2.0) (sqrt (/ 1.0 (- (- 2.0 t_2) (cos (* 2.0 kx))))))
(* th (sin ky)))
(if (<= t_1 1e-23)
(* (/ (sin ky) (sin kx)) (sin th))
(if (<= t_1 0.9972580999534978)
(*
(*
(fma
(fma
(fma (* th th) -0.0001984126984126984 0.008333333333333333)
(* th th)
-0.16666666666666666)
(* th th)
1.0)
th)
(/
(sin ky)
(sqrt (fma (- 1.0 t_2) 0.5 (* (- 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 t_2 = cos((ky + ky));
double tmp;
if (t_1 <= -0.945) {
tmp = ((1.0 / sqrt(((1.0 - cos((2.0 * ky))) * 0.5))) * sin(ky)) * sin(th);
} else if (t_1 <= -0.1) {
tmp = (sqrt(2.0) * sqrt((1.0 / ((2.0 - t_2) - cos((2.0 * kx)))))) * (th * sin(ky));
} else if (t_1 <= 1e-23) {
tmp = (sin(ky) / sin(kx)) * sin(th);
} else if (t_1 <= 0.9972580999534978) {
tmp = (fma(fma(fma((th * th), -0.0001984126984126984, 0.008333333333333333), (th * th), -0.16666666666666666), (th * th), 1.0) * th) * (sin(ky) / sqrt(fma((1.0 - t_2), 0.5, ((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)))) t_2 = cos(Float64(ky + ky)) tmp = 0.0 if (t_1 <= -0.945) tmp = Float64(Float64(Float64(1.0 / sqrt(Float64(Float64(1.0 - cos(Float64(2.0 * ky))) * 0.5))) * sin(ky)) * sin(th)); elseif (t_1 <= -0.1) tmp = Float64(Float64(sqrt(2.0) * sqrt(Float64(1.0 / Float64(Float64(2.0 - t_2) - cos(Float64(2.0 * kx)))))) * Float64(th * sin(ky))); elseif (t_1 <= 1e-23) tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); elseif (t_1 <= 0.9972580999534978) 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(sin(ky) / sqrt(fma(Float64(1.0 - t_2), 0.5, 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]}, Block[{t$95$2 = N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -0.945], N[(N[(N[(1.0 / N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.1], N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[Sqrt[N[(1.0 / N[(N[(2.0 - t$95$2), $MachinePrecision] - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-23], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.9972580999534978], 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[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] * 0.5 + N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $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}}}\\
t_2 := \cos \left(ky + ky\right)\\
\mathbf{if}\;t\_1 \leq -0.945:\\
\;\;\;\;\left(\frac{1}{\sqrt{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq -0.1:\\
\;\;\;\;\left(\sqrt{2} \cdot \sqrt{\frac{1}{\left(2 - t\_2\right) - \cos \left(2 \cdot kx\right)}}\right) \cdot \left(th \cdot \sin ky\right)\\
\mathbf{elif}\;t\_1 \leq 10^{-23}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 0.9972580999534978:\\
\;\;\;\;\left(\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\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - t\_2, 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}\\
\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.944999999999999951Initial program 90.6%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites73.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6462.2
Applied rewrites62.2%
if -0.944999999999999951 < (/.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.10000000000000001Initial 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.3
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites99.4%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites60.8%
Taylor expanded in kx around inf
Applied rewrites60.8%
Applied rewrites60.8%
if -0.10000000000000001 < (/.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.9999999999999996e-24Initial program 99.7%
Taylor expanded in ky around 0
lower-sin.f6464.1
Applied rewrites64.1%
if 9.9999999999999996e-24 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99725809995349779Initial program 99.5%
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.1
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites99.1%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites37.3%
if 0.99725809995349779 < (/.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 82.5%
Taylor expanded in kx around 0
lower-sin.f6491.5
Applied rewrites91.5%
Final simplification65.2%
(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 (+ ky ky))))
(if (<= t_1 -0.945)
(* (* (/ 1.0 (sqrt (* (- 1.0 (cos (* 2.0 ky))) 0.5))) (sin ky)) (sin th))
(if (<= t_1 -0.1)
(*
(* (sqrt 2.0) (sqrt (/ 1.0 (- (- 2.0 t_2) (cos (* 2.0 kx))))))
(* th (sin ky)))
(if (<= t_1 1e-23)
(* (/ (sin ky) (sin kx)) (sin th))
(if (<= t_1 0.9972580999534978)
(*
(*
(fma
(fma (* th th) 0.008333333333333333 -0.16666666666666666)
(* th th)
1.0)
th)
(/
(sin ky)
(sqrt (fma (- 1.0 t_2) 0.5 (* (- 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 t_2 = cos((ky + ky));
double tmp;
if (t_1 <= -0.945) {
tmp = ((1.0 / sqrt(((1.0 - cos((2.0 * ky))) * 0.5))) * sin(ky)) * sin(th);
} else if (t_1 <= -0.1) {
tmp = (sqrt(2.0) * sqrt((1.0 / ((2.0 - t_2) - cos((2.0 * kx)))))) * (th * sin(ky));
} else if (t_1 <= 1e-23) {
tmp = (sin(ky) / sin(kx)) * sin(th);
} else if (t_1 <= 0.9972580999534978) {
tmp = (fma(fma((th * th), 0.008333333333333333, -0.16666666666666666), (th * th), 1.0) * th) * (sin(ky) / sqrt(fma((1.0 - t_2), 0.5, ((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)))) t_2 = cos(Float64(ky + ky)) tmp = 0.0 if (t_1 <= -0.945) tmp = Float64(Float64(Float64(1.0 / sqrt(Float64(Float64(1.0 - cos(Float64(2.0 * ky))) * 0.5))) * sin(ky)) * sin(th)); elseif (t_1 <= -0.1) tmp = Float64(Float64(sqrt(2.0) * sqrt(Float64(1.0 / Float64(Float64(2.0 - t_2) - cos(Float64(2.0 * kx)))))) * Float64(th * sin(ky))); elseif (t_1 <= 1e-23) tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); elseif (t_1 <= 0.9972580999534978) tmp = Float64(Float64(fma(fma(Float64(th * th), 0.008333333333333333, -0.16666666666666666), Float64(th * th), 1.0) * th) * Float64(sin(ky) / sqrt(fma(Float64(1.0 - t_2), 0.5, 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]}, Block[{t$95$2 = N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -0.945], N[(N[(N[(1.0 / N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.1], N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[Sqrt[N[(1.0 / N[(N[(2.0 - t$95$2), $MachinePrecision] - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-23], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.9972580999534978], N[(N[(N[(N[(N[(th * th), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(th * th), $MachinePrecision] + 1.0), $MachinePrecision] * th), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] * 0.5 + N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $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}}}\\
t_2 := \cos \left(ky + ky\right)\\
\mathbf{if}\;t\_1 \leq -0.945:\\
\;\;\;\;\left(\frac{1}{\sqrt{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq -0.1:\\
\;\;\;\;\left(\sqrt{2} \cdot \sqrt{\frac{1}{\left(2 - t\_2\right) - \cos \left(2 \cdot kx\right)}}\right) \cdot \left(th \cdot \sin ky\right)\\
\mathbf{elif}\;t\_1 \leq 10^{-23}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 0.9972580999534978:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(th \cdot th, 0.008333333333333333, -0.16666666666666666\right), th \cdot th, 1\right) \cdot th\right) \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(1 - t\_2, 0.5, \left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5\right)}}\\
\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.944999999999999951Initial program 90.6%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites73.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6462.2
Applied rewrites62.2%
if -0.944999999999999951 < (/.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.10000000000000001Initial 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.3
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites99.4%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites60.8%
Taylor expanded in kx around inf
Applied rewrites60.8%
Applied rewrites60.8%
if -0.10000000000000001 < (/.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.9999999999999996e-24Initial program 99.7%
Taylor expanded in ky around 0
lower-sin.f6464.1
Applied rewrites64.1%
if 9.9999999999999996e-24 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99725809995349779Initial program 99.5%
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.1
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
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-*.f6437.4
Applied rewrites37.4%
if 0.99725809995349779 < (/.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 82.5%
Taylor expanded in kx around 0
lower-sin.f6491.5
Applied rewrites91.5%
Final simplification65.2%
(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 (cos (* 2.0 kx))))
(if (<= t_1 -0.945)
(* (* (/ 1.0 (sqrt (* (- 1.0 t_2) 0.5))) (sin ky)) (sin th))
(if (<= t_1 -0.1)
(*
(* (sqrt 2.0) (sqrt (/ 1.0 (- (- 2.0 (cos (+ ky ky))) t_3))))
(* th (sin ky)))
(if (<= t_1 1e-23)
(* (/ (sin ky) (sin kx)) (sin th))
(if (<= t_1 0.9972580999534978)
(*
(* (sqrt (/ 1.0 (* (- (- 1.0 t_3) (- t_2 1.0)) 0.5))) (- th))
(- (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 = cos((2.0 * kx));
double tmp;
if (t_1 <= -0.945) {
tmp = ((1.0 / sqrt(((1.0 - t_2) * 0.5))) * sin(ky)) * sin(th);
} else if (t_1 <= -0.1) {
tmp = (sqrt(2.0) * sqrt((1.0 / ((2.0 - cos((ky + ky))) - t_3)))) * (th * sin(ky));
} else if (t_1 <= 1e-23) {
tmp = (sin(ky) / sin(kx)) * sin(th);
} else if (t_1 <= 0.9972580999534978) {
tmp = (sqrt((1.0 / (((1.0 - t_3) - (t_2 - 1.0)) * 0.5))) * -th) * -sin(ky);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_1 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
t_2 = cos((2.0d0 * ky))
t_3 = cos((2.0d0 * kx))
if (t_1 <= (-0.945d0)) then
tmp = ((1.0d0 / sqrt(((1.0d0 - t_2) * 0.5d0))) * sin(ky)) * sin(th)
else if (t_1 <= (-0.1d0)) then
tmp = (sqrt(2.0d0) * sqrt((1.0d0 / ((2.0d0 - cos((ky + ky))) - t_3)))) * (th * sin(ky))
else if (t_1 <= 1d-23) then
tmp = (sin(ky) / sin(kx)) * sin(th)
else if (t_1 <= 0.9972580999534978d0) then
tmp = (sqrt((1.0d0 / (((1.0d0 - t_3) - (t_2 - 1.0d0)) * 0.5d0))) * -th) * -sin(ky)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
double t_2 = Math.cos((2.0 * ky));
double t_3 = Math.cos((2.0 * kx));
double tmp;
if (t_1 <= -0.945) {
tmp = ((1.0 / Math.sqrt(((1.0 - t_2) * 0.5))) * Math.sin(ky)) * Math.sin(th);
} else if (t_1 <= -0.1) {
tmp = (Math.sqrt(2.0) * Math.sqrt((1.0 / ((2.0 - Math.cos((ky + ky))) - t_3)))) * (th * Math.sin(ky));
} else if (t_1 <= 1e-23) {
tmp = (Math.sin(ky) / Math.sin(kx)) * Math.sin(th);
} else if (t_1 <= 0.9972580999534978) {
tmp = (Math.sqrt((1.0 / (((1.0 - t_3) - (t_2 - 1.0)) * 0.5))) * -th) * -Math.sin(ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0))) t_2 = math.cos((2.0 * ky)) t_3 = math.cos((2.0 * kx)) tmp = 0 if t_1 <= -0.945: tmp = ((1.0 / math.sqrt(((1.0 - t_2) * 0.5))) * math.sin(ky)) * math.sin(th) elif t_1 <= -0.1: tmp = (math.sqrt(2.0) * math.sqrt((1.0 / ((2.0 - math.cos((ky + ky))) - t_3)))) * (th * math.sin(ky)) elif t_1 <= 1e-23: tmp = (math.sin(ky) / math.sin(kx)) * math.sin(th) elif t_1 <= 0.9972580999534978: tmp = (math.sqrt((1.0 / (((1.0 - t_3) - (t_2 - 1.0)) * 0.5))) * -th) * -math.sin(ky) else: tmp = math.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 = cos(Float64(2.0 * kx)) tmp = 0.0 if (t_1 <= -0.945) tmp = Float64(Float64(Float64(1.0 / sqrt(Float64(Float64(1.0 - t_2) * 0.5))) * sin(ky)) * sin(th)); elseif (t_1 <= -0.1) tmp = Float64(Float64(sqrt(2.0) * sqrt(Float64(1.0 / Float64(Float64(2.0 - cos(Float64(ky + ky))) - t_3)))) * Float64(th * sin(ky))); elseif (t_1 <= 1e-23) tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); elseif (t_1 <= 0.9972580999534978) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(Float64(Float64(1.0 - t_3) - Float64(t_2 - 1.0)) * 0.5))) * Float64(-th)) * Float64(-sin(ky))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))); t_2 = cos((2.0 * ky)); t_3 = cos((2.0 * kx)); tmp = 0.0; if (t_1 <= -0.945) tmp = ((1.0 / sqrt(((1.0 - t_2) * 0.5))) * sin(ky)) * sin(th); elseif (t_1 <= -0.1) tmp = (sqrt(2.0) * sqrt((1.0 / ((2.0 - cos((ky + ky))) - t_3)))) * (th * sin(ky)); elseif (t_1 <= 1e-23) tmp = (sin(ky) / sin(kx)) * sin(th); elseif (t_1 <= 0.9972580999534978) tmp = (sqrt((1.0 / (((1.0 - t_3) - (t_2 - 1.0)) * 0.5))) * -th) * -sin(ky); else tmp = sin(th); end tmp_2 = 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[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -0.945], N[(N[(N[(1.0 / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.1], N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[Sqrt[N[(1.0 / N[(N[(2.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-23], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.9972580999534978], N[(N[(N[Sqrt[N[(1.0 / N[(N[(N[(1.0 - t$95$3), $MachinePrecision] - N[(t$95$2 - 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-th)), $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}}}\\
t_2 := \cos \left(2 \cdot ky\right)\\
t_3 := \cos \left(2 \cdot kx\right)\\
\mathbf{if}\;t\_1 \leq -0.945:\\
\;\;\;\;\left(\frac{1}{\sqrt{\left(1 - t\_2\right) \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq -0.1:\\
\;\;\;\;\left(\sqrt{2} \cdot \sqrt{\frac{1}{\left(2 - \cos \left(ky + ky\right)\right) - t\_3}}\right) \cdot \left(th \cdot \sin ky\right)\\
\mathbf{elif}\;t\_1 \leq 10^{-23}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 0.9972580999534978:\\
\;\;\;\;\left(\sqrt{\frac{1}{\left(\left(1 - t\_3\right) - \left(t\_2 - 1\right)\right) \cdot 0.5}} \cdot \left(-th\right)\right) \cdot \left(-\sin ky\right)\\
\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.944999999999999951Initial program 90.6%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites73.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6462.2
Applied rewrites62.2%
if -0.944999999999999951 < (/.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.10000000000000001Initial 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.3
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites99.4%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites60.8%
Taylor expanded in kx around inf
Applied rewrites60.8%
Applied rewrites60.8%
if -0.10000000000000001 < (/.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.9999999999999996e-24Initial program 99.7%
Taylor expanded in ky around 0
lower-sin.f6464.1
Applied rewrites64.1%
if 9.9999999999999996e-24 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99725809995349779Initial program 99.5%
Applied rewrites99.1%
Taylor expanded in th around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites38.2%
if 0.99725809995349779 < (/.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 82.5%
Taylor expanded in kx around 0
lower-sin.f6491.5
Applied rewrites91.5%
Final simplification65.3%
(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
(*
(*
(sqrt (/ 1.0 (* (- (- 1.0 (cos (* 2.0 kx))) (- t_2 1.0)) 0.5)))
(- th))
(- (sin ky)))))
(if (<= t_1 -0.945)
(* (* (/ 1.0 (sqrt (* (- 1.0 t_2) 0.5))) (sin ky)) (sin th))
(if (<= t_1 -0.1)
t_3
(if (<= t_1 1e-23)
(* (/ (sin ky) (sin kx)) (sin th))
(if (<= t_1 0.9972580999534978) t_3 (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 = (sqrt((1.0 / (((1.0 - cos((2.0 * kx))) - (t_2 - 1.0)) * 0.5))) * -th) * -sin(ky);
double tmp;
if (t_1 <= -0.945) {
tmp = ((1.0 / sqrt(((1.0 - t_2) * 0.5))) * sin(ky)) * sin(th);
} else if (t_1 <= -0.1) {
tmp = t_3;
} else if (t_1 <= 1e-23) {
tmp = (sin(ky) / sin(kx)) * sin(th);
} else if (t_1 <= 0.9972580999534978) {
tmp = t_3;
} 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) :: t_3
real(8) :: tmp
t_1 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
t_2 = cos((2.0d0 * ky))
t_3 = (sqrt((1.0d0 / (((1.0d0 - cos((2.0d0 * kx))) - (t_2 - 1.0d0)) * 0.5d0))) * -th) * -sin(ky)
if (t_1 <= (-0.945d0)) then
tmp = ((1.0d0 / sqrt(((1.0d0 - t_2) * 0.5d0))) * sin(ky)) * sin(th)
else if (t_1 <= (-0.1d0)) then
tmp = t_3
else if (t_1 <= 1d-23) then
tmp = (sin(ky) / sin(kx)) * sin(th)
else if (t_1 <= 0.9972580999534978d0) then
tmp = t_3
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
double t_2 = Math.cos((2.0 * ky));
double t_3 = (Math.sqrt((1.0 / (((1.0 - Math.cos((2.0 * kx))) - (t_2 - 1.0)) * 0.5))) * -th) * -Math.sin(ky);
double tmp;
if (t_1 <= -0.945) {
tmp = ((1.0 / Math.sqrt(((1.0 - t_2) * 0.5))) * Math.sin(ky)) * Math.sin(th);
} else if (t_1 <= -0.1) {
tmp = t_3;
} else if (t_1 <= 1e-23) {
tmp = (Math.sin(ky) / Math.sin(kx)) * Math.sin(th);
} else if (t_1 <= 0.9972580999534978) {
tmp = t_3;
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0))) t_2 = math.cos((2.0 * ky)) t_3 = (math.sqrt((1.0 / (((1.0 - math.cos((2.0 * kx))) - (t_2 - 1.0)) * 0.5))) * -th) * -math.sin(ky) tmp = 0 if t_1 <= -0.945: tmp = ((1.0 / math.sqrt(((1.0 - t_2) * 0.5))) * math.sin(ky)) * math.sin(th) elif t_1 <= -0.1: tmp = t_3 elif t_1 <= 1e-23: tmp = (math.sin(ky) / math.sin(kx)) * math.sin(th) elif t_1 <= 0.9972580999534978: tmp = t_3 else: tmp = math.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(sqrt(Float64(1.0 / Float64(Float64(Float64(1.0 - cos(Float64(2.0 * kx))) - Float64(t_2 - 1.0)) * 0.5))) * Float64(-th)) * Float64(-sin(ky))) tmp = 0.0 if (t_1 <= -0.945) tmp = Float64(Float64(Float64(1.0 / sqrt(Float64(Float64(1.0 - t_2) * 0.5))) * sin(ky)) * sin(th)); elseif (t_1 <= -0.1) tmp = t_3; elseif (t_1 <= 1e-23) tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); elseif (t_1 <= 0.9972580999534978) tmp = t_3; else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))); t_2 = cos((2.0 * ky)); t_3 = (sqrt((1.0 / (((1.0 - cos((2.0 * kx))) - (t_2 - 1.0)) * 0.5))) * -th) * -sin(ky); tmp = 0.0; if (t_1 <= -0.945) tmp = ((1.0 / sqrt(((1.0 - t_2) * 0.5))) * sin(ky)) * sin(th); elseif (t_1 <= -0.1) tmp = t_3; elseif (t_1 <= 1e-23) tmp = (sin(ky) / sin(kx)) * sin(th); elseif (t_1 <= 0.9972580999534978) tmp = t_3; else tmp = sin(th); end tmp_2 = 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[(N[Sqrt[N[(1.0 / N[(N[(N[(1.0 - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(t$95$2 - 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-th)), $MachinePrecision] * (-N[Sin[ky], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[t$95$1, -0.945], N[(N[(N[(1.0 / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.1], t$95$3, If[LessEqual[t$95$1, 1e-23], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.9972580999534978], t$95$3, N[Sin[th], $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(\sqrt{\frac{1}{\left(\left(1 - \cos \left(2 \cdot kx\right)\right) - \left(t\_2 - 1\right)\right) \cdot 0.5}} \cdot \left(-th\right)\right) \cdot \left(-\sin ky\right)\\
\mathbf{if}\;t\_1 \leq -0.945:\\
\;\;\;\;\left(\frac{1}{\sqrt{\left(1 - t\_2\right) \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq -0.1:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_1 \leq 10^{-23}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 0.9972580999534978:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.944999999999999951Initial program 90.6%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites73.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6462.2
Applied rewrites62.2%
if -0.944999999999999951 < (/.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.10000000000000001 or 9.9999999999999996e-24 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99725809995349779Initial program 99.4%
Applied rewrites99.2%
Taylor expanded in th around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites49.3%
if -0.10000000000000001 < (/.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.9999999999999996e-24Initial program 99.7%
Taylor expanded in ky around 0
lower-sin.f6464.1
Applied rewrites64.1%
if 0.99725809995349779 < (/.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 82.5%
Taylor expanded in kx around 0
lower-sin.f6491.5
Applied rewrites91.5%
Final simplification65.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (cos (* 2.0 kx)))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))))
(t_3 (cos (* 2.0 ky)))
(t_4 (- 1.0 t_3))
(t_5 (* th (sin ky))))
(if (<= t_2 -0.945)
(* (* (/ 1.0 (sqrt (* t_4 0.5))) (sin ky)) (sin th))
(if (<= t_2 -0.1)
(* (sqrt (/ 2.0 (- 1.0 (- t_1 t_4)))) t_5)
(if (<= t_2 1e-23)
(* (/ (sin ky) (sin kx)) (sin th))
(if (<= t_2 0.9972580999534978)
(* (sqrt (/ 2.0 (- (- 2.0 t_3) t_1))) t_5)
(sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = cos((2.0 * kx));
double t_2 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
double t_3 = cos((2.0 * ky));
double t_4 = 1.0 - t_3;
double t_5 = th * sin(ky);
double tmp;
if (t_2 <= -0.945) {
tmp = ((1.0 / sqrt((t_4 * 0.5))) * sin(ky)) * sin(th);
} else if (t_2 <= -0.1) {
tmp = sqrt((2.0 / (1.0 - (t_1 - t_4)))) * t_5;
} else if (t_2 <= 1e-23) {
tmp = (sin(ky) / sin(kx)) * sin(th);
} else if (t_2 <= 0.9972580999534978) {
tmp = sqrt((2.0 / ((2.0 - t_3) - t_1))) * t_5;
} 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) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_1 = cos((2.0d0 * kx))
t_2 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
t_3 = cos((2.0d0 * ky))
t_4 = 1.0d0 - t_3
t_5 = th * sin(ky)
if (t_2 <= (-0.945d0)) then
tmp = ((1.0d0 / sqrt((t_4 * 0.5d0))) * sin(ky)) * sin(th)
else if (t_2 <= (-0.1d0)) then
tmp = sqrt((2.0d0 / (1.0d0 - (t_1 - t_4)))) * t_5
else if (t_2 <= 1d-23) then
tmp = (sin(ky) / sin(kx)) * sin(th)
else if (t_2 <= 0.9972580999534978d0) then
tmp = sqrt((2.0d0 / ((2.0d0 - t_3) - t_1))) * t_5
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.cos((2.0 * kx));
double t_2 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
double t_3 = Math.cos((2.0 * ky));
double t_4 = 1.0 - t_3;
double t_5 = th * Math.sin(ky);
double tmp;
if (t_2 <= -0.945) {
tmp = ((1.0 / Math.sqrt((t_4 * 0.5))) * Math.sin(ky)) * Math.sin(th);
} else if (t_2 <= -0.1) {
tmp = Math.sqrt((2.0 / (1.0 - (t_1 - t_4)))) * t_5;
} else if (t_2 <= 1e-23) {
tmp = (Math.sin(ky) / Math.sin(kx)) * Math.sin(th);
} else if (t_2 <= 0.9972580999534978) {
tmp = Math.sqrt((2.0 / ((2.0 - t_3) - t_1))) * t_5;
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.cos((2.0 * kx)) t_2 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0))) t_3 = math.cos((2.0 * ky)) t_4 = 1.0 - t_3 t_5 = th * math.sin(ky) tmp = 0 if t_2 <= -0.945: tmp = ((1.0 / math.sqrt((t_4 * 0.5))) * math.sin(ky)) * math.sin(th) elif t_2 <= -0.1: tmp = math.sqrt((2.0 / (1.0 - (t_1 - t_4)))) * t_5 elif t_2 <= 1e-23: tmp = (math.sin(ky) / math.sin(kx)) * math.sin(th) elif t_2 <= 0.9972580999534978: tmp = math.sqrt((2.0 / ((2.0 - t_3) - t_1))) * t_5 else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = cos(Float64(2.0 * kx)) t_2 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) t_3 = cos(Float64(2.0 * ky)) t_4 = Float64(1.0 - t_3) t_5 = Float64(th * sin(ky)) tmp = 0.0 if (t_2 <= -0.945) tmp = Float64(Float64(Float64(1.0 / sqrt(Float64(t_4 * 0.5))) * sin(ky)) * sin(th)); elseif (t_2 <= -0.1) tmp = Float64(sqrt(Float64(2.0 / Float64(1.0 - Float64(t_1 - t_4)))) * t_5); elseif (t_2 <= 1e-23) tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); elseif (t_2 <= 0.9972580999534978) tmp = Float64(sqrt(Float64(2.0 / Float64(Float64(2.0 - t_3) - t_1))) * t_5); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = cos((2.0 * kx)); t_2 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))); t_3 = cos((2.0 * ky)); t_4 = 1.0 - t_3; t_5 = th * sin(ky); tmp = 0.0; if (t_2 <= -0.945) tmp = ((1.0 / sqrt((t_4 * 0.5))) * sin(ky)) * sin(th); elseif (t_2 <= -0.1) tmp = sqrt((2.0 / (1.0 - (t_1 - t_4)))) * t_5; elseif (t_2 <= 1e-23) tmp = (sin(ky) / sin(kx)) * sin(th); elseif (t_2 <= 0.9972580999534978) tmp = sqrt((2.0 / ((2.0 - t_3) - t_1))) * t_5; else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Cos[N[(2.0 * kx), $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]}, Block[{t$95$3 = N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(1.0 - t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -0.945], N[(N[(N[(1.0 / N[Sqrt[N[(t$95$4 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -0.1], N[(N[Sqrt[N[(2.0 / N[(1.0 - N[(t$95$1 - t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$5), $MachinePrecision], If[LessEqual[t$95$2, 1e-23], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.9972580999534978], N[(N[Sqrt[N[(2.0 / N[(N[(2.0 - t$95$3), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$5), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \cos \left(2 \cdot kx\right)\\
t_2 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
t_3 := \cos \left(2 \cdot ky\right)\\
t_4 := 1 - t\_3\\
t_5 := th \cdot \sin ky\\
\mathbf{if}\;t\_2 \leq -0.945:\\
\;\;\;\;\left(\frac{1}{\sqrt{t\_4 \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq -0.1:\\
\;\;\;\;\sqrt{\frac{2}{1 - \left(t\_1 - t\_4\right)}} \cdot t\_5\\
\mathbf{elif}\;t\_2 \leq 10^{-23}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq 0.9972580999534978:\\
\;\;\;\;\sqrt{\frac{2}{\left(2 - t\_3\right) - t\_1}} \cdot t\_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.944999999999999951Initial program 90.6%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites73.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6462.2
Applied rewrites62.2%
if -0.944999999999999951 < (/.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.10000000000000001Initial 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.3
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites99.4%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites60.8%
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
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
Applied rewrites60.8%
if -0.10000000000000001 < (/.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.9999999999999996e-24Initial program 99.7%
Taylor expanded in ky around 0
lower-sin.f6464.1
Applied rewrites64.1%
if 9.9999999999999996e-24 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99725809995349779Initial program 99.5%
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.1
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites99.1%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites37.9%
Taylor expanded in kx around inf
Applied rewrites38.0%
if 0.99725809995349779 < (/.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 82.5%
Taylor expanded in kx around 0
lower-sin.f6491.5
Applied rewrites91.5%
Final simplification65.3%
(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
(* (sqrt (/ 2.0 (- (- 2.0 t_2) (cos (* 2.0 kx))))) (* th (sin ky)))))
(if (<= t_1 -0.945)
(* (* (/ 1.0 (sqrt (* (- 1.0 t_2) 0.5))) (sin ky)) (sin th))
(if (<= t_1 -0.1)
t_3
(if (<= t_1 1e-23)
(* (/ (sin ky) (sin kx)) (sin th))
(if (<= t_1 0.9972580999534978) t_3 (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 = sqrt((2.0 / ((2.0 - t_2) - cos((2.0 * kx))))) * (th * sin(ky));
double tmp;
if (t_1 <= -0.945) {
tmp = ((1.0 / sqrt(((1.0 - t_2) * 0.5))) * sin(ky)) * sin(th);
} else if (t_1 <= -0.1) {
tmp = t_3;
} else if (t_1 <= 1e-23) {
tmp = (sin(ky) / sin(kx)) * sin(th);
} else if (t_1 <= 0.9972580999534978) {
tmp = t_3;
} 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) :: t_3
real(8) :: tmp
t_1 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
t_2 = cos((2.0d0 * ky))
t_3 = sqrt((2.0d0 / ((2.0d0 - t_2) - cos((2.0d0 * kx))))) * (th * sin(ky))
if (t_1 <= (-0.945d0)) then
tmp = ((1.0d0 / sqrt(((1.0d0 - t_2) * 0.5d0))) * sin(ky)) * sin(th)
else if (t_1 <= (-0.1d0)) then
tmp = t_3
else if (t_1 <= 1d-23) then
tmp = (sin(ky) / sin(kx)) * sin(th)
else if (t_1 <= 0.9972580999534978d0) then
tmp = t_3
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
double t_2 = Math.cos((2.0 * ky));
double t_3 = Math.sqrt((2.0 / ((2.0 - t_2) - Math.cos((2.0 * kx))))) * (th * Math.sin(ky));
double tmp;
if (t_1 <= -0.945) {
tmp = ((1.0 / Math.sqrt(((1.0 - t_2) * 0.5))) * Math.sin(ky)) * Math.sin(th);
} else if (t_1 <= -0.1) {
tmp = t_3;
} else if (t_1 <= 1e-23) {
tmp = (Math.sin(ky) / Math.sin(kx)) * Math.sin(th);
} else if (t_1 <= 0.9972580999534978) {
tmp = t_3;
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0))) t_2 = math.cos((2.0 * ky)) t_3 = math.sqrt((2.0 / ((2.0 - t_2) - math.cos((2.0 * kx))))) * (th * math.sin(ky)) tmp = 0 if t_1 <= -0.945: tmp = ((1.0 / math.sqrt(((1.0 - t_2) * 0.5))) * math.sin(ky)) * math.sin(th) elif t_1 <= -0.1: tmp = t_3 elif t_1 <= 1e-23: tmp = (math.sin(ky) / math.sin(kx)) * math.sin(th) elif t_1 <= 0.9972580999534978: tmp = t_3 else: tmp = math.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(sqrt(Float64(2.0 / Float64(Float64(2.0 - t_2) - cos(Float64(2.0 * kx))))) * Float64(th * sin(ky))) tmp = 0.0 if (t_1 <= -0.945) tmp = Float64(Float64(Float64(1.0 / sqrt(Float64(Float64(1.0 - t_2) * 0.5))) * sin(ky)) * sin(th)); elseif (t_1 <= -0.1) tmp = t_3; elseif (t_1 <= 1e-23) tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); elseif (t_1 <= 0.9972580999534978) tmp = t_3; else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))); t_2 = cos((2.0 * ky)); t_3 = sqrt((2.0 / ((2.0 - t_2) - cos((2.0 * kx))))) * (th * sin(ky)); tmp = 0.0; if (t_1 <= -0.945) tmp = ((1.0 / sqrt(((1.0 - t_2) * 0.5))) * sin(ky)) * sin(th); elseif (t_1 <= -0.1) tmp = t_3; elseif (t_1 <= 1e-23) tmp = (sin(ky) / sin(kx)) * sin(th); elseif (t_1 <= 0.9972580999534978) tmp = t_3; else tmp = sin(th); end tmp_2 = 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[Sqrt[N[(2.0 / N[(N[(2.0 - t$95$2), $MachinePrecision] - N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.945], N[(N[(N[(1.0 / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.1], t$95$3, If[LessEqual[t$95$1, 1e-23], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.9972580999534978], t$95$3, N[Sin[th], $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 := \sqrt{\frac{2}{\left(2 - t\_2\right) - \cos \left(2 \cdot kx\right)}} \cdot \left(th \cdot \sin ky\right)\\
\mathbf{if}\;t\_1 \leq -0.945:\\
\;\;\;\;\left(\frac{1}{\sqrt{\left(1 - t\_2\right) \cdot 0.5}} \cdot \sin ky\right) \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq -0.1:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_1 \leq 10^{-23}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 0.9972580999534978:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.944999999999999951Initial program 90.6%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites73.1%
Taylor expanded in kx around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6462.2
Applied rewrites62.2%
if -0.944999999999999951 < (/.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.10000000000000001 or 9.9999999999999996e-24 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.99725809995349779Initial 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.2
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites99.2%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites49.2%
Taylor expanded in kx around inf
Applied rewrites49.2%
if -0.10000000000000001 < (/.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.9999999999999996e-24Initial program 99.7%
Taylor expanded in ky around 0
lower-sin.f6464.1
Applied rewrites64.1%
if 0.99725809995349779 < (/.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 82.5%
Taylor expanded in kx around 0
lower-sin.f6491.5
Applied rewrites91.5%
Final simplification65.3%
(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 -1.0)
(*
(* (fma (* th th) -0.16666666666666666 1.0) th)
(/ (sin ky) (sqrt (* (- 1.0 (cos (* 2.0 ky))) 0.5))))
(if (<= t_1 2e-257)
(* (/ (sin th) (sqrt (* (- 1.0 (cos (+ kx kx))) 0.5))) (sin ky))
(if (<= t_1 1e-7) (* (/ ky (sin kx)) (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 <= -1.0) {
tmp = (fma((th * th), -0.16666666666666666, 1.0) * th) * (sin(ky) / sqrt(((1.0 - cos((2.0 * ky))) * 0.5)));
} else if (t_1 <= 2e-257) {
tmp = (sin(th) / sqrt(((1.0 - cos((kx + kx))) * 0.5))) * sin(ky);
} else if (t_1 <= 1e-7) {
tmp = (ky / sin(kx)) * 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 <= -1.0) tmp = Float64(Float64(fma(Float64(th * th), -0.16666666666666666, 1.0) * th) * Float64(sin(ky) / sqrt(Float64(Float64(1.0 - cos(Float64(2.0 * ky))) * 0.5)))); elseif (t_1 <= 2e-257) tmp = Float64(Float64(sin(th) / sqrt(Float64(Float64(1.0 - cos(Float64(kx + kx))) * 0.5))) * sin(ky)); elseif (t_1 <= 1e-7) tmp = Float64(Float64(ky / sin(kx)) * 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, -1.0], N[(N[(N[(N[(th * th), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * th), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-257], 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], If[LessEqual[t$95$1, 1e-7], N[(N[(ky / N[Sin[kx], $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 -1:\\
\;\;\;\;\left(\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th\right) \cdot \frac{\sin ky}{\sqrt{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot 0.5}}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-257}:\\
\;\;\;\;\frac{\sin th}{\sqrt{\left(1 - \cos \left(kx + kx\right)\right) \cdot 0.5}} \cdot \sin ky\\
\mathbf{elif}\;t\_1 \leq 10^{-7}:\\
\;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -1Initial program 89.0%
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-+.f6468.9
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites68.3%
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-*.f6468.3
Applied rewrites68.3%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6433.0
Applied rewrites33.0%
if -1 < (/.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-257Initial program 99.6%
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.5
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites84.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-*.f6410.1
Applied rewrites10.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6410.1
Applied rewrites52.2%
if 2e-257 < (/.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.9999999999999995e-8Initial program 99.6%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sin.f6460.6
Applied rewrites60.6%
if 9.9999999999999995e-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 89.1%
Taylor expanded in kx around 0
lower-sin.f6463.9
Applied rewrites63.9%
Final simplification53.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.1)
(* (/ (sin ky) (sqrt (* 0.5 (- 1.0 (cos (+ ky ky)))))) (sin th))
(if (<= t_1 1e-7) (* (/ (sin ky) (sin kx)) (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.1) {
tmp = (sin(ky) / sqrt((0.5 * (1.0 - cos((ky + ky)))))) * sin(th);
} else if (t_1 <= 1e-7) {
tmp = (sin(ky) / sin(kx)) * sin(th);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
if (t_1 <= (-0.1d0)) then
tmp = (sin(ky) / sqrt((0.5d0 * (1.0d0 - cos((ky + ky)))))) * sin(th)
else if (t_1 <= 1d-7) then
tmp = (sin(ky) / sin(kx)) * sin(th)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
double tmp;
if (t_1 <= -0.1) {
tmp = (Math.sin(ky) / Math.sqrt((0.5 * (1.0 - Math.cos((ky + ky)))))) * Math.sin(th);
} else if (t_1 <= 1e-7) {
tmp = (Math.sin(ky) / Math.sin(kx)) * Math.sin(th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0))) tmp = 0 if t_1 <= -0.1: tmp = (math.sin(ky) / math.sqrt((0.5 * (1.0 - math.cos((ky + ky)))))) * math.sin(th) elif t_1 <= 1e-7: tmp = (math.sin(ky) / math.sin(kx)) * math.sin(th) else: tmp = math.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.1) tmp = Float64(Float64(sin(ky) / sqrt(Float64(0.5 * Float64(1.0 - cos(Float64(ky + ky)))))) * sin(th)); elseif (t_1 <= 1e-7) tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))); tmp = 0.0; if (t_1 <= -0.1) tmp = (sin(ky) / sqrt((0.5 * (1.0 - cos((ky + ky)))))) * sin(th); elseif (t_1 <= 1e-7) tmp = (sin(ky) / sin(kx)) * sin(th); else tmp = sin(th); end tmp_2 = 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.1], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(0.5 * N[(1.0 - N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-7], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
\mathbf{if}\;t\_1 \leq -0.1:\\
\;\;\;\;\frac{\sin ky}{\sqrt{0.5 \cdot \left(1 - \cos \left(ky + ky\right)\right)}} \cdot \sin th\\
\mathbf{elif}\;t\_1 \leq 10^{-7}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001Initial program 93.9%
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-+.f6483.4
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites83.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-*.f6446.2
Applied rewrites46.2%
Applied rewrites46.2%
if -0.10000000000000001 < (/.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.9999999999999995e-8Initial program 99.7%
Taylor expanded in ky around 0
lower-sin.f6463.5
Applied rewrites63.5%
if 9.9999999999999995e-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 89.1%
Taylor expanded in kx around 0
lower-sin.f6463.9
Applied rewrites63.9%
Final simplification58.0%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0))))))
(if (<= t_1 -1.0)
(*
(* (fma (* th th) -0.16666666666666666 1.0) th)
(/ (sin ky) (sqrt (* (- 1.0 (cos (* 2.0 ky))) 0.5))))
(if (<= t_1 1e-7) (* (/ (sin ky) (sin kx)) (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 <= -1.0) {
tmp = (fma((th * th), -0.16666666666666666, 1.0) * th) * (sin(ky) / sqrt(((1.0 - cos((2.0 * ky))) * 0.5)));
} else if (t_1 <= 1e-7) {
tmp = (sin(ky) / sin(kx)) * 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 <= -1.0) tmp = Float64(Float64(fma(Float64(th * th), -0.16666666666666666, 1.0) * th) * Float64(sin(ky) / sqrt(Float64(Float64(1.0 - cos(Float64(2.0 * ky))) * 0.5)))); elseif (t_1 <= 1e-7) tmp = Float64(Float64(sin(ky) / sin(kx)) * 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, -1.0], N[(N[(N[(N[(th * th), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * th), $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-7], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
\mathbf{if}\;t\_1 \leq -1:\\
\;\;\;\;\left(\mathsf{fma}\left(th \cdot th, -0.16666666666666666, 1\right) \cdot th\right) \cdot \frac{\sin ky}{\sqrt{\left(1 - \cos \left(2 \cdot ky\right)\right) \cdot 0.5}}\\
\mathbf{elif}\;t\_1 \leq 10^{-7}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -1Initial program 89.0%
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-+.f6468.9
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites68.3%
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-*.f6468.3
Applied rewrites68.3%
Taylor expanded in th around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6433.0
Applied rewrites33.0%
if -1 < (/.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.9999999999999995e-8Initial program 99.6%
Taylor expanded in ky around 0
lower-sin.f6448.2
Applied rewrites48.2%
if 9.9999999999999995e-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 89.1%
Taylor expanded in kx around 0
lower-sin.f6463.9
Applied rewrites63.9%
Final simplification50.6%
(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.1)
(*
(sqrt (/ -1.0 (- (cos (* 2.0 ky)) 1.0)))
(* (sqrt 2.0) (* th (sin ky))))
(if (<= t_1 1e-7) (* (/ ky (sin kx)) (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.1) {
tmp = sqrt((-1.0 / (cos((2.0 * ky)) - 1.0))) * (sqrt(2.0) * (th * sin(ky)));
} else if (t_1 <= 1e-7) {
tmp = (ky / sin(kx)) * sin(th);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
if (t_1 <= (-0.1d0)) then
tmp = sqrt(((-1.0d0) / (cos((2.0d0 * ky)) - 1.0d0))) * (sqrt(2.0d0) * (th * sin(ky)))
else if (t_1 <= 1d-7) then
tmp = (ky / sin(kx)) * sin(th)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
double tmp;
if (t_1 <= -0.1) {
tmp = Math.sqrt((-1.0 / (Math.cos((2.0 * ky)) - 1.0))) * (Math.sqrt(2.0) * (th * Math.sin(ky)));
} else if (t_1 <= 1e-7) {
tmp = (ky / Math.sin(kx)) * Math.sin(th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0))) tmp = 0 if t_1 <= -0.1: tmp = math.sqrt((-1.0 / (math.cos((2.0 * ky)) - 1.0))) * (math.sqrt(2.0) * (th * math.sin(ky))) elif t_1 <= 1e-7: tmp = (ky / math.sin(kx)) * math.sin(th) else: tmp = math.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.1) tmp = Float64(sqrt(Float64(-1.0 / Float64(cos(Float64(2.0 * ky)) - 1.0))) * Float64(sqrt(2.0) * Float64(th * sin(ky)))); elseif (t_1 <= 1e-7) tmp = Float64(Float64(ky / sin(kx)) * sin(th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))); tmp = 0.0; if (t_1 <= -0.1) tmp = sqrt((-1.0 / (cos((2.0 * ky)) - 1.0))) * (sqrt(2.0) * (th * sin(ky))); elseif (t_1 <= 1e-7) tmp = (ky / sin(kx)) * sin(th); else tmp = sin(th); end tmp_2 = 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.1], N[(N[Sqrt[N[(-1.0 / N[(N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-7], N[(N[(ky / N[Sin[kx], $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.1:\\
\;\;\;\;\sqrt{\frac{-1}{\cos \left(2 \cdot ky\right) - 1}} \cdot \left(\sqrt{2} \cdot \left(th \cdot \sin ky\right)\right)\\
\mathbf{elif}\;t\_1 \leq 10^{-7}:\\
\;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001Initial program 93.9%
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-+.f6483.4
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites83.1%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.1%
Taylor expanded in kx around inf
Applied rewrites43.0%
Taylor expanded in kx around 0
Applied rewrites23.5%
if -0.10000000000000001 < (/.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.9999999999999995e-8Initial program 99.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sin.f6463.5
Applied rewrites63.5%
if 9.9999999999999995e-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 89.1%
Taylor expanded in kx around 0
lower-sin.f6463.9
Applied rewrites63.9%
Final simplification50.4%
(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.1)
(* (sqrt (/ 2.0 (- 1.0 (cos (* 2.0 ky))))) (* th (sin ky)))
(if (<= t_1 1e-7) (* (/ ky (sin kx)) (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.1) {
tmp = sqrt((2.0 / (1.0 - cos((2.0 * ky))))) * (th * sin(ky));
} else if (t_1 <= 1e-7) {
tmp = (ky / sin(kx)) * sin(th);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))
if (t_1 <= (-0.1d0)) then
tmp = sqrt((2.0d0 / (1.0d0 - cos((2.0d0 * ky))))) * (th * sin(ky))
else if (t_1 <= 1d-7) then
tmp = (ky / sin(kx)) * sin(th)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)));
double tmp;
if (t_1 <= -0.1) {
tmp = Math.sqrt((2.0 / (1.0 - Math.cos((2.0 * ky))))) * (th * Math.sin(ky));
} else if (t_1 <= 1e-7) {
tmp = (ky / Math.sin(kx)) * Math.sin(th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0))) tmp = 0 if t_1 <= -0.1: tmp = math.sqrt((2.0 / (1.0 - math.cos((2.0 * ky))))) * (th * math.sin(ky)) elif t_1 <= 1e-7: tmp = (ky / math.sin(kx)) * math.sin(th) else: tmp = math.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.1) tmp = Float64(sqrt(Float64(2.0 / Float64(1.0 - cos(Float64(2.0 * ky))))) * Float64(th * sin(ky))); elseif (t_1 <= 1e-7) tmp = Float64(Float64(ky / sin(kx)) * sin(th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))); tmp = 0.0; if (t_1 <= -0.1) tmp = sqrt((2.0 / (1.0 - cos((2.0 * ky))))) * (th * sin(ky)); elseif (t_1 <= 1e-7) tmp = (ky / sin(kx)) * sin(th); else tmp = sin(th); end tmp_2 = 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.1], N[(N[Sqrt[N[(2.0 / N[(1.0 - N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(th * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-7], N[(N[(ky / N[Sin[kx], $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.1:\\
\;\;\;\;\sqrt{\frac{2}{1 - \cos \left(2 \cdot ky\right)}} \cdot \left(th \cdot \sin ky\right)\\
\mathbf{elif}\;t\_1 \leq 10^{-7}:\\
\;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001Initial program 93.9%
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-+.f6483.4
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites83.1%
Taylor expanded in th around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.1%
Taylor expanded in kx around 0
Applied rewrites23.5%
if -0.10000000000000001 < (/.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.9999999999999995e-8Initial program 99.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sin.f6463.5
Applied rewrites63.5%
if 9.9999999999999995e-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 89.1%
Taylor expanded in kx around 0
lower-sin.f6463.9
Applied rewrites63.9%
Final simplification50.5%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 1e-7) (* (/ ky (sin kx)) (sin th)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) <= 1e-7) {
tmp = (ky / sin(kx)) * sin(th);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))) <= 1d-7) then
tmp = (ky / sin(kx)) * sin(th)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)))) <= 1e-7) {
tmp = (ky / Math.sin(kx)) * Math.sin(th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))) <= 1e-7: tmp = (ky / math.sin(kx)) * math.sin(th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 1e-7) tmp = Float64(Float64(ky / sin(kx)) * sin(th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 1e-7) tmp = (ky / sin(kx)) * sin(th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1e-7], N[(N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-7}:\\
\;\;\;\;\frac{ky}{\sin kx} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.9999999999999995e-8Initial program 96.9%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sin.f6435.1
Applied rewrites35.1%
if 9.9999999999999995e-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 89.1%
Taylor expanded in kx around 0
lower-sin.f6463.9
Applied rewrites63.9%
Final simplification44.3%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 1e-7) (* (/ (sin th) (sin kx)) ky) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) <= 1e-7) {
tmp = (sin(th) / sin(kx)) * ky;
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))) <= 1d-7) then
tmp = (sin(th) / sin(kx)) * ky
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)))) <= 1e-7) {
tmp = (Math.sin(th) / Math.sin(kx)) * ky;
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))) <= 1e-7: tmp = (math.sin(th) / math.sin(kx)) * ky else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 1e-7) 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)))) <= 1e-7) tmp = (sin(th) / sin(kx)) * ky; else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1e-7], 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 10^{-7}:\\
\;\;\;\;\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))))) < 9.9999999999999995e-8Initial program 96.9%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites31.4%
Taylor expanded in ky around 0
Applied rewrites35.1%
if 9.9999999999999995e-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 89.1%
Taylor expanded in kx around 0
lower-sin.f6463.9
Applied rewrites63.9%
Final simplification44.3%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 1e-7) (/ (* (sin th) ky) (* (fma -0.16666666666666666 (* kx kx) 1.0) kx)) (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-7) {
tmp = (sin(th) * ky) / (fma(-0.16666666666666666, (kx * kx), 1.0) * kx);
} 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)))) <= 1e-7) tmp = Float64(Float64(sin(th) * ky) / Float64(fma(-0.16666666666666666, Float64(kx * kx), 1.0) * kx)); 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], 1e-7], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / N[(N[(-0.16666666666666666 * N[(kx * kx), $MachinePrecision] + 1.0), $MachinePrecision] * kx), $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 10^{-7}:\\
\;\;\;\;\frac{\sin th \cdot ky}{\mathsf{fma}\left(-0.16666666666666666, kx \cdot kx, 1\right) \cdot kx}\\
\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.9999999999999995e-8Initial program 96.9%
Taylor expanded in kx around 0
lower-sin.f643.7
Applied rewrites3.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6434.6
Applied rewrites34.6%
Taylor expanded in kx around 0
Applied rewrites23.7%
if 9.9999999999999995e-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 89.1%
Taylor expanded in kx around 0
lower-sin.f6463.9
Applied rewrites63.9%
Final simplification36.6%
(FPCore (kx ky th)
:precision binary64
(if (<=
(*
(/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0))))
(sin th))
1e-323)
(* (* (* 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)) <= 1e-323) {
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)) <= 1d-323) 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)) <= 1e-323) {
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)) <= 1e-323: 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)) <= 1e-323) 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)) <= 1e-323) 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], 1e-323], 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 10^{-323}:\\
\;\;\;\;\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)) < 9.88131e-324Initial program 93.7%
Taylor expanded in kx around 0
lower-sin.f6420.8
Applied rewrites20.8%
Taylor expanded in th around 0
Applied rewrites9.9%
Taylor expanded in th around inf
Applied rewrites19.1%
if 9.88131e-324 < (*.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.6%
Taylor expanded in kx around 0
lower-sin.f6426.6
Applied rewrites26.6%
Taylor expanded in th around 0
Applied rewrites15.5%
Taylor expanded in th around 0
Applied rewrites15.4%
Final simplification17.7%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 1e-7) (/ (* (sin th) ky) kx) (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-7) {
tmp = (sin(th) * ky) / kx;
} 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-7) then
tmp = (sin(th) * ky) / kx
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-7) {
tmp = (Math.sin(th) * ky) / kx;
} 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-7: tmp = (math.sin(th) * ky) / kx 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-7) tmp = Float64(Float64(sin(th) * ky) / kx); 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-7) tmp = (sin(th) * ky) / kx; 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-7], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / kx), $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^{-7}:\\
\;\;\;\;\frac{\sin th \cdot ky}{kx}\\
\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.9999999999999995e-8Initial program 96.9%
Taylor expanded in kx around 0
lower-sin.f643.7
Applied rewrites3.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6434.6
Applied rewrites34.6%
Taylor expanded in kx around 0
Applied rewrites24.1%
if 9.9999999999999995e-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 89.1%
Taylor expanded in kx around 0
lower-sin.f6463.9
Applied rewrites63.9%
Final simplification36.8%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 1e-7) (* (/ ky (sin kx)) th) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)))) <= 1e-7) {
tmp = (ky / sin(kx)) * th;
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((sin(ky) / sqrt(((sin(ky) ** 2.0d0) + (sin(kx) ** 2.0d0)))) <= 1d-7) then
tmp = (ky / sin(kx)) * th
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + Math.pow(Math.sin(kx), 2.0)))) <= 1e-7) {
tmp = (ky / Math.sin(kx)) * th;
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0)))) <= 1e-7: tmp = (ky / math.sin(kx)) * th else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 1e-7) tmp = Float64(Float64(ky / sin(kx)) * th); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 1e-7) tmp = (ky / sin(kx)) * th; else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1e-7], N[(N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * th), $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^{-7}:\\
\;\;\;\;\frac{ky}{\sin kx} \cdot 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))))) < 9.9999999999999995e-8Initial program 96.9%
Taylor expanded in kx around 0
lower-sin.f643.7
Applied rewrites3.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6434.6
Applied rewrites34.6%
Taylor expanded in th around 0
Applied rewrites24.2%
if 9.9999999999999995e-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 89.1%
Taylor expanded in kx around 0
lower-sin.f6463.9
Applied rewrites63.9%
Final simplification36.9%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 9.5e-68) (* (* (* 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)))) <= 9.5e-68) {
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)))) <= 9.5d-68) 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)))) <= 9.5e-68) {
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)))) <= 9.5e-68: 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)))) <= 9.5e-68) 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)))) <= 9.5e-68) 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], 9.5e-68], 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 9.5 \cdot 10^{-68}:\\
\;\;\;\;\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))))) < 9.4999999999999997e-68Initial program 96.8%
Taylor expanded in kx around 0
lower-sin.f643.5
Applied rewrites3.5%
Taylor expanded in th around 0
Applied rewrites3.4%
Taylor expanded in th around inf
Applied rewrites18.2%
if 9.4999999999999997e-68 < (/.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 90.0%
Taylor expanded in kx around 0
lower-sin.f6458.9
Applied rewrites58.9%
Final simplification32.5%
(FPCore (kx ky th)
:precision binary64
(if (<= ky 0.003)
(*
(/
(sin ky)
(hypot (* (fma -0.16666666666666666 (* ky ky) 1.0) ky) (sin 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 (ky <= 0.003) {
tmp = (sin(ky) / hypot((fma(-0.16666666666666666, (ky * ky), 1.0) * ky), sin(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 (ky <= 0.003) tmp = Float64(Float64(sin(ky) / hypot(Float64(fma(-0.16666666666666666, Float64(ky * ky), 1.0) * ky), sin(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[ky, 0.003], N[(N[(N[Sin[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[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}\;ky \leq 0.003:\\
\;\;\;\;\frac{\sin 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 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 ky < 0.0030000000000000001Initial program 92.8%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6463.1
Applied rewrites63.1%
if 0.0030000000000000001 < ky Initial program 99.8%
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.2
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
Applied rewrites99.2%
(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 94.4%
Taylor expanded in kx around 0
lower-sin.f6423.0
Applied rewrites23.0%
Taylor expanded in th around 0
Applied rewrites12.0%
Taylor expanded in th around 0
Applied rewrites12.2%
herbie shell --seed 2024240
(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)))