
(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 93.4%
remove-double-neg93.4%
sin-neg93.4%
neg-mul-193.4%
*-commutative93.4%
associate-*l*93.4%
associate-*l/92.4%
associate-/r/92.4%
associate-*l/93.4%
associate-/r/93.3%
sin-neg93.3%
neg-mul-193.3%
associate-/r*93.3%
associate-/r/93.4%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin th) (sin kx))) (t_2 (* (sin ky) t_1)))
(if (<= (sin th) -0.001)
t_2
(if (<= (sin th) 0.0002)
(* (sin ky) (/ 1.0 (/ (hypot (sin kx) (sin ky)) th)))
(if (<= (sin th) 0.75)
(fabs (* ky t_1))
(if (<= (sin th) 0.93) (sin th) t_2))))))
double code(double kx, double ky, double th) {
double t_1 = sin(th) / sin(kx);
double t_2 = sin(ky) * t_1;
double tmp;
if (sin(th) <= -0.001) {
tmp = t_2;
} else if (sin(th) <= 0.0002) {
tmp = sin(ky) * (1.0 / (hypot(sin(kx), sin(ky)) / th));
} else if (sin(th) <= 0.75) {
tmp = fabs((ky * t_1));
} else if (sin(th) <= 0.93) {
tmp = sin(th);
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(th) / Math.sin(kx);
double t_2 = Math.sin(ky) * t_1;
double tmp;
if (Math.sin(th) <= -0.001) {
tmp = t_2;
} else if (Math.sin(th) <= 0.0002) {
tmp = Math.sin(ky) * (1.0 / (Math.hypot(Math.sin(kx), Math.sin(ky)) / th));
} else if (Math.sin(th) <= 0.75) {
tmp = Math.abs((ky * t_1));
} else if (Math.sin(th) <= 0.93) {
tmp = Math.sin(th);
} else {
tmp = t_2;
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(th) / math.sin(kx) t_2 = math.sin(ky) * t_1 tmp = 0 if math.sin(th) <= -0.001: tmp = t_2 elif math.sin(th) <= 0.0002: tmp = math.sin(ky) * (1.0 / (math.hypot(math.sin(kx), math.sin(ky)) / th)) elif math.sin(th) <= 0.75: tmp = math.fabs((ky * t_1)) elif math.sin(th) <= 0.93: tmp = math.sin(th) else: tmp = t_2 return tmp
function code(kx, ky, th) t_1 = Float64(sin(th) / sin(kx)) t_2 = Float64(sin(ky) * t_1) tmp = 0.0 if (sin(th) <= -0.001) tmp = t_2; elseif (sin(th) <= 0.0002) tmp = Float64(sin(ky) * Float64(1.0 / Float64(hypot(sin(kx), sin(ky)) / th))); elseif (sin(th) <= 0.75) tmp = abs(Float64(ky * t_1)); elseif (sin(th) <= 0.93) tmp = sin(th); else tmp = t_2; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(th) / sin(kx); t_2 = sin(ky) * t_1; tmp = 0.0; if (sin(th) <= -0.001) tmp = t_2; elseif (sin(th) <= 0.0002) tmp = sin(ky) * (1.0 / (hypot(sin(kx), sin(ky)) / th)); elseif (sin(th) <= 0.75) tmp = abs((ky * t_1)); elseif (sin(th) <= 0.93) tmp = sin(th); else tmp = t_2; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[N[Sin[th], $MachinePrecision], -0.001], t$95$2, If[LessEqual[N[Sin[th], $MachinePrecision], 0.0002], N[(N[Sin[ky], $MachinePrecision] * N[(1.0 / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.75], N[Abs[N[(ky * t$95$1), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.93], N[Sin[th], $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin th}{\sin kx}\\
t_2 := \sin ky \cdot t\_1\\
\mathbf{if}\;\sin th \leq -0.001:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\sin th \leq 0.0002:\\
\;\;\;\;\sin ky \cdot \frac{1}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\
\mathbf{elif}\;\sin th \leq 0.75:\\
\;\;\;\;\left|ky \cdot t\_1\right|\\
\mathbf{elif}\;\sin th \leq 0.93:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (sin.f64 th) < -1e-3 or 0.930000000000000049 < (sin.f64 th) Initial program 91.9%
expm1-log1p-u91.7%
expm1-udef57.1%
Applied egg-rr62.7%
expm1-def99.5%
expm1-log1p99.7%
*-commutative99.7%
associate-*r/99.6%
associate-*l/99.6%
*-commutative99.6%
hypot-def91.8%
unpow291.8%
unpow291.8%
+-commutative91.8%
unpow291.8%
unpow291.8%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 21.2%
if -1e-3 < (sin.f64 th) < 2.0000000000000001e-4Initial program 95.0%
expm1-log1p-u95.0%
expm1-udef21.6%
Applied egg-rr22.6%
expm1-def99.8%
expm1-log1p99.8%
*-commutative99.8%
associate-*r/96.5%
associate-*l/99.7%
*-commutative99.7%
hypot-def94.9%
unpow294.9%
unpow294.9%
+-commutative94.9%
unpow294.9%
unpow294.9%
hypot-def99.7%
Simplified99.7%
clear-num99.5%
inv-pow99.5%
hypot-udef94.8%
+-commutative94.8%
hypot-udef99.5%
Applied egg-rr99.5%
unpow-199.5%
hypot-def94.8%
unpow294.8%
unpow294.8%
+-commutative94.8%
unpow294.8%
unpow294.8%
hypot-def99.5%
Simplified99.5%
Taylor expanded in th around 0 94.1%
associate-*l/94.3%
+-commutative94.3%
unpow294.3%
unpow294.3%
hypot-def99.0%
*-lft-identity99.0%
hypot-def94.3%
unpow294.3%
unpow294.3%
+-commutative94.3%
unpow294.3%
unpow294.3%
hypot-def99.0%
Simplified99.0%
if 2.0000000000000001e-4 < (sin.f64 th) < 0.75Initial program 89.4%
Taylor expanded in ky around 0 23.5%
add-sqr-sqrt9.9%
sqrt-unprod19.4%
pow219.4%
*-commutative19.4%
associate-/l*19.4%
Applied egg-rr19.4%
unpow219.4%
rem-sqrt-square24.1%
associate-/r/24.2%
*-commutative24.2%
Simplified24.2%
if 0.75 < (sin.f64 th) < 0.930000000000000049Initial program 99.4%
Taylor expanded in kx around 0 8.8%
Final simplification55.9%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.01)
(/ 1.0 (/ (hypot (sin ky) (sin kx)) (* (sin ky) th)))
(if (<= (sin ky) 1e-13)
(/ (/ (sin th) (hypot (sin kx) (sin ky))) (/ 1.0 ky))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.01) {
tmp = 1.0 / (hypot(sin(ky), sin(kx)) / (sin(ky) * th));
} else if (sin(ky) <= 1e-13) {
tmp = (sin(th) / hypot(sin(kx), sin(ky))) / (1.0 / ky);
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.01) {
tmp = 1.0 / (Math.hypot(Math.sin(ky), Math.sin(kx)) / (Math.sin(ky) * th));
} else if (Math.sin(ky) <= 1e-13) {
tmp = (Math.sin(th) / Math.hypot(Math.sin(kx), Math.sin(ky))) / (1.0 / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.01: tmp = 1.0 / (math.hypot(math.sin(ky), math.sin(kx)) / (math.sin(ky) * th)) elif math.sin(ky) <= 1e-13: tmp = (math.sin(th) / math.hypot(math.sin(kx), math.sin(ky))) / (1.0 / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.01) tmp = Float64(1.0 / Float64(hypot(sin(ky), sin(kx)) / Float64(sin(ky) * th))); elseif (sin(ky) <= 1e-13) tmp = Float64(Float64(sin(th) / hypot(sin(kx), sin(ky))) / Float64(1.0 / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.01) tmp = 1.0 / (hypot(sin(ky), sin(kx)) / (sin(ky) * th)); elseif (sin(ky) <= 1e-13) tmp = (sin(th) / hypot(sin(kx), sin(ky))) / (1.0 / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.01], N[(1.0 / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-13], N[(N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[(1.0 / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.01:\\
\;\;\;\;\frac{1}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky \cdot th}}\\
\mathbf{elif}\;\sin ky \leq 10^{-13}:\\
\;\;\;\;\frac{\frac{\sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}}{\frac{1}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0100000000000000002Initial program 99.6%
associate-*l/99.7%
clear-num99.4%
unpow299.4%
unpow299.4%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in th around 0 47.0%
associate-*l/47.1%
unpow247.1%
unpow247.1%
hypot-def47.2%
*-lft-identity47.2%
hypot-def47.1%
unpow247.1%
unpow247.1%
+-commutative47.1%
unpow247.1%
unpow247.1%
hypot-def47.2%
Simplified47.2%
if -0.0100000000000000002 < (sin.f64 ky) < 1e-13Initial program 87.5%
expm1-log1p-u87.3%
expm1-udef26.7%
Applied egg-rr33.6%
expm1-def99.6%
expm1-log1p99.7%
*-commutative99.7%
associate-*r/96.9%
associate-*l/99.7%
*-commutative99.7%
hypot-def87.5%
unpow287.5%
unpow287.5%
+-commutative87.5%
unpow287.5%
unpow287.5%
hypot-def99.7%
Simplified99.7%
*-commutative99.7%
associate-*l/96.9%
hypot-udef85.6%
+-commutative85.6%
hypot-udef96.9%
associate-/l*99.6%
div-inv99.6%
associate-/r*99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 99.6%
if 1e-13 < (sin.f64 ky) Initial program 99.6%
Taylor expanded in kx around 0 55.6%
Final simplification76.1%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.005)
(* (sin th) (/ (- ky) (sin kx)))
(if (<= (sin kx) 5e-102)
(/ 1.0 (/ (sin ky) (* (sin ky) (sin th))))
(* (sin ky) (/ (sin th) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.005) {
tmp = sin(th) * (-ky / sin(kx));
} else if (sin(kx) <= 5e-102) {
tmp = 1.0 / (sin(ky) / (sin(ky) * sin(th)));
} else {
tmp = sin(ky) * (sin(th) / sin(kx));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.005d0)) then
tmp = sin(th) * (-ky / sin(kx))
else if (sin(kx) <= 5d-102) then
tmp = 1.0d0 / (sin(ky) / (sin(ky) * sin(th)))
else
tmp = sin(ky) * (sin(th) / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.005) {
tmp = Math.sin(th) * (-ky / Math.sin(kx));
} else if (Math.sin(kx) <= 5e-102) {
tmp = 1.0 / (Math.sin(ky) / (Math.sin(ky) * Math.sin(th)));
} else {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.005: tmp = math.sin(th) * (-ky / math.sin(kx)) elif math.sin(kx) <= 5e-102: tmp = 1.0 / (math.sin(ky) / (math.sin(ky) * math.sin(th))) else: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.005) tmp = Float64(sin(th) * Float64(Float64(-ky) / sin(kx))); elseif (sin(kx) <= 5e-102) tmp = Float64(1.0 / Float64(sin(ky) / Float64(sin(ky) * sin(th)))); else tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.005) tmp = sin(th) * (-ky / sin(kx)); elseif (sin(kx) <= 5e-102) tmp = 1.0 / (sin(ky) / (sin(ky) * sin(th))); else tmp = sin(ky) * (sin(th) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[(N[Sin[th], $MachinePrecision] * N[((-ky) / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-102], N[(1.0 / N[(N[Sin[ky], $MachinePrecision] / N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.005:\\
\;\;\;\;\sin th \cdot \frac{-ky}{\sin kx}\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-102}:\\
\;\;\;\;\frac{1}{\frac{\sin ky}{\sin ky \cdot \sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0050000000000000001Initial program 99.6%
Taylor expanded in ky around 0 17.8%
add-sqr-sqrt15.0%
sqrt-unprod25.4%
pow225.4%
*-commutative25.4%
associate-/l*25.3%
Applied egg-rr25.3%
Taylor expanded in ky around -inf 57.1%
mul-1-neg57.1%
associate-*l/57.3%
*-commutative57.3%
distribute-lft-neg-in57.3%
Simplified57.3%
if -0.0050000000000000001 < (sin.f64 kx) < 5.00000000000000026e-102Initial program 84.2%
associate-*l/82.6%
clear-num82.4%
unpow282.4%
unpow282.4%
hypot-def96.9%
Applied egg-rr96.9%
Taylor expanded in kx around 0 34.4%
if 5.00000000000000026e-102 < (sin.f64 kx) Initial program 99.5%
expm1-log1p-u99.5%
expm1-udef39.1%
Applied egg-rr39.0%
expm1-def99.4%
expm1-log1p99.5%
*-commutative99.5%
associate-*r/98.6%
associate-*l/99.6%
*-commutative99.6%
hypot-def99.6%
unpow299.6%
unpow299.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 52.3%
Final simplification46.4%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.005)
(* (sin th) (/ (- ky) (sin kx)))
(if (<= (sin kx) 1e-130)
(/ 1.0 (/ 1.0 (sin th)))
(* (sin ky) (/ (sin th) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.005) {
tmp = sin(th) * (-ky / sin(kx));
} else if (sin(kx) <= 1e-130) {
tmp = 1.0 / (1.0 / sin(th));
} else {
tmp = sin(ky) * (sin(th) / sin(kx));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.005d0)) then
tmp = sin(th) * (-ky / sin(kx))
else if (sin(kx) <= 1d-130) then
tmp = 1.0d0 / (1.0d0 / sin(th))
else
tmp = sin(ky) * (sin(th) / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.005) {
tmp = Math.sin(th) * (-ky / Math.sin(kx));
} else if (Math.sin(kx) <= 1e-130) {
tmp = 1.0 / (1.0 / Math.sin(th));
} else {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.005: tmp = math.sin(th) * (-ky / math.sin(kx)) elif math.sin(kx) <= 1e-130: tmp = 1.0 / (1.0 / math.sin(th)) else: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.005) tmp = Float64(sin(th) * Float64(Float64(-ky) / sin(kx))); elseif (sin(kx) <= 1e-130) tmp = Float64(1.0 / Float64(1.0 / sin(th))); else tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.005) tmp = sin(th) * (-ky / sin(kx)); elseif (sin(kx) <= 1e-130) tmp = 1.0 / (1.0 / sin(th)); else tmp = sin(ky) * (sin(th) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[(N[Sin[th], $MachinePrecision] * N[((-ky) / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-130], N[(1.0 / N[(1.0 / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.005:\\
\;\;\;\;\sin th \cdot \frac{-ky}{\sin kx}\\
\mathbf{elif}\;\sin kx \leq 10^{-130}:\\
\;\;\;\;\frac{1}{\frac{1}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0050000000000000001Initial program 99.6%
Taylor expanded in ky around 0 17.8%
add-sqr-sqrt15.0%
sqrt-unprod25.4%
pow225.4%
*-commutative25.4%
associate-/l*25.3%
Applied egg-rr25.3%
Taylor expanded in ky around -inf 57.1%
mul-1-neg57.1%
associate-*l/57.3%
*-commutative57.3%
distribute-lft-neg-in57.3%
Simplified57.3%
if -0.0050000000000000001 < (sin.f64 kx) < 1.0000000000000001e-130Initial program 83.2%
associate-*l/82.2%
clear-num82.0%
unpow282.0%
unpow282.0%
hypot-def97.3%
Applied egg-rr97.3%
Taylor expanded in kx around 0 32.9%
if 1.0000000000000001e-130 < (sin.f64 kx) Initial program 99.5%
expm1-log1p-u99.5%
expm1-udef39.9%
Applied egg-rr39.9%
expm1-def99.5%
expm1-log1p99.5%
*-commutative99.5%
associate-*r/98.0%
associate-*l/99.6%
*-commutative99.6%
hypot-def99.5%
unpow299.5%
unpow299.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 51.3%
Final simplification45.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.4%
expm1-log1p-u93.3%
expm1-udef41.0%
Applied egg-rr44.6%
expm1-def99.6%
expm1-log1p99.7%
*-commutative99.7%
associate-*r/98.2%
associate-*l/99.6%
*-commutative99.6%
hypot-def93.3%
unpow293.3%
unpow293.3%
+-commutative93.3%
unpow293.3%
unpow293.3%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin kx) (sin ky))))
(if (<= th 0.00046)
(* (sin ky) (/ 1.0 (/ t_1 th)))
(if (or (<= th 5.3e+39) (not (<= th 3.1e+73)))
(/ 1.0 (/ t_1 (* ky (sin th))))
(fabs (sin th))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (th <= 0.00046) {
tmp = sin(ky) * (1.0 / (t_1 / th));
} else if ((th <= 5.3e+39) || !(th <= 3.1e+73)) {
tmp = 1.0 / (t_1 / (ky * sin(th)));
} else {
tmp = fabs(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 (th <= 0.00046) {
tmp = Math.sin(ky) * (1.0 / (t_1 / th));
} else if ((th <= 5.3e+39) || !(th <= 3.1e+73)) {
tmp = 1.0 / (t_1 / (ky * Math.sin(th)));
} else {
tmp = Math.abs(Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if th <= 0.00046: tmp = math.sin(ky) * (1.0 / (t_1 / th)) elif (th <= 5.3e+39) or not (th <= 3.1e+73): tmp = 1.0 / (t_1 / (ky * math.sin(th))) else: tmp = math.fabs(math.sin(th)) return tmp
function code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)) tmp = 0.0 if (th <= 0.00046) tmp = Float64(sin(ky) * Float64(1.0 / Float64(t_1 / th))); elseif ((th <= 5.3e+39) || !(th <= 3.1e+73)) tmp = Float64(1.0 / Float64(t_1 / Float64(ky * sin(th)))); else tmp = abs(sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)); tmp = 0.0; if (th <= 0.00046) tmp = sin(ky) * (1.0 / (t_1 / th)); elseif ((th <= 5.3e+39) || ~((th <= 3.1e+73))) tmp = 1.0 / (t_1 / (ky * sin(th))); else tmp = abs(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[th, 0.00046], N[(N[Sin[ky], $MachinePrecision] * N[(1.0 / N[(t$95$1 / th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[th, 5.3e+39], N[Not[LessEqual[th, 3.1e+73]], $MachinePrecision]], N[(1.0 / N[(t$95$1 / N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
\mathbf{if}\;th \leq 0.00046:\\
\;\;\;\;\sin ky \cdot \frac{1}{\frac{t\_1}{th}}\\
\mathbf{elif}\;th \leq 5.3 \cdot 10^{+39} \lor \neg \left(th \leq 3.1 \cdot 10^{+73}\right):\\
\;\;\;\;\frac{1}{\frac{t\_1}{ky \cdot \sin th}}\\
\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\
\end{array}
\end{array}
if th < 4.6000000000000001e-4Initial program 93.8%
expm1-log1p-u93.7%
expm1-udef34.8%
Applied egg-rr37.6%
expm1-def99.7%
expm1-log1p99.7%
*-commutative99.7%
associate-*r/97.8%
associate-*l/99.6%
*-commutative99.6%
hypot-def93.7%
unpow293.7%
unpow293.7%
+-commutative93.7%
unpow293.7%
unpow293.7%
hypot-def99.6%
Simplified99.6%
clear-num99.5%
inv-pow99.5%
hypot-udef93.6%
+-commutative93.6%
hypot-udef99.5%
Applied egg-rr99.5%
unpow-199.5%
hypot-def93.6%
unpow293.6%
unpow293.6%
+-commutative93.6%
unpow293.6%
unpow293.6%
hypot-def99.5%
Simplified99.5%
Taylor expanded in th around 0 58.5%
associate-*l/58.6%
+-commutative58.6%
unpow258.6%
unpow258.6%
hypot-def61.5%
*-lft-identity61.5%
hypot-def58.6%
unpow258.6%
unpow258.6%
+-commutative58.6%
unpow258.6%
unpow258.6%
hypot-def61.5%
Simplified61.5%
if 4.6000000000000001e-4 < th < 5.29999999999999979e39 or 3.1e73 < th Initial program 90.9%
associate-*l/90.8%
clear-num90.7%
unpow290.7%
unpow290.7%
hypot-def99.3%
Applied egg-rr99.3%
Taylor expanded in ky around 0 56.2%
if 5.29999999999999979e39 < th < 3.1e73Initial program 99.7%
associate-*l/99.5%
clear-num98.9%
unpow298.9%
unpow298.9%
hypot-def98.9%
Applied egg-rr98.9%
Taylor expanded in kx around 0 36.9%
remove-double-div37.2%
add-sqr-sqrt12.2%
sqrt-unprod23.1%
pow223.1%
Applied egg-rr23.1%
unpow223.1%
rem-sqrt-square23.1%
Simplified23.1%
Final simplification58.8%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.005)
(* (sin th) (/ (- ky) (sin kx)))
(if (<= (sin kx) 5e-42)
(/ 1.0 (/ 1.0 (sin th)))
(* ky (/ (sin th) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.005) {
tmp = sin(th) * (-ky / sin(kx));
} else if (sin(kx) <= 5e-42) {
tmp = 1.0 / (1.0 / sin(th));
} else {
tmp = ky * (sin(th) / sin(kx));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.005d0)) then
tmp = sin(th) * (-ky / sin(kx))
else if (sin(kx) <= 5d-42) then
tmp = 1.0d0 / (1.0d0 / sin(th))
else
tmp = ky * (sin(th) / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.005) {
tmp = Math.sin(th) * (-ky / Math.sin(kx));
} else if (Math.sin(kx) <= 5e-42) {
tmp = 1.0 / (1.0 / Math.sin(th));
} else {
tmp = ky * (Math.sin(th) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.005: tmp = math.sin(th) * (-ky / math.sin(kx)) elif math.sin(kx) <= 5e-42: tmp = 1.0 / (1.0 / math.sin(th)) else: tmp = ky * (math.sin(th) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.005) tmp = Float64(sin(th) * Float64(Float64(-ky) / sin(kx))); elseif (sin(kx) <= 5e-42) tmp = Float64(1.0 / Float64(1.0 / sin(th))); else tmp = Float64(ky * Float64(sin(th) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.005) tmp = sin(th) * (-ky / sin(kx)); elseif (sin(kx) <= 5e-42) tmp = 1.0 / (1.0 / sin(th)); else tmp = ky * (sin(th) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[(N[Sin[th], $MachinePrecision] * N[((-ky) / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-42], N[(1.0 / N[(1.0 / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.005:\\
\;\;\;\;\sin th \cdot \frac{-ky}{\sin kx}\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-42}:\\
\;\;\;\;\frac{1}{\frac{1}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0050000000000000001Initial program 99.6%
Taylor expanded in ky around 0 17.8%
add-sqr-sqrt15.0%
sqrt-unprod25.4%
pow225.4%
*-commutative25.4%
associate-/l*25.3%
Applied egg-rr25.3%
Taylor expanded in ky around -inf 57.1%
mul-1-neg57.1%
associate-*l/57.3%
*-commutative57.3%
distribute-lft-neg-in57.3%
Simplified57.3%
if -0.0050000000000000001 < (sin.f64 kx) < 5.00000000000000003e-42Initial program 85.8%
associate-*l/83.6%
clear-num83.4%
unpow283.4%
unpow283.4%
hypot-def96.3%
Applied egg-rr96.3%
Taylor expanded in kx around 0 33.4%
if 5.00000000000000003e-42 < (sin.f64 kx) Initial program 99.4%
clear-num99.3%
associate-*l/99.5%
*-un-lft-identity99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 45.9%
associate-*r/45.9%
Simplified45.9%
Final simplification43.2%
(FPCore (kx ky th) :precision binary64 (if (<= ky 6.5e-80) (/ (/ (sin th) kx) (/ 1.0 ky)) (if (<= ky 8.5e+15) (sin th) (fabs (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 6.5e-80) {
tmp = (sin(th) / kx) / (1.0 / ky);
} else if (ky <= 8.5e+15) {
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 <= 6.5d-80) then
tmp = (sin(th) / kx) / (1.0d0 / ky)
else if (ky <= 8.5d+15) 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 <= 6.5e-80) {
tmp = (Math.sin(th) / kx) / (1.0 / ky);
} else if (ky <= 8.5e+15) {
tmp = Math.sin(th);
} else {
tmp = Math.abs(Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 6.5e-80: tmp = (math.sin(th) / kx) / (1.0 / ky) elif ky <= 8.5e+15: tmp = math.sin(th) else: tmp = math.fabs(math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 6.5e-80) tmp = Float64(Float64(sin(th) / kx) / Float64(1.0 / ky)); elseif (ky <= 8.5e+15) tmp = sin(th); else tmp = abs(sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 6.5e-80) tmp = (sin(th) / kx) / (1.0 / ky); elseif (ky <= 8.5e+15) tmp = sin(th); else tmp = abs(sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 6.5e-80], N[(N[(N[Sin[th], $MachinePrecision] / kx), $MachinePrecision] / N[(1.0 / ky), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 8.5e+15], N[Sin[th], $MachinePrecision], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 6.5 \cdot 10^{-80}:\\
\;\;\;\;\frac{\frac{\sin th}{kx}}{\frac{1}{ky}}\\
\mathbf{elif}\;ky \leq 8.5 \cdot 10^{+15}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\
\end{array}
\end{array}
if ky < 6.49999999999999984e-80Initial program 90.8%
Taylor expanded in ky around 0 30.2%
add-log-exp14.7%
*-commutative14.7%
associate-/l*14.7%
Applied egg-rr14.7%
rem-log-exp31.1%
div-inv31.1%
associate-/r*31.1%
Applied egg-rr31.1%
Taylor expanded in kx around 0 22.7%
if 6.49999999999999984e-80 < ky < 8.5e15Initial program 99.8%
Taylor expanded in kx around 0 51.3%
if 8.5e15 < ky Initial program 99.6%
associate-*l/99.6%
clear-num99.3%
unpow299.3%
unpow299.3%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in kx around 0 28.4%
remove-double-div28.4%
add-sqr-sqrt15.8%
sqrt-unprod24.1%
pow224.1%
Applied egg-rr24.1%
unpow224.1%
rem-sqrt-square34.1%
Simplified34.1%
Final simplification27.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky 3.4e-73) (* ky (/ (sin th) (sin kx))) (if (<= ky 8.5e+15) (sin th) (fabs (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3.4e-73) {
tmp = ky * (sin(th) / sin(kx));
} else if (ky <= 8.5e+15) {
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 <= 3.4d-73) then
tmp = ky * (sin(th) / sin(kx))
else if (ky <= 8.5d+15) 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 <= 3.4e-73) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else if (ky <= 8.5e+15) {
tmp = Math.sin(th);
} else {
tmp = Math.abs(Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 3.4e-73: tmp = ky * (math.sin(th) / math.sin(kx)) elif ky <= 8.5e+15: tmp = math.sin(th) else: tmp = math.fabs(math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 3.4e-73) tmp = Float64(ky * Float64(sin(th) / sin(kx))); elseif (ky <= 8.5e+15) tmp = sin(th); else tmp = abs(sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 3.4e-73) tmp = ky * (sin(th) / sin(kx)); elseif (ky <= 8.5e+15) tmp = sin(th); else tmp = abs(sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 3.4e-73], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 8.5e+15], N[Sin[th], $MachinePrecision], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 3.4 \cdot 10^{-73}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;ky \leq 8.5 \cdot 10^{+15}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\
\end{array}
\end{array}
if ky < 3.40000000000000021e-73Initial program 90.8%
clear-num90.7%
associate-*l/90.7%
*-un-lft-identity90.7%
unpow290.7%
unpow290.7%
hypot-def99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 30.2%
associate-*r/31.1%
Simplified31.1%
if 3.40000000000000021e-73 < ky < 8.5e15Initial program 99.8%
Taylor expanded in kx around 0 51.3%
if 8.5e15 < ky Initial program 99.6%
associate-*l/99.6%
clear-num99.3%
unpow299.3%
unpow299.3%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in kx around 0 28.4%
remove-double-div28.4%
add-sqr-sqrt15.8%
sqrt-unprod24.1%
pow224.1%
Applied egg-rr24.1%
unpow224.1%
rem-sqrt-square34.1%
Simplified34.1%
Final simplification33.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky 2.5e-87) (/ (/ (sin th) kx) (/ 1.0 ky)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 2.5e-87) {
tmp = (sin(th) / kx) / (1.0 / 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 (ky <= 2.5d-87) then
tmp = (sin(th) / kx) / (1.0d0 / ky)
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.5e-87) {
tmp = (Math.sin(th) / kx) / (1.0 / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 2.5e-87: tmp = (math.sin(th) / kx) / (1.0 / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 2.5e-87) tmp = Float64(Float64(sin(th) / kx) / Float64(1.0 / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 2.5e-87) tmp = (sin(th) / kx) / (1.0 / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 2.5e-87], N[(N[(N[Sin[th], $MachinePrecision] / kx), $MachinePrecision] / N[(1.0 / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 2.5 \cdot 10^{-87}:\\
\;\;\;\;\frac{\frac{\sin th}{kx}}{\frac{1}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 2.50000000000000021e-87Initial program 90.8%
Taylor expanded in ky around 0 30.2%
add-log-exp14.7%
*-commutative14.7%
associate-/l*14.7%
Applied egg-rr14.7%
rem-log-exp31.1%
div-inv31.1%
associate-/r*31.1%
Applied egg-rr31.1%
Taylor expanded in kx around 0 22.7%
if 2.50000000000000021e-87 < ky Initial program 99.7%
Taylor expanded in kx around 0 34.2%
Final simplification26.1%
(FPCore (kx ky th) :precision binary64 (if (<= ky 2.1e-85) (/ ky (/ kx (sin th))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 2.1e-85) {
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 <= 2.1d-85) 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 <= 2.1e-85) {
tmp = ky / (kx / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 2.1e-85: tmp = ky / (kx / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 2.1e-85) 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 <= 2.1e-85) tmp = ky / (kx / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 2.1e-85], N[(ky / N[(kx / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 2.1 \cdot 10^{-85}:\\
\;\;\;\;\frac{ky}{\frac{kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 2.1e-85Initial program 90.8%
Taylor expanded in ky around 0 30.2%
Taylor expanded in kx around 0 21.8%
associate-/l*22.8%
Simplified22.8%
if 2.1e-85 < ky Initial program 99.7%
Taylor expanded in kx around 0 34.2%
Final simplification26.1%
(FPCore (kx ky th) :precision binary64 (/ 1.0 (/ 1.0 (sin th))))
double code(double kx, double ky, double th) {
return 1.0 / (1.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 = 1.0d0 / (1.0d0 / sin(th))
end function
public static double code(double kx, double ky, double th) {
return 1.0 / (1.0 / Math.sin(th));
}
def code(kx, ky, th): return 1.0 / (1.0 / math.sin(th))
function code(kx, ky, th) return Float64(1.0 / Float64(1.0 / sin(th))) end
function tmp = code(kx, ky, th) tmp = 1.0 / (1.0 / sin(th)); end
code[kx_, ky_, th_] := N[(1.0 / N[(1.0 / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1}{\sin th}}
\end{array}
Initial program 93.4%
associate-*l/92.4%
clear-num92.1%
unpow292.1%
unpow292.1%
hypot-def97.9%
Applied egg-rr97.9%
Taylor expanded in kx around 0 20.0%
Final simplification20.0%
(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.4%
Taylor expanded in kx around 0 19.7%
Final simplification19.7%
(FPCore (kx ky th) :precision binary64 (/ 1.0 (+ (* th 0.16666666666666666) (/ 1.0 th))))
double code(double kx, double ky, double th) {
return 1.0 / ((th * 0.16666666666666666) + (1.0 / th));
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = 1.0d0 / ((th * 0.16666666666666666d0) + (1.0d0 / th))
end function
public static double code(double kx, double ky, double th) {
return 1.0 / ((th * 0.16666666666666666) + (1.0 / th));
}
def code(kx, ky, th): return 1.0 / ((th * 0.16666666666666666) + (1.0 / th))
function code(kx, ky, th) return Float64(1.0 / Float64(Float64(th * 0.16666666666666666) + Float64(1.0 / th))) end
function tmp = code(kx, ky, th) tmp = 1.0 / ((th * 0.16666666666666666) + (1.0 / th)); end
code[kx_, ky_, th_] := N[(1.0 / N[(N[(th * 0.16666666666666666), $MachinePrecision] + N[(1.0 / th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{th \cdot 0.16666666666666666 + \frac{1}{th}}
\end{array}
Initial program 93.4%
associate-*l/92.4%
clear-num92.1%
unpow292.1%
unpow292.1%
hypot-def97.9%
Applied egg-rr97.9%
Taylor expanded in kx around 0 20.0%
Taylor expanded in th around 0 13.0%
Final simplification13.0%
(FPCore (kx ky th) :precision binary64 (/ 1.0 (/ 1.0 th)))
double code(double kx, double ky, double th) {
return 1.0 / (1.0 / th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = 1.0d0 / (1.0d0 / th)
end function
public static double code(double kx, double ky, double th) {
return 1.0 / (1.0 / th);
}
def code(kx, ky, th): return 1.0 / (1.0 / th)
function code(kx, ky, th) return Float64(1.0 / Float64(1.0 / th)) end
function tmp = code(kx, ky, th) tmp = 1.0 / (1.0 / th); end
code[kx_, ky_, th_] := N[(1.0 / N[(1.0 / th), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1}{th}}
\end{array}
Initial program 93.4%
associate-*l/92.4%
clear-num92.1%
unpow292.1%
unpow292.1%
hypot-def97.9%
Applied egg-rr97.9%
Taylor expanded in kx around 0 20.0%
Taylor expanded in th around 0 12.3%
Final simplification12.3%
(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.4%
associate-*l/92.4%
clear-num92.1%
unpow292.1%
unpow292.1%
hypot-def97.9%
Applied egg-rr97.9%
Taylor expanded in kx around 0 20.0%
Taylor expanded in th around 0 12.0%
Final simplification12.0%
herbie shell --seed 2024033
(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)))