
(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.6%
+-commutative95.6%
unpow295.6%
unpow295.6%
hypot-undefine99.7%
Applied egg-rr99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.005)
(* (sin ky) (/ th (hypot (sin ky) (sin kx))))
(if (<= (sin ky) 2e-11)
(* (sin ky) (/ (sin th) (hypot ky (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.005) {
tmp = sin(ky) * (th / hypot(sin(ky), sin(kx)));
} else if (sin(ky) <= 2e-11) {
tmp = sin(ky) * (sin(th) / hypot(ky, sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.005) {
tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(ky), Math.sin(kx)));
} else if (Math.sin(ky) <= 2e-11) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.hypot(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.sin(ky) * (th / math.hypot(math.sin(ky), math.sin(kx))) elif math.sin(ky) <= 2e-11: tmp = math.sin(ky) * (math.sin(th) / math.hypot(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 = Float64(sin(ky) * Float64(th / hypot(sin(ky), sin(kx)))); elseif (sin(ky) <= 2e-11) tmp = Float64(sin(ky) * Float64(sin(th) / hypot(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 = sin(ky) * (th / hypot(sin(ky), sin(kx))); elseif (sin(ky) <= 2e-11) tmp = sin(ky) * (sin(th) / hypot(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[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-11], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.005:\\
\;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-11}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0050000000000000001Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.5%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in th around 0 51.4%
if -0.0050000000000000001 < (sin.f64 ky) < 1.99999999999999988e-11Initial program 91.8%
unpow291.8%
sqr-neg91.8%
sin-neg91.8%
sin-neg91.8%
unpow291.8%
associate-*l/86.7%
associate-/l*91.7%
+-commutative91.7%
unpow291.7%
sin-neg91.7%
sin-neg91.7%
Simplified99.6%
Taylor expanded in ky around 0 99.6%
if 1.99999999999999988e-11 < (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%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 61.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.26)
(sqrt (/ (- 1.0 (cos (* th 2.0))) 2.0))
(if (<= (sin ky) 1e-31)
(* (sin th) (/ (sin ky) (fabs (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.26) {
tmp = sqrt(((1.0 - cos((th * 2.0))) / 2.0));
} else if (sin(ky) <= 1e-31) {
tmp = sin(th) * (sin(ky) / fabs(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.26d0)) then
tmp = sqrt(((1.0d0 - cos((th * 2.0d0))) / 2.0d0))
else if (sin(ky) <= 1d-31) then
tmp = sin(th) * (sin(ky) / abs(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.26) {
tmp = Math.sqrt(((1.0 - Math.cos((th * 2.0))) / 2.0));
} else if (Math.sin(ky) <= 1e-31) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.26: tmp = math.sqrt(((1.0 - math.cos((th * 2.0))) / 2.0)) elif math.sin(ky) <= 1e-31: tmp = math.sin(th) * (math.sin(ky) / math.fabs(math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.26) tmp = sqrt(Float64(Float64(1.0 - cos(Float64(th * 2.0))) / 2.0)); elseif (sin(ky) <= 1e-31) tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.26) tmp = sqrt(((1.0 - cos((th * 2.0))) / 2.0)); elseif (sin(ky) <= 1e-31) tmp = sin(th) * (sin(ky) / abs(sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.26], N[Sqrt[N[(N[(1.0 - N[Cos[N[(th * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-31], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.26:\\
\;\;\;\;\sqrt{\frac{1 - \cos \left(th \cdot 2\right)}{2}}\\
\mathbf{elif}\;\sin ky \leq 10^{-31}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.26000000000000001Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.8%
add-sqr-sqrt1.0%
sqrt-unprod17.7%
pow217.7%
Applied egg-rr17.7%
unpow217.7%
sin-mult15.6%
Applied egg-rr15.6%
+-inverses15.6%
cos-015.6%
count-215.6%
*-commutative15.6%
Simplified15.6%
if -0.26000000000000001 < (sin.f64 ky) < 1e-31Initial program 91.9%
Taylor expanded in ky around 0 45.5%
add-sqr-sqrt36.8%
sqrt-unprod67.6%
pow267.6%
Applied egg-rr67.6%
unpow267.6%
rem-sqrt-square71.8%
Simplified71.8%
if 1e-31 < (sin.f64 ky) Initial program 99.8%
unpow299.8%
sqr-neg99.8%
sin-neg99.8%
sin-neg99.8%
unpow299.8%
associate-*l/98.9%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 63.2%
Final simplification58.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.005) (sqrt (/ (- 1.0 (cos (* th 2.0))) 2.0)) (if (<= (sin ky) 1e-31) (* (sin th) (/ ky (fabs (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.005) {
tmp = sqrt(((1.0 - cos((th * 2.0))) / 2.0));
} else if (sin(ky) <= 1e-31) {
tmp = sin(th) * (ky / fabs(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(((1.0d0 - cos((th * 2.0d0))) / 2.0d0))
else if (sin(ky) <= 1d-31) then
tmp = sin(th) * (ky / abs(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(((1.0 - Math.cos((th * 2.0))) / 2.0));
} else if (Math.sin(ky) <= 1e-31) {
tmp = Math.sin(th) * (ky / Math.abs(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(((1.0 - math.cos((th * 2.0))) / 2.0)) elif math.sin(ky) <= 1e-31: tmp = math.sin(th) * (ky / math.fabs(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(Float64(Float64(1.0 - cos(Float64(th * 2.0))) / 2.0)); elseif (sin(ky) <= 1e-31) tmp = Float64(sin(th) * Float64(ky / abs(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(((1.0 - cos((th * 2.0))) / 2.0)); elseif (sin(ky) <= 1e-31) tmp = sin(th) * (ky / abs(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[(N[(1.0 - N[Cos[N[(th * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-31], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Abs[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{\frac{1 - \cos \left(th \cdot 2\right)}{2}}\\
\mathbf{elif}\;\sin ky \leq 10^{-31}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0050000000000000001Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.5%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.8%
add-sqr-sqrt1.1%
sqrt-unprod19.6%
pow219.6%
Applied egg-rr19.6%
unpow219.6%
sin-mult16.2%
Applied egg-rr16.2%
+-inverses16.2%
cos-016.2%
count-216.2%
*-commutative16.2%
Simplified16.2%
if -0.0050000000000000001 < (sin.f64 ky) < 1e-31Initial program 91.5%
Taylor expanded in ky around 0 47.6%
add-sqr-sqrt38.5%
sqrt-unprod70.5%
pow270.5%
Applied egg-rr70.5%
unpow270.5%
rem-sqrt-square74.9%
Simplified74.9%
Taylor expanded in ky around 0 74.9%
if 1e-31 < (sin.f64 ky) Initial program 99.8%
unpow299.8%
sqr-neg99.8%
sin-neg99.8%
sin-neg99.8%
unpow299.8%
associate-*l/98.9%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 63.2%
Final simplification58.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.14) (sqrt (/ (- 1.0 (cos (* th 2.0))) 2.0)) (if (<= (sin ky) 1e-162) (* (sin ky) (/ (sin th) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.14) {
tmp = sqrt(((1.0 - cos((th * 2.0))) / 2.0));
} else if (sin(ky) <= 1e-162) {
tmp = sin(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.14d0)) then
tmp = sqrt(((1.0d0 - cos((th * 2.0d0))) / 2.0d0))
else if (sin(ky) <= 1d-162) then
tmp = sin(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.14) {
tmp = Math.sqrt(((1.0 - Math.cos((th * 2.0))) / 2.0));
} else if (Math.sin(ky) <= 1e-162) {
tmp = Math.sin(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.14: tmp = math.sqrt(((1.0 - math.cos((th * 2.0))) / 2.0)) elif math.sin(ky) <= 1e-162: tmp = math.sin(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.14) tmp = sqrt(Float64(Float64(1.0 - cos(Float64(th * 2.0))) / 2.0)); elseif (sin(ky) <= 1e-162) tmp = Float64(sin(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.14) tmp = sqrt(((1.0 - cos((th * 2.0))) / 2.0)); elseif (sin(ky) <= 1e-162) tmp = sin(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.14], N[Sqrt[N[(N[(1.0 - N[Cos[N[(th * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-162], N[(N[Sin[ky], $MachinePrecision] * 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.14:\\
\;\;\;\;\sqrt{\frac{1 - \cos \left(th \cdot 2\right)}{2}}\\
\mathbf{elif}\;\sin ky \leq 10^{-162}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.14000000000000001Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.5%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.8%
add-sqr-sqrt1.0%
sqrt-unprod17.4%
pow217.4%
Applied egg-rr17.4%
unpow217.4%
sin-mult15.5%
Applied egg-rr15.5%
+-inverses15.5%
cos-015.5%
count-215.5%
*-commutative15.5%
Simplified15.5%
if -0.14000000000000001 < (sin.f64 ky) < 9.99999999999999954e-163Initial program 89.5%
unpow289.5%
sqr-neg89.5%
sin-neg89.5%
sin-neg89.5%
unpow289.5%
associate-*l/83.8%
associate-/l*89.3%
+-commutative89.3%
unpow289.3%
sin-neg89.3%
sin-neg89.3%
Simplified99.6%
Taylor expanded in ky around 0 47.0%
if 9.99999999999999954e-163 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.7%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 53.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.6%
unpow295.6%
sqr-neg95.6%
sin-neg95.6%
sin-neg95.6%
unpow295.6%
associate-*l/92.8%
associate-/l*95.5%
+-commutative95.5%
unpow295.5%
sin-neg95.5%
sin-neg95.5%
Simplified99.6%
(FPCore (kx ky th)
:precision binary64
(if (<= th 1.25e-8)
(* (/ (sin ky) (hypot (sin ky) (sin kx))) th)
(if (<= th 1.4e+80)
(/ (* (sin ky) (sin th)) (hypot ky (sin kx)))
(* (sin th) (/ (sin ky) (hypot (sin ky) kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 1.25e-8) {
tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th;
} else if (th <= 1.4e+80) {
tmp = (sin(ky) * sin(th)) / hypot(ky, sin(kx));
} else {
tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 1.25e-8) {
tmp = (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * th;
} else if (th <= 1.4e+80) {
tmp = (Math.sin(ky) * Math.sin(th)) / Math.hypot(ky, Math.sin(kx));
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 1.25e-8: tmp = (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * th elif th <= 1.4e+80: tmp = (math.sin(ky) * math.sin(th)) / math.hypot(ky, math.sin(kx)) else: tmp = math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 1.25e-8) tmp = Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * th); elseif (th <= 1.4e+80) tmp = Float64(Float64(sin(ky) * sin(th)) / hypot(ky, sin(kx))); else tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 1.25e-8) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th; elseif (th <= 1.4e+80) tmp = (sin(ky) * sin(th)) / hypot(ky, sin(kx)); else tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 1.25e-8], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], If[LessEqual[th, 1.4e+80], N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 1.25 \cdot 10^{-8}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\
\mathbf{elif}\;th \leq 1.4 \cdot 10^{+80}:\\
\;\;\;\;\frac{\sin ky \cdot \sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
\end{array}
\end{array}
if th < 1.2499999999999999e-8Initial program 96.0%
+-commutative96.0%
unpow296.0%
unpow296.0%
hypot-undefine99.7%
Applied egg-rr99.7%
Taylor expanded in th around 0 66.8%
if 1.2499999999999999e-8 < th < 1.39999999999999992e80Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*99.4%
+-commutative99.4%
unpow299.4%
sin-neg99.4%
sin-neg99.4%
Simplified99.4%
associate-*r/99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 76.8%
if 1.39999999999999992e80 < th Initial program 92.1%
+-commutative92.1%
unpow292.1%
unpow292.1%
hypot-undefine99.8%
Applied egg-rr99.8%
Taylor expanded in kx around 0 70.1%
Final simplification68.0%
(FPCore (kx ky th)
:precision binary64
(if (<= th 1.25e-8)
(* (/ (sin ky) (hypot (sin ky) (sin kx))) th)
(if (<= th 2.1e+81)
(* (sin ky) (/ (sin th) (hypot ky (sin kx))))
(* (sin th) (/ (sin ky) (hypot (sin ky) kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 1.25e-8) {
tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th;
} else if (th <= 2.1e+81) {
tmp = sin(ky) * (sin(th) / hypot(ky, sin(kx)));
} else {
tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 1.25e-8) {
tmp = (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * th;
} else if (th <= 2.1e+81) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.hypot(ky, Math.sin(kx)));
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 1.25e-8: tmp = (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * th elif th <= 2.1e+81: tmp = math.sin(ky) * (math.sin(th) / math.hypot(ky, math.sin(kx))) else: tmp = math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 1.25e-8) tmp = Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * th); elseif (th <= 2.1e+81) tmp = Float64(sin(ky) * Float64(sin(th) / hypot(ky, sin(kx)))); else tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 1.25e-8) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th; elseif (th <= 2.1e+81) tmp = sin(ky) * (sin(th) / hypot(ky, sin(kx))); else tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 1.25e-8], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], If[LessEqual[th, 2.1e+81], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 1.25 \cdot 10^{-8}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\
\mathbf{elif}\;th \leq 2.1 \cdot 10^{+81}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
\end{array}
\end{array}
if th < 1.2499999999999999e-8Initial program 96.0%
+-commutative96.0%
unpow296.0%
unpow296.0%
hypot-undefine99.7%
Applied egg-rr99.7%
Taylor expanded in th around 0 66.8%
if 1.2499999999999999e-8 < th < 2.0999999999999999e81Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*99.4%
+-commutative99.4%
unpow299.4%
sin-neg99.4%
sin-neg99.4%
Simplified99.4%
Taylor expanded in ky around 0 76.6%
if 2.0999999999999999e81 < th Initial program 92.1%
+-commutative92.1%
unpow292.1%
unpow292.1%
hypot-undefine99.8%
Applied egg-rr99.8%
Taylor expanded in kx around 0 70.1%
Final simplification68.0%
(FPCore (kx ky th)
:precision binary64
(if (<= th 1.25e-8)
(* (sin ky) (/ th (hypot (sin ky) (sin kx))))
(if (<= th 6.8e+80)
(* (sin ky) (/ (sin th) (hypot ky (sin kx))))
(* (sin th) (/ (sin ky) (hypot (sin ky) kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 1.25e-8) {
tmp = sin(ky) * (th / hypot(sin(ky), sin(kx)));
} else if (th <= 6.8e+80) {
tmp = sin(ky) * (sin(th) / hypot(ky, sin(kx)));
} else {
tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 1.25e-8) {
tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(ky), Math.sin(kx)));
} else if (th <= 6.8e+80) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.hypot(ky, Math.sin(kx)));
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 1.25e-8: tmp = math.sin(ky) * (th / math.hypot(math.sin(ky), math.sin(kx))) elif th <= 6.8e+80: tmp = math.sin(ky) * (math.sin(th) / math.hypot(ky, math.sin(kx))) else: tmp = math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 1.25e-8) tmp = Float64(sin(ky) * Float64(th / hypot(sin(ky), sin(kx)))); elseif (th <= 6.8e+80) tmp = Float64(sin(ky) * Float64(sin(th) / hypot(ky, sin(kx)))); else tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 1.25e-8) tmp = sin(ky) * (th / hypot(sin(ky), sin(kx))); elseif (th <= 6.8e+80) tmp = sin(ky) * (sin(th) / hypot(ky, sin(kx))); else tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 1.25e-8], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[th, 6.8e+80], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 1.25 \cdot 10^{-8}:\\
\;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{elif}\;th \leq 6.8 \cdot 10^{+80}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
\end{array}
\end{array}
if th < 1.2499999999999999e-8Initial program 96.0%
unpow296.0%
sqr-neg96.0%
sin-neg96.0%
sin-neg96.0%
unpow296.0%
associate-*l/92.5%
associate-/l*95.9%
+-commutative95.9%
unpow295.9%
sin-neg95.9%
sin-neg95.9%
Simplified99.6%
Taylor expanded in th around 0 66.8%
if 1.2499999999999999e-8 < th < 6.79999999999999984e80Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*99.4%
+-commutative99.4%
unpow299.4%
sin-neg99.4%
sin-neg99.4%
Simplified99.4%
Taylor expanded in ky around 0 76.6%
if 6.79999999999999984e80 < th Initial program 92.1%
+-commutative92.1%
unpow292.1%
unpow292.1%
hypot-undefine99.8%
Applied egg-rr99.8%
Taylor expanded in kx around 0 70.1%
Final simplification67.9%
(FPCore (kx ky th) :precision binary64 (if (<= th 0.024) (* (sin ky) (/ th (hypot (sin ky) (sin kx)))) (if (<= th 1.8e+126) (* (sin th) (/ (sin ky) (fabs (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.024) {
tmp = sin(ky) * (th / hypot(sin(ky), sin(kx)));
} else if (th <= 1.8e+126) {
tmp = sin(th) * (sin(ky) / fabs(sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.024) {
tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(ky), Math.sin(kx)));
} else if (th <= 1.8e+126) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 0.024: tmp = math.sin(ky) * (th / math.hypot(math.sin(ky), math.sin(kx))) elif th <= 1.8e+126: tmp = math.sin(th) * (math.sin(ky) / math.fabs(math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 0.024) tmp = Float64(sin(ky) * Float64(th / hypot(sin(ky), sin(kx)))); elseif (th <= 1.8e+126) tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 0.024) tmp = sin(ky) * (th / hypot(sin(ky), sin(kx))); elseif (th <= 1.8e+126) tmp = sin(th) * (sin(ky) / abs(sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 0.024], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[th, 1.8e+126], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 0.024:\\
\;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{elif}\;th \leq 1.8 \cdot 10^{+126}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if th < 0.024Initial program 96.0%
unpow296.0%
sqr-neg96.0%
sin-neg96.0%
sin-neg96.0%
unpow296.0%
associate-*l/92.5%
associate-/l*95.9%
+-commutative95.9%
unpow295.9%
sin-neg95.9%
sin-neg95.9%
Simplified99.6%
Taylor expanded in th around 0 66.7%
if 0.024 < th < 1.8e126Initial program 99.7%
Taylor expanded in ky around 0 26.9%
add-sqr-sqrt25.6%
sqrt-unprod57.5%
pow257.5%
Applied egg-rr57.5%
unpow257.5%
rem-sqrt-square57.6%
Simplified57.6%
if 1.8e126 < th Initial program 90.2%
unpow290.2%
sqr-neg90.2%
sin-neg90.2%
sin-neg90.2%
unpow290.2%
associate-*l/90.0%
associate-/l*90.1%
+-commutative90.1%
unpow290.1%
sin-neg90.1%
sin-neg90.1%
Simplified99.6%
Taylor expanded in kx around 0 32.2%
Final simplification61.4%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.005) (sqrt (/ (- 1.0 (cos (* th 2.0))) 2.0)) (if (<= (sin ky) 1e-162) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.005) {
tmp = sqrt(((1.0 - cos((th * 2.0))) / 2.0));
} else if (sin(ky) <= 1e-162) {
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.005d0)) then
tmp = sqrt(((1.0d0 - cos((th * 2.0d0))) / 2.0d0))
else if (sin(ky) <= 1d-162) 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.005) {
tmp = Math.sqrt(((1.0 - Math.cos((th * 2.0))) / 2.0));
} else if (Math.sin(ky) <= 1e-162) {
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.005: tmp = math.sqrt(((1.0 - math.cos((th * 2.0))) / 2.0)) elif math.sin(ky) <= 1e-162: 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.005) tmp = sqrt(Float64(Float64(1.0 - cos(Float64(th * 2.0))) / 2.0)); elseif (sin(ky) <= 1e-162) 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.005) tmp = sqrt(((1.0 - cos((th * 2.0))) / 2.0)); elseif (sin(ky) <= 1e-162) 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.005], N[Sqrt[N[(N[(1.0 - N[Cos[N[(th * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-162], 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.005:\\
\;\;\;\;\sqrt{\frac{1 - \cos \left(th \cdot 2\right)}{2}}\\
\mathbf{elif}\;\sin ky \leq 10^{-162}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0050000000000000001Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.5%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.8%
add-sqr-sqrt1.1%
sqrt-unprod19.6%
pow219.6%
Applied egg-rr19.6%
unpow219.6%
sin-mult16.2%
Applied egg-rr16.2%
+-inverses16.2%
cos-016.2%
count-216.2%
*-commutative16.2%
Simplified16.2%
if -0.0050000000000000001 < (sin.f64 ky) < 9.99999999999999954e-163Initial program 89.0%
Taylor expanded in ky around 0 49.0%
if 9.99999999999999954e-163 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.7%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 53.9%
Final simplification43.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.08) (fabs (sin th)) (if (<= (sin ky) 1e-162) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.08) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 1e-162) {
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.08d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-162) 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.08) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-162) {
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.08: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-162: 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.08) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-162) 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.08) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-162) 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.08], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-162], 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.08:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-162}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0800000000000000017Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.5%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 2.7%
add-sqr-sqrt1.0%
sqrt-unprod17.1%
pow217.1%
Applied egg-rr17.1%
unpow217.1%
rem-sqrt-square28.8%
Applied egg-rr28.8%
if -0.0800000000000000017 < (sin.f64 ky) < 9.99999999999999954e-163Initial program 89.4%
Taylor expanded in ky around 0 47.2%
if 9.99999999999999954e-163 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.7%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 53.9%
Final simplification46.2%
(FPCore (kx ky th) :precision binary64 (if (<= ky 3.3e-158) (* ky (/ (sin th) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3.3e-158) {
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 <= 3.3d-158) 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 <= 3.3e-158) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 3.3e-158: 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 <= 3.3e-158) 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 <= 3.3e-158) tmp = ky * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 3.3e-158], 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 3.3 \cdot 10^{-158}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 3.3000000000000002e-158Initial program 93.0%
unpow293.0%
sqr-neg93.0%
sin-neg93.0%
sin-neg93.0%
unpow293.0%
associate-*l/89.1%
associate-/l*92.8%
+-commutative92.8%
unpow292.8%
sin-neg92.8%
sin-neg92.8%
Simplified99.6%
Taylor expanded in ky around 0 31.0%
associate-/l*31.7%
Simplified31.7%
if 3.3000000000000002e-158 < ky Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.6%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.7%
Taylor expanded in kx around 0 37.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.5e-161) (+ 1.0 (+ (sin th) -1.0)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.5e-161) {
tmp = 1.0 + (sin(th) + -1.0);
} 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.5d-161) then
tmp = 1.0d0 + (sin(th) + (-1.0d0))
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.5e-161) {
tmp = 1.0 + (Math.sin(th) + -1.0);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.5e-161: tmp = 1.0 + (math.sin(th) + -1.0) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.5e-161) tmp = Float64(1.0 + Float64(sin(th) + -1.0)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.5e-161) tmp = 1.0 + (sin(th) + -1.0); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.5e-161], N[(1.0 + N[(N[Sin[th], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.5 \cdot 10^{-161}:\\
\;\;\;\;1 + \left(\sin th + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.49999999999999994e-161Initial program 93.0%
unpow293.0%
sqr-neg93.0%
sin-neg93.0%
sin-neg93.0%
unpow293.0%
associate-*l/89.1%
associate-/l*92.8%
+-commutative92.8%
unpow292.8%
sin-neg92.8%
sin-neg92.8%
Simplified99.6%
Taylor expanded in kx around 0 14.9%
expm1-log1p-u14.9%
expm1-undefine26.9%
Applied egg-rr26.9%
sub-neg26.9%
log1p-undefine26.9%
rem-exp-log26.9%
metadata-eval26.9%
Applied egg-rr26.9%
associate-+l+26.9%
Simplified26.9%
if 1.49999999999999994e-161 < ky Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.6%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.7%
Taylor expanded in kx around 0 37.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky 8e-162) (+ -1.0 (+ th 1.0)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 8e-162) {
tmp = -1.0 + (th + 1.0);
} 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 <= 8d-162) then
tmp = (-1.0d0) + (th + 1.0d0)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 8e-162) {
tmp = -1.0 + (th + 1.0);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 8e-162: tmp = -1.0 + (th + 1.0) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 8e-162) tmp = Float64(-1.0 + Float64(th + 1.0)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 8e-162) tmp = -1.0 + (th + 1.0); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 8e-162], N[(-1.0 + N[(th + 1.0), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 8 \cdot 10^{-162}:\\
\;\;\;\;-1 + \left(th + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 7.99999999999999963e-162Initial program 93.0%
unpow293.0%
sqr-neg93.0%
sin-neg93.0%
sin-neg93.0%
unpow293.0%
associate-*l/89.1%
associate-/l*92.8%
+-commutative92.8%
unpow292.8%
sin-neg92.8%
sin-neg92.8%
Simplified99.6%
Taylor expanded in kx around 0 14.9%
expm1-log1p-u14.9%
expm1-undefine26.9%
Applied egg-rr26.9%
Taylor expanded in th around 0 19.0%
+-commutative19.0%
Simplified19.0%
if 7.99999999999999963e-162 < ky Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.6%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.7%
Taylor expanded in kx around 0 37.5%
Final simplification26.2%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.3e-160) (+ -1.0 (+ th 1.0)) th))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.3e-160) {
tmp = -1.0 + (th + 1.0);
} 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 <= 1.3d-160) then
tmp = (-1.0d0) + (th + 1.0d0)
else
tmp = th
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.3e-160) {
tmp = -1.0 + (th + 1.0);
} else {
tmp = th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.3e-160: tmp = -1.0 + (th + 1.0) else: tmp = th return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.3e-160) tmp = Float64(-1.0 + Float64(th + 1.0)); else tmp = th; end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.3e-160) tmp = -1.0 + (th + 1.0); else tmp = th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.3e-160], N[(-1.0 + N[(th + 1.0), $MachinePrecision]), $MachinePrecision], th]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.3 \cdot 10^{-160}:\\
\;\;\;\;-1 + \left(th + 1\right)\\
\mathbf{else}:\\
\;\;\;\;th\\
\end{array}
\end{array}
if ky < 1.30000000000000002e-160Initial program 93.0%
unpow293.0%
sqr-neg93.0%
sin-neg93.0%
sin-neg93.0%
unpow293.0%
associate-*l/89.1%
associate-/l*92.8%
+-commutative92.8%
unpow292.8%
sin-neg92.8%
sin-neg92.8%
Simplified99.6%
Taylor expanded in kx around 0 14.9%
expm1-log1p-u14.9%
expm1-undefine26.9%
Applied egg-rr26.9%
Taylor expanded in th around 0 19.0%
+-commutative19.0%
Simplified19.0%
if 1.30000000000000002e-160 < ky Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.6%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.7%
Taylor expanded in kx around 0 37.5%
Taylor expanded in th around 0 19.2%
Final simplification19.1%
(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.6%
unpow295.6%
sqr-neg95.6%
sin-neg95.6%
sin-neg95.6%
unpow295.6%
associate-*l/92.8%
associate-/l*95.5%
+-commutative95.5%
unpow295.5%
sin-neg95.5%
sin-neg95.5%
Simplified99.6%
Taylor expanded in kx around 0 23.7%
Taylor expanded in th around 0 11.7%
herbie shell --seed 2024177
(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)))