
(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 18 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 th) (/ (hypot (sin kx) (sin ky)) (sin ky))))
double code(double kx, double ky, double th) {
return sin(th) / (hypot(sin(kx), sin(ky)) / sin(ky));
}
public static double code(double kx, double ky, double th) {
return Math.sin(th) / (Math.hypot(Math.sin(kx), Math.sin(ky)) / Math.sin(ky));
}
def code(kx, ky, th): return math.sin(th) / (math.hypot(math.sin(kx), math.sin(ky)) / math.sin(ky))
function code(kx, ky, th) return Float64(sin(th) / Float64(hypot(sin(kx), sin(ky)) / sin(ky))) end
function tmp = code(kx, ky, th) tmp = sin(th) / (hypot(sin(kx), sin(ky)) / sin(ky)); end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin ky}}
\end{array}
Initial program 93.9%
clear-num93.9%
associate-*l/94.0%
*-un-lft-identity94.0%
unpow294.0%
unpow294.0%
hypot-def99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.02) (fabs (sin th)) (if (<= (sin ky) 1e-80) (fabs (* ky (/ (sin th) (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.02) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 1e-80) {
tmp = fabs((ky * (sin(th) / sin(kx))));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.02d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-80) then
tmp = abs((ky * (sin(th) / sin(kx))))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.02) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-80) {
tmp = Math.abs((ky * (Math.sin(th) / Math.sin(kx))));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.02: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-80: tmp = math.fabs((ky * (math.sin(th) / math.sin(kx)))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.02) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-80) tmp = abs(Float64(ky * Float64(sin(th) / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.02) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-80) tmp = abs((ky * (sin(th) / sin(kx)))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-80], N[Abs[N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.02:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-80}:\\
\;\;\;\;\left|ky \cdot \frac{\sin th}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0200000000000000004Initial program 99.6%
associate-*l/99.4%
clear-num99.3%
unpow299.3%
unpow299.3%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in kx around 0 2.7%
remove-double-div2.7%
add-sqr-sqrt1.4%
sqrt-unprod29.3%
pow229.3%
Applied egg-rr29.3%
unpow229.3%
rem-sqrt-square37.5%
Simplified37.5%
if -0.0200000000000000004 < (sin.f64 ky) < 9.99999999999999961e-81Initial program 87.3%
Taylor expanded in ky around 0 46.1%
add-sqr-sqrt31.6%
sqrt-unprod35.7%
pow235.7%
associate-/l*36.4%
associate-/r/36.5%
Applied egg-rr36.5%
unpow236.5%
rem-sqrt-square49.0%
associate-*l/47.6%
associate-*r/49.0%
Simplified49.0%
if 9.99999999999999961e-81 < (sin.f64 ky) Initial program 99.8%
Taylor expanded in kx around 0 66.2%
Final simplification51.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.02) (fabs (sin th)) (if (<= (sin ky) 2e-50) (/ (* (sin th) ky) (fabs (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.02) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 2e-50) {
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.02d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 2d-50) 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.02) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 2e-50) {
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.02: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 2e-50: 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.02) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-50) tmp = Float64(Float64(sin(th) * 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.02) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-50) 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.02], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-50], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.02:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-50}:\\
\;\;\;\;\frac{\sin th \cdot ky}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0200000000000000004Initial program 99.6%
associate-*l/99.4%
clear-num99.3%
unpow299.3%
unpow299.3%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in kx around 0 2.7%
remove-double-div2.7%
add-sqr-sqrt1.4%
sqrt-unprod29.3%
pow229.3%
Applied egg-rr29.3%
unpow229.3%
rem-sqrt-square37.5%
Simplified37.5%
if -0.0200000000000000004 < (sin.f64 ky) < 2.00000000000000002e-50Initial program 88.2%
Taylor expanded in ky around 0 46.5%
add-sqr-sqrt37.2%
sqrt-prod70.8%
rem-sqrt-square75.4%
Applied egg-rr75.4%
if 2.00000000000000002e-50 < (sin.f64 ky) Initial program 99.8%
Taylor expanded in kx around 0 68.0%
Final simplification64.6%
(FPCore (kx ky th)
:precision binary64
(if (<= kx 130.0)
(/ (sin th) (/ (hypot kx (sin ky)) (sin ky)))
(if (<= kx 3.8e+248)
(/ (* (sin th) ky) (exp (log (fabs (sin kx)))))
(/
(sin ky)
(*
(hypot (sin kx) (sin ky))
(+ (/ 1.0 th) (* th 0.16666666666666666)))))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 130.0) {
tmp = sin(th) / (hypot(kx, sin(ky)) / sin(ky));
} else if (kx <= 3.8e+248) {
tmp = (sin(th) * ky) / exp(log(fabs(sin(kx))));
} else {
tmp = sin(ky) / (hypot(sin(kx), sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 130.0) {
tmp = Math.sin(th) / (Math.hypot(kx, Math.sin(ky)) / Math.sin(ky));
} else if (kx <= 3.8e+248) {
tmp = (Math.sin(th) * ky) / Math.exp(Math.log(Math.abs(Math.sin(kx))));
} else {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), Math.sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 130.0: tmp = math.sin(th) / (math.hypot(kx, math.sin(ky)) / math.sin(ky)) elif kx <= 3.8e+248: tmp = (math.sin(th) * ky) / math.exp(math.log(math.fabs(math.sin(kx)))) else: tmp = math.sin(ky) / (math.hypot(math.sin(kx), math.sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666))) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 130.0) tmp = Float64(sin(th) / Float64(hypot(kx, sin(ky)) / sin(ky))); elseif (kx <= 3.8e+248) tmp = Float64(Float64(sin(th) * ky) / exp(log(abs(sin(kx))))); else tmp = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 130.0) tmp = sin(th) / (hypot(kx, sin(ky)) / sin(ky)); elseif (kx <= 3.8e+248) tmp = (sin(th) * ky) / exp(log(abs(sin(kx)))); else tmp = sin(ky) / (hypot(sin(kx), sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 130.0], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[kx ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[kx, 3.8e+248], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / N[Exp[N[Log[N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 130:\\
\;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(kx, \sin ky\right)}{\sin ky}}\\
\mathbf{elif}\;kx \leq 3.8 \cdot 10^{+248}:\\
\;\;\;\;\frac{\sin th \cdot ky}{e^{\log \left(\left|\sin kx\right|\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\end{array}
\end{array}
if kx < 130Initial program 92.4%
clear-num92.4%
associate-*l/92.4%
*-un-lft-identity92.4%
unpow292.4%
unpow292.4%
hypot-def99.8%
Applied egg-rr99.8%
Taylor expanded in kx around 0 73.1%
if 130 < kx < 3.8000000000000001e248Initial program 99.6%
Taylor expanded in ky around 0 31.3%
add-exp-log29.2%
Applied egg-rr29.2%
add-sqr-sqrt29.2%
sqrt-prod56.3%
rem-sqrt-square56.3%
Applied egg-rr56.3%
if 3.8000000000000001e248 < kx Initial program 99.6%
associate-*l/99.4%
associate-/l*99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 63.0%
+-commutative63.0%
*-commutative63.0%
unpow263.0%
unpow263.0%
hypot-def63.0%
associate-*r/63.0%
*-rgt-identity63.0%
*-lft-identity63.0%
associate-*l/63.0%
associate-*r*63.0%
Simplified63.0%
Final simplification69.8%
(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.9%
expm1-log1p-u93.8%
expm1-udef42.1%
Applied egg-rr44.1%
expm1-def99.6%
expm1-log1p99.7%
*-commutative99.7%
associate-*r/95.8%
associate-*l/99.6%
*-commutative99.6%
hypot-def93.8%
unpow293.8%
unpow293.8%
+-commutative93.8%
unpow293.8%
unpow293.8%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th) :precision binary64 (* (sin th) (/ (sin ky) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
return sin(th) * (sin(ky) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th): return math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th) return Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), sin(kx)))) end
function tmp = code(kx, ky, th) tmp = sin(th) * (sin(ky) / hypot(sin(ky), sin(kx))); end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Initial program 93.9%
remove-double-neg93.9%
sin-neg93.9%
neg-mul-193.9%
*-commutative93.9%
associate-*l*93.9%
associate-*l/91.9%
associate-/r/91.9%
associate-*l/93.9%
associate-/r/93.9%
sin-neg93.9%
neg-mul-193.9%
associate-/r*93.9%
associate-/r/93.9%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= kx 130.0)
(/ (sin th) (/ (hypot kx (sin ky)) (sin ky)))
(if (<= kx 3e+248)
(/ (* (sin th) ky) (fabs (sin kx)))
(/
(sin ky)
(*
(hypot (sin kx) (sin ky))
(+ (/ 1.0 th) (* th 0.16666666666666666)))))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 130.0) {
tmp = sin(th) / (hypot(kx, sin(ky)) / sin(ky));
} else if (kx <= 3e+248) {
tmp = (sin(th) * ky) / fabs(sin(kx));
} else {
tmp = sin(ky) / (hypot(sin(kx), sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 130.0) {
tmp = Math.sin(th) / (Math.hypot(kx, Math.sin(ky)) / Math.sin(ky));
} else if (kx <= 3e+248) {
tmp = (Math.sin(th) * ky) / Math.abs(Math.sin(kx));
} else {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), Math.sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 130.0: tmp = math.sin(th) / (math.hypot(kx, math.sin(ky)) / math.sin(ky)) elif kx <= 3e+248: tmp = (math.sin(th) * ky) / math.fabs(math.sin(kx)) else: tmp = math.sin(ky) / (math.hypot(math.sin(kx), math.sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666))) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 130.0) tmp = Float64(sin(th) / Float64(hypot(kx, sin(ky)) / sin(ky))); elseif (kx <= 3e+248) tmp = Float64(Float64(sin(th) * ky) / abs(sin(kx))); else tmp = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 130.0) tmp = sin(th) / (hypot(kx, sin(ky)) / sin(ky)); elseif (kx <= 3e+248) tmp = (sin(th) * ky) / abs(sin(kx)); else tmp = sin(ky) / (hypot(sin(kx), sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 130.0], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[kx ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[kx, 3e+248], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 130:\\
\;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(kx, \sin ky\right)}{\sin ky}}\\
\mathbf{elif}\;kx \leq 3 \cdot 10^{+248}:\\
\;\;\;\;\frac{\sin th \cdot ky}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\end{array}
\end{array}
if kx < 130Initial program 92.4%
clear-num92.4%
associate-*l/92.4%
*-un-lft-identity92.4%
unpow292.4%
unpow292.4%
hypot-def99.8%
Applied egg-rr99.8%
Taylor expanded in kx around 0 73.1%
if 130 < kx < 3e248Initial program 99.6%
Taylor expanded in ky around 0 31.3%
add-sqr-sqrt29.2%
sqrt-prod56.3%
rem-sqrt-square56.3%
Applied egg-rr56.3%
if 3e248 < kx Initial program 99.6%
associate-*l/99.4%
associate-/l*99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 63.0%
+-commutative63.0%
*-commutative63.0%
unpow263.0%
unpow263.0%
hypot-def63.0%
associate-*r/63.0%
*-rgt-identity63.0%
*-lft-identity63.0%
associate-*l/63.0%
associate-*r*63.0%
Simplified63.0%
Final simplification69.8%
(FPCore (kx ky th)
:precision binary64
(if (<= kx 130.0)
(* (sin th) (/ (sin ky) (hypot (sin ky) kx)))
(if (<= kx 3.1e+248)
(/ (* (sin th) ky) (fabs (sin kx)))
(/ (sin ky) (/ (hypot (sin kx) (sin ky)) th)))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 130.0) {
tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx));
} else if (kx <= 3.1e+248) {
tmp = (sin(th) * ky) / fabs(sin(kx));
} else {
tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 130.0) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), kx));
} else if (kx <= 3.1e+248) {
tmp = (Math.sin(th) * ky) / Math.abs(Math.sin(kx));
} else {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), Math.sin(ky)) / th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 130.0: tmp = math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), kx)) elif kx <= 3.1e+248: tmp = (math.sin(th) * ky) / math.fabs(math.sin(kx)) else: tmp = math.sin(ky) / (math.hypot(math.sin(kx), math.sin(ky)) / th) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 130.0) tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), kx))); elseif (kx <= 3.1e+248) tmp = Float64(Float64(sin(th) * ky) / abs(sin(kx))); else tmp = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) / th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 130.0) tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx)); elseif (kx <= 3.1e+248) tmp = (sin(th) * ky) / abs(sin(kx)); else tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 130.0], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[kx, 3.1e+248], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 130:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
\mathbf{elif}\;kx \leq 3.1 \cdot 10^{+248}:\\
\;\;\;\;\frac{\sin th \cdot ky}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\
\end{array}
\end{array}
if kx < 130Initial program 92.4%
remove-double-neg92.4%
sin-neg92.4%
neg-mul-192.4%
*-commutative92.4%
associate-*l*92.4%
associate-*l/89.8%
associate-/r/89.8%
associate-*l/92.4%
associate-/r/92.3%
sin-neg92.3%
neg-mul-192.3%
associate-/r*92.3%
associate-/r/92.4%
Simplified99.7%
Taylor expanded in kx around 0 73.0%
if 130 < kx < 3.10000000000000005e248Initial program 99.6%
Taylor expanded in ky around 0 31.3%
add-sqr-sqrt29.2%
sqrt-prod56.3%
rem-sqrt-square56.3%
Applied egg-rr56.3%
if 3.10000000000000005e248 < kx Initial program 99.6%
associate-*l/99.4%
associate-/l*99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 62.6%
associate-*l/62.6%
unpow262.6%
unpow262.6%
hypot-def62.6%
*-lft-identity62.6%
Simplified62.6%
Final simplification69.7%
(FPCore (kx ky th)
:precision binary64
(if (<= kx 130.0)
(/ (sin th) (/ (hypot kx (sin ky)) (sin ky)))
(if (<= kx 3.1e+248)
(/ (* (sin th) ky) (fabs (sin kx)))
(/ (sin ky) (/ (hypot (sin kx) (sin ky)) th)))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 130.0) {
tmp = sin(th) / (hypot(kx, sin(ky)) / sin(ky));
} else if (kx <= 3.1e+248) {
tmp = (sin(th) * ky) / fabs(sin(kx));
} else {
tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 130.0) {
tmp = Math.sin(th) / (Math.hypot(kx, Math.sin(ky)) / Math.sin(ky));
} else if (kx <= 3.1e+248) {
tmp = (Math.sin(th) * ky) / Math.abs(Math.sin(kx));
} else {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), Math.sin(ky)) / th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 130.0: tmp = math.sin(th) / (math.hypot(kx, math.sin(ky)) / math.sin(ky)) elif kx <= 3.1e+248: tmp = (math.sin(th) * ky) / math.fabs(math.sin(kx)) else: tmp = math.sin(ky) / (math.hypot(math.sin(kx), math.sin(ky)) / th) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 130.0) tmp = Float64(sin(th) / Float64(hypot(kx, sin(ky)) / sin(ky))); elseif (kx <= 3.1e+248) tmp = Float64(Float64(sin(th) * ky) / abs(sin(kx))); else tmp = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) / th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 130.0) tmp = sin(th) / (hypot(kx, sin(ky)) / sin(ky)); elseif (kx <= 3.1e+248) tmp = (sin(th) * ky) / abs(sin(kx)); else tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 130.0], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[kx ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[kx, 3.1e+248], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 130:\\
\;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(kx, \sin ky\right)}{\sin ky}}\\
\mathbf{elif}\;kx \leq 3.1 \cdot 10^{+248}:\\
\;\;\;\;\frac{\sin th \cdot ky}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\
\end{array}
\end{array}
if kx < 130Initial program 92.4%
clear-num92.4%
associate-*l/92.4%
*-un-lft-identity92.4%
unpow292.4%
unpow292.4%
hypot-def99.8%
Applied egg-rr99.8%
Taylor expanded in kx around 0 73.1%
if 130 < kx < 3.10000000000000005e248Initial program 99.6%
Taylor expanded in ky around 0 31.3%
add-sqr-sqrt29.2%
sqrt-prod56.3%
rem-sqrt-square56.3%
Applied egg-rr56.3%
if 3.10000000000000005e248 < kx Initial program 99.6%
associate-*l/99.4%
associate-/l*99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 62.6%
associate-*l/62.6%
unpow262.6%
unpow262.6%
hypot-def62.6%
*-lft-identity62.6%
Simplified62.6%
Final simplification69.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.02) (fabs (sin th)) (if (<= (sin ky) 5e-100) (/ (sin th) (/ (sin kx) ky)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.02) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 5e-100) {
tmp = sin(th) / (sin(kx) / ky);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.02d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 5d-100) then
tmp = sin(th) / (sin(kx) / ky)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.02) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 5e-100) {
tmp = Math.sin(th) / (Math.sin(kx) / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.02: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 5e-100: tmp = math.sin(th) / (math.sin(kx) / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.02) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-100) tmp = Float64(sin(th) / Float64(sin(kx) / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.02) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-100) tmp = sin(th) / (sin(kx) / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-100], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.02:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-100}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0200000000000000004Initial program 99.6%
associate-*l/99.4%
clear-num99.3%
unpow299.3%
unpow299.3%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in kx around 0 2.7%
remove-double-div2.7%
add-sqr-sqrt1.4%
sqrt-unprod29.3%
pow229.3%
Applied egg-rr29.3%
unpow229.3%
rem-sqrt-square37.5%
Simplified37.5%
if -0.0200000000000000004 < (sin.f64 ky) < 5.0000000000000001e-100Initial program 87.1%
clear-num87.1%
associate-*l/87.2%
*-un-lft-identity87.2%
unpow287.2%
unpow287.2%
hypot-def99.8%
Applied egg-rr99.8%
Taylor expanded in ky around 0 49.7%
if 5.0000000000000001e-100 < (sin.f64 ky) Initial program 99.8%
Taylor expanded in kx around 0 66.6%
Final simplification52.2%
(FPCore (kx ky th) :precision binary64 (if (<= kx 130.0) (* (sin th) (/ (sin ky) (hypot (sin ky) kx))) (/ (* (sin th) ky) (fabs (sin kx)))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 130.0) {
tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx));
} else {
tmp = (sin(th) * ky) / fabs(sin(kx));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 130.0) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), kx));
} else {
tmp = (Math.sin(th) * ky) / Math.abs(Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 130.0: tmp = math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), kx)) else: tmp = (math.sin(th) * ky) / math.fabs(math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 130.0) tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), kx))); else tmp = Float64(Float64(sin(th) * ky) / abs(sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 130.0) tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx)); else tmp = (sin(th) * ky) / abs(sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 130.0], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 130:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th \cdot ky}{\left|\sin kx\right|}\\
\end{array}
\end{array}
if kx < 130Initial program 92.4%
remove-double-neg92.4%
sin-neg92.4%
neg-mul-192.4%
*-commutative92.4%
associate-*l*92.4%
associate-*l/89.8%
associate-/r/89.8%
associate-*l/92.4%
associate-/r/92.3%
sin-neg92.3%
neg-mul-192.3%
associate-/r*92.3%
associate-/r/92.4%
Simplified99.7%
Taylor expanded in kx around 0 73.0%
if 130 < kx Initial program 99.6%
Taylor expanded in ky around 0 35.1%
add-sqr-sqrt29.6%
sqrt-prod55.9%
rem-sqrt-square55.9%
Applied egg-rr55.9%
Final simplification69.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky 4.5e-115) (/ ky (/ kx (sin th))) (if (<= ky 9.2e+19) (sin th) (fabs (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.5e-115) {
tmp = ky / (kx / sin(th));
} else if (ky <= 9.2e+19) {
tmp = sin(th);
} else {
tmp = fabs(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 <= 4.5d-115) then
tmp = ky / (kx / sin(th))
else if (ky <= 9.2d+19) then
tmp = sin(th)
else
tmp = abs(sin(th))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.5e-115) {
tmp = ky / (kx / Math.sin(th));
} else if (ky <= 9.2e+19) {
tmp = Math.sin(th);
} else {
tmp = Math.abs(Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 4.5e-115: tmp = ky / (kx / math.sin(th)) elif ky <= 9.2e+19: tmp = math.sin(th) else: tmp = math.fabs(math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 4.5e-115) tmp = Float64(ky / Float64(kx / sin(th))); elseif (ky <= 9.2e+19) tmp = sin(th); else tmp = abs(sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 4.5e-115) tmp = ky / (kx / sin(th)); elseif (ky <= 9.2e+19) tmp = sin(th); else tmp = abs(sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 4.5e-115], N[(ky / N[(kx / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 9.2e+19], N[Sin[th], $MachinePrecision], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 4.5 \cdot 10^{-115}:\\
\;\;\;\;\frac{ky}{\frac{kx}{\sin th}}\\
\mathbf{elif}\;ky \leq 9.2 \cdot 10^{+19}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\
\end{array}
\end{array}
if ky < 4.50000000000000023e-115Initial program 91.1%
Taylor expanded in ky around 0 32.0%
Taylor expanded in kx around 0 21.9%
associate-/l*24.1%
Simplified24.1%
if 4.50000000000000023e-115 < ky < 9.2e19Initial program 99.8%
Taylor expanded in kx around 0 58.2%
if 9.2e19 < ky Initial program 99.7%
associate-*l/99.5%
clear-num99.4%
unpow299.4%
unpow299.4%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in kx around 0 30.4%
remove-double-div30.5%
add-sqr-sqrt11.6%
sqrt-unprod21.7%
pow221.7%
Applied egg-rr21.7%
unpow221.7%
rem-sqrt-square32.3%
Simplified32.3%
Final simplification29.8%
(FPCore (kx ky th) :precision binary64 (if (<= ky 7.8e-100) (* ky (/ (sin th) (sin kx))) (if (<= ky 1e+20) (sin th) (fabs (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 7.8e-100) {
tmp = ky * (sin(th) / sin(kx));
} else if (ky <= 1e+20) {
tmp = sin(th);
} else {
tmp = fabs(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 <= 7.8d-100) then
tmp = ky * (sin(th) / sin(kx))
else if (ky <= 1d+20) then
tmp = sin(th)
else
tmp = abs(sin(th))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 7.8e-100) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else if (ky <= 1e+20) {
tmp = Math.sin(th);
} else {
tmp = Math.abs(Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 7.8e-100: tmp = ky * (math.sin(th) / math.sin(kx)) elif ky <= 1e+20: tmp = math.sin(th) else: tmp = math.fabs(math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 7.8e-100) tmp = Float64(ky * Float64(sin(th) / sin(kx))); elseif (ky <= 1e+20) tmp = sin(th); else tmp = abs(sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 7.8e-100) tmp = ky * (sin(th) / sin(kx)); elseif (ky <= 1e+20) tmp = sin(th); else tmp = abs(sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 7.8e-100], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 1e+20], N[Sin[th], $MachinePrecision], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 7.8 \cdot 10^{-100}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;ky \leq 10^{+20}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\
\end{array}
\end{array}
if ky < 7.79999999999999955e-100Initial program 91.2%
clear-num91.2%
associate-*l/91.3%
*-un-lft-identity91.3%
unpow291.3%
unpow291.3%
hypot-def99.8%
Applied egg-rr99.8%
Taylor expanded in ky around 0 32.1%
associate-*r/34.2%
Simplified34.2%
if 7.79999999999999955e-100 < ky < 1e20Initial program 99.9%
Taylor expanded in kx around 0 64.3%
if 1e20 < ky Initial program 99.7%
associate-*l/99.5%
clear-num99.4%
unpow299.4%
unpow299.4%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in kx around 0 30.4%
remove-double-div30.5%
add-sqr-sqrt11.6%
sqrt-unprod21.7%
pow221.7%
Applied egg-rr21.7%
unpow221.7%
rem-sqrt-square32.3%
Simplified32.3%
Final simplification36.9%
(FPCore (kx ky th) :precision binary64 (if (<= ky 3.8e-100) (* ky (/ th (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3.8e-100) {
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 <= 3.8d-100) 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 <= 3.8e-100) {
tmp = ky * (th / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 3.8e-100: tmp = ky * (th / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 3.8e-100) 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 <= 3.8e-100) tmp = ky * (th / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 3.8e-100], 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.8 \cdot 10^{-100}:\\
\;\;\;\;ky \cdot \frac{th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 3.79999999999999997e-100Initial program 91.2%
associate-*l/88.8%
clear-num88.2%
unpow288.2%
unpow288.2%
hypot-def94.0%
Applied egg-rr94.0%
Taylor expanded in ky around 0 31.6%
Taylor expanded in th around 0 20.1%
*-lft-identity20.1%
times-frac22.2%
/-rgt-identity22.2%
Simplified22.2%
if 3.79999999999999997e-100 < ky Initial program 99.8%
Taylor expanded in kx around 0 41.2%
Final simplification28.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky 3.2e-114) (/ ky (/ kx (sin th))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3.2e-114) {
tmp = ky / (kx / sin(th));
} 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.2d-114) then
tmp = ky / (kx / sin(th))
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.2e-114) {
tmp = ky / (kx / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 3.2e-114: tmp = ky / (kx / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 3.2e-114) tmp = Float64(ky / Float64(kx / sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 3.2e-114) tmp = ky / (kx / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 3.2e-114], N[(ky / N[(kx / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 3.2 \cdot 10^{-114}:\\
\;\;\;\;\frac{ky}{\frac{kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 3.2000000000000002e-114Initial program 91.1%
Taylor expanded in ky around 0 32.0%
Taylor expanded in kx around 0 21.9%
associate-/l*24.1%
Simplified24.1%
if 3.2000000000000002e-114 < ky Initial program 99.8%
Taylor expanded in kx around 0 39.9%
Final simplification29.4%
(FPCore (kx ky th) :precision binary64 (sin th))
double code(double kx, double ky, double th) {
return sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = sin(th)
end function
public static double code(double kx, double ky, double th) {
return Math.sin(th);
}
def code(kx, ky, th): return math.sin(th)
function code(kx, ky, th) return sin(th) end
function tmp = code(kx, ky, th) tmp = sin(th); end
code[kx_, ky_, th_] := N[Sin[th], $MachinePrecision]
\begin{array}{l}
\\
\sin th
\end{array}
Initial program 93.9%
Taylor expanded in kx around 0 26.0%
Final simplification26.0%
(FPCore (kx ky th) :precision binary64 (/ 1.0 (+ (/ 1.0 th) (* th 0.16666666666666666))))
double code(double kx, double ky, double th) {
return 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = 1.0d0 / ((1.0d0 / th) + (th * 0.16666666666666666d0))
end function
public static double code(double kx, double ky, double th) {
return 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
}
def code(kx, ky, th): return 1.0 / ((1.0 / th) + (th * 0.16666666666666666))
function code(kx, ky, th) return Float64(1.0 / Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666))) end
function tmp = code(kx, ky, th) tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666)); end
code[kx_, ky_, th_] := N[(1.0 / N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1}{th} + th \cdot 0.16666666666666666}
\end{array}
Initial program 93.9%
associate-*l/91.9%
clear-num91.4%
unpow291.4%
unpow291.4%
hypot-def95.4%
Applied egg-rr95.4%
Taylor expanded in kx around 0 26.0%
Taylor expanded in th around 0 15.0%
Final simplification15.0%
(FPCore (kx ky th) :precision binary64 th)
double code(double kx, double ky, double th) {
return th;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = th
end function
public static double code(double kx, double ky, double th) {
return th;
}
def code(kx, ky, th): return th
function code(kx, ky, th) return th end
function tmp = code(kx, ky, th) tmp = th; end
code[kx_, ky_, th_] := th
\begin{array}{l}
\\
th
\end{array}
Initial program 93.9%
associate-*l/91.9%
clear-num91.4%
unpow291.4%
unpow291.4%
hypot-def95.4%
Applied egg-rr95.4%
Taylor expanded in kx around 0 26.0%
Taylor expanded in th around 0 14.2%
Final simplification14.2%
herbie shell --seed 2024027
(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)))