
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2) (pow (sin ky) 2)))) (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);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(kx, ky, th)
use fmin_fmax_functions
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], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2) (pow (sin ky) 2)))) (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);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(kx, ky, th)
use fmin_fmax_functions
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], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky))))
(*
(copysign 1 ky)
(if (<=
(fabs ky)
3480865949723965/4351082437154956072465106588077822995084026820419845514849846380137705962380101572519219218556758308199541387151331336317719177934050977705242787666055883587123865770683541250307916824576)
(* (sin th) (/ (fabs ky) (fabs (sin kx))))
(* (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2)))) (sin th))))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double tmp;
if (fabs(ky) <= 8e-172) {
tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
} else {
tmp = (t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)))) * sin(th);
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(Math.abs(ky));
double tmp;
if (Math.abs(ky) <= 8e-172) {
tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
} else {
tmp = (t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)))) * Math.sin(th);
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) tmp = 0 if math.fabs(ky) <= 8e-172: tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx))) else: tmp = (t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0)))) * math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) tmp = 0.0 if (abs(ky) <= 8e-172) tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx)))); else tmp = Float64(Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0)))) * sin(th)); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = sin(abs(ky)); tmp = 0.0; if (abs(ky) <= 8e-172) tmp = sin(th) * (abs(ky) / abs(sin(kx))); else tmp = (t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0)))) * sin(th); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[ky], $MachinePrecision], 3480865949723965/4351082437154956072465106588077822995084026820419845514849846380137705962380101572519219218556758308199541387151331336317719177934050977705242787666055883587123865770683541250307916824576], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|ky\right| \leq \frac{3480865949723965}{4351082437154956072465106588077822995084026820419845514849846380137705962380101572519219218556758308199541387151331336317719177934050977705242787666055883587123865770683541250307916824576}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}} \cdot \sin th\\
\end{array}
\end{array}
if ky < 8.0000000000000003e-172Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6434.3%
lift-sqrt.f64N/A
lift-pow.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f6436.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.6%
Applied rewrites36.6%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-square-revN/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.7%
Applied rewrites38.7%
if 8.0000000000000003e-172 < ky Initial program 93.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky))))
(*
(copysign 1 ky)
(if (<=
(fabs ky)
3480865949723965/4351082437154956072465106588077822995084026820419845514849846380137705962380101572519219218556758308199541387151331336317719177934050977705242787666055883587123865770683541250307916824576)
(* (sin th) (/ (fabs ky) (fabs (sin kx))))
(if (<= (fabs ky) 7673845534663173/73786976294838206464)
(*
(/ t_1 (sqrt (+ (pow (sin kx) 2) (pow (fabs ky) 2))))
(sin th))
(/
(* (sin th) t_1)
(sqrt
(-
1/2
(+
(* (cos (+ (fabs ky) (fabs ky))) 1/2)
(- (* (cos (+ kx kx)) 1/2) 1/2))))))))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double tmp;
if (fabs(ky) <= 8e-172) {
tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
} else if (fabs(ky) <= 0.000104) {
tmp = (t_1 / sqrt((pow(sin(kx), 2.0) + pow(fabs(ky), 2.0)))) * sin(th);
} else {
tmp = (sin(th) * t_1) / sqrt((0.5 - ((cos((fabs(ky) + fabs(ky))) * 0.5) + ((cos((kx + kx)) * 0.5) - 0.5))));
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(Math.abs(ky));
double tmp;
if (Math.abs(ky) <= 8e-172) {
tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
} else if (Math.abs(ky) <= 0.000104) {
tmp = (t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.abs(ky), 2.0)))) * Math.sin(th);
} else {
tmp = (Math.sin(th) * t_1) / Math.sqrt((0.5 - ((Math.cos((Math.abs(ky) + Math.abs(ky))) * 0.5) + ((Math.cos((kx + kx)) * 0.5) - 0.5))));
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) tmp = 0 if math.fabs(ky) <= 8e-172: tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx))) elif math.fabs(ky) <= 0.000104: tmp = (t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.fabs(ky), 2.0)))) * math.sin(th) else: tmp = (math.sin(th) * t_1) / math.sqrt((0.5 - ((math.cos((math.fabs(ky) + math.fabs(ky))) * 0.5) + ((math.cos((kx + kx)) * 0.5) - 0.5)))) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) tmp = 0.0 if (abs(ky) <= 8e-172) tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx)))); elseif (abs(ky) <= 0.000104) tmp = Float64(Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (abs(ky) ^ 2.0)))) * sin(th)); else tmp = Float64(Float64(sin(th) * t_1) / sqrt(Float64(0.5 - Float64(Float64(cos(Float64(abs(ky) + abs(ky))) * 0.5) + Float64(Float64(cos(Float64(kx + kx)) * 0.5) - 0.5))))); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = sin(abs(ky)); tmp = 0.0; if (abs(ky) <= 8e-172) tmp = sin(th) * (abs(ky) / abs(sin(kx))); elseif (abs(ky) <= 0.000104) tmp = (t_1 / sqrt(((sin(kx) ^ 2.0) + (abs(ky) ^ 2.0)))) * sin(th); else tmp = (sin(th) * t_1) / sqrt((0.5 - ((cos((abs(ky) + abs(ky))) * 0.5) + ((cos((kx + kx)) * 0.5) - 0.5)))); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[ky], $MachinePrecision], 3480865949723965/4351082437154956072465106588077822995084026820419845514849846380137705962380101572519219218556758308199541387151331336317719177934050977705242787666055883587123865770683541250307916824576], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[ky], $MachinePrecision], 7673845534663173/73786976294838206464], N[(N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[N[Abs[ky], $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[th], $MachinePrecision] * t$95$1), $MachinePrecision] / N[Sqrt[N[(1/2 - N[(N[(N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1/2), $MachinePrecision] + N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] * 1/2), $MachinePrecision] - 1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|ky\right| \leq \frac{3480865949723965}{4351082437154956072465106588077822995084026820419845514849846380137705962380101572519219218556758308199541387151331336317719177934050977705242787666055883587123865770683541250307916824576}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\
\mathbf{elif}\;\left|ky\right| \leq \frac{7673845534663173}{73786976294838206464}:\\
\;\;\;\;\frac{t\_1}{\sqrt{{\sin kx}^{2} + {\left(\left|ky\right|\right)}^{2}}} \cdot \sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th \cdot t\_1}{\sqrt{\frac{1}{2} - \left(\cos \left(\left|ky\right| + \left|ky\right|\right) \cdot \frac{1}{2} + \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \frac{1}{2}\right)\right)}}\\
\end{array}
\end{array}
if ky < 8.0000000000000003e-172Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6434.3%
lift-sqrt.f64N/A
lift-pow.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f6436.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.6%
Applied rewrites36.6%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-square-revN/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.7%
Applied rewrites38.7%
if 8.0000000000000003e-172 < ky < 1.0399999999999999e-4Initial program 93.7%
Taylor expanded in ky around 0
lower-pow.f6446.7%
Applied rewrites46.7%
if 1.0399999999999999e-4 < ky Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.9%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate--l-N/A
lower--.f64N/A
lower-+.f64N/A
Applied rewrites74.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky))) (t_2 (pow (sin kx) 2)))
(*
(copysign 1 ky)
(if (<=
(/ t_1 (sqrt (+ t_2 (pow t_1 2))))
2206763817411543/2251799813685248)
(*
(/
t_1
(sqrt (+ t_2 (- 1/2 (* (cos (+ (fabs ky) (fabs ky))) 1/2)))))
(sin th))
(sin th)))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double t_2 = pow(sin(kx), 2.0);
double tmp;
if ((t_1 / sqrt((t_2 + pow(t_1, 2.0)))) <= 0.98) {
tmp = (t_1 / sqrt((t_2 + (0.5 - (cos((fabs(ky) + fabs(ky))) * 0.5))))) * sin(th);
} else {
tmp = sin(th);
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(Math.abs(ky));
double t_2 = Math.pow(Math.sin(kx), 2.0);
double tmp;
if ((t_1 / Math.sqrt((t_2 + Math.pow(t_1, 2.0)))) <= 0.98) {
tmp = (t_1 / Math.sqrt((t_2 + (0.5 - (Math.cos((Math.abs(ky) + Math.abs(ky))) * 0.5))))) * Math.sin(th);
} else {
tmp = Math.sin(th);
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) t_2 = math.pow(math.sin(kx), 2.0) tmp = 0 if (t_1 / math.sqrt((t_2 + math.pow(t_1, 2.0)))) <= 0.98: tmp = (t_1 / math.sqrt((t_2 + (0.5 - (math.cos((math.fabs(ky) + math.fabs(ky))) * 0.5))))) * math.sin(th) else: tmp = math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) t_2 = sin(kx) ^ 2.0 tmp = 0.0 if (Float64(t_1 / sqrt(Float64(t_2 + (t_1 ^ 2.0)))) <= 0.98) tmp = Float64(Float64(t_1 / sqrt(Float64(t_2 + Float64(0.5 - Float64(cos(Float64(abs(ky) + abs(ky))) * 0.5))))) * sin(th)); else tmp = sin(th); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = sin(abs(ky)); t_2 = sin(kx) ^ 2.0; tmp = 0.0; if ((t_1 / sqrt((t_2 + (t_1 ^ 2.0)))) <= 0.98) tmp = (t_1 / sqrt((t_2 + (0.5 - (cos((abs(ky) + abs(ky))) * 0.5))))) * sin(th); else tmp = sin(th); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(t$95$1 / N[Sqrt[N[(t$95$2 + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2206763817411543/2251799813685248], N[(N[(t$95$1 / N[Sqrt[N[(t$95$2 + N[(1/2 - N[(N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]), $MachinePrecision]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := {\sin kx}^{2}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;\frac{t\_1}{\sqrt{t\_2 + {t\_1}^{2}}} \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;\frac{t\_1}{\sqrt{t\_2 + \left(\frac{1}{2} - \cos \left(\left|ky\right| + \left|ky\right|\right) \cdot \frac{1}{2}\right)}} \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.97999999999999998Initial program 93.7%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6483.9%
Applied rewrites83.9%
if 0.97999999999999998 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
Taylor expanded in ky around 0
lower-sin.f6424.3%
Applied rewrites24.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (cos (+ kx kx)))
(t_2 (sin (fabs ky)))
(t_3 (* (sin th) t_2))
(t_4 (/ t_2 (sqrt (+ (pow (sin kx) 2) (pow t_2 2)))))
(t_5 (cos (+ (fabs ky) (fabs ky)))))
(*
(copysign 1 ky)
(if (<= t_4 -3602879701896397/36028797018963968)
(/ t_3 (sqrt (- 1/2 (+ (* t_5 1/2) (- (* t_1 1/2) 1/2)))))
(if (<=
t_4
5316911983139663/5316911983139663491615228241121378304)
(* (sin th) (/ (fabs ky) (fabs (sin kx))))
(if (<= t_4 2206763817411543/2251799813685248)
(/ t_3 (sqrt (- 1/2 (* (- t_1 (- 1 t_5)) 1/2))))
(sin th)))))))double code(double kx, double ky, double th) {
double t_1 = cos((kx + kx));
double t_2 = sin(fabs(ky));
double t_3 = sin(th) * t_2;
double t_4 = t_2 / sqrt((pow(sin(kx), 2.0) + pow(t_2, 2.0)));
double t_5 = cos((fabs(ky) + fabs(ky)));
double tmp;
if (t_4 <= -0.1) {
tmp = t_3 / sqrt((0.5 - ((t_5 * 0.5) + ((t_1 * 0.5) - 0.5))));
} else if (t_4 <= 1e-21) {
tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
} else if (t_4 <= 0.98) {
tmp = t_3 / sqrt((0.5 - ((t_1 - (1.0 - t_5)) * 0.5)));
} else {
tmp = sin(th);
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.cos((kx + kx));
double t_2 = Math.sin(Math.abs(ky));
double t_3 = Math.sin(th) * t_2;
double t_4 = t_2 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_2, 2.0)));
double t_5 = Math.cos((Math.abs(ky) + Math.abs(ky)));
double tmp;
if (t_4 <= -0.1) {
tmp = t_3 / Math.sqrt((0.5 - ((t_5 * 0.5) + ((t_1 * 0.5) - 0.5))));
} else if (t_4 <= 1e-21) {
tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
} else if (t_4 <= 0.98) {
tmp = t_3 / Math.sqrt((0.5 - ((t_1 - (1.0 - t_5)) * 0.5)));
} else {
tmp = Math.sin(th);
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.cos((kx + kx)) t_2 = math.sin(math.fabs(ky)) t_3 = math.sin(th) * t_2 t_4 = t_2 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_2, 2.0))) t_5 = math.cos((math.fabs(ky) + math.fabs(ky))) tmp = 0 if t_4 <= -0.1: tmp = t_3 / math.sqrt((0.5 - ((t_5 * 0.5) + ((t_1 * 0.5) - 0.5)))) elif t_4 <= 1e-21: tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx))) elif t_4 <= 0.98: tmp = t_3 / math.sqrt((0.5 - ((t_1 - (1.0 - t_5)) * 0.5))) else: tmp = math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = cos(Float64(kx + kx)) t_2 = sin(abs(ky)) t_3 = Float64(sin(th) * t_2) t_4 = Float64(t_2 / sqrt(Float64((sin(kx) ^ 2.0) + (t_2 ^ 2.0)))) t_5 = cos(Float64(abs(ky) + abs(ky))) tmp = 0.0 if (t_4 <= -0.1) tmp = Float64(t_3 / sqrt(Float64(0.5 - Float64(Float64(t_5 * 0.5) + Float64(Float64(t_1 * 0.5) - 0.5))))); elseif (t_4 <= 1e-21) tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx)))); elseif (t_4 <= 0.98) tmp = Float64(t_3 / sqrt(Float64(0.5 - Float64(Float64(t_1 - Float64(1.0 - t_5)) * 0.5)))); else tmp = sin(th); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = cos((kx + kx)); t_2 = sin(abs(ky)); t_3 = sin(th) * t_2; t_4 = t_2 / sqrt(((sin(kx) ^ 2.0) + (t_2 ^ 2.0))); t_5 = cos((abs(ky) + abs(ky))); tmp = 0.0; if (t_4 <= -0.1) tmp = t_3 / sqrt((0.5 - ((t_5 * 0.5) + ((t_1 * 0.5) - 0.5)))); elseif (t_4 <= 1e-21) tmp = sin(th) * (abs(ky) / abs(sin(kx))); elseif (t_4 <= 0.98) tmp = t_3 / sqrt((0.5 - ((t_1 - (1.0 - t_5)) * 0.5))); else tmp = sin(th); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[th], $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$2, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$4, -3602879701896397/36028797018963968], N[(t$95$3 / N[Sqrt[N[(1/2 - N[(N[(t$95$5 * 1/2), $MachinePrecision] + N[(N[(t$95$1 * 1/2), $MachinePrecision] - 1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 5316911983139663/5316911983139663491615228241121378304], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 2206763817411543/2251799813685248], N[(t$95$3 / N[Sqrt[N[(1/2 - N[(N[(t$95$1 - N[(1 - t$95$5), $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]), $MachinePrecision]]]]]]
\begin{array}{l}
t_1 := \cos \left(kx + kx\right)\\
t_2 := \sin \left(\left|ky\right|\right)\\
t_3 := \sin th \cdot t\_2\\
t_4 := \frac{t\_2}{\sqrt{{\sin kx}^{2} + {t\_2}^{2}}}\\
t_5 := \cos \left(\left|ky\right| + \left|ky\right|\right)\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_4 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;\frac{t\_3}{\sqrt{\frac{1}{2} - \left(t\_5 \cdot \frac{1}{2} + \left(t\_1 \cdot \frac{1}{2} - \frac{1}{2}\right)\right)}}\\
\mathbf{elif}\;t\_4 \leq \frac{5316911983139663}{5316911983139663491615228241121378304}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\
\mathbf{elif}\;t\_4 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;\frac{t\_3}{\sqrt{\frac{1}{2} - \left(t\_1 - \left(1 - t\_5\right)\right) \cdot \frac{1}{2}}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.9%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate--l-N/A
lower--.f64N/A
lower-+.f64N/A
Applied rewrites74.6%
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.9999999999999991e-22Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6434.3%
lift-sqrt.f64N/A
lift-pow.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f6436.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.6%
Applied rewrites36.6%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-square-revN/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.7%
Applied rewrites38.7%
if 9.9999999999999991e-22 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.97999999999999998Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.9%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate--l-N/A
lower--.f64N/A
lower-+.f64N/A
Applied rewrites74.6%
Applied rewrites74.6%
if 0.97999999999999998 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
Taylor expanded in ky around 0
lower-sin.f6424.3%
Applied rewrites24.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky)))
(t_2
(/
(* (sin th) t_1)
(sqrt
(-
1/2
(*
(- (cos (+ kx kx)) (- 1 (cos (+ (fabs ky) (fabs ky)))))
1/2)))))
(t_3 (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2))))))
(*
(copysign 1 ky)
(if (<= t_3 -3602879701896397/36028797018963968)
t_2
(if (<=
t_3
5316911983139663/5316911983139663491615228241121378304)
(* (sin th) (/ (fabs ky) (fabs (sin kx))))
(if (<= t_3 2206763817411543/2251799813685248)
t_2
(sin th)))))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double t_2 = (sin(th) * t_1) / sqrt((0.5 - ((cos((kx + kx)) - (1.0 - cos((fabs(ky) + fabs(ky))))) * 0.5)));
double t_3 = t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)));
double tmp;
if (t_3 <= -0.1) {
tmp = t_2;
} else if (t_3 <= 1e-21) {
tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
} else if (t_3 <= 0.98) {
tmp = t_2;
} else {
tmp = sin(th);
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(Math.abs(ky));
double t_2 = (Math.sin(th) * t_1) / Math.sqrt((0.5 - ((Math.cos((kx + kx)) - (1.0 - Math.cos((Math.abs(ky) + Math.abs(ky))))) * 0.5)));
double t_3 = t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)));
double tmp;
if (t_3 <= -0.1) {
tmp = t_2;
} else if (t_3 <= 1e-21) {
tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
} else if (t_3 <= 0.98) {
tmp = t_2;
} else {
tmp = Math.sin(th);
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) t_2 = (math.sin(th) * t_1) / math.sqrt((0.5 - ((math.cos((kx + kx)) - (1.0 - math.cos((math.fabs(ky) + math.fabs(ky))))) * 0.5))) t_3 = t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0))) tmp = 0 if t_3 <= -0.1: tmp = t_2 elif t_3 <= 1e-21: tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx))) elif t_3 <= 0.98: tmp = t_2 else: tmp = math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) t_2 = Float64(Float64(sin(th) * t_1) / sqrt(Float64(0.5 - Float64(Float64(cos(Float64(kx + kx)) - Float64(1.0 - cos(Float64(abs(ky) + abs(ky))))) * 0.5)))) t_3 = Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0)))) tmp = 0.0 if (t_3 <= -0.1) tmp = t_2; elseif (t_3 <= 1e-21) tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx)))); elseif (t_3 <= 0.98) tmp = t_2; else tmp = sin(th); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = sin(abs(ky)); t_2 = (sin(th) * t_1) / sqrt((0.5 - ((cos((kx + kx)) - (1.0 - cos((abs(ky) + abs(ky))))) * 0.5))); t_3 = t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0))); tmp = 0.0; if (t_3 <= -0.1) tmp = t_2; elseif (t_3 <= 1e-21) tmp = sin(th) * (abs(ky) / abs(sin(kx))); elseif (t_3 <= 0.98) tmp = t_2; else tmp = sin(th); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Sin[th], $MachinePrecision] * t$95$1), $MachinePrecision] / N[Sqrt[N[(1/2 - N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] - N[(1 - N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, -3602879701896397/36028797018963968], t$95$2, If[LessEqual[t$95$3, 5316911983139663/5316911983139663491615228241121378304], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2206763817411543/2251799813685248], t$95$2, N[Sin[th], $MachinePrecision]]]]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := \frac{\sin th \cdot t\_1}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) - \left(1 - \cos \left(\left|ky\right| + \left|ky\right|\right)\right)\right) \cdot \frac{1}{2}}}\\
t_3 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq \frac{5316911983139663}{5316911983139663491615228241121378304}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\
\mathbf{elif}\;t\_3 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001 or 9.9999999999999991e-22 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.97999999999999998Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.9%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate--l-N/A
lower--.f64N/A
lower-+.f64N/A
Applied rewrites74.6%
Applied rewrites74.6%
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.9999999999999991e-22Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6434.3%
lift-sqrt.f64N/A
lift-pow.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f6436.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.6%
Applied rewrites36.6%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-square-revN/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.7%
Applied rewrites38.7%
if 0.97999999999999998 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
Taylor expanded in ky around 0
lower-sin.f6424.3%
Applied rewrites24.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky)))
(t_2
(/
(* (sin th) t_1)
(sqrt
(-
1
(*
(+ (cos (+ kx kx)) (cos (+ (fabs ky) (fabs ky))))
1/2)))))
(t_3 (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2))))))
(*
(copysign 1 ky)
(if (<= t_3 -3602879701896397/36028797018963968)
t_2
(if (<=
t_3
2857840190937569/664613997892457936451903530140172288)
(* (sin th) (/ (fabs ky) (fabs (sin kx))))
(if (<= t_3 2206763817411543/2251799813685248)
t_2
(sin th)))))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double t_2 = (sin(th) * t_1) / sqrt((1.0 - ((cos((kx + kx)) + cos((fabs(ky) + fabs(ky)))) * 0.5)));
double t_3 = t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)));
double tmp;
if (t_3 <= -0.1) {
tmp = t_2;
} else if (t_3 <= 4.3e-21) {
tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
} else if (t_3 <= 0.98) {
tmp = t_2;
} else {
tmp = sin(th);
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(Math.abs(ky));
double t_2 = (Math.sin(th) * t_1) / Math.sqrt((1.0 - ((Math.cos((kx + kx)) + Math.cos((Math.abs(ky) + Math.abs(ky)))) * 0.5)));
double t_3 = t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)));
double tmp;
if (t_3 <= -0.1) {
tmp = t_2;
} else if (t_3 <= 4.3e-21) {
tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
} else if (t_3 <= 0.98) {
tmp = t_2;
} else {
tmp = Math.sin(th);
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) t_2 = (math.sin(th) * t_1) / math.sqrt((1.0 - ((math.cos((kx + kx)) + math.cos((math.fabs(ky) + math.fabs(ky)))) * 0.5))) t_3 = t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0))) tmp = 0 if t_3 <= -0.1: tmp = t_2 elif t_3 <= 4.3e-21: tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx))) elif t_3 <= 0.98: tmp = t_2 else: tmp = math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) t_2 = Float64(Float64(sin(th) * t_1) / sqrt(Float64(1.0 - Float64(Float64(cos(Float64(kx + kx)) + cos(Float64(abs(ky) + abs(ky)))) * 0.5)))) t_3 = Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0)))) tmp = 0.0 if (t_3 <= -0.1) tmp = t_2; elseif (t_3 <= 4.3e-21) tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx)))); elseif (t_3 <= 0.98) tmp = t_2; else tmp = sin(th); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = sin(abs(ky)); t_2 = (sin(th) * t_1) / sqrt((1.0 - ((cos((kx + kx)) + cos((abs(ky) + abs(ky)))) * 0.5))); t_3 = t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0))); tmp = 0.0; if (t_3 <= -0.1) tmp = t_2; elseif (t_3 <= 4.3e-21) tmp = sin(th) * (abs(ky) / abs(sin(kx))); elseif (t_3 <= 0.98) tmp = t_2; else tmp = sin(th); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Sin[th], $MachinePrecision] * t$95$1), $MachinePrecision] / N[Sqrt[N[(1 - N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, -3602879701896397/36028797018963968], t$95$2, If[LessEqual[t$95$3, 2857840190937569/664613997892457936451903530140172288], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2206763817411543/2251799813685248], t$95$2, N[Sin[th], $MachinePrecision]]]]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := \frac{\sin th \cdot t\_1}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}}\\
t_3 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\
\mathbf{elif}\;t\_3 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001 or 4.2999999999999998e-21 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.97999999999999998Initial program 93.7%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6483.9%
Applied rewrites83.9%
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
fp-cancel-sign-sub-invN/A
flip3--N/A
lower-unsound-/.f64N/A
Applied rewrites77.8%
Applied rewrites74.4%
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))))) < 4.2999999999999998e-21Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6434.3%
lift-sqrt.f64N/A
lift-pow.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f6436.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.6%
Applied rewrites36.6%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-square-revN/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.7%
Applied rewrites38.7%
if 0.97999999999999998 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
Taylor expanded in ky around 0
lower-sin.f6424.3%
Applied rewrites24.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky)))
(t_2
(*
t_1
(/
(sin th)
(sqrt
(-
1
(*
(+ (cos (+ kx kx)) (cos (+ (fabs ky) (fabs ky))))
1/2))))))
(t_3 (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2))))))
(*
(copysign 1 ky)
(if (<= t_3 -3602879701896397/36028797018963968)
t_2
(if (<=
t_3
2857840190937569/664613997892457936451903530140172288)
(* (sin th) (/ (fabs ky) (fabs (sin kx))))
(if (<= t_3 2206763817411543/2251799813685248)
t_2
(sin th)))))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double t_2 = t_1 * (sin(th) / sqrt((1.0 - ((cos((kx + kx)) + cos((fabs(ky) + fabs(ky)))) * 0.5))));
double t_3 = t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)));
double tmp;
if (t_3 <= -0.1) {
tmp = t_2;
} else if (t_3 <= 4.3e-21) {
tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
} else if (t_3 <= 0.98) {
tmp = t_2;
} else {
tmp = sin(th);
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(Math.abs(ky));
double t_2 = t_1 * (Math.sin(th) / Math.sqrt((1.0 - ((Math.cos((kx + kx)) + Math.cos((Math.abs(ky) + Math.abs(ky)))) * 0.5))));
double t_3 = t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)));
double tmp;
if (t_3 <= -0.1) {
tmp = t_2;
} else if (t_3 <= 4.3e-21) {
tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
} else if (t_3 <= 0.98) {
tmp = t_2;
} else {
tmp = Math.sin(th);
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) t_2 = t_1 * (math.sin(th) / math.sqrt((1.0 - ((math.cos((kx + kx)) + math.cos((math.fabs(ky) + math.fabs(ky)))) * 0.5)))) t_3 = t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0))) tmp = 0 if t_3 <= -0.1: tmp = t_2 elif t_3 <= 4.3e-21: tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx))) elif t_3 <= 0.98: tmp = t_2 else: tmp = math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) t_2 = Float64(t_1 * Float64(sin(th) / sqrt(Float64(1.0 - Float64(Float64(cos(Float64(kx + kx)) + cos(Float64(abs(ky) + abs(ky)))) * 0.5))))) t_3 = Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0)))) tmp = 0.0 if (t_3 <= -0.1) tmp = t_2; elseif (t_3 <= 4.3e-21) tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx)))); elseif (t_3 <= 0.98) tmp = t_2; else tmp = sin(th); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = sin(abs(ky)); t_2 = t_1 * (sin(th) / sqrt((1.0 - ((cos((kx + kx)) + cos((abs(ky) + abs(ky)))) * 0.5)))); t_3 = t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0))); tmp = 0.0; if (t_3 <= -0.1) tmp = t_2; elseif (t_3 <= 4.3e-21) tmp = sin(th) * (abs(ky) / abs(sin(kx))); elseif (t_3 <= 0.98) tmp = t_2; else tmp = sin(th); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(1 - N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, -3602879701896397/36028797018963968], t$95$2, If[LessEqual[t$95$3, 2857840190937569/664613997892457936451903530140172288], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2206763817411543/2251799813685248], t$95$2, N[Sin[th], $MachinePrecision]]]]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := t\_1 \cdot \frac{\sin th}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}}\\
t_3 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\
\mathbf{elif}\;t\_3 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001 or 4.2999999999999998e-21 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.97999999999999998Initial program 93.7%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6483.9%
Applied rewrites83.9%
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
fp-cancel-sign-sub-invN/A
flip3--N/A
lower-unsound-/.f64N/A
Applied rewrites77.8%
Applied rewrites74.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))))) < 4.2999999999999998e-21Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6434.3%
lift-sqrt.f64N/A
lift-pow.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f6436.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.6%
Applied rewrites36.6%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-square-revN/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.7%
Applied rewrites38.7%
if 0.97999999999999998 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
Taylor expanded in ky around 0
lower-sin.f6424.3%
Applied rewrites24.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1
(sqrt
(-
1
(* (+ (cos (+ kx kx)) (cos (+ (fabs ky) (fabs ky)))) 1/2))))
(t_2 (sin (fabs ky)))
(t_3 (/ t_2 (sqrt (+ (pow (sin kx) 2) (pow t_2 2)))))
(t_4 (- t_2)))
(*
(copysign 1 ky)
(if (<= t_3 -1)
(* (/ t_2 (fabs t_2)) (sin th))
(if (<= t_3 -3602879701896397/36028797018963968)
(* t_4 (/ 1 (/ t_1 (- th))))
(if (<=
t_3
2857840190937569/664613997892457936451903530140172288)
(* (sin th) (/ (fabs ky) (fabs (sin kx))))
(if (<= t_3 2206763817411543/2251799813685248)
(* t_4 (* th (/ -1 t_1)))
(sin th))))))))double code(double kx, double ky, double th) {
double t_1 = sqrt((1.0 - ((cos((kx + kx)) + cos((fabs(ky) + fabs(ky)))) * 0.5)));
double t_2 = sin(fabs(ky));
double t_3 = t_2 / sqrt((pow(sin(kx), 2.0) + pow(t_2, 2.0)));
double t_4 = -t_2;
double tmp;
if (t_3 <= -1.0) {
tmp = (t_2 / fabs(t_2)) * sin(th);
} else if (t_3 <= -0.1) {
tmp = t_4 * (1.0 / (t_1 / -th));
} else if (t_3 <= 4.3e-21) {
tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
} else if (t_3 <= 0.98) {
tmp = t_4 * (th * (-1.0 / t_1));
} else {
tmp = sin(th);
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sqrt((1.0 - ((Math.cos((kx + kx)) + Math.cos((Math.abs(ky) + Math.abs(ky)))) * 0.5)));
double t_2 = Math.sin(Math.abs(ky));
double t_3 = t_2 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_2, 2.0)));
double t_4 = -t_2;
double tmp;
if (t_3 <= -1.0) {
tmp = (t_2 / Math.abs(t_2)) * Math.sin(th);
} else if (t_3 <= -0.1) {
tmp = t_4 * (1.0 / (t_1 / -th));
} else if (t_3 <= 4.3e-21) {
tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
} else if (t_3 <= 0.98) {
tmp = t_4 * (th * (-1.0 / t_1));
} else {
tmp = Math.sin(th);
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sqrt((1.0 - ((math.cos((kx + kx)) + math.cos((math.fabs(ky) + math.fabs(ky)))) * 0.5))) t_2 = math.sin(math.fabs(ky)) t_3 = t_2 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_2, 2.0))) t_4 = -t_2 tmp = 0 if t_3 <= -1.0: tmp = (t_2 / math.fabs(t_2)) * math.sin(th) elif t_3 <= -0.1: tmp = t_4 * (1.0 / (t_1 / -th)) elif t_3 <= 4.3e-21: tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx))) elif t_3 <= 0.98: tmp = t_4 * (th * (-1.0 / t_1)) else: tmp = math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sqrt(Float64(1.0 - Float64(Float64(cos(Float64(kx + kx)) + cos(Float64(abs(ky) + abs(ky)))) * 0.5))) t_2 = sin(abs(ky)) t_3 = Float64(t_2 / sqrt(Float64((sin(kx) ^ 2.0) + (t_2 ^ 2.0)))) t_4 = Float64(-t_2) tmp = 0.0 if (t_3 <= -1.0) tmp = Float64(Float64(t_2 / abs(t_2)) * sin(th)); elseif (t_3 <= -0.1) tmp = Float64(t_4 * Float64(1.0 / Float64(t_1 / Float64(-th)))); elseif (t_3 <= 4.3e-21) tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx)))); elseif (t_3 <= 0.98) tmp = Float64(t_4 * Float64(th * Float64(-1.0 / t_1))); else tmp = sin(th); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = sqrt((1.0 - ((cos((kx + kx)) + cos((abs(ky) + abs(ky)))) * 0.5))); t_2 = sin(abs(ky)); t_3 = t_2 / sqrt(((sin(kx) ^ 2.0) + (t_2 ^ 2.0))); t_4 = -t_2; tmp = 0.0; if (t_3 <= -1.0) tmp = (t_2 / abs(t_2)) * sin(th); elseif (t_3 <= -0.1) tmp = t_4 * (1.0 / (t_1 / -th)); elseif (t_3 <= 4.3e-21) tmp = sin(th) * (abs(ky) / abs(sin(kx))); elseif (t_3 <= 0.98) tmp = t_4 * (th * (-1.0 / t_1)); else tmp = sin(th); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[(1 - N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$2, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = (-t$95$2)}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, -1], N[(N[(t$95$2 / N[Abs[t$95$2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -3602879701896397/36028797018963968], N[(t$95$4 * N[(1 / N[(t$95$1 / (-th)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2857840190937569/664613997892457936451903530140172288], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2206763817411543/2251799813685248], N[(t$95$4 * N[(th * N[(-1 / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]), $MachinePrecision]]]]]
\begin{array}{l}
t_1 := \sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}\\
t_2 := \sin \left(\left|ky\right|\right)\\
t_3 := \frac{t\_2}{\sqrt{{\sin kx}^{2} + {t\_2}^{2}}}\\
t_4 := -t\_2\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq -1:\\
\;\;\;\;\frac{t\_2}{\left|t\_2\right|} \cdot \sin th\\
\mathbf{elif}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_4 \cdot \frac{1}{\frac{t\_1}{-th}}\\
\mathbf{elif}\;t\_3 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\
\mathbf{elif}\;t\_3 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;t\_4 \cdot \left(th \cdot \frac{-1}{t\_1}\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))))) < -1Initial program 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f6431.5%
lift-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
cos-2N/A
cos-sumN/A
lift-+.f64N/A
lift-cos.f64N/A
sub-flipN/A
distribute-lft-inN/A
Applied rewrites31.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6431.5%
Applied rewrites45.5%
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.10000000000000001Initial program 93.7%
Applied rewrites74.6%
Taylor expanded in th around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6438.6%
Applied rewrites38.6%
Applied rewrites38.6%
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))))) < 4.2999999999999998e-21Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6434.3%
lift-sqrt.f64N/A
lift-pow.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f6436.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.6%
Applied rewrites36.6%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-square-revN/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.7%
Applied rewrites38.7%
if 4.2999999999999998e-21 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.97999999999999998Initial program 93.7%
Applied rewrites74.6%
Taylor expanded in th around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6438.6%
Applied rewrites38.6%
Applied rewrites38.6%
if 0.97999999999999998 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
Taylor expanded in ky around 0
lower-sin.f6424.3%
Applied rewrites24.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky)))
(t_2 (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2))))))
(*
(copysign 1 ky)
(if (<= t_2 -1)
(* (/ t_1 (fabs t_1)) (sin th))
(if (<= t_2 -3602879701896397/36028797018963968)
(/
(* th t_1)
(sqrt
(-
1
(+ (* 1/2 (cos (* 2 kx))) (* 1/2 (cos (* 2 (fabs ky))))))))
(if (<=
t_2
2857840190937569/664613997892457936451903530140172288)
(* (sin th) (/ (fabs ky) (fabs (sin kx))))
(if (<= t_2 2206763817411543/2251799813685248)
(*
(- t_1)
(*
th
(/
-1
(sqrt
(-
1
(*
(+ (cos (+ kx kx)) (cos (+ (fabs ky) (fabs ky))))
1/2))))))
(sin th))))))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double t_2 = t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)));
double tmp;
if (t_2 <= -1.0) {
tmp = (t_1 / fabs(t_1)) * sin(th);
} else if (t_2 <= -0.1) {
tmp = (th * t_1) / sqrt((1.0 - ((0.5 * cos((2.0 * kx))) + (0.5 * cos((2.0 * fabs(ky)))))));
} else if (t_2 <= 4.3e-21) {
tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
} else if (t_2 <= 0.98) {
tmp = -t_1 * (th * (-1.0 / sqrt((1.0 - ((cos((kx + kx)) + cos((fabs(ky) + fabs(ky)))) * 0.5)))));
} else {
tmp = sin(th);
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(Math.abs(ky));
double t_2 = t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)));
double tmp;
if (t_2 <= -1.0) {
tmp = (t_1 / Math.abs(t_1)) * Math.sin(th);
} else if (t_2 <= -0.1) {
tmp = (th * t_1) / Math.sqrt((1.0 - ((0.5 * Math.cos((2.0 * kx))) + (0.5 * Math.cos((2.0 * Math.abs(ky)))))));
} else if (t_2 <= 4.3e-21) {
tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
} else if (t_2 <= 0.98) {
tmp = -t_1 * (th * (-1.0 / Math.sqrt((1.0 - ((Math.cos((kx + kx)) + Math.cos((Math.abs(ky) + Math.abs(ky)))) * 0.5)))));
} else {
tmp = Math.sin(th);
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) t_2 = t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0))) tmp = 0 if t_2 <= -1.0: tmp = (t_1 / math.fabs(t_1)) * math.sin(th) elif t_2 <= -0.1: tmp = (th * t_1) / math.sqrt((1.0 - ((0.5 * math.cos((2.0 * kx))) + (0.5 * math.cos((2.0 * math.fabs(ky))))))) elif t_2 <= 4.3e-21: tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx))) elif t_2 <= 0.98: tmp = -t_1 * (th * (-1.0 / math.sqrt((1.0 - ((math.cos((kx + kx)) + math.cos((math.fabs(ky) + math.fabs(ky)))) * 0.5))))) else: tmp = math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) t_2 = Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0)))) tmp = 0.0 if (t_2 <= -1.0) tmp = Float64(Float64(t_1 / abs(t_1)) * sin(th)); elseif (t_2 <= -0.1) tmp = Float64(Float64(th * t_1) / sqrt(Float64(1.0 - Float64(Float64(0.5 * cos(Float64(2.0 * kx))) + Float64(0.5 * cos(Float64(2.0 * abs(ky)))))))); elseif (t_2 <= 4.3e-21) tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx)))); elseif (t_2 <= 0.98) tmp = Float64(Float64(-t_1) * Float64(th * Float64(-1.0 / sqrt(Float64(1.0 - Float64(Float64(cos(Float64(kx + kx)) + cos(Float64(abs(ky) + abs(ky)))) * 0.5)))))); else tmp = sin(th); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = sin(abs(ky)); t_2 = t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0))); tmp = 0.0; if (t_2 <= -1.0) tmp = (t_1 / abs(t_1)) * sin(th); elseif (t_2 <= -0.1) tmp = (th * t_1) / sqrt((1.0 - ((0.5 * cos((2.0 * kx))) + (0.5 * cos((2.0 * abs(ky))))))); elseif (t_2 <= 4.3e-21) tmp = sin(th) * (abs(ky) / abs(sin(kx))); elseif (t_2 <= 0.98) tmp = -t_1 * (th * (-1.0 / sqrt((1.0 - ((cos((kx + kx)) + cos((abs(ky) + abs(ky)))) * 0.5))))); else tmp = sin(th); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -1], N[(N[(t$95$1 / N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -3602879701896397/36028797018963968], N[(N[(th * t$95$1), $MachinePrecision] / N[Sqrt[N[(1 - N[(N[(1/2 * N[Cos[N[(2 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(1/2 * N[Cos[N[(2 * N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2857840190937569/664613997892457936451903530140172288], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2206763817411543/2251799813685248], N[((-t$95$1) * N[(th * N[(-1 / N[Sqrt[N[(1 - N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]), $MachinePrecision]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -1:\\
\;\;\;\;\frac{t\_1}{\left|t\_1\right|} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;\frac{th \cdot t\_1}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot \left|ky\right|\right)\right)}}\\
\mathbf{elif}\;t\_2 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\
\mathbf{elif}\;t\_2 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;\left(-t\_1\right) \cdot \left(th \cdot \frac{-1}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}}\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))))) < -1Initial program 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f6431.5%
lift-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
cos-2N/A
cos-sumN/A
lift-+.f64N/A
lift-cos.f64N/A
sub-flipN/A
distribute-lft-inN/A
Applied rewrites31.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6431.5%
Applied rewrites45.5%
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.10000000000000001Initial program 93.7%
Applied rewrites74.6%
Taylor expanded in th around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6438.5%
Applied rewrites38.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))))) < 4.2999999999999998e-21Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6434.3%
lift-sqrt.f64N/A
lift-pow.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f6436.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.6%
Applied rewrites36.6%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-square-revN/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.7%
Applied rewrites38.7%
if 4.2999999999999998e-21 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.97999999999999998Initial program 93.7%
Applied rewrites74.6%
Taylor expanded in th around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6438.6%
Applied rewrites38.6%
Applied rewrites38.6%
if 0.97999999999999998 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
Taylor expanded in ky around 0
lower-sin.f6424.3%
Applied rewrites24.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1
(sqrt
(-
1
(* (+ (cos (+ kx kx)) (cos (+ (fabs ky) (fabs ky)))) 1/2))))
(t_2 (sin (fabs ky)))
(t_3 (/ t_2 (sqrt (+ (pow (sin kx) 2) (pow t_2 2))))))
(*
(copysign 1 ky)
(if (<= t_3 -1)
(* (/ t_2 (fabs t_2)) (sin th))
(if (<= t_3 -3602879701896397/36028797018963968)
(* t_2 (- (/ (- th) t_1)))
(if (<=
t_3
2857840190937569/664613997892457936451903530140172288)
(* (sin th) (/ (fabs ky) (fabs (sin kx))))
(if (<= t_3 2206763817411543/2251799813685248)
(* (- t_2) (* th (/ -1 t_1)))
(sin th))))))))double code(double kx, double ky, double th) {
double t_1 = sqrt((1.0 - ((cos((kx + kx)) + cos((fabs(ky) + fabs(ky)))) * 0.5)));
double t_2 = sin(fabs(ky));
double t_3 = t_2 / sqrt((pow(sin(kx), 2.0) + pow(t_2, 2.0)));
double tmp;
if (t_3 <= -1.0) {
tmp = (t_2 / fabs(t_2)) * sin(th);
} else if (t_3 <= -0.1) {
tmp = t_2 * -(-th / t_1);
} else if (t_3 <= 4.3e-21) {
tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
} else if (t_3 <= 0.98) {
tmp = -t_2 * (th * (-1.0 / t_1));
} else {
tmp = sin(th);
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sqrt((1.0 - ((Math.cos((kx + kx)) + Math.cos((Math.abs(ky) + Math.abs(ky)))) * 0.5)));
double t_2 = Math.sin(Math.abs(ky));
double t_3 = t_2 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_2, 2.0)));
double tmp;
if (t_3 <= -1.0) {
tmp = (t_2 / Math.abs(t_2)) * Math.sin(th);
} else if (t_3 <= -0.1) {
tmp = t_2 * -(-th / t_1);
} else if (t_3 <= 4.3e-21) {
tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
} else if (t_3 <= 0.98) {
tmp = -t_2 * (th * (-1.0 / t_1));
} else {
tmp = Math.sin(th);
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sqrt((1.0 - ((math.cos((kx + kx)) + math.cos((math.fabs(ky) + math.fabs(ky)))) * 0.5))) t_2 = math.sin(math.fabs(ky)) t_3 = t_2 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_2, 2.0))) tmp = 0 if t_3 <= -1.0: tmp = (t_2 / math.fabs(t_2)) * math.sin(th) elif t_3 <= -0.1: tmp = t_2 * -(-th / t_1) elif t_3 <= 4.3e-21: tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx))) elif t_3 <= 0.98: tmp = -t_2 * (th * (-1.0 / t_1)) else: tmp = math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sqrt(Float64(1.0 - Float64(Float64(cos(Float64(kx + kx)) + cos(Float64(abs(ky) + abs(ky)))) * 0.5))) t_2 = sin(abs(ky)) t_3 = Float64(t_2 / sqrt(Float64((sin(kx) ^ 2.0) + (t_2 ^ 2.0)))) tmp = 0.0 if (t_3 <= -1.0) tmp = Float64(Float64(t_2 / abs(t_2)) * sin(th)); elseif (t_3 <= -0.1) tmp = Float64(t_2 * Float64(-Float64(Float64(-th) / t_1))); elseif (t_3 <= 4.3e-21) tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx)))); elseif (t_3 <= 0.98) tmp = Float64(Float64(-t_2) * Float64(th * Float64(-1.0 / t_1))); else tmp = sin(th); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = sqrt((1.0 - ((cos((kx + kx)) + cos((abs(ky) + abs(ky)))) * 0.5))); t_2 = sin(abs(ky)); t_3 = t_2 / sqrt(((sin(kx) ^ 2.0) + (t_2 ^ 2.0))); tmp = 0.0; if (t_3 <= -1.0) tmp = (t_2 / abs(t_2)) * sin(th); elseif (t_3 <= -0.1) tmp = t_2 * -(-th / t_1); elseif (t_3 <= 4.3e-21) tmp = sin(th) * (abs(ky) / abs(sin(kx))); elseif (t_3 <= 0.98) tmp = -t_2 * (th * (-1.0 / t_1)); else tmp = sin(th); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[(1 - N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$2, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, -1], N[(N[(t$95$2 / N[Abs[t$95$2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -3602879701896397/36028797018963968], N[(t$95$2 * (-N[((-th) / t$95$1), $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$3, 2857840190937569/664613997892457936451903530140172288], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2206763817411543/2251799813685248], N[((-t$95$2) * N[(th * N[(-1 / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}\\
t_2 := \sin \left(\left|ky\right|\right)\\
t_3 := \frac{t\_2}{\sqrt{{\sin kx}^{2} + {t\_2}^{2}}}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq -1:\\
\;\;\;\;\frac{t\_2}{\left|t\_2\right|} \cdot \sin th\\
\mathbf{elif}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_2 \cdot \left(-\frac{-th}{t\_1}\right)\\
\mathbf{elif}\;t\_3 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\
\mathbf{elif}\;t\_3 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;\left(-t\_2\right) \cdot \left(th \cdot \frac{-1}{t\_1}\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))))) < -1Initial program 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f6431.5%
lift-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
cos-2N/A
cos-sumN/A
lift-+.f64N/A
lift-cos.f64N/A
sub-flipN/A
distribute-lft-inN/A
Applied rewrites31.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6431.5%
Applied rewrites45.5%
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.10000000000000001Initial program 93.7%
Applied rewrites74.6%
Taylor expanded in th around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6438.6%
Applied rewrites38.6%
Applied rewrites38.6%
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))))) < 4.2999999999999998e-21Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6434.3%
lift-sqrt.f64N/A
lift-pow.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f6436.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.6%
Applied rewrites36.6%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-square-revN/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.7%
Applied rewrites38.7%
if 4.2999999999999998e-21 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.97999999999999998Initial program 93.7%
Applied rewrites74.6%
Taylor expanded in th around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6438.6%
Applied rewrites38.6%
Applied rewrites38.6%
if 0.97999999999999998 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
Taylor expanded in ky around 0
lower-sin.f6424.3%
Applied rewrites24.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky)))
(t_2 (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2)))))
(t_3
(*
t_1
(-
(/
(- th)
(sqrt
(-
1
(*
(+ (cos (+ kx kx)) (cos (+ (fabs ky) (fabs ky))))
1/2))))))))
(*
(copysign 1 ky)
(if (<= t_2 -1)
(* (/ t_1 (fabs t_1)) (sin th))
(if (<= t_2 -3602879701896397/36028797018963968)
t_3
(if (<=
t_2
2857840190937569/664613997892457936451903530140172288)
(* (sin th) (/ (fabs ky) (fabs (sin kx))))
(if (<= t_2 2206763817411543/2251799813685248)
t_3
(sin th))))))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double t_2 = t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)));
double t_3 = t_1 * -(-th / sqrt((1.0 - ((cos((kx + kx)) + cos((fabs(ky) + fabs(ky)))) * 0.5))));
double tmp;
if (t_2 <= -1.0) {
tmp = (t_1 / fabs(t_1)) * sin(th);
} else if (t_2 <= -0.1) {
tmp = t_3;
} else if (t_2 <= 4.3e-21) {
tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
} else if (t_2 <= 0.98) {
tmp = t_3;
} else {
tmp = sin(th);
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(Math.abs(ky));
double t_2 = t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)));
double t_3 = t_1 * -(-th / Math.sqrt((1.0 - ((Math.cos((kx + kx)) + Math.cos((Math.abs(ky) + Math.abs(ky)))) * 0.5))));
double tmp;
if (t_2 <= -1.0) {
tmp = (t_1 / Math.abs(t_1)) * Math.sin(th);
} else if (t_2 <= -0.1) {
tmp = t_3;
} else if (t_2 <= 4.3e-21) {
tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
} else if (t_2 <= 0.98) {
tmp = t_3;
} else {
tmp = Math.sin(th);
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) t_2 = t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0))) t_3 = t_1 * -(-th / math.sqrt((1.0 - ((math.cos((kx + kx)) + math.cos((math.fabs(ky) + math.fabs(ky)))) * 0.5)))) tmp = 0 if t_2 <= -1.0: tmp = (t_1 / math.fabs(t_1)) * math.sin(th) elif t_2 <= -0.1: tmp = t_3 elif t_2 <= 4.3e-21: tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx))) elif t_2 <= 0.98: tmp = t_3 else: tmp = math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) t_2 = Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0)))) t_3 = Float64(t_1 * Float64(-Float64(Float64(-th) / sqrt(Float64(1.0 - Float64(Float64(cos(Float64(kx + kx)) + cos(Float64(abs(ky) + abs(ky)))) * 0.5)))))) tmp = 0.0 if (t_2 <= -1.0) tmp = Float64(Float64(t_1 / abs(t_1)) * sin(th)); elseif (t_2 <= -0.1) tmp = t_3; elseif (t_2 <= 4.3e-21) tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx)))); elseif (t_2 <= 0.98) tmp = t_3; else tmp = sin(th); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = sin(abs(ky)); t_2 = t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0))); t_3 = t_1 * -(-th / sqrt((1.0 - ((cos((kx + kx)) + cos((abs(ky) + abs(ky)))) * 0.5)))); tmp = 0.0; if (t_2 <= -1.0) tmp = (t_1 / abs(t_1)) * sin(th); elseif (t_2 <= -0.1) tmp = t_3; elseif (t_2 <= 4.3e-21) tmp = sin(th) * (abs(ky) / abs(sin(kx))); elseif (t_2 <= 0.98) tmp = t_3; else tmp = sin(th); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * (-N[((-th) / N[Sqrt[N[(1 - N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -1], N[(N[(t$95$1 / N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -3602879701896397/36028797018963968], t$95$3, If[LessEqual[t$95$2, 2857840190937569/664613997892457936451903530140172288], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2206763817411543/2251799813685248], t$95$3, N[Sin[th], $MachinePrecision]]]]]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\
t_3 := t\_1 \cdot \left(-\frac{-th}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}}\right)\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -1:\\
\;\;\;\;\frac{t\_1}{\left|t\_1\right|} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\
\mathbf{elif}\;t\_2 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;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))))) < -1Initial program 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f6431.5%
lift-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
cos-2N/A
cos-sumN/A
lift-+.f64N/A
lift-cos.f64N/A
sub-flipN/A
distribute-lft-inN/A
Applied rewrites31.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6431.5%
Applied rewrites45.5%
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.10000000000000001 or 4.2999999999999998e-21 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.97999999999999998Initial program 93.7%
Applied rewrites74.6%
Taylor expanded in th around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6438.6%
Applied rewrites38.6%
Applied rewrites38.6%
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))))) < 4.2999999999999998e-21Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6434.3%
lift-sqrt.f64N/A
lift-pow.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f6436.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.6%
Applied rewrites36.6%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-square-revN/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.7%
Applied rewrites38.7%
if 0.97999999999999998 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) Initial program 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
Taylor expanded in ky around 0
lower-sin.f6424.3%
Applied rewrites24.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (/ (sin ky) (fabs (sin ky))) (sin th)))
(t_2
(/ (sin ky) (sqrt (+ (pow (sin kx) 2) (pow (sin ky) 2))))))
(if (<= t_2 -3602879701896397/36028797018963968)
t_1
(if (<=
t_2
6646139978924579/1329227995784915872903807060280344576)
(* (sin th) (/ ky (fabs (sin kx))))
t_1))))double code(double kx, double ky, double th) {
double t_1 = (sin(ky) / fabs(sin(ky))) * sin(th);
double t_2 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
double tmp;
if (t_2 <= -0.1) {
tmp = t_1;
} else if (t_2 <= 5e-21) {
tmp = sin(th) * (ky / fabs(sin(kx)));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(kx, ky, th)
use fmin_fmax_functions
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (sin(ky) / abs(sin(ky))) * sin(th)
t_2 = sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))
if (t_2 <= (-0.1d0)) then
tmp = t_1
else if (t_2 <= 5d-21) then
tmp = sin(th) * (ky / abs(sin(kx)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = (Math.sin(ky) / Math.abs(Math.sin(ky))) * Math.sin(th);
double t_2 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
double tmp;
if (t_2 <= -0.1) {
tmp = t_1;
} else if (t_2 <= 5e-21) {
tmp = Math.sin(th) * (ky / Math.abs(Math.sin(kx)));
} else {
tmp = t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = (math.sin(ky) / math.fabs(math.sin(ky))) * math.sin(th) t_2 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0))) tmp = 0 if t_2 <= -0.1: tmp = t_1 elif t_2 <= 5e-21: tmp = math.sin(th) * (ky / math.fabs(math.sin(kx))) else: tmp = t_1 return tmp
function code(kx, ky, th) t_1 = Float64(Float64(sin(ky) / abs(sin(ky))) * sin(th)) t_2 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) tmp = 0.0 if (t_2 <= -0.1) tmp = t_1; elseif (t_2 <= 5e-21) tmp = Float64(sin(th) * Float64(ky / abs(sin(kx)))); else tmp = t_1; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = (sin(ky) / abs(sin(ky))) * sin(th); t_2 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))); tmp = 0.0; if (t_2 <= -0.1) tmp = t_1; elseif (t_2 <= 5e-21) tmp = sin(th) * (ky / abs(sin(kx))); else tmp = t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -3602879701896397/36028797018963968], t$95$1, If[LessEqual[t$95$2, 6646139978924579/1329227995784915872903807060280344576], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_1 := \frac{\sin ky}{\left|\sin ky\right|} \cdot \sin th\\
t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_2 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq \frac{6646139978924579}{1329227995784915872903807060280344576}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\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.10000000000000001 or 4.9999999999999997e-21 < (/.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 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f6431.5%
lift-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
cos-2N/A
cos-sumN/A
lift-+.f64N/A
lift-cos.f64N/A
sub-flipN/A
distribute-lft-inN/A
Applied rewrites31.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6431.5%
Applied rewrites45.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))))) < 4.9999999999999997e-21Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6434.3%
lift-sqrt.f64N/A
lift-pow.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f6436.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.6%
Applied rewrites36.6%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-square-revN/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.7%
Applied rewrites38.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky)))
(t_2 (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2))))))
(*
(copysign 1 ky)
(if (<= t_2 -3602879701896397/36028797018963968)
(/ (* th t_1) (sqrt (* 1/2 (- 1 (cos (* 2 (fabs ky)))))))
(if (<=
t_2
6646139978924579/1329227995784915872903807060280344576)
(* (sin th) (/ (fabs ky) (fabs (sin kx))))
(sin th))))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double t_2 = t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)));
double tmp;
if (t_2 <= -0.1) {
tmp = (th * t_1) / sqrt((0.5 * (1.0 - cos((2.0 * fabs(ky))))));
} else if (t_2 <= 5e-21) {
tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
} else {
tmp = sin(th);
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(Math.abs(ky));
double t_2 = t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)));
double tmp;
if (t_2 <= -0.1) {
tmp = (th * t_1) / Math.sqrt((0.5 * (1.0 - Math.cos((2.0 * Math.abs(ky))))));
} else if (t_2 <= 5e-21) {
tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) t_2 = t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0))) tmp = 0 if t_2 <= -0.1: tmp = (th * t_1) / math.sqrt((0.5 * (1.0 - math.cos((2.0 * math.fabs(ky)))))) elif t_2 <= 5e-21: tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx))) else: tmp = math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) t_2 = Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0)))) tmp = 0.0 if (t_2 <= -0.1) tmp = Float64(Float64(th * t_1) / sqrt(Float64(0.5 * Float64(1.0 - cos(Float64(2.0 * abs(ky))))))); elseif (t_2 <= 5e-21) tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx)))); else tmp = sin(th); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = sin(abs(ky)); t_2 = t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0))); tmp = 0.0; if (t_2 <= -0.1) tmp = (th * t_1) / sqrt((0.5 * (1.0 - cos((2.0 * abs(ky)))))); elseif (t_2 <= 5e-21) tmp = sin(th) * (abs(ky) / abs(sin(kx))); else tmp = sin(th); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -3602879701896397/36028797018963968], N[(N[(th * t$95$1), $MachinePrecision] / N[Sqrt[N[(1/2 * N[(1 - N[Cos[N[(2 * N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 6646139978924579/1329227995784915872903807060280344576], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]), $MachinePrecision]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;\frac{th \cdot t\_1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot \left|ky\right|\right)\right)}}\\
\mathbf{elif}\;t\_2 \leq \frac{6646139978924579}{1329227995784915872903807060280344576}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\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.10000000000000001Initial program 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
Taylor expanded in th around 0
lower-*.f64N/A
lower-sin.f6417.0%
Applied rewrites17.0%
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))))) < 4.9999999999999997e-21Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6434.3%
lift-sqrt.f64N/A
lift-pow.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f6436.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.6%
Applied rewrites36.6%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-square-revN/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.7%
Applied rewrites38.7%
if 4.9999999999999997e-21 < (/.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 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
Taylor expanded in ky around 0
lower-sin.f6424.3%
Applied rewrites24.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky))))
(*
(copysign 1 ky)
(if (<=
(/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2))))
6646139978924579/1329227995784915872903807060280344576)
(* (sin th) (/ (fabs ky) (fabs (sin kx))))
(sin th)))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double tmp;
if ((t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)))) <= 5e-21) {
tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
} else {
tmp = sin(th);
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(Math.abs(ky));
double tmp;
if ((t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)))) <= 5e-21) {
tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) tmp = 0 if (t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0)))) <= 5e-21: tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx))) else: tmp = math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) tmp = 0.0 if (Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0)))) <= 5e-21) tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx)))); else tmp = sin(th); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = sin(abs(ky)); tmp = 0.0; if ((t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0)))) <= 5e-21) tmp = sin(th) * (abs(ky) / abs(sin(kx))); else tmp = sin(th); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 6646139978924579/1329227995784915872903807060280344576], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;\frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}} \leq \frac{6646139978924579}{1329227995784915872903807060280344576}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\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))))) < 4.9999999999999997e-21Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6434.3%
lift-sqrt.f64N/A
lift-pow.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f6436.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.6%
Applied rewrites36.6%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
unpow2N/A
rem-sqrt-square-revN/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.7%
Applied rewrites38.7%
if 4.9999999999999997e-21 < (/.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 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
Taylor expanded in ky around 0
lower-sin.f6424.3%
Applied rewrites24.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky)))
(t_2 (sin (fabs kx)))
(t_3 (/ t_1 (sqrt (+ (pow t_2 2) (pow t_1 2))))))
(*
(copysign 1 ky)
(if (<=
t_3
8069530869021589/20173827172553973356686868531273530268200826506478308693989526222973809547006571833044104322501076808092993531037089792)
(/ (* (fabs ky) th) (fabs t_2))
(if (<=
t_3
7136238463529799/356811923176489970264571492362373784095686656)
(* (sin th) (/ (fabs ky) (fabs kx)))
(sin th))))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double t_2 = sin(fabs(kx));
double t_3 = t_1 / sqrt((pow(t_2, 2.0) + pow(t_1, 2.0)));
double tmp;
if (t_3 <= 4e-103) {
tmp = (fabs(ky) * th) / fabs(t_2);
} else if (t_3 <= 2e-29) {
tmp = sin(th) * (fabs(ky) / fabs(kx));
} else {
tmp = sin(th);
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(Math.abs(ky));
double t_2 = Math.sin(Math.abs(kx));
double t_3 = t_1 / Math.sqrt((Math.pow(t_2, 2.0) + Math.pow(t_1, 2.0)));
double tmp;
if (t_3 <= 4e-103) {
tmp = (Math.abs(ky) * th) / Math.abs(t_2);
} else if (t_3 <= 2e-29) {
tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(kx));
} else {
tmp = Math.sin(th);
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) t_2 = math.sin(math.fabs(kx)) t_3 = t_1 / math.sqrt((math.pow(t_2, 2.0) + math.pow(t_1, 2.0))) tmp = 0 if t_3 <= 4e-103: tmp = (math.fabs(ky) * th) / math.fabs(t_2) elif t_3 <= 2e-29: tmp = math.sin(th) * (math.fabs(ky) / math.fabs(kx)) else: tmp = math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) t_2 = sin(abs(kx)) t_3 = Float64(t_1 / sqrt(Float64((t_2 ^ 2.0) + (t_1 ^ 2.0)))) tmp = 0.0 if (t_3 <= 4e-103) tmp = Float64(Float64(abs(ky) * th) / abs(t_2)); elseif (t_3 <= 2e-29) tmp = Float64(sin(th) * Float64(abs(ky) / abs(kx))); else tmp = sin(th); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = sin(abs(ky)); t_2 = sin(abs(kx)); t_3 = t_1 / sqrt(((t_2 ^ 2.0) + (t_1 ^ 2.0))); tmp = 0.0; if (t_3 <= 4e-103) tmp = (abs(ky) * th) / abs(t_2); elseif (t_3 <= 2e-29) tmp = sin(th) * (abs(ky) / abs(kx)); else tmp = sin(th); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[kx], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 / N[Sqrt[N[(N[Power[t$95$2, 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, 8069530869021589/20173827172553973356686868531273530268200826506478308693989526222973809547006571833044104322501076808092993531037089792], N[(N[(N[Abs[ky], $MachinePrecision] * th), $MachinePrecision] / N[Abs[t$95$2], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 7136238463529799/356811923176489970264571492362373784095686656], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := \sin \left(\left|kx\right|\right)\\
t_3 := \frac{t\_1}{\sqrt{{t\_2}^{2} + {t\_1}^{2}}}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq \frac{8069530869021589}{20173827172553973356686868531273530268200826506478308693989526222973809547006571833044104322501076808092993531037089792}:\\
\;\;\;\;\frac{\left|ky\right| \cdot th}{\left|t\_2\right|}\\
\mathbf{elif}\;t\_3 \leq \frac{7136238463529799}{356811923176489970264571492362373784095686656}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|kx\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))))) < 3.9999999999999998e-103Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6434.3%
lift-sqrt.f64N/A
lift-pow.f64N/A
unpow2N/A
rem-sqrt-squareN/A
lower-fabs.f6436.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.6%
Applied rewrites36.6%
Taylor expanded in th around 0
lower-/.f64N/A
lower-*.f64N/A
lower-fabs.f64N/A
lower-sin.f6418.7%
Applied rewrites18.7%
if 3.9999999999999998e-103 < (/.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.9999999999999999e-29Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f6415.8%
Applied rewrites15.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6416.5%
Applied rewrites16.5%
if 1.9999999999999999e-29 < (/.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 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
Taylor expanded in ky around 0
lower-sin.f6424.3%
Applied rewrites24.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky))))
(*
(copysign 1 ky)
(if (<=
(/ t_1 (sqrt (+ (pow (sin (fabs kx)) 2) (pow t_1 2))))
7136238463529799/356811923176489970264571492362373784095686656)
(* (sin th) (/ (fabs ky) (fabs kx)))
(sin th)))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double tmp;
if ((t_1 / sqrt((pow(sin(fabs(kx)), 2.0) + pow(t_1, 2.0)))) <= 2e-29) {
tmp = sin(th) * (fabs(ky) / fabs(kx));
} else {
tmp = sin(th);
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(Math.abs(ky));
double tmp;
if ((t_1 / Math.sqrt((Math.pow(Math.sin(Math.abs(kx)), 2.0) + Math.pow(t_1, 2.0)))) <= 2e-29) {
tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(kx));
} else {
tmp = Math.sin(th);
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) tmp = 0 if (t_1 / math.sqrt((math.pow(math.sin(math.fabs(kx)), 2.0) + math.pow(t_1, 2.0)))) <= 2e-29: tmp = math.sin(th) * (math.fabs(ky) / math.fabs(kx)) else: tmp = math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) tmp = 0.0 if (Float64(t_1 / sqrt(Float64((sin(abs(kx)) ^ 2.0) + (t_1 ^ 2.0)))) <= 2e-29) tmp = Float64(sin(th) * Float64(abs(ky) / abs(kx))); else tmp = sin(th); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = sin(abs(ky)); tmp = 0.0; if ((t_1 / sqrt(((sin(abs(kx)) ^ 2.0) + (t_1 ^ 2.0)))) <= 2e-29) tmp = sin(th) * (abs(ky) / abs(kx)); else tmp = sin(th); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[N[Abs[kx], $MachinePrecision]], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 7136238463529799/356811923176489970264571492362373784095686656], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;\frac{t\_1}{\sqrt{{\sin \left(\left|kx\right|\right)}^{2} + {t\_1}^{2}}} \leq \frac{7136238463529799}{356811923176489970264571492362373784095686656}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|kx\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))))) < 1.9999999999999999e-29Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f6415.8%
Applied rewrites15.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6416.5%
Applied rewrites16.5%
if 1.9999999999999999e-29 < (/.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 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
Taylor expanded in ky around 0
lower-sin.f6424.3%
Applied rewrites24.3%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky))))
(*
(copysign 1 ky)
(if (<=
(/ t_1 (sqrt (+ (pow (sin (fabs kx)) 2) (pow t_1 2))))
7136238463529799/356811923176489970264571492362373784095686656)
(/ (* (fabs ky) th) (fabs kx))
(sin th)))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double tmp;
if ((t_1 / sqrt((pow(sin(fabs(kx)), 2.0) + pow(t_1, 2.0)))) <= 2e-29) {
tmp = (fabs(ky) * th) / fabs(kx);
} else {
tmp = sin(th);
}
return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(Math.abs(ky));
double tmp;
if ((t_1 / Math.sqrt((Math.pow(Math.sin(Math.abs(kx)), 2.0) + Math.pow(t_1, 2.0)))) <= 2e-29) {
tmp = (Math.abs(ky) * th) / Math.abs(kx);
} else {
tmp = Math.sin(th);
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) tmp = 0 if (t_1 / math.sqrt((math.pow(math.sin(math.fabs(kx)), 2.0) + math.pow(t_1, 2.0)))) <= 2e-29: tmp = (math.fabs(ky) * th) / math.fabs(kx) else: tmp = math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) tmp = 0.0 if (Float64(t_1 / sqrt(Float64((sin(abs(kx)) ^ 2.0) + (t_1 ^ 2.0)))) <= 2e-29) tmp = Float64(Float64(abs(ky) * th) / abs(kx)); else tmp = sin(th); end return Float64(copysign(1.0, ky) * tmp) end
function tmp_2 = code(kx, ky, th) t_1 = sin(abs(ky)); tmp = 0.0; if ((t_1 / sqrt(((sin(abs(kx)) ^ 2.0) + (t_1 ^ 2.0)))) <= 2e-29) tmp = (abs(ky) * th) / abs(kx); else tmp = sin(th); end tmp_2 = (sign(ky) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[N[Abs[kx], $MachinePrecision]], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 7136238463529799/356811923176489970264571492362373784095686656], N[(N[(N[Abs[ky], $MachinePrecision] * th), $MachinePrecision] / N[Abs[kx], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;\frac{t\_1}{\sqrt{{\sin \left(\left|kx\right|\right)}^{2} + {t\_1}^{2}}} \leq \frac{7136238463529799}{356811923176489970264571492362373784095686656}:\\
\;\;\;\;\frac{\left|ky\right| \cdot th}{\left|kx\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))))) < 1.9999999999999999e-29Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f6415.8%
Applied rewrites15.8%
Taylor expanded in th around 0
lower-*.f6412.3%
Applied rewrites12.3%
if 1.9999999999999999e-29 < (/.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 93.7%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
count-2-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-+.f6474.9%
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sin-multN/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites74.7%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-cos.f64N/A
lower-*.f6431.3%
Applied rewrites31.3%
Taylor expanded in ky around 0
lower-sin.f6424.3%
Applied rewrites24.3%
(FPCore (kx ky th) :precision binary64 (/ (* ky th) (fabs kx)))
double code(double kx, double ky, double th) {
return (ky * th) / fabs(kx);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(kx, ky, th)
use fmin_fmax_functions
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (ky * th) / abs(kx)
end function
public static double code(double kx, double ky, double th) {
return (ky * th) / Math.abs(kx);
}
def code(kx, ky, th): return (ky * th) / math.fabs(kx)
function code(kx, ky, th) return Float64(Float64(ky * th) / abs(kx)) end
function tmp = code(kx, ky, th) tmp = (ky * th) / abs(kx); end
code[kx_, ky_, th_] := N[(N[(ky * th), $MachinePrecision] / N[Abs[kx], $MachinePrecision]), $MachinePrecision]
\frac{ky \cdot th}{\left|kx\right|}
Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6434.6%
Applied rewrites34.6%
Taylor expanded in kx around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f6415.8%
Applied rewrites15.8%
Taylor expanded in th around 0
lower-*.f6412.3%
Applied rewrites12.3%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (kx ky th)
:name "Toniolo and Linder, Equation (3b), real"
:precision binary64
(* (/ (sin ky) (sqrt (+ (pow (sin kx) 2) (pow (sin ky) 2)))) (sin th)))