
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
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.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
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.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $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 (/ (sin th) (/ (hypot (sin ky) (sin kx)) (sin ky))))
double code(double kx, double ky, double th) {
return sin(th) / (hypot(sin(ky), sin(kx)) / sin(ky));
}
public static double code(double kx, double ky, double th) {
return Math.sin(th) / (Math.hypot(Math.sin(ky), Math.sin(kx)) / Math.sin(ky));
}
def code(kx, ky, th): return math.sin(th) / (math.hypot(math.sin(ky), math.sin(kx)) / math.sin(ky))
function code(kx, ky, th) return Float64(sin(th) / Float64(hypot(sin(ky), sin(kx)) / sin(ky))) end
function tmp = code(kx, ky, th) tmp = sin(th) / (hypot(sin(ky), sin(kx)) / sin(ky)); end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}}
Initial program 93.7%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6493.7
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.7
lift-hypot.f64N/A
+-commutativeN/A
lower-hypot.f6499.7
Applied rewrites99.7%
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (hypot (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th
Initial program 93.7%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky)))
(t_2 (pow (sin kx) 2.0))
(t_3 (/ t_1 (sqrt (+ t_2 (pow t_1 2.0)))))
(t_4 (* t_3 th)))
(*
(copysign 1.0 ky)
(if (<= t_3 -1.0)
(* (/ t_1 (hypot t_1 kx)) (sin th))
(if (<= t_3 -0.2)
t_4
(if (<= t_3 1e-5)
(* (/ t_1 (sqrt (+ t_2 (pow (fabs ky) 2.0)))) (sin th))
(if (<= t_3 0.998)
t_4
(/ (sin th) (/ (hypot (fabs ky) (sin kx)) (fabs ky))))))))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double t_2 = pow(sin(kx), 2.0);
double t_3 = t_1 / sqrt((t_2 + pow(t_1, 2.0)));
double t_4 = t_3 * th;
double tmp;
if (t_3 <= -1.0) {
tmp = (t_1 / hypot(t_1, kx)) * sin(th);
} else if (t_3 <= -0.2) {
tmp = t_4;
} else if (t_3 <= 1e-5) {
tmp = (t_1 / sqrt((t_2 + pow(fabs(ky), 2.0)))) * sin(th);
} else if (t_3 <= 0.998) {
tmp = t_4;
} else {
tmp = sin(th) / (hypot(fabs(ky), sin(kx)) / fabs(ky));
}
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 t_3 = t_1 / Math.sqrt((t_2 + Math.pow(t_1, 2.0)));
double t_4 = t_3 * th;
double tmp;
if (t_3 <= -1.0) {
tmp = (t_1 / Math.hypot(t_1, kx)) * Math.sin(th);
} else if (t_3 <= -0.2) {
tmp = t_4;
} else if (t_3 <= 1e-5) {
tmp = (t_1 / Math.sqrt((t_2 + Math.pow(Math.abs(ky), 2.0)))) * Math.sin(th);
} else if (t_3 <= 0.998) {
tmp = t_4;
} else {
tmp = Math.sin(th) / (Math.hypot(Math.abs(ky), Math.sin(kx)) / Math.abs(ky));
}
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) t_3 = t_1 / math.sqrt((t_2 + math.pow(t_1, 2.0))) t_4 = t_3 * th tmp = 0 if t_3 <= -1.0: tmp = (t_1 / math.hypot(t_1, kx)) * math.sin(th) elif t_3 <= -0.2: tmp = t_4 elif t_3 <= 1e-5: tmp = (t_1 / math.sqrt((t_2 + math.pow(math.fabs(ky), 2.0)))) * math.sin(th) elif t_3 <= 0.998: tmp = t_4 else: tmp = math.sin(th) / (math.hypot(math.fabs(ky), math.sin(kx)) / math.fabs(ky)) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) t_2 = sin(kx) ^ 2.0 t_3 = Float64(t_1 / sqrt(Float64(t_2 + (t_1 ^ 2.0)))) t_4 = Float64(t_3 * th) tmp = 0.0 if (t_3 <= -1.0) tmp = Float64(Float64(t_1 / hypot(t_1, kx)) * sin(th)); elseif (t_3 <= -0.2) tmp = t_4; elseif (t_3 <= 1e-5) tmp = Float64(Float64(t_1 / sqrt(Float64(t_2 + (abs(ky) ^ 2.0)))) * sin(th)); elseif (t_3 <= 0.998) tmp = t_4; else tmp = Float64(sin(th) / Float64(hypot(abs(ky), sin(kx)) / abs(ky))); 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; t_3 = t_1 / sqrt((t_2 + (t_1 ^ 2.0))); t_4 = t_3 * th; tmp = 0.0; if (t_3 <= -1.0) tmp = (t_1 / hypot(t_1, kx)) * sin(th); elseif (t_3 <= -0.2) tmp = t_4; elseif (t_3 <= 1e-5) tmp = (t_1 / sqrt((t_2 + (abs(ky) ^ 2.0)))) * sin(th); elseif (t_3 <= 0.998) tmp = t_4; else tmp = sin(th) / (hypot(abs(ky), sin(kx)) / abs(ky)); 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.0], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 / N[Sqrt[N[(t$95$2 + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * th), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, -1.0], N[(N[(t$95$1 / N[Sqrt[t$95$1 ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -0.2], t$95$4, If[LessEqual[t$95$3, 1e-5], N[(N[(t$95$1 / N[Sqrt[N[(t$95$2 + N[Power[N[Abs[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.998], t$95$4, N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Abs[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Abs[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]), $MachinePrecision]]]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := {\sin kx}^{2}\\
t_3 := \frac{t\_1}{\sqrt{t\_2 + {t\_1}^{2}}}\\
t_4 := t\_3 \cdot th\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq -1:\\
\;\;\;\;\frac{t\_1}{\mathsf{hypot}\left(t\_1, kx\right)} \cdot \sin th\\
\mathbf{elif}\;t\_3 \leq -0.2:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;t\_3 \leq 10^{-5}:\\
\;\;\;\;\frac{t\_1}{\sqrt{t\_2 + {\left(\left|ky\right|\right)}^{2}}} \cdot \sin th\\
\mathbf{elif}\;t\_3 \leq 0.998:\\
\;\;\;\;t\_4\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(\left|ky\right|, \sin kx\right)}{\left|ky\right|}}\\
\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-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in kx around 0
Applied rewrites58.2%
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.20000000000000001 or 1.00000000000000008e-5 < (/.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.998Initial program 93.7%
Taylor expanded in th around 0
Applied rewrites47.8%
if -0.20000000000000001 < (/.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.00000000000000008e-5Initial program 93.7%
Taylor expanded in ky around 0
lower-pow.f6447.1
Applied rewrites47.1%
if 0.998 < (/.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
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6493.7
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.7
lift-hypot.f64N/A
+-commutativeN/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
Applied rewrites53.1%
Taylor expanded in ky around 0
Applied rewrites65.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky)))
(t_2 (/ t_1 (sqrt (+ (pow (sin kx) 2.0) (pow t_1 2.0)))))
(t_3 (* t_2 th)))
(*
(copysign 1.0 ky)
(if (<= t_2 -1.0)
(* (/ t_1 (hypot t_1 kx)) (sin th))
(if (<= t_2 -0.2)
t_3
(if (<= t_2 1e-5)
(* t_1 (/ (sin th) (fabs (sin kx))))
(if (<= t_2 0.998)
t_3
(/ (sin th) (/ (hypot (fabs ky) (sin kx)) (fabs ky))))))))))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_2 * th;
double tmp;
if (t_2 <= -1.0) {
tmp = (t_1 / hypot(t_1, kx)) * sin(th);
} else if (t_2 <= -0.2) {
tmp = t_3;
} else if (t_2 <= 1e-5) {
tmp = t_1 * (sin(th) / fabs(sin(kx)));
} else if (t_2 <= 0.998) {
tmp = t_3;
} else {
tmp = sin(th) / (hypot(fabs(ky), sin(kx)) / fabs(ky));
}
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_2 * th;
double tmp;
if (t_2 <= -1.0) {
tmp = (t_1 / Math.hypot(t_1, kx)) * Math.sin(th);
} else if (t_2 <= -0.2) {
tmp = t_3;
} else if (t_2 <= 1e-5) {
tmp = t_1 * (Math.sin(th) / Math.abs(Math.sin(kx)));
} else if (t_2 <= 0.998) {
tmp = t_3;
} else {
tmp = Math.sin(th) / (Math.hypot(Math.abs(ky), Math.sin(kx)) / Math.abs(ky));
}
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_2 * th tmp = 0 if t_2 <= -1.0: tmp = (t_1 / math.hypot(t_1, kx)) * math.sin(th) elif t_2 <= -0.2: tmp = t_3 elif t_2 <= 1e-5: tmp = t_1 * (math.sin(th) / math.fabs(math.sin(kx))) elif t_2 <= 0.998: tmp = t_3 else: tmp = math.sin(th) / (math.hypot(math.fabs(ky), math.sin(kx)) / math.fabs(ky)) 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_2 * th) tmp = 0.0 if (t_2 <= -1.0) tmp = Float64(Float64(t_1 / hypot(t_1, kx)) * sin(th)); elseif (t_2 <= -0.2) tmp = t_3; elseif (t_2 <= 1e-5) tmp = Float64(t_1 * Float64(sin(th) / abs(sin(kx)))); elseif (t_2 <= 0.998) tmp = t_3; else tmp = Float64(sin(th) / Float64(hypot(abs(ky), sin(kx)) / abs(ky))); 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_2 * th; tmp = 0.0; if (t_2 <= -1.0) tmp = (t_1 / hypot(t_1, kx)) * sin(th); elseif (t_2 <= -0.2) tmp = t_3; elseif (t_2 <= 1e-5) tmp = t_1 * (sin(th) / abs(sin(kx))); elseif (t_2 <= 0.998) tmp = t_3; else tmp = sin(th) / (hypot(abs(ky), sin(kx)) / abs(ky)); 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.0], $MachinePrecision] + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * th), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -1.0], N[(N[(t$95$1 / N[Sqrt[t$95$1 ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -0.2], t$95$3, If[LessEqual[t$95$2, 1e-5], N[(t$95$1 * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.998], t$95$3, N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Abs[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Abs[ky], $MachinePrecision]), $MachinePrecision]), $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\_2 \cdot th\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -1:\\
\;\;\;\;\frac{t\_1}{\mathsf{hypot}\left(t\_1, kx\right)} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq -0.2:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 10^{-5}:\\
\;\;\;\;t\_1 \cdot \frac{\sin th}{\left|\sin kx\right|}\\
\mathbf{elif}\;t\_2 \leq 0.998:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(\left|ky\right|, \sin kx\right)}{\left|ky\right|}}\\
\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-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in kx around 0
Applied rewrites58.2%
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.20000000000000001 or 1.00000000000000008e-5 < (/.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.998Initial program 93.7%
Taylor expanded in th around 0
Applied rewrites47.8%
if -0.20000000000000001 < (/.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.00000000000000008e-5Initial program 93.7%
Taylor expanded in ky around 0
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6441.9
Applied rewrites41.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6441.9
lift-sqrt.f64N/A
lift-pow.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f6445.0
Applied rewrites45.0%
if 0.998 < (/.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
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6493.7
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.7
lift-hypot.f64N/A
+-commutativeN/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
Applied rewrites53.1%
Taylor expanded in ky around 0
Applied rewrites65.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky)))
(t_2 (/ t_1 (sqrt (+ (pow (sin kx) 2.0) (pow t_1 2.0)))))
(t_3 (hypot t_1 (sin kx))))
(*
(copysign 1.0 ky)
(if (<= t_2 -1.0)
(* (/ t_1 (hypot t_1 kx)) (sin th))
(if (<= t_2 -0.2)
(* (/ t_1 t_3) th)
(if (<= t_2 1e-5)
(* t_1 (/ (sin th) (fabs (sin kx))))
(if (<= t_2 0.998)
(/ (* t_1 th) t_3)
(/ (sin th) (/ (hypot (fabs ky) (sin kx)) (fabs ky))))))))))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 = hypot(t_1, sin(kx));
double tmp;
if (t_2 <= -1.0) {
tmp = (t_1 / hypot(t_1, kx)) * sin(th);
} else if (t_2 <= -0.2) {
tmp = (t_1 / t_3) * th;
} else if (t_2 <= 1e-5) {
tmp = t_1 * (sin(th) / fabs(sin(kx)));
} else if (t_2 <= 0.998) {
tmp = (t_1 * th) / t_3;
} else {
tmp = sin(th) / (hypot(fabs(ky), sin(kx)) / fabs(ky));
}
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 = Math.hypot(t_1, Math.sin(kx));
double tmp;
if (t_2 <= -1.0) {
tmp = (t_1 / Math.hypot(t_1, kx)) * Math.sin(th);
} else if (t_2 <= -0.2) {
tmp = (t_1 / t_3) * th;
} else if (t_2 <= 1e-5) {
tmp = t_1 * (Math.sin(th) / Math.abs(Math.sin(kx)));
} else if (t_2 <= 0.998) {
tmp = (t_1 * th) / t_3;
} else {
tmp = Math.sin(th) / (Math.hypot(Math.abs(ky), Math.sin(kx)) / Math.abs(ky));
}
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 = math.hypot(t_1, math.sin(kx)) tmp = 0 if t_2 <= -1.0: tmp = (t_1 / math.hypot(t_1, kx)) * math.sin(th) elif t_2 <= -0.2: tmp = (t_1 / t_3) * th elif t_2 <= 1e-5: tmp = t_1 * (math.sin(th) / math.fabs(math.sin(kx))) elif t_2 <= 0.998: tmp = (t_1 * th) / t_3 else: tmp = math.sin(th) / (math.hypot(math.fabs(ky), math.sin(kx)) / math.fabs(ky)) 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 = hypot(t_1, sin(kx)) tmp = 0.0 if (t_2 <= -1.0) tmp = Float64(Float64(t_1 / hypot(t_1, kx)) * sin(th)); elseif (t_2 <= -0.2) tmp = Float64(Float64(t_1 / t_3) * th); elseif (t_2 <= 1e-5) tmp = Float64(t_1 * Float64(sin(th) / abs(sin(kx)))); elseif (t_2 <= 0.998) tmp = Float64(Float64(t_1 * th) / t_3); else tmp = Float64(sin(th) / Float64(hypot(abs(ky), sin(kx)) / abs(ky))); 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 = hypot(t_1, sin(kx)); tmp = 0.0; if (t_2 <= -1.0) tmp = (t_1 / hypot(t_1, kx)) * sin(th); elseif (t_2 <= -0.2) tmp = (t_1 / t_3) * th; elseif (t_2 <= 1e-5) tmp = t_1 * (sin(th) / abs(sin(kx))); elseif (t_2 <= 0.998) tmp = (t_1 * th) / t_3; else tmp = sin(th) / (hypot(abs(ky), sin(kx)) / abs(ky)); 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.0], $MachinePrecision] + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[t$95$1 ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -1.0], N[(N[(t$95$1 / N[Sqrt[t$95$1 ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -0.2], N[(N[(t$95$1 / t$95$3), $MachinePrecision] * th), $MachinePrecision], If[LessEqual[t$95$2, 1e-5], N[(t$95$1 * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.998], N[(N[(t$95$1 * th), $MachinePrecision] / t$95$3), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Abs[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Abs[ky], $MachinePrecision]), $MachinePrecision]), $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 := \mathsf{hypot}\left(t\_1, \sin kx\right)\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -1:\\
\;\;\;\;\frac{t\_1}{\mathsf{hypot}\left(t\_1, kx\right)} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq -0.2:\\
\;\;\;\;\frac{t\_1}{t\_3} \cdot th\\
\mathbf{elif}\;t\_2 \leq 10^{-5}:\\
\;\;\;\;t\_1 \cdot \frac{\sin th}{\left|\sin kx\right|}\\
\mathbf{elif}\;t\_2 \leq 0.998:\\
\;\;\;\;\frac{t\_1 \cdot th}{t\_3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(\left|ky\right|, \sin kx\right)}{\left|ky\right|}}\\
\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-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in kx around 0
Applied rewrites58.2%
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.20000000000000001Initial program 93.7%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in th around 0
Applied rewrites50.7%
if -0.20000000000000001 < (/.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.00000000000000008e-5Initial program 93.7%
Taylor expanded in ky around 0
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6441.9
Applied rewrites41.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6441.9
lift-sqrt.f64N/A
lift-pow.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f6445.0
Applied rewrites45.0%
if 1.00000000000000008e-5 < (/.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.998Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f64N/A
*-commutativeN/A
Applied rewrites95.9%
Taylor expanded in th around 0
Applied rewrites47.1%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6447.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6447.1
lift-hypot.f64N/A
+-commutativeN/A
lower-hypot.f6447.1
Applied rewrites47.1%
if 0.998 < (/.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
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6493.7
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.7
lift-hypot.f64N/A
+-commutativeN/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
Applied rewrites53.1%
Taylor expanded in ky around 0
Applied rewrites65.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky)))
(t_2 (/ t_1 (sqrt (+ (pow (sin kx) 2.0) (pow t_1 2.0)))))
(t_3 (/ (* t_1 th) (hypot t_1 (sin kx)))))
(*
(copysign 1.0 ky)
(if (<= t_2 -1.0)
(* (/ t_1 (hypot t_1 kx)) (sin th))
(if (<= t_2 -0.2)
t_3
(if (<= t_2 1e-5)
(* t_1 (/ (sin th) (fabs (sin kx))))
(if (<= t_2 0.998)
t_3
(/ (sin th) (/ (hypot (fabs ky) (sin kx)) (fabs ky))))))))))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) / hypot(t_1, sin(kx));
double tmp;
if (t_2 <= -1.0) {
tmp = (t_1 / hypot(t_1, kx)) * sin(th);
} else if (t_2 <= -0.2) {
tmp = t_3;
} else if (t_2 <= 1e-5) {
tmp = t_1 * (sin(th) / fabs(sin(kx)));
} else if (t_2 <= 0.998) {
tmp = t_3;
} else {
tmp = sin(th) / (hypot(fabs(ky), sin(kx)) / fabs(ky));
}
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.hypot(t_1, Math.sin(kx));
double tmp;
if (t_2 <= -1.0) {
tmp = (t_1 / Math.hypot(t_1, kx)) * Math.sin(th);
} else if (t_2 <= -0.2) {
tmp = t_3;
} else if (t_2 <= 1e-5) {
tmp = t_1 * (Math.sin(th) / Math.abs(Math.sin(kx)));
} else if (t_2 <= 0.998) {
tmp = t_3;
} else {
tmp = Math.sin(th) / (Math.hypot(Math.abs(ky), Math.sin(kx)) / Math.abs(ky));
}
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.hypot(t_1, math.sin(kx)) tmp = 0 if t_2 <= -1.0: tmp = (t_1 / math.hypot(t_1, kx)) * math.sin(th) elif t_2 <= -0.2: tmp = t_3 elif t_2 <= 1e-5: tmp = t_1 * (math.sin(th) / math.fabs(math.sin(kx))) elif t_2 <= 0.998: tmp = t_3 else: tmp = math.sin(th) / (math.hypot(math.fabs(ky), math.sin(kx)) / math.fabs(ky)) 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(Float64(t_1 * th) / hypot(t_1, sin(kx))) tmp = 0.0 if (t_2 <= -1.0) tmp = Float64(Float64(t_1 / hypot(t_1, kx)) * sin(th)); elseif (t_2 <= -0.2) tmp = t_3; elseif (t_2 <= 1e-5) tmp = Float64(t_1 * Float64(sin(th) / abs(sin(kx)))); elseif (t_2 <= 0.998) tmp = t_3; else tmp = Float64(sin(th) / Float64(hypot(abs(ky), sin(kx)) / abs(ky))); 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) / hypot(t_1, sin(kx)); tmp = 0.0; if (t_2 <= -1.0) tmp = (t_1 / hypot(t_1, kx)) * sin(th); elseif (t_2 <= -0.2) tmp = t_3; elseif (t_2 <= 1e-5) tmp = t_1 * (sin(th) / abs(sin(kx))); elseif (t_2 <= 0.998) tmp = t_3; else tmp = sin(th) / (hypot(abs(ky), sin(kx)) / abs(ky)); 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.0], $MachinePrecision] + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$1 * th), $MachinePrecision] / N[Sqrt[t$95$1 ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -1.0], N[(N[(t$95$1 / N[Sqrt[t$95$1 ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -0.2], t$95$3, If[LessEqual[t$95$2, 1e-5], N[(t$95$1 * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.998], t$95$3, N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Abs[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Abs[ky], $MachinePrecision]), $MachinePrecision]), $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 := \frac{t\_1 \cdot th}{\mathsf{hypot}\left(t\_1, \sin kx\right)}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -1:\\
\;\;\;\;\frac{t\_1}{\mathsf{hypot}\left(t\_1, kx\right)} \cdot \sin th\\
\mathbf{elif}\;t\_2 \leq -0.2:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 10^{-5}:\\
\;\;\;\;t\_1 \cdot \frac{\sin th}{\left|\sin kx\right|}\\
\mathbf{elif}\;t\_2 \leq 0.998:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(\left|ky\right|, \sin kx\right)}{\left|ky\right|}}\\
\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-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in kx around 0
Applied rewrites58.2%
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.20000000000000001 or 1.00000000000000008e-5 < (/.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.998Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f64N/A
*-commutativeN/A
Applied rewrites95.9%
Taylor expanded in th around 0
Applied rewrites47.1%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6447.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6447.1
lift-hypot.f64N/A
+-commutativeN/A
lower-hypot.f6447.1
Applied rewrites47.1%
if -0.20000000000000001 < (/.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.00000000000000008e-5Initial program 93.7%
Taylor expanded in ky around 0
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6441.9
Applied rewrites41.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6441.9
lift-sqrt.f64N/A
lift-pow.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f6445.0
Applied rewrites45.0%
if 0.998 < (/.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
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6493.7
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.7
lift-hypot.f64N/A
+-commutativeN/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
Applied rewrites53.1%
Taylor expanded in ky around 0
Applied rewrites65.8%
(FPCore (kx ky th)
:precision binary64
(*
(copysign 1.0 th)
(if (<= (fabs th) 7.5e-13)
(* (sin ky) (/ (fabs th) (hypot (sin kx) (sin ky))))
(/ (sin (fabs th)) (/ (hypot ky (sin kx)) ky)))))double code(double kx, double ky, double th) {
double tmp;
if (fabs(th) <= 7.5e-13) {
tmp = sin(ky) * (fabs(th) / hypot(sin(kx), sin(ky)));
} else {
tmp = sin(fabs(th)) / (hypot(ky, sin(kx)) / ky);
}
return copysign(1.0, th) * tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.abs(th) <= 7.5e-13) {
tmp = Math.sin(ky) * (Math.abs(th) / Math.hypot(Math.sin(kx), Math.sin(ky)));
} else {
tmp = Math.sin(Math.abs(th)) / (Math.hypot(ky, Math.sin(kx)) / ky);
}
return Math.copySign(1.0, th) * tmp;
}
def code(kx, ky, th): tmp = 0 if math.fabs(th) <= 7.5e-13: tmp = math.sin(ky) * (math.fabs(th) / math.hypot(math.sin(kx), math.sin(ky))) else: tmp = math.sin(math.fabs(th)) / (math.hypot(ky, math.sin(kx)) / ky) return math.copysign(1.0, th) * tmp
function code(kx, ky, th) tmp = 0.0 if (abs(th) <= 7.5e-13) tmp = Float64(sin(ky) * Float64(abs(th) / hypot(sin(kx), sin(ky)))); else tmp = Float64(sin(abs(th)) / Float64(hypot(ky, sin(kx)) / ky)); end return Float64(copysign(1.0, th) * tmp) end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (abs(th) <= 7.5e-13) tmp = sin(ky) * (abs(th) / hypot(sin(kx), sin(ky))); else tmp = sin(abs(th)) / (hypot(ky, sin(kx)) / ky); end tmp_2 = (sign(th) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[th]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[th], $MachinePrecision], 7.5e-13], N[(N[Sin[ky], $MachinePrecision] * N[(N[Abs[th], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[N[Abs[th], $MachinePrecision]], $MachinePrecision] / N[(N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, th\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|th\right| \leq 7.5 \cdot 10^{-13}:\\
\;\;\;\;\sin ky \cdot \frac{\left|th\right|}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin \left(\left|th\right|\right)}{\frac{\mathsf{hypot}\left(ky, \sin kx\right)}{ky}}\\
\end{array}
if th < 7.5000000000000004e-13Initial program 93.7%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in th around 0
Applied rewrites50.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6450.7
lift-hypot.f64N/A
pow2N/A
lift-sin.f64N/A
+-commutativeN/A
pow2N/A
lift-sin.f64N/A
sqrt-fabs-revN/A
lift-sin.f64N/A
pow2N/A
Applied rewrites50.7%
if 7.5000000000000004e-13 < th Initial program 93.7%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6493.7
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.7
lift-hypot.f64N/A
+-commutativeN/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
Applied rewrites53.1%
Taylor expanded in ky around 0
Applied rewrites65.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky)))
(t_2 (/ (* t_1 th) (hypot t_1 (sin kx))))
(t_3 (/ t_1 (sqrt (+ (pow (sin kx) 2.0) (pow t_1 2.0))))))
(*
(copysign 1.0 ky)
(if (<= t_3 -0.2)
t_2
(if (<= t_3 1e-5)
(* t_1 (/ (sin th) (fabs (sin kx))))
(if (<= t_3 0.998)
t_2
(/ (sin th) (/ (hypot (fabs ky) (sin kx)) (fabs ky)))))))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double t_2 = (t_1 * th) / hypot(t_1, sin(kx));
double t_3 = t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)));
double tmp;
if (t_3 <= -0.2) {
tmp = t_2;
} else if (t_3 <= 1e-5) {
tmp = t_1 * (sin(th) / fabs(sin(kx)));
} else if (t_3 <= 0.998) {
tmp = t_2;
} else {
tmp = sin(th) / (hypot(fabs(ky), sin(kx)) / fabs(ky));
}
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 * th) / Math.hypot(t_1, Math.sin(kx));
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.2) {
tmp = t_2;
} else if (t_3 <= 1e-5) {
tmp = t_1 * (Math.sin(th) / Math.abs(Math.sin(kx)));
} else if (t_3 <= 0.998) {
tmp = t_2;
} else {
tmp = Math.sin(th) / (Math.hypot(Math.abs(ky), Math.sin(kx)) / Math.abs(ky));
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) t_2 = (t_1 * th) / math.hypot(t_1, math.sin(kx)) 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.2: tmp = t_2 elif t_3 <= 1e-5: tmp = t_1 * (math.sin(th) / math.fabs(math.sin(kx))) elif t_3 <= 0.998: tmp = t_2 else: tmp = math.sin(th) / (math.hypot(math.fabs(ky), math.sin(kx)) / math.fabs(ky)) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) t_2 = Float64(Float64(t_1 * th) / hypot(t_1, sin(kx))) t_3 = Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0)))) tmp = 0.0 if (t_3 <= -0.2) tmp = t_2; elseif (t_3 <= 1e-5) tmp = Float64(t_1 * Float64(sin(th) / abs(sin(kx)))); elseif (t_3 <= 0.998) tmp = t_2; else tmp = Float64(sin(th) / Float64(hypot(abs(ky), sin(kx)) / abs(ky))); 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 * th) / hypot(t_1, sin(kx)); t_3 = t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0))); tmp = 0.0; if (t_3 <= -0.2) tmp = t_2; elseif (t_3 <= 1e-5) tmp = t_1 * (sin(th) / abs(sin(kx))); elseif (t_3 <= 0.998) tmp = t_2; else tmp = sin(th) / (hypot(abs(ky), sin(kx)) / abs(ky)); 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[(t$95$1 * th), $MachinePrecision] / N[Sqrt[t$95$1 ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, -0.2], t$95$2, If[LessEqual[t$95$3, 1e-5], N[(t$95$1 * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.998], t$95$2, N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Abs[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Abs[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := \frac{t\_1 \cdot th}{\mathsf{hypot}\left(t\_1, \sin kx\right)}\\
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 -0.2:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 10^{-5}:\\
\;\;\;\;t\_1 \cdot \frac{\sin th}{\left|\sin kx\right|}\\
\mathbf{elif}\;t\_3 \leq 0.998:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(\left|ky\right|, \sin kx\right)}{\left|ky\right|}}\\
\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.20000000000000001 or 1.00000000000000008e-5 < (/.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.998Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f64N/A
*-commutativeN/A
Applied rewrites95.9%
Taylor expanded in th around 0
Applied rewrites47.1%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6447.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6447.1
lift-hypot.f64N/A
+-commutativeN/A
lower-hypot.f6447.1
Applied rewrites47.1%
if -0.20000000000000001 < (/.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.00000000000000008e-5Initial program 93.7%
Taylor expanded in ky around 0
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6441.9
Applied rewrites41.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6441.9
lift-sqrt.f64N/A
lift-pow.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f6445.0
Applied rewrites45.0%
if 0.998 < (/.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
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6493.7
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.7
lift-hypot.f64N/A
+-commutativeN/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
Applied rewrites53.1%
Taylor expanded in ky around 0
Applied rewrites65.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky))) (t_2 (pow t_1 2.0)))
(*
(copysign 1.0 ky)
(if (<= (/ t_1 (sqrt (+ (pow (sin kx) 2.0) t_2))) -0.2)
(* (/ t_1 (sqrt t_2)) th)
(/ (sin th) (/ (hypot (fabs ky) (sin kx)) (fabs ky)))))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double t_2 = pow(t_1, 2.0);
double tmp;
if ((t_1 / sqrt((pow(sin(kx), 2.0) + t_2))) <= -0.2) {
tmp = (t_1 / sqrt(t_2)) * th;
} else {
tmp = sin(th) / (hypot(fabs(ky), sin(kx)) / fabs(ky));
}
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(t_1, 2.0);
double tmp;
if ((t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + t_2))) <= -0.2) {
tmp = (t_1 / Math.sqrt(t_2)) * th;
} else {
tmp = Math.sin(th) / (Math.hypot(Math.abs(ky), Math.sin(kx)) / Math.abs(ky));
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) t_2 = math.pow(t_1, 2.0) tmp = 0 if (t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + t_2))) <= -0.2: tmp = (t_1 / math.sqrt(t_2)) * th else: tmp = math.sin(th) / (math.hypot(math.fabs(ky), math.sin(kx)) / math.fabs(ky)) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) t_2 = t_1 ^ 2.0 tmp = 0.0 if (Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + t_2))) <= -0.2) tmp = Float64(Float64(t_1 / sqrt(t_2)) * th); else tmp = Float64(sin(th) / Float64(hypot(abs(ky), sin(kx)) / abs(ky))); 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 ^ 2.0; tmp = 0.0; if ((t_1 / sqrt(((sin(kx) ^ 2.0) + t_2))) <= -0.2) tmp = (t_1 / sqrt(t_2)) * th; else tmp = sin(th) / (hypot(abs(ky), sin(kx)) / abs(ky)); 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[t$95$1, 2.0], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], 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.0], $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.2], N[(N[(t$95$1 / N[Sqrt[t$95$2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Abs[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Abs[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := {t\_1}^{2}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;\frac{t\_1}{\sqrt{{\sin kx}^{2} + t\_2}} \leq -0.2:\\
\;\;\;\;\frac{t\_1}{\sqrt{t\_2}} \cdot th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(\left|ky\right|, \sin kx\right)}{\left|ky\right|}}\\
\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.20000000000000001Initial program 93.7%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in th around 0
Applied rewrites50.7%
Taylor expanded in kx around 0
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6421.0
Applied rewrites21.0%
if -0.20000000000000001 < (/.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
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6493.7
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.7
lift-hypot.f64N/A
+-commutativeN/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
Applied rewrites53.1%
Taylor expanded in ky around 0
Applied rewrites65.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky))))
(*
(copysign 1.0 ky)
(if (<= (/ t_1 (sqrt (+ (pow (sin kx) 2.0) (pow t_1 2.0)))) -0.2)
(* (/ 1.0 (hypot kx t_1)) (* th t_1))
(/ (sin th) (/ (hypot (fabs ky) (sin kx)) (fabs ky)))))))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)))) <= -0.2) {
tmp = (1.0 / hypot(kx, t_1)) * (th * t_1);
} else {
tmp = sin(th) / (hypot(fabs(ky), sin(kx)) / fabs(ky));
}
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)))) <= -0.2) {
tmp = (1.0 / Math.hypot(kx, t_1)) * (th * t_1);
} else {
tmp = Math.sin(th) / (Math.hypot(Math.abs(ky), Math.sin(kx)) / Math.abs(ky));
}
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)))) <= -0.2: tmp = (1.0 / math.hypot(kx, t_1)) * (th * t_1) else: tmp = math.sin(th) / (math.hypot(math.fabs(ky), math.sin(kx)) / math.fabs(ky)) 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)))) <= -0.2) tmp = Float64(Float64(1.0 / hypot(kx, t_1)) * Float64(th * t_1)); else tmp = Float64(sin(th) / Float64(hypot(abs(ky), sin(kx)) / abs(ky))); 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)))) <= -0.2) tmp = (1.0 / hypot(kx, t_1)) * (th * t_1); else tmp = sin(th) / (hypot(abs(ky), sin(kx)) / abs(ky)); 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.0], 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.0], $MachinePrecision] + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.2], N[(N[(1.0 / N[Sqrt[kx ^ 2 + t$95$1 ^ 2], $MachinePrecision]), $MachinePrecision] * N[(th * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Abs[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Abs[ky], $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}\;\frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}} \leq -0.2:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(kx, t\_1\right)} \cdot \left(th \cdot t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(\left|ky\right|, \sin kx\right)}{\left|ky\right|}}\\
\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.20000000000000001Initial program 93.7%
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f64N/A
*-commutativeN/A
Applied rewrites95.9%
Taylor expanded in th around 0
Applied rewrites47.1%
Taylor expanded in kx around 0
Applied rewrites30.1%
if -0.20000000000000001 < (/.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
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6493.7
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.7
lift-hypot.f64N/A
+-commutativeN/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
Applied rewrites53.1%
Taylor expanded in ky around 0
Applied rewrites65.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky))))
(*
(copysign 1.0 ky)
(if (<= t_1 -0.05)
(* (* th t_1) (/ 1.0 (fabs (sin kx))))
(/ (sin th) (/ (hypot (fabs ky) (sin kx)) (fabs ky)))))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double tmp;
if (t_1 <= -0.05) {
tmp = (th * t_1) * (1.0 / fabs(sin(kx)));
} else {
tmp = sin(th) / (hypot(fabs(ky), sin(kx)) / fabs(ky));
}
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 <= -0.05) {
tmp = (th * t_1) * (1.0 / Math.abs(Math.sin(kx)));
} else {
tmp = Math.sin(th) / (Math.hypot(Math.abs(ky), Math.sin(kx)) / Math.abs(ky));
}
return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th): t_1 = math.sin(math.fabs(ky)) tmp = 0 if t_1 <= -0.05: tmp = (th * t_1) * (1.0 / math.fabs(math.sin(kx))) else: tmp = math.sin(th) / (math.hypot(math.fabs(ky), math.sin(kx)) / math.fabs(ky)) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) tmp = 0.0 if (t_1 <= -0.05) tmp = Float64(Float64(th * t_1) * Float64(1.0 / abs(sin(kx)))); else tmp = Float64(sin(th) / Float64(hypot(abs(ky), sin(kx)) / abs(ky))); 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 <= -0.05) tmp = (th * t_1) * (1.0 / abs(sin(kx))); else tmp = sin(th) / (hypot(abs(ky), sin(kx)) / abs(ky)); 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.0], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, -0.05], N[(N[(th * t$95$1), $MachinePrecision] * N[(1.0 / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Abs[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Abs[ky], $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}\;t\_1 \leq -0.05:\\
\;\;\;\;\left(th \cdot t\_1\right) \cdot \frac{1}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(\left|ky\right|, \sin kx\right)}{\left|ky\right|}}\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 93.7%
Taylor expanded in ky around 0
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6441.9
Applied rewrites41.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
lower-*.f64N/A
lower-/.f6440.9
lift-sqrt.f64N/A
lift-pow.f64N/A
pow2N/A
rem-sqrt-square-revN/A
Applied rewrites43.2%
Taylor expanded in th around 0
lower-*.f64N/A
lower-sin.f6422.1
Applied rewrites22.1%
if -0.050000000000000003 < (sin.f64 ky) Initial program 93.7%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6493.7
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.7
lift-hypot.f64N/A
+-commutativeN/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
Applied rewrites53.1%
Taylor expanded in ky around 0
Applied rewrites65.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (sin (fabs ky))))
(*
(copysign 1.0 ky)
(if (<= t_1 -0.05)
(* (* th t_1) (/ 1.0 (fabs (sin kx))))
(* (/ (fabs ky) (hypot (fabs ky) (sin kx))) (sin th))))))double code(double kx, double ky, double th) {
double t_1 = sin(fabs(ky));
double tmp;
if (t_1 <= -0.05) {
tmp = (th * t_1) * (1.0 / fabs(sin(kx)));
} else {
tmp = (fabs(ky) / hypot(fabs(ky), sin(kx))) * 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 <= -0.05) {
tmp = (th * t_1) * (1.0 / Math.abs(Math.sin(kx)));
} else {
tmp = (Math.abs(ky) / Math.hypot(Math.abs(ky), Math.sin(kx))) * 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 <= -0.05: tmp = (th * t_1) * (1.0 / math.fabs(math.sin(kx))) else: tmp = (math.fabs(ky) / math.hypot(math.fabs(ky), math.sin(kx))) * math.sin(th) return math.copysign(1.0, ky) * tmp
function code(kx, ky, th) t_1 = sin(abs(ky)) tmp = 0.0 if (t_1 <= -0.05) tmp = Float64(Float64(th * t_1) * Float64(1.0 / abs(sin(kx)))); else tmp = Float64(Float64(abs(ky) / hypot(abs(ky), sin(kx))) * 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 <= -0.05) tmp = (th * t_1) * (1.0 / abs(sin(kx))); else tmp = (abs(ky) / hypot(abs(ky), sin(kx))) * 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.0], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, -0.05], N[(N[(th * t$95$1), $MachinePrecision] * N[(1.0 / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Abs[ky], $MachinePrecision] / N[Sqrt[N[Abs[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $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}\;t\_1 \leq -0.05:\\
\;\;\;\;\left(th \cdot t\_1\right) \cdot \frac{1}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|ky\right|}{\mathsf{hypot}\left(\left|ky\right|, \sin kx\right)} \cdot \sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 93.7%
Taylor expanded in ky around 0
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6441.9
Applied rewrites41.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
lower-*.f64N/A
lower-/.f6440.9
lift-sqrt.f64N/A
lift-pow.f64N/A
pow2N/A
rem-sqrt-square-revN/A
Applied rewrites43.2%
Taylor expanded in th around 0
lower-*.f64N/A
lower-sin.f6422.1
Applied rewrites22.1%
if -0.050000000000000003 < (sin.f64 ky) Initial program 93.7%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in ky around 0
Applied rewrites51.9%
Taylor expanded in ky around 0
Applied rewrites65.8%
(FPCore (kx ky th)
:precision binary64
(*
(copysign 1.0 th)
(if (<= (fabs th) 6e-9)
(* (/ ky (hypot ky (sin kx))) (fabs th))
(* (/ 1.0 (/ (fabs (sin kx)) ky)) (sin (fabs th))))))double code(double kx, double ky, double th) {
double tmp;
if (fabs(th) <= 6e-9) {
tmp = (ky / hypot(ky, sin(kx))) * fabs(th);
} else {
tmp = (1.0 / (fabs(sin(kx)) / ky)) * sin(fabs(th));
}
return copysign(1.0, th) * tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.abs(th) <= 6e-9) {
tmp = (ky / Math.hypot(ky, Math.sin(kx))) * Math.abs(th);
} else {
tmp = (1.0 / (Math.abs(Math.sin(kx)) / ky)) * Math.sin(Math.abs(th));
}
return Math.copySign(1.0, th) * tmp;
}
def code(kx, ky, th): tmp = 0 if math.fabs(th) <= 6e-9: tmp = (ky / math.hypot(ky, math.sin(kx))) * math.fabs(th) else: tmp = (1.0 / (math.fabs(math.sin(kx)) / ky)) * math.sin(math.fabs(th)) return math.copysign(1.0, th) * tmp
function code(kx, ky, th) tmp = 0.0 if (abs(th) <= 6e-9) tmp = Float64(Float64(ky / hypot(ky, sin(kx))) * abs(th)); else tmp = Float64(Float64(1.0 / Float64(abs(sin(kx)) / ky)) * sin(abs(th))); end return Float64(copysign(1.0, th) * tmp) end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (abs(th) <= 6e-9) tmp = (ky / hypot(ky, sin(kx))) * abs(th); else tmp = (1.0 / (abs(sin(kx)) / ky)) * sin(abs(th)); end tmp_2 = (sign(th) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[th]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[th], $MachinePrecision], 6e-9], N[(N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Abs[th], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision] * N[Sin[N[Abs[th], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, th\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|th\right| \leq 6 \cdot 10^{-9}:\\
\;\;\;\;\frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)} \cdot \left|th\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\left|\sin kx\right|}{ky}} \cdot \sin \left(\left|th\right|\right)\\
\end{array}
if th < 5.99999999999999996e-9Initial program 93.7%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in th around 0
Applied rewrites50.7%
Taylor expanded in ky around 0
Applied rewrites27.2%
Taylor expanded in ky around 0
Applied rewrites34.3%
if 5.99999999999999996e-9 < th Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6436.9
Applied rewrites36.9%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6436.9
lift-sqrt.f64N/A
lift-pow.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f6439.9
Applied rewrites39.9%
(FPCore (kx ky th)
:precision binary64
(*
(copysign 1.0 th)
(if (<= (fabs th) 6e-9)
(* (/ ky (hypot ky (sin kx))) (fabs th))
(* (sin (fabs th)) (/ ky (fabs (sin kx)))))))double code(double kx, double ky, double th) {
double tmp;
if (fabs(th) <= 6e-9) {
tmp = (ky / hypot(ky, sin(kx))) * fabs(th);
} else {
tmp = sin(fabs(th)) * (ky / fabs(sin(kx)));
}
return copysign(1.0, th) * tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.abs(th) <= 6e-9) {
tmp = (ky / Math.hypot(ky, Math.sin(kx))) * Math.abs(th);
} else {
tmp = Math.sin(Math.abs(th)) * (ky / Math.abs(Math.sin(kx)));
}
return Math.copySign(1.0, th) * tmp;
}
def code(kx, ky, th): tmp = 0 if math.fabs(th) <= 6e-9: tmp = (ky / math.hypot(ky, math.sin(kx))) * math.fabs(th) else: tmp = math.sin(math.fabs(th)) * (ky / math.fabs(math.sin(kx))) return math.copysign(1.0, th) * tmp
function code(kx, ky, th) tmp = 0.0 if (abs(th) <= 6e-9) tmp = Float64(Float64(ky / hypot(ky, sin(kx))) * abs(th)); else tmp = Float64(sin(abs(th)) * Float64(ky / abs(sin(kx)))); end return Float64(copysign(1.0, th) * tmp) end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (abs(th) <= 6e-9) tmp = (ky / hypot(ky, sin(kx))) * abs(th); else tmp = sin(abs(th)) * (ky / abs(sin(kx))); end tmp_2 = (sign(th) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[th]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[th], $MachinePrecision], 6e-9], N[(N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Abs[th], $MachinePrecision]), $MachinePrecision], N[(N[Sin[N[Abs[th], $MachinePrecision]], $MachinePrecision] * N[(ky / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, th\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|th\right| \leq 6 \cdot 10^{-9}:\\
\;\;\;\;\frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)} \cdot \left|th\right|\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\left|th\right|\right) \cdot \frac{ky}{\left|\sin kx\right|}\\
\end{array}
if th < 5.99999999999999996e-9Initial program 93.7%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in th around 0
Applied rewrites50.7%
Taylor expanded in ky around 0
Applied rewrites27.2%
Taylor expanded in ky around 0
Applied rewrites34.3%
if 5.99999999999999996e-9 < th Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6436.9
Applied rewrites36.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.9
lift-sqrt.f64N/A
lift-pow.f64N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f6439.9
Applied rewrites39.9%
(FPCore (kx ky th)
:precision binary64
(*
(copysign 1.0 th)
(if (<= (fabs th) 620.0)
(* (/ ky (hypot ky (sin (fabs kx)))) (fabs th))
(* (/ 1.0 (/ (fabs kx) ky)) (sin (fabs th))))))double code(double kx, double ky, double th) {
double tmp;
if (fabs(th) <= 620.0) {
tmp = (ky / hypot(ky, sin(fabs(kx)))) * fabs(th);
} else {
tmp = (1.0 / (fabs(kx) / ky)) * sin(fabs(th));
}
return copysign(1.0, th) * tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.abs(th) <= 620.0) {
tmp = (ky / Math.hypot(ky, Math.sin(Math.abs(kx)))) * Math.abs(th);
} else {
tmp = (1.0 / (Math.abs(kx) / ky)) * Math.sin(Math.abs(th));
}
return Math.copySign(1.0, th) * tmp;
}
def code(kx, ky, th): tmp = 0 if math.fabs(th) <= 620.0: tmp = (ky / math.hypot(ky, math.sin(math.fabs(kx)))) * math.fabs(th) else: tmp = (1.0 / (math.fabs(kx) / ky)) * math.sin(math.fabs(th)) return math.copysign(1.0, th) * tmp
function code(kx, ky, th) tmp = 0.0 if (abs(th) <= 620.0) tmp = Float64(Float64(ky / hypot(ky, sin(abs(kx)))) * abs(th)); else tmp = Float64(Float64(1.0 / Float64(abs(kx) / ky)) * sin(abs(th))); end return Float64(copysign(1.0, th) * tmp) end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (abs(th) <= 620.0) tmp = (ky / hypot(ky, sin(abs(kx)))) * abs(th); else tmp = (1.0 / (abs(kx) / ky)) * sin(abs(th)); end tmp_2 = (sign(th) * abs(1.0)) * tmp; end
code[kx_, ky_, th_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[th]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[th], $MachinePrecision], 620.0], N[(N[(ky / N[Sqrt[ky ^ 2 + N[Sin[N[Abs[kx], $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Abs[th], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Abs[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision] * N[Sin[N[Abs[th], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, th\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|th\right| \leq 620:\\
\;\;\;\;\frac{ky}{\mathsf{hypot}\left(ky, \sin \left(\left|kx\right|\right)\right)} \cdot \left|th\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\left|kx\right|}{ky}} \cdot \sin \left(\left|th\right|\right)\\
\end{array}
if th < 620Initial program 93.7%
lift-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6499.7
Applied rewrites99.7%
Taylor expanded in th around 0
Applied rewrites50.7%
Taylor expanded in ky around 0
Applied rewrites27.2%
Taylor expanded in ky around 0
Applied rewrites34.3%
if 620 < th Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6436.9
Applied rewrites36.9%
Taylor expanded in kx around 0
lower-/.f6417.0
Applied rewrites17.0%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6417.0
Applied rewrites17.0%
(FPCore (kx ky th) :precision binary64 (* (/ ky (fabs kx)) (sin th)))
double code(double kx, double ky, double th) {
return (ky / fabs(kx)) * 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 = (ky / abs(kx)) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (ky / Math.abs(kx)) * Math.sin(th);
}
def code(kx, ky, th): return (ky / math.fabs(kx)) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(ky / abs(kx)) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (ky / abs(kx)) * sin(th); end
code[kx_, ky_, th_] := N[(N[(ky / N[Abs[kx], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\frac{ky}{\left|kx\right|} \cdot \sin th
Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6436.9
Applied rewrites36.9%
Taylor expanded in kx around 0
lower-/.f6417.0
Applied rewrites17.0%
(FPCore (kx ky th) :precision binary64 (* (/ ky (fabs kx)) (* th 1.0)))
double code(double kx, double ky, double th) {
return (ky / fabs(kx)) * (th * 1.0);
}
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 / abs(kx)) * (th * 1.0d0)
end function
public static double code(double kx, double ky, double th) {
return (ky / Math.abs(kx)) * (th * 1.0);
}
def code(kx, ky, th): return (ky / math.fabs(kx)) * (th * 1.0)
function code(kx, ky, th) return Float64(Float64(ky / abs(kx)) * Float64(th * 1.0)) end
function tmp = code(kx, ky, th) tmp = (ky / abs(kx)) * (th * 1.0); end
code[kx_, ky_, th_] := N[(N[(ky / N[Abs[kx], $MachinePrecision]), $MachinePrecision] * N[(th * 1.0), $MachinePrecision]), $MachinePrecision]
\frac{ky}{\left|kx\right|} \cdot \left(th \cdot 1\right)
Initial program 93.7%
Taylor expanded in ky around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f6436.9
Applied rewrites36.9%
Taylor expanded in kx around 0
lower-/.f6417.0
Applied rewrites17.0%
Taylor expanded in th around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6413.2
Applied rewrites13.2%
Taylor expanded in th around 0
Applied rewrites13.8%
herbie shell --seed 2025168
(FPCore (kx ky th)
:name "Toniolo and Linder, Equation (3b), real"
:precision binary64
(* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))