
(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 15 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 93.6%
remove-double-neg93.6%
sin-neg93.6%
neg-mul-193.6%
*-commutative93.6%
associate-*l*93.6%
associate-*l/91.8%
associate-/r/91.8%
associate-*l/93.6%
associate-/r/93.5%
sin-neg93.5%
neg-mul-193.5%
associate-/r*93.5%
associate-/r/93.6%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.005)
(sqrt (pow (sin th) 2.0))
(if (or (<= (sin ky) 5e-68)
(and (not (<= (sin ky) 5e-47)) (<= (sin ky) 4e-21)))
(* (sin th) (fabs (/ ky (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.005) {
tmp = sqrt(pow(sin(th), 2.0));
} else if ((sin(ky) <= 5e-68) || (!(sin(ky) <= 5e-47) && (sin(ky) <= 4e-21))) {
tmp = sin(th) * fabs((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.005d0)) then
tmp = sqrt((sin(th) ** 2.0d0))
else if ((sin(ky) <= 5d-68) .or. (.not. (sin(ky) <= 5d-47)) .and. (sin(ky) <= 4d-21)) then
tmp = sin(th) * abs((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.005) {
tmp = Math.sqrt(Math.pow(Math.sin(th), 2.0));
} else if ((Math.sin(ky) <= 5e-68) || (!(Math.sin(ky) <= 5e-47) && (Math.sin(ky) <= 4e-21))) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.005: tmp = math.sqrt(math.pow(math.sin(th), 2.0)) elif (math.sin(ky) <= 5e-68) or (not (math.sin(ky) <= 5e-47) and (math.sin(ky) <= 4e-21)): tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.005) tmp = sqrt((sin(th) ^ 2.0)); elseif ((sin(ky) <= 5e-68) || (!(sin(ky) <= 5e-47) && (sin(ky) <= 4e-21))) tmp = Float64(sin(th) * abs(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.005) tmp = sqrt((sin(th) ^ 2.0)); elseif ((sin(ky) <= 5e-68) || (~((sin(ky) <= 5e-47)) && (sin(ky) <= 4e-21))) tmp = sin(th) * abs((ky / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.005], N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[N[Sin[ky], $MachinePrecision], 5e-68], And[N[Not[LessEqual[N[Sin[ky], $MachinePrecision], 5e-47]], $MachinePrecision], LessEqual[N[Sin[ky], $MachinePrecision], 4e-21]]], N[(N[Sin[th], $MachinePrecision] * N[Abs[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.005:\\
\;\;\;\;\sqrt{{\sin th}^{2}}\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-68} \lor \neg \left(\sin ky \leq 5 \cdot 10^{-47}\right) \land \sin ky \leq 4 \cdot 10^{-21}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0050000000000000001Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.7%
associate-/r/99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 2.8%
add-sqr-sqrt1.6%
sqrt-unprod24.9%
pow224.9%
Applied egg-rr24.9%
if -0.0050000000000000001 < (sin.f64 ky) < 4.99999999999999971e-68 or 5.00000000000000011e-47 < (sin.f64 ky) < 3.99999999999999963e-21Initial program 86.4%
Taylor expanded in ky around 0 54.6%
add-sqr-sqrt24.6%
sqrt-unprod43.1%
pow243.1%
Applied egg-rr43.1%
unpow243.1%
rem-sqrt-square53.6%
Simplified53.6%
if 4.99999999999999971e-68 < (sin.f64 ky) < 5.00000000000000011e-47 or 3.99999999999999963e-21 < (sin.f64 ky) Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/99.7%
associate-/r/99.7%
associate-*l/99.7%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 67.6%
Final simplification50.0%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin kx) (sin ky))))
(if (<= (sin ky) 2e-301)
(/ th (/ t_1 (sin ky)))
(if (<= (sin ky) 6e-6) (/ 1.0 (/ t_1 (* ky (sin th)))) (sin th)))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (sin(ky) <= 2e-301) {
tmp = th / (t_1 / sin(ky));
} else if (sin(ky) <= 6e-6) {
tmp = 1.0 / (t_1 / (ky * sin(th)));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(kx), Math.sin(ky));
double tmp;
if (Math.sin(ky) <= 2e-301) {
tmp = th / (t_1 / Math.sin(ky));
} else if (Math.sin(ky) <= 6e-6) {
tmp = 1.0 / (t_1 / (ky * Math.sin(th)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if math.sin(ky) <= 2e-301: tmp = th / (t_1 / math.sin(ky)) elif math.sin(ky) <= 6e-6: tmp = 1.0 / (t_1 / (ky * math.sin(th))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)) tmp = 0.0 if (sin(ky) <= 2e-301) tmp = Float64(th / Float64(t_1 / sin(ky))); elseif (sin(ky) <= 6e-6) tmp = Float64(1.0 / Float64(t_1 / Float64(ky * sin(th)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)); tmp = 0.0; if (sin(ky) <= 2e-301) tmp = th / (t_1 / sin(ky)); elseif (sin(ky) <= 6e-6) tmp = 1.0 / (t_1 / (ky * sin(th))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-301], N[(th / N[(t$95$1 / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 6e-6], N[(1.0 / N[(t$95$1 / N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
\mathbf{if}\;\sin ky \leq 2 \cdot 10^{-301}:\\
\;\;\;\;\frac{th}{\frac{t\_1}{\sin ky}}\\
\mathbf{elif}\;\sin ky \leq 6 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{\frac{t\_1}{ky \cdot \sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 2.00000000000000013e-301Initial program 93.5%
remove-double-neg93.5%
sin-neg93.5%
neg-mul-193.5%
*-commutative93.5%
associate-*l*93.5%
associate-*l/91.4%
associate-/r/91.4%
associate-*l/93.5%
associate-/r/93.5%
sin-neg93.5%
neg-mul-193.5%
associate-/r*93.5%
associate-/r/93.5%
Simplified99.7%
*-commutative99.7%
clear-num99.7%
un-div-inv99.7%
hypot-udef93.5%
unpow293.5%
unpow293.5%
+-commutative93.5%
unpow293.5%
unpow293.5%
hypot-def99.7%
Applied egg-rr99.7%
Taylor expanded in th around 0 54.0%
if 2.00000000000000013e-301 < (sin.f64 ky) < 6.0000000000000002e-6Initial program 88.2%
remove-double-neg88.2%
sin-neg88.2%
neg-mul-188.2%
*-commutative88.2%
associate-*l*88.2%
associate-*l/85.1%
associate-/r/85.1%
associate-*l/88.2%
associate-/r/87.9%
sin-neg87.9%
neg-mul-187.9%
associate-/r*87.9%
associate-/r/88.2%
Simplified99.8%
associate-*l/92.8%
clear-num92.5%
hypot-udef84.8%
unpow284.8%
unpow284.8%
+-commutative84.8%
unpow284.8%
unpow284.8%
hypot-def92.5%
Applied egg-rr92.5%
Taylor expanded in ky around 0 92.0%
if 6.0000000000000002e-6 < (sin.f64 ky) Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.7%
associate-/r/99.7%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.7%
Taylor expanded in kx around 0 66.8%
Final simplification67.1%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin kx) (sin ky))))
(if (<= (sin ky) 2e-301)
(/ (sin ky) (* t_1 (+ (/ 1.0 th) (* th 0.16666666666666666))))
(if (<= (sin ky) 6e-6) (/ 1.0 (/ t_1 (* ky (sin th)))) (sin th)))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (sin(ky) <= 2e-301) {
tmp = sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666)));
} else if (sin(ky) <= 6e-6) {
tmp = 1.0 / (t_1 / (ky * sin(th)));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(kx), Math.sin(ky));
double tmp;
if (Math.sin(ky) <= 2e-301) {
tmp = Math.sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666)));
} else if (Math.sin(ky) <= 6e-6) {
tmp = 1.0 / (t_1 / (ky * Math.sin(th)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if math.sin(ky) <= 2e-301: tmp = math.sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666))) elif math.sin(ky) <= 6e-6: tmp = 1.0 / (t_1 / (ky * math.sin(th))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)) tmp = 0.0 if (sin(ky) <= 2e-301) tmp = Float64(sin(ky) / Float64(t_1 * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); elseif (sin(ky) <= 6e-6) tmp = Float64(1.0 / Float64(t_1 / Float64(ky * sin(th)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)); tmp = 0.0; if (sin(ky) <= 2e-301) tmp = sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666))); elseif (sin(ky) <= 6e-6) tmp = 1.0 / (t_1 / (ky * sin(th))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-301], N[(N[Sin[ky], $MachinePrecision] / N[(t$95$1 * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 6e-6], N[(1.0 / N[(t$95$1 / N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
\mathbf{if}\;\sin ky \leq 2 \cdot 10^{-301}:\\
\;\;\;\;\frac{\sin ky}{t\_1 \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{elif}\;\sin ky \leq 6 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{\frac{t\_1}{ky \cdot \sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 2.00000000000000013e-301Initial program 93.5%
remove-double-neg93.5%
sin-neg93.5%
neg-mul-193.5%
*-commutative93.5%
associate-*l*93.5%
associate-*l/91.4%
associate-/r/91.4%
associate-*l/93.5%
associate-/r/93.5%
sin-neg93.5%
neg-mul-193.5%
associate-/r*93.5%
associate-/r/93.5%
Simplified99.7%
associate-*l/96.4%
associate-/l*99.7%
hypot-udef93.5%
unpow293.5%
unpow293.5%
+-commutative93.5%
unpow293.5%
unpow293.5%
hypot-def99.7%
Applied egg-rr99.7%
Taylor expanded in th around 0 52.9%
+-commutative52.9%
*-commutative52.9%
unpow252.9%
unpow252.9%
hypot-def54.5%
associate-*r/54.6%
*-rgt-identity54.6%
*-lft-identity54.6%
associate-*l/54.5%
associate-*r*54.5%
Simplified54.6%
if 2.00000000000000013e-301 < (sin.f64 ky) < 6.0000000000000002e-6Initial program 88.2%
remove-double-neg88.2%
sin-neg88.2%
neg-mul-188.2%
*-commutative88.2%
associate-*l*88.2%
associate-*l/85.1%
associate-/r/85.1%
associate-*l/88.2%
associate-/r/87.9%
sin-neg87.9%
neg-mul-187.9%
associate-/r*87.9%
associate-/r/88.2%
Simplified99.8%
associate-*l/92.8%
clear-num92.5%
hypot-udef84.8%
unpow284.8%
unpow284.8%
+-commutative84.8%
unpow284.8%
unpow284.8%
hypot-def92.5%
Applied egg-rr92.5%
Taylor expanded in ky around 0 92.0%
if 6.0000000000000002e-6 < (sin.f64 ky) Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.7%
associate-/r/99.7%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.7%
Taylor expanded in kx around 0 66.8%
Final simplification67.3%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.01)
(sin th)
(if (<= (sin th) 0.04)
(* (sin ky) (/ th (hypot (sin ky) (sin kx))))
(* (sin th) (fabs (/ ky (sin kx)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.01) {
tmp = sin(th);
} else if (sin(th) <= 0.04) {
tmp = sin(ky) * (th / hypot(sin(ky), sin(kx)));
} else {
tmp = sin(th) * fabs((ky / sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(th) <= -0.01) {
tmp = Math.sin(th);
} else if (Math.sin(th) <= 0.04) {
tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(ky), Math.sin(kx)));
} else {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(th) <= -0.01: tmp = math.sin(th) elif math.sin(th) <= 0.04: tmp = math.sin(ky) * (th / math.hypot(math.sin(ky), math.sin(kx))) else: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(th) <= -0.01) tmp = sin(th); elseif (sin(th) <= 0.04) tmp = Float64(sin(ky) * Float64(th / hypot(sin(ky), sin(kx)))); else tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(th) <= -0.01) tmp = sin(th); elseif (sin(th) <= 0.04) tmp = sin(ky) * (th / hypot(sin(ky), sin(kx))); else tmp = sin(th) * abs((ky / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[th], $MachinePrecision], -0.01], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.04], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -0.01:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin th \leq 0.04:\\
\;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\end{array}
\end{array}
if (sin.f64 th) < -0.0100000000000000002Initial program 90.9%
remove-double-neg90.9%
sin-neg90.9%
neg-mul-190.9%
*-commutative90.9%
associate-*l*90.9%
associate-*l/90.8%
associate-/r/90.8%
associate-*l/90.9%
associate-/r/90.8%
sin-neg90.8%
neg-mul-190.8%
associate-/r*90.8%
associate-/r/90.9%
Simplified99.7%
Taylor expanded in kx around 0 27.0%
if -0.0100000000000000002 < (sin.f64 th) < 0.0400000000000000008Initial program 94.7%
remove-double-neg94.7%
sin-neg94.7%
neg-mul-194.7%
*-commutative94.7%
associate-*l*94.7%
associate-*l/91.3%
associate-/r/91.3%
associate-*l/94.7%
associate-/r/94.6%
sin-neg94.6%
neg-mul-194.6%
associate-/r*94.6%
associate-/r/94.7%
Simplified99.8%
expm1-log1p-u99.8%
expm1-udef24.7%
hypot-udef23.5%
unpow223.5%
unpow223.5%
+-commutative23.5%
unpow223.5%
unpow223.5%
hypot-def24.7%
Applied egg-rr24.7%
expm1-def99.8%
expm1-log1p99.8%
associate-*l/93.3%
*-commutative93.3%
associate-*l/99.7%
*-commutative99.7%
hypot-def94.6%
unpow294.6%
unpow294.6%
+-commutative94.6%
unpow294.6%
unpow294.6%
hypot-def99.7%
Simplified99.7%
Taylor expanded in th around 0 97.8%
if 0.0400000000000000008 < (sin.f64 th) Initial program 93.8%
Taylor expanded in ky around 0 18.1%
add-sqr-sqrt7.2%
sqrt-unprod11.7%
pow211.7%
Applied egg-rr11.7%
unpow211.7%
rem-sqrt-square18.8%
Simplified18.8%
Final simplification62.2%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.01)
(sin th)
(if (<= (sin th) 0.04)
(/ th (/ (hypot (sin kx) (sin ky)) (sin ky)))
(* (sin th) (fabs (/ ky (sin kx)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.01) {
tmp = sin(th);
} else if (sin(th) <= 0.04) {
tmp = th / (hypot(sin(kx), sin(ky)) / sin(ky));
} else {
tmp = sin(th) * fabs((ky / sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(th) <= -0.01) {
tmp = Math.sin(th);
} else if (Math.sin(th) <= 0.04) {
tmp = th / (Math.hypot(Math.sin(kx), Math.sin(ky)) / Math.sin(ky));
} else {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(th) <= -0.01: tmp = math.sin(th) elif math.sin(th) <= 0.04: tmp = th / (math.hypot(math.sin(kx), math.sin(ky)) / math.sin(ky)) else: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(th) <= -0.01) tmp = sin(th); elseif (sin(th) <= 0.04) tmp = Float64(th / Float64(hypot(sin(kx), sin(ky)) / sin(ky))); else tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(th) <= -0.01) tmp = sin(th); elseif (sin(th) <= 0.04) tmp = th / (hypot(sin(kx), sin(ky)) / sin(ky)); else tmp = sin(th) * abs((ky / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[th], $MachinePrecision], -0.01], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.04], N[(th / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -0.01:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin th \leq 0.04:\\
\;\;\;\;\frac{th}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\end{array}
\end{array}
if (sin.f64 th) < -0.0100000000000000002Initial program 90.9%
remove-double-neg90.9%
sin-neg90.9%
neg-mul-190.9%
*-commutative90.9%
associate-*l*90.9%
associate-*l/90.8%
associate-/r/90.8%
associate-*l/90.9%
associate-/r/90.8%
sin-neg90.8%
neg-mul-190.8%
associate-/r*90.8%
associate-/r/90.9%
Simplified99.7%
Taylor expanded in kx around 0 27.0%
if -0.0100000000000000002 < (sin.f64 th) < 0.0400000000000000008Initial program 94.7%
remove-double-neg94.7%
sin-neg94.7%
neg-mul-194.7%
*-commutative94.7%
associate-*l*94.7%
associate-*l/91.3%
associate-/r/91.3%
associate-*l/94.7%
associate-/r/94.6%
sin-neg94.6%
neg-mul-194.6%
associate-/r*94.6%
associate-/r/94.7%
Simplified99.8%
*-commutative99.8%
clear-num99.7%
un-div-inv99.8%
hypot-udef94.6%
unpow294.6%
unpow294.6%
+-commutative94.6%
unpow294.6%
unpow294.6%
hypot-def99.8%
Applied egg-rr99.8%
Taylor expanded in th around 0 97.8%
if 0.0400000000000000008 < (sin.f64 th) Initial program 93.8%
Taylor expanded in ky around 0 18.1%
add-sqr-sqrt7.2%
sqrt-unprod11.7%
pow211.7%
Applied egg-rr11.7%
unpow211.7%
rem-sqrt-square18.8%
Simplified18.8%
Final simplification62.2%
(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 93.6%
remove-double-neg93.6%
sin-neg93.6%
neg-mul-193.6%
*-commutative93.6%
associate-*l*93.6%
associate-*l/91.8%
associate-/r/91.8%
associate-*l/93.6%
associate-/r/93.5%
sin-neg93.5%
neg-mul-193.5%
associate-/r*93.5%
associate-/r/93.6%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef45.6%
hypot-udef43.0%
unpow243.0%
unpow243.0%
+-commutative43.0%
unpow243.0%
unpow243.0%
hypot-def45.6%
Applied egg-rr45.6%
expm1-def99.7%
expm1-log1p99.7%
associate-*l/96.3%
*-commutative96.3%
associate-*l/99.7%
*-commutative99.7%
hypot-def93.5%
unpow293.5%
unpow293.5%
+-commutative93.5%
unpow293.5%
unpow293.5%
hypot-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th) :precision binary64 (let* ((t_1 (* ky (/ (sin th) (sin kx))))) (if (<= (sin kx) -0.02) (fabs t_1) (if (<= (sin kx) 5e-92) (sin th) t_1))))
double code(double kx, double ky, double th) {
double t_1 = ky * (sin(th) / sin(kx));
double tmp;
if (sin(kx) <= -0.02) {
tmp = fabs(t_1);
} else if (sin(kx) <= 5e-92) {
tmp = sin(th);
} else {
tmp = 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 = ky * (sin(th) / sin(kx))
if (sin(kx) <= (-0.02d0)) then
tmp = abs(t_1)
else if (sin(kx) <= 5d-92) then
tmp = sin(th)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = ky * (Math.sin(th) / Math.sin(kx));
double tmp;
if (Math.sin(kx) <= -0.02) {
tmp = Math.abs(t_1);
} else if (Math.sin(kx) <= 5e-92) {
tmp = Math.sin(th);
} else {
tmp = t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = ky * (math.sin(th) / math.sin(kx)) tmp = 0 if math.sin(kx) <= -0.02: tmp = math.fabs(t_1) elif math.sin(kx) <= 5e-92: tmp = math.sin(th) else: tmp = t_1 return tmp
function code(kx, ky, th) t_1 = Float64(ky * Float64(sin(th) / sin(kx))) tmp = 0.0 if (sin(kx) <= -0.02) tmp = abs(t_1); elseif (sin(kx) <= 5e-92) tmp = sin(th); else tmp = t_1; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = ky * (sin(th) / sin(kx)); tmp = 0.0; if (sin(kx) <= -0.02) tmp = abs(t_1); elseif (sin(kx) <= 5e-92) tmp = sin(th); else tmp = t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[kx], $MachinePrecision], -0.02], N[Abs[t$95$1], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-92], N[Sin[th], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{if}\;\sin kx \leq -0.02:\\
\;\;\;\;\left|t\_1\right|\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-92}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0200000000000000004Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.4%
associate-/r/99.4%
associate-*l/99.6%
associate-/r/99.4%
sin-neg99.4%
neg-mul-199.4%
associate-/r*99.4%
associate-/r/99.6%
Simplified99.7%
Taylor expanded in ky around 0 24.7%
add-sqr-sqrt21.0%
sqrt-unprod28.3%
pow228.3%
*-commutative28.3%
associate-/l*28.3%
Applied egg-rr28.3%
unpow228.3%
rem-sqrt-square41.1%
associate-/r/41.2%
*-commutative41.2%
Simplified41.2%
if -0.0200000000000000004 < (sin.f64 kx) < 5.00000000000000011e-92Initial program 86.9%
remove-double-neg86.9%
sin-neg86.9%
neg-mul-186.9%
*-commutative86.9%
associate-*l*86.9%
associate-*l/85.3%
associate-/r/85.3%
associate-*l/86.9%
associate-/r/86.8%
sin-neg86.8%
neg-mul-186.8%
associate-/r*86.8%
associate-/r/86.9%
Simplified99.9%
Taylor expanded in kx around 0 42.6%
if 5.00000000000000011e-92 < (sin.f64 kx) Initial program 99.4%
remove-double-neg99.4%
sin-neg99.4%
neg-mul-199.4%
*-commutative99.4%
associate-*l*99.4%
associate-*l/96.3%
associate-/r/96.3%
associate-*l/99.4%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.4%
Simplified99.5%
*-commutative99.5%
clear-num99.5%
un-div-inv99.6%
hypot-udef99.5%
unpow299.5%
unpow299.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 46.7%
associate-*r/50.0%
Simplified50.0%
Final simplification44.8%
(FPCore (kx ky th) :precision binary64 (if (<= ky 6.5e-68) (* ky (/ (sin th) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 6.5e-68) {
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 <= 6.5d-68) 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 <= 6.5e-68) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 6.5e-68: 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 <= 6.5e-68) 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 <= 6.5e-68) tmp = ky * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 6.5e-68], 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 6.5 \cdot 10^{-68}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 6.4999999999999997e-68Initial program 91.2%
remove-double-neg91.2%
sin-neg91.2%
neg-mul-191.2%
*-commutative91.2%
associate-*l*91.2%
associate-*l/88.6%
associate-/r/88.6%
associate-*l/91.2%
associate-/r/91.1%
sin-neg91.1%
neg-mul-191.1%
associate-/r*91.1%
associate-/r/91.2%
Simplified99.7%
*-commutative99.7%
clear-num99.6%
un-div-inv99.6%
hypot-udef91.1%
unpow291.1%
unpow291.1%
+-commutative91.1%
unpow291.1%
unpow291.1%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 32.7%
associate-*r/35.3%
Simplified35.3%
if 6.4999999999999997e-68 < ky Initial program 99.8%
remove-double-neg99.8%
sin-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-*l*99.8%
associate-*l/99.7%
associate-/r/99.7%
associate-*l/99.8%
associate-/r/99.7%
sin-neg99.7%
neg-mul-199.7%
associate-/r*99.7%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in kx around 0 43.0%
Final simplification37.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky 3e-143) (* ky (/ th (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3e-143) {
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 <= 3d-143) 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 <= 3e-143) {
tmp = ky * (th / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 3e-143: tmp = ky * (th / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 3e-143) 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 <= 3e-143) tmp = ky * (th / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 3e-143], N[(ky * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 3 \cdot 10^{-143}:\\
\;\;\;\;ky \cdot \frac{th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 2.99999999999999985e-143Initial program 90.5%
remove-double-neg90.5%
sin-neg90.5%
neg-mul-190.5%
*-commutative90.5%
associate-*l*90.5%
associate-*l/88.3%
associate-/r/88.3%
associate-*l/90.5%
associate-/r/90.3%
sin-neg90.3%
neg-mul-190.3%
associate-/r*90.3%
associate-/r/90.5%
Simplified99.7%
Taylor expanded in ky around 0 33.4%
associate-/l*35.6%
div-inv35.6%
Applied egg-rr35.6%
Taylor expanded in th around 0 25.0%
if 2.99999999999999985e-143 < ky Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/98.6%
associate-/r/98.6%
associate-*l/99.7%
associate-/r/99.7%
sin-neg99.7%
neg-mul-199.7%
associate-/r*99.7%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 43.6%
Final simplification31.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky 2.1e-113) (* ky (/ (sin th) kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 2.1e-113) {
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 <= 2.1d-113) 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 <= 2.1e-113) {
tmp = ky * (Math.sin(th) / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 2.1e-113: tmp = ky * (math.sin(th) / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 2.1e-113) 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 <= 2.1e-113) tmp = ky * (sin(th) / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 2.1e-113], N[(ky * N[(N[Sin[th], $MachinePrecision] / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 2.1 \cdot 10^{-113}:\\
\;\;\;\;ky \cdot \frac{\sin th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 2.1e-113Initial program 90.6%
remove-double-neg90.6%
sin-neg90.6%
neg-mul-190.6%
*-commutative90.6%
associate-*l*90.6%
associate-*l/87.9%
associate-/r/87.9%
associate-*l/90.6%
associate-/r/90.5%
sin-neg90.5%
neg-mul-190.5%
associate-/r*90.5%
associate-/r/90.6%
Simplified99.7%
Taylor expanded in ky around 0 32.9%
associate-/l*35.6%
div-inv35.6%
Applied egg-rr35.6%
Taylor expanded in kx around 0 26.0%
if 2.1e-113 < ky Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.7%
associate-/r/99.7%
sin-neg99.7%
neg-mul-199.7%
associate-/r*99.7%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 42.7%
Final simplification31.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky 2.4e-111) (* (sin th) (/ ky kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 2.4e-111) {
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 <= 2.4d-111) 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 <= 2.4e-111) {
tmp = Math.sin(th) * (ky / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 2.4e-111: tmp = math.sin(th) * (ky / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 2.4e-111) 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 <= 2.4e-111) tmp = sin(th) * (ky / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 2.4e-111], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 2.4 \cdot 10^{-111}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 2.4000000000000001e-111Initial program 90.6%
Taylor expanded in ky around 0 35.6%
Taylor expanded in kx around 0 26.0%
if 2.4000000000000001e-111 < ky Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.7%
associate-/r/99.7%
sin-neg99.7%
neg-mul-199.7%
associate-/r*99.7%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 42.7%
Final simplification31.4%
(FPCore (kx ky th) :precision binary64 (if (<= ky 7e-147) (* ky (/ th kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 7e-147) {
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 <= 7d-147) 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 <= 7e-147) {
tmp = ky * (th / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 7e-147: tmp = ky * (th / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 7e-147) 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 <= 7e-147) tmp = ky * (th / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 7e-147], N[(ky * N[(th / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 7 \cdot 10^{-147}:\\
\;\;\;\;ky \cdot \frac{th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 7.00000000000000007e-147Initial program 90.5%
remove-double-neg90.5%
sin-neg90.5%
neg-mul-190.5%
*-commutative90.5%
associate-*l*90.5%
associate-*l/88.3%
associate-/r/88.3%
associate-*l/90.5%
associate-/r/90.3%
sin-neg90.3%
neg-mul-190.3%
associate-/r*90.3%
associate-/r/90.5%
Simplified99.7%
Taylor expanded in ky around 0 33.4%
associate-/l*35.6%
div-inv35.6%
Applied egg-rr35.6%
Taylor expanded in th around 0 25.0%
Taylor expanded in kx around 0 20.5%
if 7.00000000000000007e-147 < ky Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/98.6%
associate-/r/98.6%
associate-*l/99.7%
associate-/r/99.7%
sin-neg99.7%
neg-mul-199.7%
associate-/r*99.7%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 43.6%
Final simplification28.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky 9.6e-113) (* ky (/ th kx)) th))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 9.6e-113) {
tmp = ky * (th / kx);
} else {
tmp = 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 <= 9.6d-113) then
tmp = ky * (th / kx)
else
tmp = th
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 9.6e-113) {
tmp = ky * (th / kx);
} else {
tmp = th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 9.6e-113: tmp = ky * (th / kx) else: tmp = th return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 9.6e-113) tmp = Float64(ky * Float64(th / kx)); else tmp = th; end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 9.6e-113) tmp = ky * (th / kx); else tmp = th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 9.6e-113], N[(ky * N[(th / kx), $MachinePrecision]), $MachinePrecision], th]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 9.6 \cdot 10^{-113}:\\
\;\;\;\;ky \cdot \frac{th}{kx}\\
\mathbf{else}:\\
\;\;\;\;th\\
\end{array}
\end{array}
if ky < 9.60000000000000049e-113Initial program 90.6%
remove-double-neg90.6%
sin-neg90.6%
neg-mul-190.6%
*-commutative90.6%
associate-*l*90.6%
associate-*l/87.9%
associate-/r/87.9%
associate-*l/90.6%
associate-/r/90.5%
sin-neg90.5%
neg-mul-190.5%
associate-/r*90.5%
associate-/r/90.6%
Simplified99.7%
Taylor expanded in ky around 0 32.9%
associate-/l*35.6%
div-inv35.6%
Applied egg-rr35.6%
Taylor expanded in th around 0 25.1%
Taylor expanded in kx around 0 20.7%
if 9.60000000000000049e-113 < ky Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.7%
associate-/r/99.7%
sin-neg99.7%
neg-mul-199.7%
associate-/r*99.7%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in kx around 0 42.7%
Taylor expanded in th around 0 18.3%
Final simplification19.9%
(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 93.6%
remove-double-neg93.6%
sin-neg93.6%
neg-mul-193.6%
*-commutative93.6%
associate-*l*93.6%
associate-*l/91.8%
associate-/r/91.8%
associate-*l/93.6%
associate-/r/93.5%
sin-neg93.5%
neg-mul-193.5%
associate-/r*93.5%
associate-/r/93.6%
Simplified99.7%
Taylor expanded in kx around 0 24.8%
Taylor expanded in th around 0 12.8%
Final simplification12.8%
herbie shell --seed 2024101
(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)))