
(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 14 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 90.7%
+-commutative90.7%
unpow290.7%
unpow290.7%
hypot-undefine99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.175)
(* (* ky (sin th)) (fabs (/ 1.0 (sin kx))))
(if (<= (sin kx) 1e-103)
(sin th)
(if (<= (sin kx) 1e-77)
(* (sin ky) (/ (sin th) (sin kx)))
(if (<= (sin kx) 4e-42)
(sin th)
(* (sin th) (/ 1.0 (/ (sin kx) (sin ky)))))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.175) {
tmp = (ky * sin(th)) * fabs((1.0 / sin(kx)));
} else if (sin(kx) <= 1e-103) {
tmp = sin(th);
} else if (sin(kx) <= 1e-77) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else if (sin(kx) <= 4e-42) {
tmp = sin(th);
} else {
tmp = sin(th) * (1.0 / (sin(kx) / sin(ky)));
}
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.175d0)) then
tmp = (ky * sin(th)) * abs((1.0d0 / sin(kx)))
else if (sin(kx) <= 1d-103) then
tmp = sin(th)
else if (sin(kx) <= 1d-77) then
tmp = sin(ky) * (sin(th) / sin(kx))
else if (sin(kx) <= 4d-42) then
tmp = sin(th)
else
tmp = sin(th) * (1.0d0 / (sin(kx) / sin(ky)))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.175) {
tmp = (ky * Math.sin(th)) * Math.abs((1.0 / Math.sin(kx)));
} else if (Math.sin(kx) <= 1e-103) {
tmp = Math.sin(th);
} else if (Math.sin(kx) <= 1e-77) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else if (Math.sin(kx) <= 4e-42) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (1.0 / (Math.sin(kx) / Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.175: tmp = (ky * math.sin(th)) * math.fabs((1.0 / math.sin(kx))) elif math.sin(kx) <= 1e-103: tmp = math.sin(th) elif math.sin(kx) <= 1e-77: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) elif math.sin(kx) <= 4e-42: tmp = math.sin(th) else: tmp = math.sin(th) * (1.0 / (math.sin(kx) / math.sin(ky))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.175) tmp = Float64(Float64(ky * sin(th)) * abs(Float64(1.0 / sin(kx)))); elseif (sin(kx) <= 1e-103) tmp = sin(th); elseif (sin(kx) <= 1e-77) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); elseif (sin(kx) <= 4e-42) tmp = sin(th); else tmp = Float64(sin(th) * Float64(1.0 / Float64(sin(kx) / sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.175) tmp = (ky * sin(th)) * abs((1.0 / sin(kx))); elseif (sin(kx) <= 1e-103) tmp = sin(th); elseif (sin(kx) <= 1e-77) tmp = sin(ky) * (sin(th) / sin(kx)); elseif (sin(kx) <= 4e-42) tmp = sin(th); else tmp = sin(th) * (1.0 / (sin(kx) / sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.175], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(1.0 / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-103], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-77], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 4e-42], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(1.0 / N[(N[Sin[kx], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.175:\\
\;\;\;\;\left(ky \cdot \sin th\right) \cdot \left|\frac{1}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 10^{-103}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin kx \leq 10^{-77}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;\sin kx \leq 4 \cdot 10^{-42}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{1}{\frac{\sin kx}{\sin ky}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.17499999999999999Initial program 99.6%
associate-*l/99.4%
associate-/l*99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
sqr-neg99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in ky around 0 19.0%
associate-/l*19.0%
Simplified19.0%
associate-*r/19.0%
clear-num19.0%
Applied egg-rr19.0%
associate-/r/19.0%
Simplified19.0%
add-sqr-sqrt0.0%
sqrt-unprod54.2%
rem-sqrt-square54.2%
Applied egg-rr54.2%
if -0.17499999999999999 < (sin.f64 kx) < 9.99999999999999958e-104 or 9.9999999999999993e-78 < (sin.f64 kx) < 4.00000000000000015e-42Initial program 81.8%
associate-*l/78.4%
associate-/l*81.6%
unpow281.6%
sqr-neg81.6%
sin-neg81.6%
sin-neg81.6%
unpow281.6%
unpow281.6%
sin-neg81.6%
sin-neg81.6%
sqr-neg81.6%
unpow281.6%
Simplified99.7%
Taylor expanded in kx around 0 40.4%
if 9.99999999999999958e-104 < (sin.f64 kx) < 9.9999999999999993e-78Initial program 99.8%
associate-*l/79.8%
associate-/l*99.9%
unpow299.9%
sqr-neg99.9%
sin-neg99.9%
sin-neg99.9%
unpow299.9%
unpow299.9%
sin-neg99.9%
sin-neg99.9%
sqr-neg99.9%
unpow299.9%
Simplified99.9%
Taylor expanded in ky around 0 49.1%
if 4.00000000000000015e-42 < (sin.f64 kx) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-undefine99.6%
Applied egg-rr99.6%
clear-num99.6%
inv-pow99.6%
Applied egg-rr99.6%
unpow-199.6%
hypot-undefine99.6%
unpow299.6%
unpow299.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-undefine99.6%
Simplified99.6%
Taylor expanded in ky around 0 64.0%
Final simplification49.5%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin th) (sin kx))))
(if (<= (sin kx) -0.18)
(* ky (fabs t_1))
(if (or (<= (sin kx) 1e-103)
(and (not (<= (sin kx) 1e-77)) (<= (sin kx) 4e-42)))
(sin th)
(* (sin ky) t_1)))))
double code(double kx, double ky, double th) {
double t_1 = sin(th) / sin(kx);
double tmp;
if (sin(kx) <= -0.18) {
tmp = ky * fabs(t_1);
} else if ((sin(kx) <= 1e-103) || (!(sin(kx) <= 1e-77) && (sin(kx) <= 4e-42))) {
tmp = sin(th);
} else {
tmp = sin(ky) * t_1;
}
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) / sin(kx)
if (sin(kx) <= (-0.18d0)) then
tmp = ky * abs(t_1)
else if ((sin(kx) <= 1d-103) .or. (.not. (sin(kx) <= 1d-77)) .and. (sin(kx) <= 4d-42)) then
tmp = sin(th)
else
tmp = sin(ky) * t_1
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(th) / Math.sin(kx);
double tmp;
if (Math.sin(kx) <= -0.18) {
tmp = ky * Math.abs(t_1);
} else if ((Math.sin(kx) <= 1e-103) || (!(Math.sin(kx) <= 1e-77) && (Math.sin(kx) <= 4e-42))) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(ky) * t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(th) / math.sin(kx) tmp = 0 if math.sin(kx) <= -0.18: tmp = ky * math.fabs(t_1) elif (math.sin(kx) <= 1e-103) or (not (math.sin(kx) <= 1e-77) and (math.sin(kx) <= 4e-42)): tmp = math.sin(th) else: tmp = math.sin(ky) * t_1 return tmp
function code(kx, ky, th) t_1 = Float64(sin(th) / sin(kx)) tmp = 0.0 if (sin(kx) <= -0.18) tmp = Float64(ky * abs(t_1)); elseif ((sin(kx) <= 1e-103) || (!(sin(kx) <= 1e-77) && (sin(kx) <= 4e-42))) tmp = sin(th); else tmp = Float64(sin(ky) * t_1); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(th) / sin(kx); tmp = 0.0; if (sin(kx) <= -0.18) tmp = ky * abs(t_1); elseif ((sin(kx) <= 1e-103) || (~((sin(kx) <= 1e-77)) && (sin(kx) <= 4e-42))) tmp = sin(th); else tmp = sin(ky) * t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[kx], $MachinePrecision], -0.18], N[(ky * N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[Sin[kx], $MachinePrecision], 1e-103], And[N[Not[LessEqual[N[Sin[kx], $MachinePrecision], 1e-77]], $MachinePrecision], LessEqual[N[Sin[kx], $MachinePrecision], 4e-42]]], N[Sin[th], $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin th}{\sin kx}\\
\mathbf{if}\;\sin kx \leq -0.18:\\
\;\;\;\;ky \cdot \left|t\_1\right|\\
\mathbf{elif}\;\sin kx \leq 10^{-103} \lor \neg \left(\sin kx \leq 10^{-77}\right) \land \sin kx \leq 4 \cdot 10^{-42}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot t\_1\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.17999999999999999Initial program 99.6%
associate-*l/99.4%
associate-/l*99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
sqr-neg99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in ky around 0 19.0%
associate-/l*19.0%
Simplified19.0%
add-sqr-sqrt13.5%
sqrt-unprod37.6%
pow237.6%
Applied egg-rr37.6%
unpow237.6%
rem-sqrt-square38.9%
Simplified38.9%
if -0.17999999999999999 < (sin.f64 kx) < 9.99999999999999958e-104 or 9.9999999999999993e-78 < (sin.f64 kx) < 4.00000000000000015e-42Initial program 81.8%
associate-*l/78.4%
associate-/l*81.6%
unpow281.6%
sqr-neg81.6%
sin-neg81.6%
sin-neg81.6%
unpow281.6%
unpow281.6%
sin-neg81.6%
sin-neg81.6%
sqr-neg81.6%
unpow281.6%
Simplified99.7%
Taylor expanded in kx around 0 40.4%
if 9.99999999999999958e-104 < (sin.f64 kx) < 9.9999999999999993e-78 or 4.00000000000000015e-42 < (sin.f64 kx) Initial program 99.7%
associate-*l/95.8%
associate-/l*99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
sqr-neg99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in ky around 0 61.3%
Final simplification46.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin th) (sin kx))))
(if (<= (sin kx) -0.18)
(* ky (fabs t_1))
(if (<= (sin kx) 1e-103)
(sin th)
(if (<= (sin kx) 1e-77)
(* (sin ky) t_1)
(if (<= (sin kx) 4e-42)
(sin th)
(/ (sin th) (/ (sin kx) (sin ky)))))))))
double code(double kx, double ky, double th) {
double t_1 = sin(th) / sin(kx);
double tmp;
if (sin(kx) <= -0.18) {
tmp = ky * fabs(t_1);
} else if (sin(kx) <= 1e-103) {
tmp = sin(th);
} else if (sin(kx) <= 1e-77) {
tmp = sin(ky) * t_1;
} else if (sin(kx) <= 4e-42) {
tmp = sin(th);
} else {
tmp = sin(th) / (sin(kx) / sin(ky));
}
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) / sin(kx)
if (sin(kx) <= (-0.18d0)) then
tmp = ky * abs(t_1)
else if (sin(kx) <= 1d-103) then
tmp = sin(th)
else if (sin(kx) <= 1d-77) then
tmp = sin(ky) * t_1
else if (sin(kx) <= 4d-42) then
tmp = sin(th)
else
tmp = sin(th) / (sin(kx) / sin(ky))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(th) / Math.sin(kx);
double tmp;
if (Math.sin(kx) <= -0.18) {
tmp = ky * Math.abs(t_1);
} else if (Math.sin(kx) <= 1e-103) {
tmp = Math.sin(th);
} else if (Math.sin(kx) <= 1e-77) {
tmp = Math.sin(ky) * t_1;
} else if (Math.sin(kx) <= 4e-42) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) / (Math.sin(kx) / Math.sin(ky));
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(th) / math.sin(kx) tmp = 0 if math.sin(kx) <= -0.18: tmp = ky * math.fabs(t_1) elif math.sin(kx) <= 1e-103: tmp = math.sin(th) elif math.sin(kx) <= 1e-77: tmp = math.sin(ky) * t_1 elif math.sin(kx) <= 4e-42: tmp = math.sin(th) else: tmp = math.sin(th) / (math.sin(kx) / math.sin(ky)) return tmp
function code(kx, ky, th) t_1 = Float64(sin(th) / sin(kx)) tmp = 0.0 if (sin(kx) <= -0.18) tmp = Float64(ky * abs(t_1)); elseif (sin(kx) <= 1e-103) tmp = sin(th); elseif (sin(kx) <= 1e-77) tmp = Float64(sin(ky) * t_1); elseif (sin(kx) <= 4e-42) tmp = sin(th); else tmp = Float64(sin(th) / Float64(sin(kx) / sin(ky))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(th) / sin(kx); tmp = 0.0; if (sin(kx) <= -0.18) tmp = ky * abs(t_1); elseif (sin(kx) <= 1e-103) tmp = sin(th); elseif (sin(kx) <= 1e-77) tmp = sin(ky) * t_1; elseif (sin(kx) <= 4e-42) tmp = sin(th); else tmp = sin(th) / (sin(kx) / sin(ky)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[kx], $MachinePrecision], -0.18], N[(ky * N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-103], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-77], N[(N[Sin[ky], $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 4e-42], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin th}{\sin kx}\\
\mathbf{if}\;\sin kx \leq -0.18:\\
\;\;\;\;ky \cdot \left|t\_1\right|\\
\mathbf{elif}\;\sin kx \leq 10^{-103}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin kx \leq 10^{-77}:\\
\;\;\;\;\sin ky \cdot t\_1\\
\mathbf{elif}\;\sin kx \leq 4 \cdot 10^{-42}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.17999999999999999Initial program 99.6%
associate-*l/99.4%
associate-/l*99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
sqr-neg99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in ky around 0 19.0%
associate-/l*19.0%
Simplified19.0%
add-sqr-sqrt13.5%
sqrt-unprod37.6%
pow237.6%
Applied egg-rr37.6%
unpow237.6%
rem-sqrt-square38.9%
Simplified38.9%
if -0.17999999999999999 < (sin.f64 kx) < 9.99999999999999958e-104 or 9.9999999999999993e-78 < (sin.f64 kx) < 4.00000000000000015e-42Initial program 81.8%
associate-*l/78.4%
associate-/l*81.6%
unpow281.6%
sqr-neg81.6%
sin-neg81.6%
sin-neg81.6%
unpow281.6%
unpow281.6%
sin-neg81.6%
sin-neg81.6%
sqr-neg81.6%
unpow281.6%
Simplified99.7%
Taylor expanded in kx around 0 40.4%
if 9.99999999999999958e-104 < (sin.f64 kx) < 9.9999999999999993e-78Initial program 99.8%
associate-*l/79.8%
associate-/l*99.9%
unpow299.9%
sqr-neg99.9%
sin-neg99.9%
sin-neg99.9%
unpow299.9%
unpow299.9%
sin-neg99.9%
sin-neg99.9%
sqr-neg99.9%
unpow299.9%
Simplified99.9%
Taylor expanded in ky around 0 49.1%
if 4.00000000000000015e-42 < (sin.f64 kx) Initial program 99.7%
associate-*l/99.2%
associate-/l*99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
unpow299.5%
sin-neg99.5%
sin-neg99.5%
sqr-neg99.5%
unpow299.5%
Simplified99.6%
associate-*r/99.3%
hypot-undefine99.2%
unpow299.2%
unpow299.2%
+-commutative99.2%
associate-*l/99.7%
*-commutative99.7%
clear-num99.6%
un-div-inv99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-undefine99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 64.0%
Final simplification46.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.175)
(* (* ky (sin th)) (fabs (/ 1.0 (sin kx))))
(if (<= (sin kx) 1e-103)
(sin th)
(if (<= (sin kx) 1e-77)
(* (sin ky) (/ (sin th) (sin kx)))
(if (<= (sin kx) 4e-42) (sin th) (/ (sin th) (/ (sin kx) (sin ky))))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.175) {
tmp = (ky * sin(th)) * fabs((1.0 / sin(kx)));
} else if (sin(kx) <= 1e-103) {
tmp = sin(th);
} else if (sin(kx) <= 1e-77) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else if (sin(kx) <= 4e-42) {
tmp = sin(th);
} else {
tmp = sin(th) / (sin(kx) / sin(ky));
}
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.175d0)) then
tmp = (ky * sin(th)) * abs((1.0d0 / sin(kx)))
else if (sin(kx) <= 1d-103) then
tmp = sin(th)
else if (sin(kx) <= 1d-77) then
tmp = sin(ky) * (sin(th) / sin(kx))
else if (sin(kx) <= 4d-42) then
tmp = sin(th)
else
tmp = sin(th) / (sin(kx) / sin(ky))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.175) {
tmp = (ky * Math.sin(th)) * Math.abs((1.0 / Math.sin(kx)));
} else if (Math.sin(kx) <= 1e-103) {
tmp = Math.sin(th);
} else if (Math.sin(kx) <= 1e-77) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else if (Math.sin(kx) <= 4e-42) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) / (Math.sin(kx) / Math.sin(ky));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.175: tmp = (ky * math.sin(th)) * math.fabs((1.0 / math.sin(kx))) elif math.sin(kx) <= 1e-103: tmp = math.sin(th) elif math.sin(kx) <= 1e-77: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) elif math.sin(kx) <= 4e-42: tmp = math.sin(th) else: tmp = math.sin(th) / (math.sin(kx) / math.sin(ky)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.175) tmp = Float64(Float64(ky * sin(th)) * abs(Float64(1.0 / sin(kx)))); elseif (sin(kx) <= 1e-103) tmp = sin(th); elseif (sin(kx) <= 1e-77) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); elseif (sin(kx) <= 4e-42) tmp = sin(th); else tmp = Float64(sin(th) / Float64(sin(kx) / sin(ky))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.175) tmp = (ky * sin(th)) * abs((1.0 / sin(kx))); elseif (sin(kx) <= 1e-103) tmp = sin(th); elseif (sin(kx) <= 1e-77) tmp = sin(ky) * (sin(th) / sin(kx)); elseif (sin(kx) <= 4e-42) tmp = sin(th); else tmp = sin(th) / (sin(kx) / sin(ky)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.175], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(1.0 / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-103], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-77], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 4e-42], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.175:\\
\;\;\;\;\left(ky \cdot \sin th\right) \cdot \left|\frac{1}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 10^{-103}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin kx \leq 10^{-77}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;\sin kx \leq 4 \cdot 10^{-42}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.17499999999999999Initial program 99.6%
associate-*l/99.4%
associate-/l*99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
sqr-neg99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in ky around 0 19.0%
associate-/l*19.0%
Simplified19.0%
associate-*r/19.0%
clear-num19.0%
Applied egg-rr19.0%
associate-/r/19.0%
Simplified19.0%
add-sqr-sqrt0.0%
sqrt-unprod54.2%
rem-sqrt-square54.2%
Applied egg-rr54.2%
if -0.17499999999999999 < (sin.f64 kx) < 9.99999999999999958e-104 or 9.9999999999999993e-78 < (sin.f64 kx) < 4.00000000000000015e-42Initial program 81.8%
associate-*l/78.4%
associate-/l*81.6%
unpow281.6%
sqr-neg81.6%
sin-neg81.6%
sin-neg81.6%
unpow281.6%
unpow281.6%
sin-neg81.6%
sin-neg81.6%
sqr-neg81.6%
unpow281.6%
Simplified99.7%
Taylor expanded in kx around 0 40.4%
if 9.99999999999999958e-104 < (sin.f64 kx) < 9.9999999999999993e-78Initial program 99.8%
associate-*l/79.8%
associate-/l*99.9%
unpow299.9%
sqr-neg99.9%
sin-neg99.9%
sin-neg99.9%
unpow299.9%
unpow299.9%
sin-neg99.9%
sin-neg99.9%
sqr-neg99.9%
unpow299.9%
Simplified99.9%
Taylor expanded in ky around 0 49.1%
if 4.00000000000000015e-42 < (sin.f64 kx) Initial program 99.7%
associate-*l/99.2%
associate-/l*99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
unpow299.5%
sin-neg99.5%
sin-neg99.5%
sqr-neg99.5%
unpow299.5%
Simplified99.6%
associate-*r/99.3%
hypot-undefine99.2%
unpow299.2%
unpow299.2%
+-commutative99.2%
associate-*l/99.7%
*-commutative99.7%
clear-num99.6%
un-div-inv99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-undefine99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 64.0%
Final simplification49.5%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) 1e-306)
(* (sin ky) (fabs (/ (sin th) (sin kx))))
(if (<= (sin ky) 1e-5)
(* (/ 1.0 (hypot (sin ky) (sin kx))) (* ky (sin th)))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-306) {
tmp = sin(ky) * fabs((sin(th) / sin(kx)));
} else if (sin(ky) <= 1e-5) {
tmp = (1.0 / hypot(sin(ky), sin(kx))) * (ky * sin(th));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= 1e-306) {
tmp = Math.sin(ky) * Math.abs((Math.sin(th) / Math.sin(kx)));
} else if (Math.sin(ky) <= 1e-5) {
tmp = (1.0 / Math.hypot(Math.sin(ky), Math.sin(kx))) * (ky * Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-306: tmp = math.sin(ky) * math.fabs((math.sin(th) / math.sin(kx))) elif math.sin(ky) <= 1e-5: tmp = (1.0 / math.hypot(math.sin(ky), math.sin(kx))) * (ky * math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-306) tmp = Float64(sin(ky) * abs(Float64(sin(th) / sin(kx)))); elseif (sin(ky) <= 1e-5) tmp = Float64(Float64(1.0 / hypot(sin(ky), sin(kx))) * Float64(ky * sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 1e-306) tmp = sin(ky) * abs((sin(th) / sin(kx))); elseif (sin(ky) <= 1e-5) tmp = (1.0 / hypot(sin(ky), sin(kx))) * (ky * sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-306], N[(N[Sin[ky], $MachinePrecision] * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-5], N[(N[(1.0 / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-306}:\\
\;\;\;\;\sin ky \cdot \left|\frac{\sin th}{\sin kx}\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-5}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \left(ky \cdot \sin th\right)\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 1.00000000000000003e-306Initial program 89.5%
associate-*l/86.0%
associate-/l*89.4%
unpow289.4%
sqr-neg89.4%
sin-neg89.4%
sin-neg89.4%
unpow289.4%
unpow289.4%
sin-neg89.4%
sin-neg89.4%
sqr-neg89.4%
unpow289.4%
Simplified99.7%
Taylor expanded in ky around 0 26.2%
add-sqr-sqrt9.3%
sqrt-unprod19.5%
pow219.5%
Applied egg-rr20.9%
unpow219.5%
rem-sqrt-square21.2%
Simplified22.9%
if 1.00000000000000003e-306 < (sin.f64 ky) < 1.00000000000000008e-5Initial program 86.2%
associate-*l/82.3%
associate-/l*86.2%
unpow286.2%
sqr-neg86.2%
sin-neg86.2%
sin-neg86.2%
unpow286.2%
unpow286.2%
sin-neg86.2%
sin-neg86.2%
sqr-neg86.2%
unpow286.2%
Simplified99.6%
associate-*r/92.2%
hypot-undefine82.3%
unpow282.3%
unpow282.3%
+-commutative82.3%
associate-*l/86.2%
*-commutative86.2%
clear-num86.2%
un-div-inv86.2%
+-commutative86.2%
unpow286.2%
unpow286.2%
hypot-undefine99.7%
Applied egg-rr99.7%
associate-/r/99.6%
associate-*l/92.2%
*-commutative92.2%
div-inv92.2%
Applied egg-rr92.2%
Taylor expanded in ky around 0 91.6%
if 1.00000000000000008e-5 < (sin.f64 ky) Initial program 99.8%
associate-*l/99.5%
associate-/l*99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
unpow299.5%
sin-neg99.5%
sin-neg99.5%
sqr-neg99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in kx around 0 58.4%
Final simplification51.2%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ 1.0 (hypot (sin ky) (sin kx)))))
(if (<= (sin ky) -0.002)
(* (* (sin ky) th) t_1)
(if (<= (sin ky) 1e-5) (* t_1 (* ky (sin th))) (sin th)))))
double code(double kx, double ky, double th) {
double t_1 = 1.0 / hypot(sin(ky), sin(kx));
double tmp;
if (sin(ky) <= -0.002) {
tmp = (sin(ky) * th) * t_1;
} else if (sin(ky) <= 1e-5) {
tmp = t_1 * (ky * sin(th));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = 1.0 / Math.hypot(Math.sin(ky), Math.sin(kx));
double tmp;
if (Math.sin(ky) <= -0.002) {
tmp = (Math.sin(ky) * th) * t_1;
} else if (Math.sin(ky) <= 1e-5) {
tmp = t_1 * (ky * Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = 1.0 / math.hypot(math.sin(ky), math.sin(kx)) tmp = 0 if math.sin(ky) <= -0.002: tmp = (math.sin(ky) * th) * t_1 elif math.sin(ky) <= 1e-5: tmp = t_1 * (ky * math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = Float64(1.0 / hypot(sin(ky), sin(kx))) tmp = 0.0 if (sin(ky) <= -0.002) tmp = Float64(Float64(sin(ky) * th) * t_1); elseif (sin(ky) <= 1e-5) tmp = Float64(t_1 * Float64(ky * sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = 1.0 / hypot(sin(ky), sin(kx)); tmp = 0.0; if (sin(ky) <= -0.002) tmp = (sin(ky) * th) * t_1; elseif (sin(ky) <= 1e-5) tmp = t_1 * (ky * sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(1.0 / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.002], N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-5], N[(t$95$1 * N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{1}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{if}\;\sin ky \leq -0.002:\\
\;\;\;\;\left(\sin ky \cdot th\right) \cdot t\_1\\
\mathbf{elif}\;\sin ky \leq 10^{-5}:\\
\;\;\;\;t\_1 \cdot \left(ky \cdot \sin th\right)\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2e-3Initial program 99.8%
associate-*l/99.6%
associate-/l*99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
unpow299.7%
sin-neg99.7%
sin-neg99.7%
sqr-neg99.7%
unpow299.7%
Simplified99.7%
associate-*r/99.7%
hypot-undefine99.6%
unpow299.6%
unpow299.6%
+-commutative99.6%
associate-*l/99.8%
*-commutative99.8%
clear-num99.8%
un-div-inv99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-undefine99.8%
Applied egg-rr99.8%
associate-/r/99.7%
associate-*l/99.7%
*-commutative99.7%
div-inv99.3%
Applied egg-rr99.3%
Taylor expanded in th around 0 53.3%
if -2e-3 < (sin.f64 ky) < 1.00000000000000008e-5Initial program 83.0%
associate-*l/77.7%
associate-/l*82.9%
unpow282.9%
sqr-neg82.9%
sin-neg82.9%
sin-neg82.9%
unpow282.9%
unpow282.9%
sin-neg82.9%
sin-neg82.9%
sqr-neg82.9%
unpow282.9%
Simplified99.6%
associate-*r/90.9%
hypot-undefine77.7%
unpow277.7%
unpow277.7%
+-commutative77.7%
associate-*l/83.0%
*-commutative83.0%
clear-num82.9%
un-div-inv83.0%
+-commutative83.0%
unpow283.0%
unpow283.0%
hypot-undefine99.7%
Applied egg-rr99.7%
associate-/r/99.6%
associate-*l/90.9%
*-commutative90.9%
div-inv90.7%
Applied egg-rr90.7%
Taylor expanded in ky around 0 90.5%
if 1.00000000000000008e-5 < (sin.f64 ky) Initial program 99.8%
associate-*l/99.5%
associate-/l*99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
unpow299.5%
sin-neg99.5%
sin-neg99.5%
sqr-neg99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in kx around 0 58.4%
Final simplification74.4%
(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 90.7%
associate-*l/87.8%
associate-/l*90.6%
unpow290.6%
sqr-neg90.6%
sin-neg90.6%
sin-neg90.6%
unpow290.6%
unpow290.6%
sin-neg90.6%
sin-neg90.6%
sqr-neg90.6%
unpow290.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th) :precision binary64 (if (<= kx 6e-23) (sin th) (* ky (fabs (/ th (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 6e-23) {
tmp = sin(th);
} else {
tmp = ky * fabs((th / 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 (kx <= 6d-23) then
tmp = sin(th)
else
tmp = ky * abs((th / sin(kx)))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 6e-23) {
tmp = Math.sin(th);
} else {
tmp = ky * Math.abs((th / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 6e-23: tmp = math.sin(th) else: tmp = ky * math.fabs((th / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 6e-23) tmp = sin(th); else tmp = Float64(ky * abs(Float64(th / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 6e-23) tmp = sin(th); else tmp = ky * abs((th / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 6e-23], N[Sin[th], $MachinePrecision], N[(ky * N[Abs[N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 6 \cdot 10^{-23}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;ky \cdot \left|\frac{th}{\sin kx}\right|\\
\end{array}
\end{array}
if kx < 6.00000000000000006e-23Initial program 87.9%
associate-*l/84.2%
associate-/l*87.8%
unpow287.8%
sqr-neg87.8%
sin-neg87.8%
sin-neg87.8%
unpow287.8%
unpow287.8%
sin-neg87.8%
sin-neg87.8%
sqr-neg87.8%
unpow287.8%
Simplified99.6%
Taylor expanded in kx around 0 30.9%
if 6.00000000000000006e-23 < kx Initial program 99.7%
associate-*l/99.3%
associate-/l*99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
sqr-neg99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in ky around 0 45.7%
associate-/l*45.9%
Simplified45.9%
Taylor expanded in th around 0 34.3%
associate-/l*34.6%
Simplified34.6%
add-sqr-sqrt16.9%
sqrt-unprod31.1%
pow231.1%
Applied egg-rr31.1%
unpow231.1%
rem-sqrt-square30.9%
Simplified30.9%
Final simplification30.9%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.3e-85) (* ky (/ (sin th) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.3e-85) {
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 (ky <= 1.3d-85) 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 (ky <= 1.3e-85) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.3e-85: tmp = ky * (math.sin(th) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.3e-85) 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 (ky <= 1.3e-85) tmp = ky * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.3e-85], 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}\;ky \leq 1.3 \cdot 10^{-85}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.30000000000000006e-85Initial program 87.7%
associate-*l/84.3%
associate-/l*87.6%
unpow287.6%
sqr-neg87.6%
sin-neg87.6%
sin-neg87.6%
unpow287.6%
unpow287.6%
sin-neg87.6%
sin-neg87.6%
sqr-neg87.6%
unpow287.6%
Simplified99.6%
Taylor expanded in ky around 0 30.7%
associate-/l*32.7%
Simplified32.7%
if 1.30000000000000006e-85 < ky Initial program 99.8%
associate-*l/98.2%
associate-/l*99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
sqr-neg99.6%
unpow299.6%
Simplified99.7%
Taylor expanded in kx around 0 46.4%
Final simplification36.1%
(FPCore (kx ky th) :precision binary64 (if (or (<= ky 3e-161) (and (not (<= ky 2.8e-140)) (<= ky 3.3e-86))) (* ky (/ (sin th) kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((ky <= 3e-161) || (!(ky <= 2.8e-140) && (ky <= 3.3e-86))) {
tmp = ky * (sin(th) / 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 <= 3d-161) .or. (.not. (ky <= 2.8d-140)) .and. (ky <= 3.3d-86)) then
tmp = ky * (sin(th) / 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 <= 3e-161) || (!(ky <= 2.8e-140) && (ky <= 3.3e-86))) {
tmp = ky * (Math.sin(th) / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (ky <= 3e-161) or (not (ky <= 2.8e-140) and (ky <= 3.3e-86)): tmp = ky * (math.sin(th) / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if ((ky <= 3e-161) || (!(ky <= 2.8e-140) && (ky <= 3.3e-86))) tmp = Float64(ky * Float64(sin(th) / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((ky <= 3e-161) || (~((ky <= 2.8e-140)) && (ky <= 3.3e-86))) tmp = ky * (sin(th) / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, 3e-161], And[N[Not[LessEqual[ky, 2.8e-140]], $MachinePrecision], LessEqual[ky, 3.3e-86]]], N[(ky * N[(N[Sin[th], $MachinePrecision] / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 3 \cdot 10^{-161} \lor \neg \left(ky \leq 2.8 \cdot 10^{-140}\right) \land ky \leq 3.3 \cdot 10^{-86}:\\
\;\;\;\;ky \cdot \frac{\sin th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 2.99999999999999989e-161 or 2.8000000000000002e-140 < ky < 3.29999999999999987e-86Initial program 87.5%
associate-*l/83.9%
associate-/l*87.4%
unpow287.4%
sqr-neg87.4%
sin-neg87.4%
sin-neg87.4%
unpow287.4%
unpow287.4%
sin-neg87.4%
sin-neg87.4%
sqr-neg87.4%
unpow287.4%
Simplified99.6%
Taylor expanded in ky around 0 29.4%
associate-/l*31.5%
Simplified31.5%
Taylor expanded in kx around 0 21.7%
associate-/l*23.8%
Simplified23.8%
if 2.99999999999999989e-161 < ky < 2.8000000000000002e-140 or 3.29999999999999987e-86 < ky Initial program 98.9%
associate-*l/97.4%
associate-/l*98.7%
unpow298.7%
sqr-neg98.7%
sin-neg98.7%
sin-neg98.7%
unpow298.7%
unpow298.7%
sin-neg98.7%
sin-neg98.7%
sqr-neg98.7%
unpow298.7%
Simplified99.7%
Taylor expanded in kx around 0 45.3%
Final simplification29.9%
(FPCore (kx ky th) :precision binary64 (if (<= kx 2.1e-29) (sin th) (* ky (/ th (sin kx)))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 2.1e-29) {
tmp = sin(th);
} else {
tmp = ky * (th / 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 (kx <= 2.1d-29) then
tmp = sin(th)
else
tmp = ky * (th / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 2.1e-29) {
tmp = Math.sin(th);
} else {
tmp = ky * (th / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 2.1e-29: tmp = math.sin(th) else: tmp = ky * (th / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 2.1e-29) tmp = sin(th); else tmp = Float64(ky * Float64(th / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 2.1e-29) tmp = sin(th); else tmp = ky * (th / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 2.1e-29], N[Sin[th], $MachinePrecision], N[(ky * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 2.1 \cdot 10^{-29}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;ky \cdot \frac{th}{\sin kx}\\
\end{array}
\end{array}
if kx < 2.09999999999999989e-29Initial program 87.9%
associate-*l/84.2%
associate-/l*87.8%
unpow287.8%
sqr-neg87.8%
sin-neg87.8%
sin-neg87.8%
unpow287.8%
unpow287.8%
sin-neg87.8%
sin-neg87.8%
sqr-neg87.8%
unpow287.8%
Simplified99.6%
Taylor expanded in kx around 0 30.9%
if 2.09999999999999989e-29 < kx Initial program 99.7%
associate-*l/99.3%
associate-/l*99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
sqr-neg99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in ky around 0 45.7%
associate-/l*45.9%
Simplified45.9%
Taylor expanded in th around 0 34.3%
associate-/l*34.6%
Simplified34.6%
Final simplification31.8%
(FPCore (kx ky th) :precision binary64 (if (<= ky 3e-161) (* ky (/ th kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3e-161) {
tmp = ky * (th / 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 <= 3d-161) then
tmp = ky * (th / 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 <= 3e-161) {
tmp = ky * (th / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 3e-161: tmp = ky * (th / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 3e-161) tmp = Float64(ky * Float64(th / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 3e-161) tmp = ky * (th / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 3e-161], N[(ky * N[(th / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 3 \cdot 10^{-161}:\\
\;\;\;\;ky \cdot \frac{th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 2.99999999999999989e-161Initial program 86.5%
associate-*l/82.8%
associate-/l*86.4%
unpow286.4%
sqr-neg86.4%
sin-neg86.4%
sin-neg86.4%
unpow286.4%
unpow286.4%
sin-neg86.4%
sin-neg86.4%
sqr-neg86.4%
unpow286.4%
Simplified99.6%
Taylor expanded in ky around 0 27.5%
associate-/l*29.7%
Simplified29.7%
Taylor expanded in th around 0 19.1%
associate-/l*21.3%
Simplified21.3%
Taylor expanded in kx around 0 16.8%
associate-/l*18.9%
Simplified18.9%
if 2.99999999999999989e-161 < ky Initial program 99.0%
associate-*l/97.6%
associate-/l*98.9%
unpow298.9%
sqr-neg98.9%
sin-neg98.9%
sin-neg98.9%
unpow298.9%
unpow298.9%
sin-neg98.9%
sin-neg98.9%
sqr-neg98.9%
unpow298.9%
Simplified99.7%
Taylor expanded in kx around 0 41.7%
Final simplification26.6%
(FPCore (kx ky th) :precision binary64 (* ky (/ th kx)))
double code(double kx, double ky, double th) {
return ky * (th / kx);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = ky * (th / kx)
end function
public static double code(double kx, double ky, double th) {
return ky * (th / kx);
}
def code(kx, ky, th): return ky * (th / kx)
function code(kx, ky, th) return Float64(ky * Float64(th / kx)) end
function tmp = code(kx, ky, th) tmp = ky * (th / kx); end
code[kx_, ky_, th_] := N[(ky * N[(th / kx), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
ky \cdot \frac{th}{kx}
\end{array}
Initial program 90.7%
associate-*l/87.8%
associate-/l*90.6%
unpow290.6%
sqr-neg90.6%
sin-neg90.6%
sin-neg90.6%
unpow290.6%
unpow290.6%
sin-neg90.6%
sin-neg90.6%
sqr-neg90.6%
unpow290.6%
Simplified99.6%
Taylor expanded in ky around 0 24.0%
associate-/l*25.5%
Simplified25.5%
Taylor expanded in th around 0 17.3%
associate-/l*18.7%
Simplified18.7%
Taylor expanded in kx around 0 14.8%
associate-/l*16.3%
Simplified16.3%
Final simplification16.3%
herbie shell --seed 2024043
(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)))