
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 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);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (hypot (sin 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]
\begin{array}{l}
\\
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th
\end{array}
Initial program 95.0%
+-commutative95.0%
unpow295.0%
unpow295.0%
hypot-undefine99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.02)
(fabs (sin th))
(if (or (<= (sin ky) 5e-87)
(and (not (<= (sin ky) 2e-47)) (<= (sin ky) 2e-24)))
(* ky (/ (sin th) (sin kx)))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.02) {
tmp = fabs(sin(th));
} else if ((sin(ky) <= 5e-87) || (!(sin(ky) <= 2e-47) && (sin(ky) <= 2e-24))) {
tmp = ky * (sin(th) / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.02d0)) then
tmp = abs(sin(th))
else if ((sin(ky) <= 5d-87) .or. (.not. (sin(ky) <= 2d-47)) .and. (sin(ky) <= 2d-24)) then
tmp = ky * (sin(th) / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.02) {
tmp = Math.abs(Math.sin(th));
} else if ((Math.sin(ky) <= 5e-87) || (!(Math.sin(ky) <= 2e-47) && (Math.sin(ky) <= 2e-24))) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.02: tmp = math.fabs(math.sin(th)) elif (math.sin(ky) <= 5e-87) or (not (math.sin(ky) <= 2e-47) and (math.sin(ky) <= 2e-24)): tmp = ky * (math.sin(th) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.02) tmp = abs(sin(th)); elseif ((sin(ky) <= 5e-87) || (!(sin(ky) <= 2e-47) && (sin(ky) <= 2e-24))) tmp = Float64(ky * Float64(sin(th) / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.02) tmp = abs(sin(th)); elseif ((sin(ky) <= 5e-87) || (~((sin(ky) <= 2e-47)) && (sin(ky) <= 2e-24))) tmp = ky * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[N[Sin[ky], $MachinePrecision], 5e-87], And[N[Not[LessEqual[N[Sin[ky], $MachinePrecision], 2e-47]], $MachinePrecision], LessEqual[N[Sin[ky], $MachinePrecision], 2e-24]]], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.02:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-87} \lor \neg \left(\sin ky \leq 2 \cdot 10^{-47}\right) \land \sin ky \leq 2 \cdot 10^{-24}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0200000000000000004Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 2.5%
add-sqr-sqrt1.2%
sqrt-unprod29.9%
pow229.9%
Applied egg-rr29.9%
unpow229.9%
rem-sqrt-square36.5%
associate-*r/36.5%
*-rgt-identity36.5%
times-frac36.6%
/-rgt-identity36.6%
*-inverses36.6%
*-lft-identity36.6%
Simplified36.6%
if -0.0200000000000000004 < (sin.f64 ky) < 5.00000000000000042e-87 or 1.9999999999999999e-47 < (sin.f64 ky) < 1.99999999999999985e-24Initial program 89.6%
unpow289.6%
sqr-neg89.6%
sin-neg89.6%
sin-neg89.6%
unpow289.6%
associate-*l/86.5%
associate-/l*89.5%
unpow289.5%
Simplified99.6%
Taylor expanded in ky around 0 55.2%
associate-/l*58.2%
Simplified58.2%
if 5.00000000000000042e-87 < (sin.f64 ky) < 1.9999999999999999e-47 or 1.99999999999999985e-24 < (sin.f64 ky) Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.5%
associate-/l*99.7%
unpow299.7%
Simplified99.7%
Taylor expanded in kx around 0 68.8%
Final simplification53.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.02)
(fabs (sin th))
(if (or (<= (sin ky) 5e-87)
(and (not (<= (sin ky) 2e-47)) (<= (sin ky) 2e-24)))
(* (sin th) (/ ky (sin kx)))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.02) {
tmp = fabs(sin(th));
} else if ((sin(ky) <= 5e-87) || (!(sin(ky) <= 2e-47) && (sin(ky) <= 2e-24))) {
tmp = sin(th) * (ky / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.02d0)) then
tmp = abs(sin(th))
else if ((sin(ky) <= 5d-87) .or. (.not. (sin(ky) <= 2d-47)) .and. (sin(ky) <= 2d-24)) then
tmp = sin(th) * (ky / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.02) {
tmp = Math.abs(Math.sin(th));
} else if ((Math.sin(ky) <= 5e-87) || (!(Math.sin(ky) <= 2e-47) && (Math.sin(ky) <= 2e-24))) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.02: tmp = math.fabs(math.sin(th)) elif (math.sin(ky) <= 5e-87) or (not (math.sin(ky) <= 2e-47) and (math.sin(ky) <= 2e-24)): tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.02) tmp = abs(sin(th)); elseif ((sin(ky) <= 5e-87) || (!(sin(ky) <= 2e-47) && (sin(ky) <= 2e-24))) tmp = Float64(sin(th) * Float64(ky / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.02) tmp = abs(sin(th)); elseif ((sin(ky) <= 5e-87) || (~((sin(ky) <= 2e-47)) && (sin(ky) <= 2e-24))) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[N[Sin[ky], $MachinePrecision], 5e-87], And[N[Not[LessEqual[N[Sin[ky], $MachinePrecision], 2e-47]], $MachinePrecision], LessEqual[N[Sin[ky], $MachinePrecision], 2e-24]]], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.02:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-87} \lor \neg \left(\sin ky \leq 2 \cdot 10^{-47}\right) \land \sin ky \leq 2 \cdot 10^{-24}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0200000000000000004Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 2.5%
add-sqr-sqrt1.2%
sqrt-unprod29.9%
pow229.9%
Applied egg-rr29.9%
unpow229.9%
rem-sqrt-square36.5%
associate-*r/36.5%
*-rgt-identity36.5%
times-frac36.6%
/-rgt-identity36.6%
*-inverses36.6%
*-lft-identity36.6%
Simplified36.6%
if -0.0200000000000000004 < (sin.f64 ky) < 5.00000000000000042e-87 or 1.9999999999999999e-47 < (sin.f64 ky) < 1.99999999999999985e-24Initial program 89.6%
+-commutative89.6%
unpow289.6%
unpow289.6%
hypot-undefine99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 58.3%
if 5.00000000000000042e-87 < (sin.f64 ky) < 1.9999999999999999e-47 or 1.99999999999999985e-24 < (sin.f64 ky) Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.5%
associate-/l*99.7%
unpow299.7%
Simplified99.7%
Taylor expanded in kx around 0 68.8%
Final simplification53.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (sin th) (/ ky (sin kx)))))
(if (<= (sin ky) -0.02)
(fabs (sin th))
(if (<= (sin ky) 5e-87)
t_1
(if (<= (sin ky) 2e-47)
(/ 1.0 (/ (sin ky) (* ky (sin th))))
(if (<= (sin ky) 2e-24) t_1 (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = sin(th) * (ky / sin(kx));
double tmp;
if (sin(ky) <= -0.02) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 5e-87) {
tmp = t_1;
} else if (sin(ky) <= 2e-47) {
tmp = 1.0 / (sin(ky) / (ky * sin(th)));
} else if (sin(ky) <= 2e-24) {
tmp = t_1;
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = sin(th) * (ky / sin(kx))
if (sin(ky) <= (-0.02d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 5d-87) then
tmp = t_1
else if (sin(ky) <= 2d-47) then
tmp = 1.0d0 / (sin(ky) / (ky * sin(th)))
else if (sin(ky) <= 2d-24) then
tmp = t_1
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(th) * (ky / Math.sin(kx));
double tmp;
if (Math.sin(ky) <= -0.02) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 5e-87) {
tmp = t_1;
} else if (Math.sin(ky) <= 2e-47) {
tmp = 1.0 / (Math.sin(ky) / (ky * Math.sin(th)));
} else if (Math.sin(ky) <= 2e-24) {
tmp = t_1;
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(th) * (ky / math.sin(kx)) tmp = 0 if math.sin(ky) <= -0.02: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 5e-87: tmp = t_1 elif math.sin(ky) <= 2e-47: tmp = 1.0 / (math.sin(ky) / (ky * math.sin(th))) elif math.sin(ky) <= 2e-24: tmp = t_1 else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = Float64(sin(th) * Float64(ky / sin(kx))) tmp = 0.0 if (sin(ky) <= -0.02) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-87) tmp = t_1; elseif (sin(ky) <= 2e-47) tmp = Float64(1.0 / Float64(sin(ky) / Float64(ky * sin(th)))); elseif (sin(ky) <= 2e-24) tmp = t_1; else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(th) * (ky / sin(kx)); tmp = 0.0; if (sin(ky) <= -0.02) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-87) tmp = t_1; elseif (sin(ky) <= 2e-47) tmp = 1.0 / (sin(ky) / (ky * sin(th))); elseif (sin(ky) <= 2e-24) tmp = t_1; else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-87], t$95$1, If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-47], N[(1.0 / N[(N[Sin[ky], $MachinePrecision] / N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-24], t$95$1, N[Sin[th], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{if}\;\sin ky \leq -0.02:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-87}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-47}:\\
\;\;\;\;\frac{1}{\frac{\sin ky}{ky \cdot \sin th}}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-24}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0200000000000000004Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 2.5%
add-sqr-sqrt1.2%
sqrt-unprod29.9%
pow229.9%
Applied egg-rr29.9%
unpow229.9%
rem-sqrt-square36.5%
associate-*r/36.5%
*-rgt-identity36.5%
times-frac36.6%
/-rgt-identity36.6%
*-inverses36.6%
*-lft-identity36.6%
Simplified36.6%
if -0.0200000000000000004 < (sin.f64 ky) < 5.00000000000000042e-87 or 1.9999999999999999e-47 < (sin.f64 ky) < 1.99999999999999985e-24Initial program 89.6%
+-commutative89.6%
unpow289.6%
unpow289.6%
hypot-undefine99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 58.3%
if 5.00000000000000042e-87 < (sin.f64 ky) < 1.9999999999999999e-47Initial program 99.1%
unpow299.1%
sqr-neg99.1%
sin-neg99.1%
sin-neg99.1%
unpow299.1%
associate-*l/98.5%
associate-/l*99.7%
unpow299.7%
Simplified99.7%
Taylor expanded in kx around 0 53.5%
associate-*r/53.0%
clear-num53.0%
Applied egg-rr53.0%
Taylor expanded in ky around 0 53.0%
if 1.99999999999999985e-24 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.7%
unpow299.7%
Simplified99.7%
Taylor expanded in kx around 0 70.7%
Final simplification53.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (sin th) (/ ky (sin kx)))))
(if (<= (sin ky) -0.02)
(fabs (sin th))
(if (<= (sin ky) 5e-130)
t_1
(if (<= (sin ky) 1e-53) (fabs t_1) (sin th))))))
double code(double kx, double ky, double th) {
double t_1 = sin(th) * (ky / sin(kx));
double tmp;
if (sin(ky) <= -0.02) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 5e-130) {
tmp = t_1;
} else if (sin(ky) <= 1e-53) {
tmp = fabs(t_1);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = sin(th) * (ky / sin(kx))
if (sin(ky) <= (-0.02d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 5d-130) then
tmp = t_1
else if (sin(ky) <= 1d-53) then
tmp = abs(t_1)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(th) * (ky / Math.sin(kx));
double tmp;
if (Math.sin(ky) <= -0.02) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 5e-130) {
tmp = t_1;
} else if (Math.sin(ky) <= 1e-53) {
tmp = Math.abs(t_1);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(th) * (ky / math.sin(kx)) tmp = 0 if math.sin(ky) <= -0.02: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 5e-130: tmp = t_1 elif math.sin(ky) <= 1e-53: tmp = math.fabs(t_1) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = Float64(sin(th) * Float64(ky / sin(kx))) tmp = 0.0 if (sin(ky) <= -0.02) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-130) tmp = t_1; elseif (sin(ky) <= 1e-53) tmp = abs(t_1); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(th) * (ky / sin(kx)); tmp = 0.0; if (sin(ky) <= -0.02) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-130) tmp = t_1; elseif (sin(ky) <= 1e-53) tmp = abs(t_1); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-130], t$95$1, If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-53], N[Abs[t$95$1], $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{if}\;\sin ky \leq -0.02:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-130}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\sin ky \leq 10^{-53}:\\
\;\;\;\;\left|t\_1\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0200000000000000004Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 2.5%
add-sqr-sqrt1.2%
sqrt-unprod29.9%
pow229.9%
Applied egg-rr29.9%
unpow229.9%
rem-sqrt-square36.5%
associate-*r/36.5%
*-rgt-identity36.5%
times-frac36.6%
/-rgt-identity36.6%
*-inverses36.6%
*-lft-identity36.6%
Simplified36.6%
if -0.0200000000000000004 < (sin.f64 ky) < 4.9999999999999996e-130Initial program 88.6%
+-commutative88.6%
unpow288.6%
unpow288.6%
hypot-undefine99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 59.7%
if 4.9999999999999996e-130 < (sin.f64 ky) < 1.00000000000000003e-53Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in ky around 0 29.9%
add-sqr-sqrt29.4%
sqrt-unprod39.3%
pow239.3%
associate-/l*39.3%
Applied egg-rr39.3%
unpow239.3%
rem-sqrt-square39.0%
*-commutative39.0%
associate-*l/39.0%
associate-*r/38.8%
Simplified38.8%
if 1.00000000000000003e-53 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.7%
Taylor expanded in kx around 0 67.5%
Final simplification53.2%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.05)
(* (sin ky) (fabs (/ (sin th) (sin ky))))
(if (<= (sin ky) 2e-134)
(* (sin th) (/ (sin ky) (sin kx)))
(if (<= (sin ky) 1e-53) (fabs (* (sin th) (/ ky (sin kx)))) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.05) {
tmp = sin(ky) * fabs((sin(th) / sin(ky)));
} else if (sin(ky) <= 2e-134) {
tmp = sin(th) * (sin(ky) / sin(kx));
} else if (sin(ky) <= 1e-53) {
tmp = fabs((sin(th) * (ky / sin(kx))));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.05d0)) then
tmp = sin(ky) * abs((sin(th) / sin(ky)))
else if (sin(ky) <= 2d-134) then
tmp = sin(th) * (sin(ky) / sin(kx))
else if (sin(ky) <= 1d-53) then
tmp = abs((sin(th) * (ky / sin(kx))))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.05) {
tmp = Math.sin(ky) * Math.abs((Math.sin(th) / Math.sin(ky)));
} else if (Math.sin(ky) <= 2e-134) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
} else if (Math.sin(ky) <= 1e-53) {
tmp = Math.abs((Math.sin(th) * (ky / Math.sin(kx))));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.05: tmp = math.sin(ky) * math.fabs((math.sin(th) / math.sin(ky))) elif math.sin(ky) <= 2e-134: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) elif math.sin(ky) <= 1e-53: tmp = math.fabs((math.sin(th) * (ky / math.sin(kx)))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.05) tmp = Float64(sin(ky) * abs(Float64(sin(th) / sin(ky)))); elseif (sin(ky) <= 2e-134) tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); elseif (sin(ky) <= 1e-53) tmp = abs(Float64(sin(th) * Float64(ky / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.05) tmp = sin(ky) * abs((sin(th) / sin(ky))); elseif (sin(ky) <= 2e-134) tmp = sin(th) * (sin(ky) / sin(kx)); elseif (sin(ky) <= 1e-53) tmp = abs((sin(th) * (ky / sin(kx)))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.05], N[(N[Sin[ky], $MachinePrecision] * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-134], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-53], N[Abs[N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.05:\\
\;\;\;\;\sin ky \cdot \left|\frac{\sin th}{\sin ky}\right|\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-134}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 10^{-53}:\\
\;\;\;\;\left|\sin th \cdot \frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.050000000000000003Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 2.6%
add-sqr-sqrt1.3%
sqrt-unprod24.8%
pow224.8%
Applied egg-rr24.8%
unpow224.8%
rem-sqrt-square31.5%
Simplified31.5%
if -0.050000000000000003 < (sin.f64 ky) < 2.00000000000000008e-134Initial program 88.5%
+-commutative88.5%
unpow288.5%
unpow288.5%
hypot-undefine99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 59.3%
if 2.00000000000000008e-134 < (sin.f64 ky) < 1.00000000000000003e-53Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in ky around 0 33.7%
add-sqr-sqrt32.4%
sqrt-unprod41.1%
pow241.1%
associate-/l*41.1%
Applied egg-rr41.1%
unpow241.1%
rem-sqrt-square40.9%
*-commutative40.9%
associate-*l/40.9%
associate-*r/40.7%
Simplified40.7%
if 1.00000000000000003e-53 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.7%
Taylor expanded in kx around 0 67.5%
Final simplification51.5%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.005)
(fabs (* (sin th) (/ ky (sin kx))))
(if (<= (sin kx) 1e-7)
(* (sin ky) (/ (sin th) (hypot (sin ky) kx)))
(* (sin th) (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.005) {
tmp = fabs((sin(th) * (ky / sin(kx))));
} else if (sin(kx) <= 1e-7) {
tmp = sin(ky) * (sin(th) / hypot(sin(ky), kx));
} else {
tmp = sin(th) * (sin(ky) / sin(kx));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.005) {
tmp = Math.abs((Math.sin(th) * (ky / Math.sin(kx))));
} else if (Math.sin(kx) <= 1e-7) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.hypot(Math.sin(ky), kx));
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.005: tmp = math.fabs((math.sin(th) * (ky / math.sin(kx)))) elif math.sin(kx) <= 1e-7: tmp = math.sin(ky) * (math.sin(th) / math.hypot(math.sin(ky), kx)) else: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.005) tmp = abs(Float64(sin(th) * Float64(ky / sin(kx)))); elseif (sin(kx) <= 1e-7) tmp = Float64(sin(ky) * Float64(sin(th) / hypot(sin(ky), kx))); else tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.005) tmp = abs((sin(th) * (ky / sin(kx)))); elseif (sin(kx) <= 1e-7) tmp = sin(ky) * (sin(th) / hypot(sin(ky), kx)); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[Abs[N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-7], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.005:\\
\;\;\;\;\left|\sin th \cdot \frac{ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 10^{-7}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0050000000000000001Initial program 99.3%
unpow299.3%
sqr-neg99.3%
sin-neg99.3%
sin-neg99.3%
unpow299.3%
associate-*l/99.5%
associate-/l*99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in ky around 0 14.6%
add-sqr-sqrt13.2%
sqrt-unprod21.8%
pow221.8%
associate-/l*21.9%
Applied egg-rr21.9%
unpow221.9%
rem-sqrt-square28.9%
*-commutative28.9%
associate-*l/28.9%
associate-*r/28.9%
Simplified28.9%
if -0.0050000000000000001 < (sin.f64 kx) < 9.9999999999999995e-8Initial program 91.3%
unpow291.3%
sqr-neg91.3%
sin-neg91.3%
sin-neg91.3%
unpow291.3%
associate-*l/88.5%
associate-/l*91.2%
unpow291.2%
Simplified99.8%
Taylor expanded in kx around 0 99.4%
if 9.9999999999999995e-8 < (sin.f64 kx) Initial program 99.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-undefine99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 67.1%
Final simplification76.8%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.005)
(fabs (* (sin th) (/ ky (sin kx))))
(if (<= (sin kx) 1e-7)
(* (sin th) (/ (sin ky) (hypot (sin ky) kx)))
(* (sin th) (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.005) {
tmp = fabs((sin(th) * (ky / sin(kx))));
} else if (sin(kx) <= 1e-7) {
tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx));
} else {
tmp = sin(th) * (sin(ky) / sin(kx));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.005) {
tmp = Math.abs((Math.sin(th) * (ky / Math.sin(kx))));
} else if (Math.sin(kx) <= 1e-7) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), kx));
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.005: tmp = math.fabs((math.sin(th) * (ky / math.sin(kx)))) elif math.sin(kx) <= 1e-7: tmp = math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), kx)) else: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.005) tmp = abs(Float64(sin(th) * Float64(ky / sin(kx)))); elseif (sin(kx) <= 1e-7) tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), kx))); else tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.005) tmp = abs((sin(th) * (ky / sin(kx)))); elseif (sin(kx) <= 1e-7) tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx)); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[Abs[N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-7], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.005:\\
\;\;\;\;\left|\sin th \cdot \frac{ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 10^{-7}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0050000000000000001Initial program 99.3%
unpow299.3%
sqr-neg99.3%
sin-neg99.3%
sin-neg99.3%
unpow299.3%
associate-*l/99.5%
associate-/l*99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in ky around 0 14.6%
add-sqr-sqrt13.2%
sqrt-unprod21.8%
pow221.8%
associate-/l*21.9%
Applied egg-rr21.9%
unpow221.9%
rem-sqrt-square28.9%
*-commutative28.9%
associate-*l/28.9%
associate-*r/28.9%
Simplified28.9%
if -0.0050000000000000001 < (sin.f64 kx) < 9.9999999999999995e-8Initial program 91.3%
+-commutative91.3%
unpow291.3%
unpow291.3%
hypot-undefine99.9%
Applied egg-rr99.9%
Taylor expanded in kx around 0 99.6%
if 9.9999999999999995e-8 < (sin.f64 kx) Initial program 99.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-undefine99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 67.1%
Final simplification76.9%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.005)
(/ (sin ky) (/ (hypot (sin kx) (sin ky)) th))
(if (<= (sin kx) 1e-7)
(* (sin th) (/ (sin ky) (hypot (sin ky) kx)))
(* (sin th) (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.005) {
tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th);
} else if (sin(kx) <= 1e-7) {
tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx));
} else {
tmp = sin(th) * (sin(ky) / sin(kx));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.005) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), Math.sin(ky)) / th);
} else if (Math.sin(kx) <= 1e-7) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), kx));
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.005: tmp = math.sin(ky) / (math.hypot(math.sin(kx), math.sin(ky)) / th) elif math.sin(kx) <= 1e-7: tmp = math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), kx)) else: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.005) tmp = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) / th)); elseif (sin(kx) <= 1e-7) tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), kx))); else tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.005) tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th); elseif (sin(kx) <= 1e-7) tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx)); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-7], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.005:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\
\mathbf{elif}\;\sin kx \leq 10^{-7}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0050000000000000001Initial program 99.3%
unpow299.3%
sqr-neg99.3%
sin-neg99.3%
sin-neg99.3%
unpow299.3%
associate-*l/99.5%
associate-/l*99.5%
unpow299.5%
Simplified99.5%
clear-num99.3%
un-div-inv99.4%
Applied egg-rr99.4%
Taylor expanded in th around 0 59.0%
+-commutative59.0%
unpow259.0%
unpow259.0%
hypot-undefine59.0%
associate-*l/59.1%
*-lft-identity59.1%
hypot-undefine59.2%
unpow259.2%
unpow259.2%
+-commutative59.2%
unpow259.2%
unpow259.2%
hypot-define59.1%
Simplified59.1%
if -0.0050000000000000001 < (sin.f64 kx) < 9.9999999999999995e-8Initial program 91.3%
+-commutative91.3%
unpow291.3%
unpow291.3%
hypot-undefine99.9%
Applied egg-rr99.9%
Taylor expanded in kx around 0 99.6%
if 9.9999999999999995e-8 < (sin.f64 kx) Initial program 99.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-undefine99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 67.1%
Final simplification83.0%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 2e-121) (* (sin ky) (/ (sin th) (sin kx))) (if (<= (sin ky) 1e-53) (fabs (* (sin th) (/ ky (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 2e-121) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else if (sin(ky) <= 1e-53) {
tmp = fabs((sin(th) * (ky / sin(kx))));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= 2d-121) then
tmp = sin(ky) * (sin(th) / sin(kx))
else if (sin(ky) <= 1d-53) then
tmp = abs((sin(th) * (ky / sin(kx))))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= 2e-121) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else if (Math.sin(ky) <= 1e-53) {
tmp = Math.abs((Math.sin(th) * (ky / Math.sin(kx))));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 2e-121: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) elif math.sin(ky) <= 1e-53: tmp = math.fabs((math.sin(th) * (ky / math.sin(kx)))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 2e-121) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); elseif (sin(ky) <= 1e-53) tmp = abs(Float64(sin(th) * Float64(ky / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 2e-121) tmp = sin(ky) * (sin(th) / sin(kx)); elseif (sin(ky) <= 1e-53) tmp = abs((sin(th) * (ky / sin(kx)))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-121], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-53], N[Abs[N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 2 \cdot 10^{-121}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 10^{-53}:\\
\;\;\;\;\left|\sin th \cdot \frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 2e-121Initial program 93.3%
unpow293.3%
sqr-neg93.3%
sin-neg93.3%
sin-neg93.3%
unpow293.3%
associate-*l/91.4%
associate-/l*93.3%
unpow293.3%
Simplified99.6%
Taylor expanded in ky around 0 37.0%
if 2e-121 < (sin.f64 ky) < 1.00000000000000003e-53Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in ky around 0 29.9%
add-sqr-sqrt29.4%
sqrt-unprod39.3%
pow239.3%
associate-/l*39.3%
Applied egg-rr39.3%
unpow239.3%
rem-sqrt-square39.0%
*-commutative39.0%
associate-*l/39.0%
associate-*r/38.8%
Simplified38.8%
if 1.00000000000000003e-53 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.6%
unpow299.6%
Simplified99.7%
Taylor expanded in kx around 0 67.5%
Final simplification43.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.005) (fabs (* (sin th) (/ ky (sin kx)))) (if (<= (sin kx) 2e-127) (sin th) (* (sin th) (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.005) {
tmp = fabs((sin(th) * (ky / sin(kx))));
} else if (sin(kx) <= 2e-127) {
tmp = sin(th);
} else {
tmp = sin(th) * (sin(ky) / sin(kx));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.005d0)) then
tmp = abs((sin(th) * (ky / sin(kx))))
else if (sin(kx) <= 2d-127) then
tmp = sin(th)
else
tmp = sin(th) * (sin(ky) / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.005) {
tmp = Math.abs((Math.sin(th) * (ky / Math.sin(kx))));
} else if (Math.sin(kx) <= 2e-127) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.005: tmp = math.fabs((math.sin(th) * (ky / math.sin(kx)))) elif math.sin(kx) <= 2e-127: tmp = math.sin(th) else: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.005) tmp = abs(Float64(sin(th) * Float64(ky / sin(kx)))); elseif (sin(kx) <= 2e-127) tmp = sin(th); else tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.005) tmp = abs((sin(th) * (ky / sin(kx)))); elseif (sin(kx) <= 2e-127) tmp = sin(th); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[Abs[N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-127], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.005:\\
\;\;\;\;\left|\sin th \cdot \frac{ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-127}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0050000000000000001Initial program 99.3%
unpow299.3%
sqr-neg99.3%
sin-neg99.3%
sin-neg99.3%
unpow299.3%
associate-*l/99.5%
associate-/l*99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in ky around 0 14.6%
add-sqr-sqrt13.2%
sqrt-unprod21.8%
pow221.8%
associate-/l*21.9%
Applied egg-rr21.9%
unpow221.9%
rem-sqrt-square28.9%
*-commutative28.9%
associate-*l/28.9%
associate-*r/28.9%
Simplified28.9%
if -0.0050000000000000001 < (sin.f64 kx) < 2.0000000000000001e-127Initial program 89.0%
unpow289.0%
sqr-neg89.0%
sin-neg89.0%
sin-neg89.0%
unpow289.0%
associate-*l/87.2%
associate-/l*88.9%
unpow288.9%
Simplified99.8%
Taylor expanded in kx around 0 35.4%
if 2.0000000000000001e-127 < (sin.f64 kx) Initial program 99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-undefine99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 64.5%
Final simplification44.9%
(FPCore (kx ky th) :precision binary64 (* (sin ky) (/ (sin th) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
return sin(ky) * (sin(th) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(ky) * (Math.sin(th) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th): return math.sin(ky) * (math.sin(th) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th) return Float64(sin(ky) * Float64(sin(th) / hypot(sin(ky), sin(kx)))) end
function tmp = code(kx, ky, th) tmp = sin(ky) * (sin(th) / hypot(sin(ky), sin(kx))); end
code[kx_, ky_, th_] := N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Initial program 95.0%
unpow295.0%
sqr-neg95.0%
sin-neg95.0%
sin-neg95.0%
unpow295.0%
associate-*l/93.5%
associate-/l*95.0%
unpow295.0%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th) :precision binary64 (if (<= ky 5.6e-89) (* ky (/ th (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 5.6e-89) {
tmp = ky * (th / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 5.6d-89) then
tmp = ky * (th / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 5.6e-89) {
tmp = ky * (th / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 5.6e-89: tmp = ky * (th / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 5.6e-89) tmp = Float64(ky * Float64(th / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 5.6e-89) tmp = ky * (th / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 5.6e-89], N[(ky * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 5.6 \cdot 10^{-89}:\\
\;\;\;\;ky \cdot \frac{th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 5.5999999999999998e-89Initial program 93.3%
unpow293.3%
sqr-neg93.3%
sin-neg93.3%
sin-neg93.3%
unpow293.3%
associate-*l/91.3%
associate-/l*93.2%
unpow293.2%
Simplified99.6%
Taylor expanded in ky around 0 34.8%
Taylor expanded in th around 0 19.8%
associate-/l*21.7%
Simplified21.7%
if 5.5999999999999998e-89 < ky Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.7%
unpow299.7%
Simplified99.7%
Taylor expanded in kx around 0 35.8%
Final simplification25.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.32e-101) (* (sin th) (/ ky kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.32e-101) {
tmp = sin(th) * (ky / kx);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 1.32d-101) then
tmp = sin(th) * (ky / kx)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.32e-101) {
tmp = Math.sin(th) * (ky / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.32e-101: tmp = math.sin(th) * (ky / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.32e-101) tmp = Float64(sin(th) * Float64(ky / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.32e-101) tmp = sin(th) * (ky / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.32e-101], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.32 \cdot 10^{-101}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.32e-101Initial program 93.2%
+-commutative93.2%
unpow293.2%
unpow293.2%
hypot-undefine99.7%
Applied egg-rr99.7%
Taylor expanded in kx around 0 64.4%
Taylor expanded in ky around 0 25.1%
if 1.32e-101 < ky Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.7%
unpow299.7%
Simplified99.7%
Taylor expanded in kx around 0 35.8%
Final simplification28.1%
(FPCore (kx ky th) :precision binary64 (sin th))
double code(double kx, double ky, double th) {
return sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = sin(th)
end function
public static double code(double kx, double ky, double th) {
return Math.sin(th);
}
def code(kx, ky, th): return math.sin(th)
function code(kx, ky, th) return sin(th) end
function tmp = code(kx, ky, th) tmp = sin(th); end
code[kx_, ky_, th_] := N[Sin[th], $MachinePrecision]
\begin{array}{l}
\\
\sin th
\end{array}
Initial program 95.0%
unpow295.0%
sqr-neg95.0%
sin-neg95.0%
sin-neg95.0%
unpow295.0%
associate-*l/93.5%
associate-/l*95.0%
unpow295.0%
Simplified99.6%
Taylor expanded in kx around 0 20.8%
Final simplification20.8%
(FPCore (kx ky th) :precision binary64 (/ 1.0 (+ (* th 0.16666666666666666) (/ 1.0 th))))
double code(double kx, double ky, double th) {
return 1.0 / ((th * 0.16666666666666666) + (1.0 / th));
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = 1.0d0 / ((th * 0.16666666666666666d0) + (1.0d0 / th))
end function
public static double code(double kx, double ky, double th) {
return 1.0 / ((th * 0.16666666666666666) + (1.0 / th));
}
def code(kx, ky, th): return 1.0 / ((th * 0.16666666666666666) + (1.0 / th))
function code(kx, ky, th) return Float64(1.0 / Float64(Float64(th * 0.16666666666666666) + Float64(1.0 / th))) end
function tmp = code(kx, ky, th) tmp = 1.0 / ((th * 0.16666666666666666) + (1.0 / th)); end
code[kx_, ky_, th_] := N[(1.0 / N[(N[(th * 0.16666666666666666), $MachinePrecision] + N[(1.0 / th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{th \cdot 0.16666666666666666 + \frac{1}{th}}
\end{array}
Initial program 95.0%
unpow295.0%
sqr-neg95.0%
sin-neg95.0%
sin-neg95.0%
unpow295.0%
associate-*l/93.5%
associate-/l*95.0%
unpow295.0%
Simplified99.6%
Taylor expanded in kx around 0 20.8%
associate-*r/27.8%
clear-num27.8%
Applied egg-rr27.8%
Taylor expanded in th around 0 15.0%
Final simplification15.0%
(FPCore (kx ky th) :precision binary64 th)
double code(double kx, double ky, double th) {
return th;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = th
end function
public static double code(double kx, double ky, double th) {
return th;
}
def code(kx, ky, th): return th
function code(kx, ky, th) return th end
function tmp = code(kx, ky, th) tmp = th; end
code[kx_, ky_, th_] := th
\begin{array}{l}
\\
th
\end{array}
Initial program 95.0%
unpow295.0%
sqr-neg95.0%
sin-neg95.0%
sin-neg95.0%
unpow295.0%
associate-*l/93.5%
associate-/l*95.0%
unpow295.0%
Simplified99.6%
Taylor expanded in kx around 0 20.8%
Taylor expanded in th around 0 14.3%
Final simplification14.3%
herbie shell --seed 2024050
(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)))