
(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 19 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 ky) (hypot (sin kx) (sin ky))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / hypot(sin(kx), sin(ky))) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / hypot(sin(kx), sin(ky))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / hypot(sin(kx), sin(ky))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin th
\end{array}
Initial program 95.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6495.2
lift-sqrt.f64N/A
lift-+.f64N/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) (hypot kx (sin ky))) (sin th)))
(t_2 (hypot (sin kx) (sin ky)))
(t_3 (pow (sin kx) 2.0))
(t_4 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) t_3)))))
(if (<= t_4 -1.0)
t_1
(if (<= t_4 -0.4)
(* th (/ (sin ky) t_2))
(if (<= t_4 1e-6)
(* (* (sqrt (/ 1.0 t_3)) (sin ky)) (sin th))
(if (<= t_4 0.995) (/ th (/ t_2 (sin ky))) t_1))))))
double code(double kx, double ky, double th) {
double t_1 = (sin(ky) / hypot(kx, sin(ky))) * sin(th);
double t_2 = hypot(sin(kx), sin(ky));
double t_3 = pow(sin(kx), 2.0);
double t_4 = sin(ky) / sqrt((pow(sin(ky), 2.0) + t_3));
double tmp;
if (t_4 <= -1.0) {
tmp = t_1;
} else if (t_4 <= -0.4) {
tmp = th * (sin(ky) / t_2);
} else if (t_4 <= 1e-6) {
tmp = (sqrt((1.0 / t_3)) * sin(ky)) * sin(th);
} else if (t_4 <= 0.995) {
tmp = th / (t_2 / sin(ky));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = (Math.sin(ky) / Math.hypot(kx, Math.sin(ky))) * Math.sin(th);
double t_2 = Math.hypot(Math.sin(kx), Math.sin(ky));
double t_3 = Math.pow(Math.sin(kx), 2.0);
double t_4 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(ky), 2.0) + t_3));
double tmp;
if (t_4 <= -1.0) {
tmp = t_1;
} else if (t_4 <= -0.4) {
tmp = th * (Math.sin(ky) / t_2);
} else if (t_4 <= 1e-6) {
tmp = (Math.sqrt((1.0 / t_3)) * Math.sin(ky)) * Math.sin(th);
} else if (t_4 <= 0.995) {
tmp = th / (t_2 / Math.sin(ky));
} else {
tmp = t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = (math.sin(ky) / math.hypot(kx, math.sin(ky))) * math.sin(th) t_2 = math.hypot(math.sin(kx), math.sin(ky)) t_3 = math.pow(math.sin(kx), 2.0) t_4 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + t_3)) tmp = 0 if t_4 <= -1.0: tmp = t_1 elif t_4 <= -0.4: tmp = th * (math.sin(ky) / t_2) elif t_4 <= 1e-6: tmp = (math.sqrt((1.0 / t_3)) * math.sin(ky)) * math.sin(th) elif t_4 <= 0.995: tmp = th / (t_2 / math.sin(ky)) else: tmp = t_1 return tmp
function code(kx, ky, th) t_1 = Float64(Float64(sin(ky) / hypot(kx, sin(ky))) * sin(th)) t_2 = hypot(sin(kx), sin(ky)) t_3 = sin(kx) ^ 2.0 t_4 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + t_3))) tmp = 0.0 if (t_4 <= -1.0) tmp = t_1; elseif (t_4 <= -0.4) tmp = Float64(th * Float64(sin(ky) / t_2)); elseif (t_4 <= 1e-6) tmp = Float64(Float64(sqrt(Float64(1.0 / t_3)) * sin(ky)) * sin(th)); elseif (t_4 <= 0.995) tmp = Float64(th / Float64(t_2 / sin(ky))); else tmp = t_1; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = (sin(ky) / hypot(kx, sin(ky))) * sin(th); t_2 = hypot(sin(kx), sin(ky)); t_3 = sin(kx) ^ 2.0; t_4 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + t_3)); tmp = 0.0; if (t_4 <= -1.0) tmp = t_1; elseif (t_4 <= -0.4) tmp = th * (sin(ky) / t_2); elseif (t_4 <= 1e-6) tmp = (sqrt((1.0 / t_3)) * sin(ky)) * sin(th); elseif (t_4 <= 0.995) tmp = th / (t_2 / sin(ky)); else tmp = t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[kx ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, -1.0], t$95$1, If[LessEqual[t$95$4, -0.4], N[(th * N[(N[Sin[ky], $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 1e-6], N[(N[(N[Sqrt[N[(1.0 / t$95$3), $MachinePrecision]], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 0.995], N[(th / N[(t$95$2 / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\mathsf{hypot}\left(kx, \sin ky\right)} \cdot \sin th\\
t_2 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
t_3 := {\sin kx}^{2}\\
t_4 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + t\_3}}\\
\mathbf{if}\;t\_4 \leq -1:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_4 \leq -0.4:\\
\;\;\;\;th \cdot \frac{\sin ky}{t\_2}\\
\mathbf{elif}\;t\_4 \leq 10^{-6}:\\
\;\;\;\;\left(\sqrt{\frac{1}{t\_3}} \cdot \sin ky\right) \cdot \sin th\\
\mathbf{elif}\;t\_4 \leq 0.995:\\
\;\;\;\;\frac{th}{\frac{t\_2}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\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))))) < -1 or 0.994999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 90.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.3
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f64100.0
Applied rewrites100.0%
Taylor expanded in kx around 0
Applied rewrites100.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))))) < -0.40000000000000002Initial program 96.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6496.2
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.4
Applied rewrites99.4%
Taylor expanded in th around 0
Applied rewrites44.8%
if -0.40000000000000002 < (/.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.99999999999999955e-7Initial program 99.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in kx around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
Taylor expanded in ky around 0
Applied rewrites96.4%
if 9.99999999999999955e-7 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.994999999999999996Initial program 99.3%
lift-pow.f64N/A
pow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
lower-*.f64N/A
metadata-eval99.4
Applied rewrites99.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-aN/A
lift-pow.f64N/A
Applied rewrites99.4%
Taylor expanded in th around 0
Applied rewrites51.6%
Final simplification89.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (/ (sin ky) (hypot kx (sin ky))) (sin th)))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))))
(t_3 (hypot (sin kx) (sin ky))))
(if (<= t_2 -1.0)
t_1
(if (<= t_2 -0.4)
(* th (/ (sin ky) t_3))
(if (<= t_2 1e-6)
(* (/ (sin ky) (hypot (sin kx) ky)) (sin th))
(if (<= t_2 0.995) (/ th (/ t_3 (sin ky))) t_1))))))
double code(double kx, double ky, double th) {
double t_1 = (sin(ky) / hypot(kx, sin(ky))) * sin(th);
double t_2 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
double t_3 = hypot(sin(kx), sin(ky));
double tmp;
if (t_2 <= -1.0) {
tmp = t_1;
} else if (t_2 <= -0.4) {
tmp = th * (sin(ky) / t_3);
} else if (t_2 <= 1e-6) {
tmp = (sin(ky) / hypot(sin(kx), ky)) * sin(th);
} else if (t_2 <= 0.995) {
tmp = th / (t_3 / sin(ky));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = (Math.sin(ky) / Math.hypot(kx, Math.sin(ky))) * Math.sin(th);
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.hypot(Math.sin(kx), Math.sin(ky));
double tmp;
if (t_2 <= -1.0) {
tmp = t_1;
} else if (t_2 <= -0.4) {
tmp = th * (Math.sin(ky) / t_3);
} else if (t_2 <= 1e-6) {
tmp = (Math.sin(ky) / Math.hypot(Math.sin(kx), ky)) * Math.sin(th);
} else if (t_2 <= 0.995) {
tmp = th / (t_3 / Math.sin(ky));
} else {
tmp = t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = (math.sin(ky) / math.hypot(kx, math.sin(ky))) * math.sin(th) t_2 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0))) t_3 = math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if t_2 <= -1.0: tmp = t_1 elif t_2 <= -0.4: tmp = th * (math.sin(ky) / t_3) elif t_2 <= 1e-6: tmp = (math.sin(ky) / math.hypot(math.sin(kx), ky)) * math.sin(th) elif t_2 <= 0.995: tmp = th / (t_3 / math.sin(ky)) else: tmp = t_1 return tmp
function code(kx, ky, th) t_1 = Float64(Float64(sin(ky) / hypot(kx, sin(ky))) * sin(th)) t_2 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) t_3 = hypot(sin(kx), sin(ky)) tmp = 0.0 if (t_2 <= -1.0) tmp = t_1; elseif (t_2 <= -0.4) tmp = Float64(th * Float64(sin(ky) / t_3)); elseif (t_2 <= 1e-6) tmp = Float64(Float64(sin(ky) / hypot(sin(kx), ky)) * sin(th)); elseif (t_2 <= 0.995) tmp = Float64(th / Float64(t_3 / sin(ky))); else tmp = t_1; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = (sin(ky) / hypot(kx, sin(ky))) * sin(th); t_2 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))); t_3 = hypot(sin(kx), sin(ky)); tmp = 0.0; if (t_2 <= -1.0) tmp = t_1; elseif (t_2 <= -0.4) tmp = th * (sin(ky) / t_3); elseif (t_2 <= 1e-6) tmp = (sin(ky) / hypot(sin(kx), ky)) * sin(th); elseif (t_2 <= 0.995) tmp = th / (t_3 / sin(ky)); else tmp = t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[kx ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $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[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[t$95$2, -1.0], t$95$1, If[LessEqual[t$95$2, -0.4], N[(th * N[(N[Sin[ky], $MachinePrecision] / t$95$3), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e-6], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.995], N[(th / N[(t$95$3 / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\mathsf{hypot}\left(kx, \sin ky\right)} \cdot \sin th\\
t_2 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
t_3 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
\mathbf{if}\;t\_2 \leq -1:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -0.4:\\
\;\;\;\;th \cdot \frac{\sin ky}{t\_3}\\
\mathbf{elif}\;t\_2 \leq 10^{-6}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, ky\right)} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq 0.995:\\
\;\;\;\;\frac{th}{\frac{t\_3}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\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))))) < -1 or 0.994999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 90.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.3
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f64100.0
Applied rewrites100.0%
Taylor expanded in kx around 0
Applied rewrites100.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))))) < -0.40000000000000002Initial program 96.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6496.2
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.4
Applied rewrites99.4%
Taylor expanded in th around 0
Applied rewrites44.8%
if -0.40000000000000002 < (/.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.99999999999999955e-7Initial program 99.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in ky around 0
Applied rewrites95.8%
if 9.99999999999999955e-7 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.994999999999999996Initial program 99.3%
lift-pow.f64N/A
pow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
lower-*.f64N/A
metadata-eval99.4
Applied rewrites99.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-aN/A
lift-pow.f64N/A
Applied rewrites99.4%
Taylor expanded in th around 0
Applied rewrites51.6%
Final simplification89.5%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (/ (sin ky) (hypot kx (sin ky))) (sin th)))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))))
(t_3 (* th (/ (sin ky) (hypot (sin kx) (sin ky))))))
(if (<= t_2 -1.0)
t_1
(if (<= t_2 -0.4)
t_3
(if (<= t_2 1e-6)
(* (/ (sin ky) (hypot (sin kx) ky)) (sin th))
(if (<= t_2 0.995) t_3 t_1))))))
double code(double kx, double ky, double th) {
double t_1 = (sin(ky) / hypot(kx, sin(ky))) * sin(th);
double t_2 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
double t_3 = th * (sin(ky) / hypot(sin(kx), sin(ky)));
double tmp;
if (t_2 <= -1.0) {
tmp = t_1;
} else if (t_2 <= -0.4) {
tmp = t_3;
} else if (t_2 <= 1e-6) {
tmp = (sin(ky) / hypot(sin(kx), ky)) * sin(th);
} else if (t_2 <= 0.995) {
tmp = t_3;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = (Math.sin(ky) / Math.hypot(kx, Math.sin(ky))) * Math.sin(th);
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 = th * (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky)));
double tmp;
if (t_2 <= -1.0) {
tmp = t_1;
} else if (t_2 <= -0.4) {
tmp = t_3;
} else if (t_2 <= 1e-6) {
tmp = (Math.sin(ky) / Math.hypot(Math.sin(kx), ky)) * Math.sin(th);
} else if (t_2 <= 0.995) {
tmp = t_3;
} else {
tmp = t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = (math.sin(ky) / math.hypot(kx, math.sin(ky))) * math.sin(th) t_2 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0))) t_3 = th * (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) tmp = 0 if t_2 <= -1.0: tmp = t_1 elif t_2 <= -0.4: tmp = t_3 elif t_2 <= 1e-6: tmp = (math.sin(ky) / math.hypot(math.sin(kx), ky)) * math.sin(th) elif t_2 <= 0.995: tmp = t_3 else: tmp = t_1 return tmp
function code(kx, ky, th) t_1 = Float64(Float64(sin(ky) / hypot(kx, sin(ky))) * sin(th)) t_2 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) t_3 = Float64(th * Float64(sin(ky) / hypot(sin(kx), sin(ky)))) tmp = 0.0 if (t_2 <= -1.0) tmp = t_1; elseif (t_2 <= -0.4) tmp = t_3; elseif (t_2 <= 1e-6) tmp = Float64(Float64(sin(ky) / hypot(sin(kx), ky)) * sin(th)); elseif (t_2 <= 0.995) tmp = t_3; else tmp = t_1; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = (sin(ky) / hypot(kx, sin(ky))) * sin(th); t_2 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))); t_3 = th * (sin(ky) / hypot(sin(kx), sin(ky))); tmp = 0.0; if (t_2 <= -1.0) tmp = t_1; elseif (t_2 <= -0.4) tmp = t_3; elseif (t_2 <= 1e-6) tmp = (sin(ky) / hypot(sin(kx), ky)) * sin(th); elseif (t_2 <= 0.995) tmp = t_3; else tmp = t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[kx ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $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[(th * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1.0], t$95$1, If[LessEqual[t$95$2, -0.4], t$95$3, If[LessEqual[t$95$2, 1e-6], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.995], t$95$3, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\mathsf{hypot}\left(kx, \sin ky\right)} \cdot \sin th\\
t_2 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
t_3 := th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\mathbf{if}\;t\_2 \leq -1:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -0.4:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 10^{-6}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, ky\right)} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq 0.995:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\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))))) < -1 or 0.994999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 90.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.3
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f64100.0
Applied rewrites100.0%
Taylor expanded in kx around 0
Applied rewrites100.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))))) < -0.40000000000000002 or 9.99999999999999955e-7 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.994999999999999996Initial program 98.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.0
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in th around 0
Applied rewrites48.6%
if -0.40000000000000002 < (/.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.99999999999999955e-7Initial program 99.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in ky around 0
Applied rewrites95.8%
Final simplification89.5%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (/ (sin ky) (hypot kx (sin ky))) (sin th)))
(t_2 (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))))
(t_3 (* th (/ (sin ky) (hypot (sin kx) (sin ky))))))
(if (<= t_2 -1.0)
t_1
(if (<= t_2 -0.4)
t_3
(if (<= t_2 1e-6)
(* (/ ky (hypot (sin kx) ky)) (sin th))
(if (<= t_2 0.995) t_3 t_1))))))
double code(double kx, double ky, double th) {
double t_1 = (sin(ky) / hypot(kx, sin(ky))) * sin(th);
double t_2 = sin(ky) / sqrt((pow(sin(ky), 2.0) + pow(sin(kx), 2.0)));
double t_3 = th * (sin(ky) / hypot(sin(kx), sin(ky)));
double tmp;
if (t_2 <= -1.0) {
tmp = t_1;
} else if (t_2 <= -0.4) {
tmp = t_3;
} else if (t_2 <= 1e-6) {
tmp = (ky / hypot(sin(kx), ky)) * sin(th);
} else if (t_2 <= 0.995) {
tmp = t_3;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = (Math.sin(ky) / Math.hypot(kx, Math.sin(ky))) * Math.sin(th);
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 = th * (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky)));
double tmp;
if (t_2 <= -1.0) {
tmp = t_1;
} else if (t_2 <= -0.4) {
tmp = t_3;
} else if (t_2 <= 1e-6) {
tmp = (ky / Math.hypot(Math.sin(kx), ky)) * Math.sin(th);
} else if (t_2 <= 0.995) {
tmp = t_3;
} else {
tmp = t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = (math.sin(ky) / math.hypot(kx, math.sin(ky))) * math.sin(th) t_2 = math.sin(ky) / math.sqrt((math.pow(math.sin(ky), 2.0) + math.pow(math.sin(kx), 2.0))) t_3 = th * (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) tmp = 0 if t_2 <= -1.0: tmp = t_1 elif t_2 <= -0.4: tmp = t_3 elif t_2 <= 1e-6: tmp = (ky / math.hypot(math.sin(kx), ky)) * math.sin(th) elif t_2 <= 0.995: tmp = t_3 else: tmp = t_1 return tmp
function code(kx, ky, th) t_1 = Float64(Float64(sin(ky) / hypot(kx, sin(ky))) * sin(th)) t_2 = Float64(sin(ky) / sqrt(Float64((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) t_3 = Float64(th * Float64(sin(ky) / hypot(sin(kx), sin(ky)))) tmp = 0.0 if (t_2 <= -1.0) tmp = t_1; elseif (t_2 <= -0.4) tmp = t_3; elseif (t_2 <= 1e-6) tmp = Float64(Float64(ky / hypot(sin(kx), ky)) * sin(th)); elseif (t_2 <= 0.995) tmp = t_3; else tmp = t_1; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = (sin(ky) / hypot(kx, sin(ky))) * sin(th); t_2 = sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0))); t_3 = th * (sin(ky) / hypot(sin(kx), sin(ky))); tmp = 0.0; if (t_2 <= -1.0) tmp = t_1; elseif (t_2 <= -0.4) tmp = t_3; elseif (t_2 <= 1e-6) tmp = (ky / hypot(sin(kx), ky)) * sin(th); elseif (t_2 <= 0.995) tmp = t_3; else tmp = t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[kx ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $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[(th * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1.0], t$95$1, If[LessEqual[t$95$2, -0.4], t$95$3, If[LessEqual[t$95$2, 1e-6], N[(N[(ky / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.995], t$95$3, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\mathsf{hypot}\left(kx, \sin ky\right)} \cdot \sin th\\
t_2 := \frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}\\
t_3 := th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\mathbf{if}\;t\_2 \leq -1:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -0.4:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 10^{-6}:\\
\;\;\;\;\frac{ky}{\mathsf{hypot}\left(\sin kx, ky\right)} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq 0.995:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\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))))) < -1 or 0.994999999999999996 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 90.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.3
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f64100.0
Applied rewrites100.0%
Taylor expanded in kx around 0
Applied rewrites100.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))))) < -0.40000000000000002 or 9.99999999999999955e-7 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.994999999999999996Initial program 98.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.0
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in th around 0
Applied rewrites48.6%
if -0.40000000000000002 < (/.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.99999999999999955e-7Initial program 99.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.5
Applied rewrites99.5%
Taylor expanded in ky around 0
Applied rewrites95.8%
Taylor expanded in ky around 0
Applied rewrites95.9%
Final simplification89.5%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (pow (sin ky) 2.0)))
(if (<= (/ (sin ky) (sqrt (+ t_1 (pow (sin kx) 2.0)))) -0.4)
(* (sqrt (/ 1.0 t_1)) (* (sin ky) th))
(* (/ ky (hypot (sin kx) ky)) (sin th)))))
double code(double kx, double ky, double th) {
double t_1 = pow(sin(ky), 2.0);
double tmp;
if ((sin(ky) / sqrt((t_1 + pow(sin(kx), 2.0)))) <= -0.4) {
tmp = sqrt((1.0 / t_1)) * (sin(ky) * th);
} else {
tmp = (ky / hypot(sin(kx), ky)) * sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.pow(Math.sin(ky), 2.0);
double tmp;
if ((Math.sin(ky) / Math.sqrt((t_1 + Math.pow(Math.sin(kx), 2.0)))) <= -0.4) {
tmp = Math.sqrt((1.0 / t_1)) * (Math.sin(ky) * th);
} else {
tmp = (ky / Math.hypot(Math.sin(kx), ky)) * Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.pow(math.sin(ky), 2.0) tmp = 0 if (math.sin(ky) / math.sqrt((t_1 + math.pow(math.sin(kx), 2.0)))) <= -0.4: tmp = math.sqrt((1.0 / t_1)) * (math.sin(ky) * th) else: tmp = (ky / math.hypot(math.sin(kx), ky)) * math.sin(th) return tmp
function code(kx, ky, th) t_1 = sin(ky) ^ 2.0 tmp = 0.0 if (Float64(sin(ky) / sqrt(Float64(t_1 + (sin(kx) ^ 2.0)))) <= -0.4) tmp = Float64(sqrt(Float64(1.0 / t_1)) * Float64(sin(ky) * th)); else tmp = Float64(Float64(ky / hypot(sin(kx), ky)) * sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(ky) ^ 2.0; tmp = 0.0; if ((sin(ky) / sqrt((t_1 + (sin(kx) ^ 2.0)))) <= -0.4) tmp = sqrt((1.0 / t_1)) * (sin(ky) * th); else tmp = (ky / hypot(sin(kx), ky)) * sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.4], N[(N[Sqrt[N[(1.0 / t$95$1), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision]), $MachinePrecision], N[(N[(ky / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\sin ky}^{2}\\
\mathbf{if}\;\frac{\sin ky}{\sqrt{t\_1 + {\sin kx}^{2}}} \leq -0.4:\\
\;\;\;\;\sqrt{\frac{1}{t\_1}} \cdot \left(\sin ky \cdot th\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\mathsf{hypot}\left(\sin kx, ky\right)} \cdot \sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.40000000000000002Initial program 93.7%
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
unpow2N/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-sin.f6437.2
Applied rewrites37.2%
Taylor expanded in kx around 0
Applied rewrites29.7%
if -0.40000000000000002 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 95.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6495.9
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
Taylor expanded in ky around 0
Applied rewrites68.9%
Taylor expanded in ky around 0
Applied rewrites76.0%
Final simplification62.6%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 1e-6) (/ (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-6) {
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-6) 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-6) {
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-6: 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-6) tmp = Float64(sin(th) / Float64(sin(kx) / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) / sqrt(((sin(ky) ^ 2.0) + (sin(kx) ^ 2.0)))) <= 1e-6) 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-6], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}} \leq 10^{-6}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 9.99999999999999955e-7Initial program 97.0%
lift-pow.f64N/A
pow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
lower-*.f64N/A
metadata-eval83.0
Applied rewrites83.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-aN/A
lift-pow.f64N/A
Applied rewrites99.6%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sin.f6435.4
Applied rewrites35.4%
if 9.99999999999999955e-7 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.4%
Taylor expanded in kx around 0
lower-sin.f6470.1
Applied rewrites70.1%
Final simplification46.4%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 1e-6) (* (/ 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-6) {
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-6) 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-6) {
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-6: 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-6) 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-6) 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-6], 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^{-6}:\\
\;\;\;\;\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.99999999999999955e-7Initial program 97.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6497.0
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sin.f6435.4
Applied rewrites35.4%
if 9.99999999999999955e-7 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.4%
Taylor expanded in kx around 0
lower-sin.f6470.1
Applied rewrites70.1%
Final simplification46.4%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 5e-15) (* (/ (sin 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)))) <= 5e-15) {
tmp = (sin(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)))) <= 5d-15) then
tmp = (sin(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)))) <= 5e-15) {
tmp = (Math.sin(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)))) <= 5e-15: tmp = (math.sin(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)))) <= 5e-15) tmp = Float64(Float64(sin(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)))) <= 5e-15) tmp = (sin(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], 5e-15], N[(N[(N[Sin[ky], $MachinePrecision] / 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 5 \cdot 10^{-15}:\\
\;\;\;\;\frac{\sin 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))))) < 4.99999999999999999e-15Initial program 97.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6497.0
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
Taylor expanded in th around 0
Applied rewrites44.1%
Taylor expanded in ky around 0
lower-sin.f6423.0
Applied rewrites23.0%
if 4.99999999999999999e-15 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.7%
Taylor expanded in kx around 0
lower-sin.f6468.0
Applied rewrites68.0%
Final simplification37.8%
(FPCore (kx ky th)
:precision binary64
(if (<= (pow (sin kx) 2.0) 4e-12)
(* (/ (sin ky) (hypot kx (sin ky))) (sin th))
(*
(/
(sin ky)
(sqrt
(+ (- 0.5 (* (cos (* 2.0 ky)) 0.5)) (fma (cos (* 2.0 kx)) -0.5 0.5))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (pow(sin(kx), 2.0) <= 4e-12) {
tmp = (sin(ky) / hypot(kx, sin(ky))) * sin(th);
} else {
tmp = (sin(ky) / sqrt(((0.5 - (cos((2.0 * ky)) * 0.5)) + fma(cos((2.0 * kx)), -0.5, 0.5)))) * sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if ((sin(kx) ^ 2.0) <= 4e-12) tmp = Float64(Float64(sin(ky) / hypot(kx, sin(ky))) * sin(th)); else tmp = Float64(Float64(sin(ky) / sqrt(Float64(Float64(0.5 - Float64(cos(Float64(2.0 * ky)) * 0.5)) + fma(cos(Float64(2.0 * kx)), -0.5, 0.5)))) * sin(th)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision], 4e-12], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[kx ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[(0.5 - N[(N[Cos[N[(2.0 * ky), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\sin kx}^{2} \leq 4 \cdot 10^{-12}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(kx, \sin ky\right)} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\sqrt{\left(0.5 - \cos \left(2 \cdot ky\right) \cdot 0.5\right) + \mathsf{fma}\left(\cos \left(2 \cdot kx\right), -0.5, 0.5\right)}} \cdot \sin th\\
\end{array}
\end{array}
if (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) < 3.99999999999999992e-12Initial program 91.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.6
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.9
Applied rewrites99.9%
Taylor expanded in kx around 0
Applied rewrites99.8%
if 3.99999999999999992e-12 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) Initial program 99.4%
lift-pow.f64N/A
pow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
lower-*.f64N/A
metadata-eval98.4
Applied rewrites98.4%
lift-pow.f64N/A
pow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
lower-*.f6498.4
Applied rewrites98.4%
Final simplification99.1%
(FPCore (kx ky th) :precision binary64 (if (<= (/ (sin ky) (sqrt (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)))) 5e-15) (* (/ 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)))) <= 5e-15) {
tmp = (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)))) <= 5d-15) then
tmp = (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)))) <= 5e-15) {
tmp = (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)))) <= 5e-15: tmp = (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)))) <= 5e-15) tmp = Float64(Float64(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)))) <= 5e-15) tmp = (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], 5e-15], N[(N[(th / 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 5 \cdot 10^{-15}:\\
\;\;\;\;\frac{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))))) < 4.99999999999999999e-15Initial program 97.0%
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
unpow2N/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-sin.f6441.4
Applied rewrites41.4%
Taylor expanded in ky around 0
Applied rewrites22.2%
if 4.99999999999999999e-15 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 91.7%
Taylor expanded in kx around 0
lower-sin.f6468.0
Applied rewrites68.0%
Final simplification37.2%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.01) (* (* (sqrt (/ 1.0 (fma (cos (* 2.0 kx)) -0.5 0.5))) ky) (sin th)) (if (<= (sin kx) 5e-96) (sin th) (* (/ (sin ky) (sin kx)) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.01) {
tmp = (sqrt((1.0 / fma(cos((2.0 * kx)), -0.5, 0.5))) * ky) * sin(th);
} else if (sin(kx) <= 5e-96) {
tmp = sin(th);
} else {
tmp = (sin(ky) / sin(kx)) * sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.01) tmp = Float64(Float64(sqrt(Float64(1.0 / fma(cos(Float64(2.0 * kx)), -0.5, 0.5))) * ky) * sin(th)); elseif (sin(kx) <= 5e-96) tmp = sin(th); else tmp = Float64(Float64(sin(ky) / sin(kx)) * sin(th)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.01], N[(N[(N[Sqrt[N[(1.0 / N[(N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * ky), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-96], N[Sin[th], $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.01:\\
\;\;\;\;\left(\sqrt{\frac{1}{\mathsf{fma}\left(\cos \left(2 \cdot kx\right), -0.5, 0.5\right)}} \cdot ky\right) \cdot \sin th\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-96}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\sin kx} \cdot \sin th\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0100000000000000002Initial program 99.4%
lift-pow.f64N/A
pow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
lower-*.f64N/A
metadata-eval99.3
Applied rewrites99.3%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f6468.1
Applied rewrites68.1%
if -0.0100000000000000002 < (sin.f64 kx) < 4.99999999999999995e-96Initial program 90.7%
Taylor expanded in kx around 0
lower-sin.f6440.4
Applied rewrites40.4%
if 4.99999999999999995e-96 < (sin.f64 kx) Initial program 99.5%
Taylor expanded in ky around 0
lower-sin.f6459.4
Applied rewrites59.4%
(FPCore (kx ky th) :precision binary64 (* (/ (sin th) (hypot (sin kx) (sin ky))) (sin ky)))
double code(double kx, double ky, double th) {
return (sin(th) / hypot(sin(kx), sin(ky))) * sin(ky);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(th) / Math.hypot(Math.sin(kx), Math.sin(ky))) * Math.sin(ky);
}
def code(kx, ky, th): return (math.sin(th) / math.hypot(math.sin(kx), math.sin(ky))) * math.sin(ky)
function code(kx, ky, th) return Float64(Float64(sin(th) / hypot(sin(kx), sin(ky))) * sin(ky)) end
function tmp = code(kx, ky, th) tmp = (sin(th) / hypot(sin(kx), sin(ky))) * sin(ky); end
code[kx_, ky_, th_] := N[(N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin ky
\end{array}
Initial program 95.2%
lift-pow.f64N/A
pow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
lower-*.f64N/A
metadata-eval85.6
Applied rewrites85.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-aN/A
lift-pow.f64N/A
Applied rewrites99.6%
Final simplification99.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.01) (* (* (sqrt (/ 1.0 (fma (cos (* 2.0 kx)) -0.5 0.5))) ky) (sin th)) (if (<= (sin kx) 5e-96) (sin th) (/ (sin th) (/ (sin kx) ky)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.01) {
tmp = (sqrt((1.0 / fma(cos((2.0 * kx)), -0.5, 0.5))) * ky) * sin(th);
} else if (sin(kx) <= 5e-96) {
tmp = sin(th);
} else {
tmp = sin(th) / (sin(kx) / ky);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.01) tmp = Float64(Float64(sqrt(Float64(1.0 / fma(cos(Float64(2.0 * kx)), -0.5, 0.5))) * ky) * sin(th)); elseif (sin(kx) <= 5e-96) tmp = sin(th); else tmp = Float64(sin(th) / Float64(sin(kx) / ky)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.01], N[(N[(N[Sqrt[N[(1.0 / N[(N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * ky), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-96], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.01:\\
\;\;\;\;\left(\sqrt{\frac{1}{\mathsf{fma}\left(\cos \left(2 \cdot kx\right), -0.5, 0.5\right)}} \cdot ky\right) \cdot \sin th\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-96}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0100000000000000002Initial program 99.4%
lift-pow.f64N/A
pow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
lower-*.f64N/A
metadata-eval99.3
Applied rewrites99.3%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f6468.1
Applied rewrites68.1%
if -0.0100000000000000002 < (sin.f64 kx) < 4.99999999999999995e-96Initial program 90.7%
Taylor expanded in kx around 0
lower-sin.f6440.4
Applied rewrites40.4%
if 4.99999999999999995e-96 < (sin.f64 kx) Initial program 99.5%
lift-pow.f64N/A
pow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
lower-*.f64N/A
metadata-eval88.0
Applied rewrites88.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-aN/A
lift-pow.f64N/A
Applied rewrites99.5%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sin.f6452.9
Applied rewrites52.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.01) (* (* ky (sin th)) (sqrt (/ 1.0 (fma (cos (* 2.0 kx)) -0.5 0.5)))) (if (<= (sin kx) 5e-96) (sin th) (/ (sin th) (/ (sin kx) ky)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.01) {
tmp = (ky * sin(th)) * sqrt((1.0 / fma(cos((2.0 * kx)), -0.5, 0.5)));
} else if (sin(kx) <= 5e-96) {
tmp = sin(th);
} else {
tmp = sin(th) / (sin(kx) / ky);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.01) tmp = Float64(Float64(ky * sin(th)) * sqrt(Float64(1.0 / fma(cos(Float64(2.0 * kx)), -0.5, 0.5)))); elseif (sin(kx) <= 5e-96) tmp = sin(th); else tmp = Float64(sin(th) / Float64(sin(kx) / ky)); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.01], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(N[Cos[N[(2.0 * kx), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-96], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.01:\\
\;\;\;\;\left(ky \cdot \sin th\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\cos \left(2 \cdot kx\right), -0.5, 0.5\right)}}\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-96}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0100000000000000002Initial program 99.4%
lift-pow.f64N/A
pow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
lower-*.f64N/A
metadata-eval99.3
Applied rewrites99.3%
Taylor expanded in ky around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6468.0
Applied rewrites68.0%
if -0.0100000000000000002 < (sin.f64 kx) < 4.99999999999999995e-96Initial program 90.7%
Taylor expanded in kx around 0
lower-sin.f6440.4
Applied rewrites40.4%
if 4.99999999999999995e-96 < (sin.f64 kx) Initial program 99.5%
lift-pow.f64N/A
pow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
count-2N/A
lower-cos.f64N/A
count-2N/A
lower-*.f64N/A
metadata-eval88.0
Applied rewrites88.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-aN/A
lift-pow.f64N/A
Applied rewrites99.5%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sin.f6452.9
Applied rewrites52.9%
Final simplification50.1%
(FPCore (kx ky th) :precision binary64 (if (<= th 9.5e-5) (* th (/ (sin ky) (hypot (sin kx) (sin ky)))) (* (/ ky (hypot (sin kx) ky)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 9.5e-5) {
tmp = th * (sin(ky) / hypot(sin(kx), sin(ky)));
} else {
tmp = (ky / hypot(sin(kx), ky)) * sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 9.5e-5) {
tmp = th * (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky)));
} else {
tmp = (ky / Math.hypot(Math.sin(kx), ky)) * Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 9.5e-5: tmp = th * (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) else: tmp = (ky / math.hypot(math.sin(kx), ky)) * math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 9.5e-5) tmp = Float64(th * Float64(sin(ky) / hypot(sin(kx), sin(ky)))); else tmp = Float64(Float64(ky / hypot(sin(kx), ky)) * sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 9.5e-5) tmp = th * (sin(ky) / hypot(sin(kx), sin(ky))); else tmp = (ky / hypot(sin(kx), ky)) * sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 9.5e-5], N[(th * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 9.5 \cdot 10^{-5}:\\
\;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\mathsf{hypot}\left(\sin kx, ky\right)} \cdot \sin th\\
\end{array}
\end{array}
if th < 9.5000000000000005e-5Initial program 95.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6495.2
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in th around 0
Applied rewrites64.5%
if 9.5000000000000005e-5 < th Initial program 95.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6495.4
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
Taylor expanded in ky around 0
Applied rewrites61.2%
Taylor expanded in ky around 0
Applied rewrites66.7%
Final simplification65.1%
(FPCore (kx ky th) :precision binary64 (* (/ ky (hypot (sin kx) ky)) (sin th)))
double code(double kx, double ky, double th) {
return (ky / hypot(sin(kx), ky)) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (ky / Math.hypot(Math.sin(kx), ky)) * Math.sin(th);
}
def code(kx, ky, th): return (ky / math.hypot(math.sin(kx), ky)) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(ky / hypot(sin(kx), ky)) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (ky / hypot(sin(kx), ky)) * sin(th); end
code[kx_, ky_, th_] := N[(N[(ky / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + ky ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{ky}{\mathsf{hypot}\left(\sin kx, ky\right)} \cdot \sin th
\end{array}
Initial program 95.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6495.2
lift-sqrt.f64N/A
lift-+.f64N/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
Applied rewrites57.9%
Taylor expanded in ky around 0
Applied rewrites69.8%
Final simplification69.8%
(FPCore (kx ky th) :precision binary64 (sin th))
double code(double kx, double ky, double th) {
return sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = sin(th)
end function
public static double code(double kx, double ky, double th) {
return Math.sin(th);
}
def code(kx, ky, th): return math.sin(th)
function code(kx, ky, th) return sin(th) end
function tmp = code(kx, ky, th) tmp = sin(th); end
code[kx_, ky_, th_] := N[Sin[th], $MachinePrecision]
\begin{array}{l}
\\
\sin th
\end{array}
Initial program 95.2%
Taylor expanded in kx around 0
lower-sin.f6424.7
Applied rewrites24.7%
(FPCore (kx ky th) :precision binary64 th)
double code(double kx, double ky, double th) {
return th;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = th
end function
public static double code(double kx, double ky, double th) {
return th;
}
def code(kx, ky, th): return th
function code(kx, ky, th) return th end
function tmp = code(kx, ky, th) tmp = th; end
code[kx_, ky_, th_] := th
\begin{array}{l}
\\
th
\end{array}
Initial program 95.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
unpow2N/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-sin.f6443.8
Applied rewrites43.8%
Taylor expanded in kx around 0
Applied rewrites15.7%
herbie shell --seed 2024272
(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)))