
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (hypot (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th
\end{array}
Initial program 93.4%
remove-double-neg93.4%
sin-neg93.4%
neg-mul-193.4%
*-commutative93.4%
associate-*l*93.4%
associate-*l/90.7%
associate-/r/90.7%
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
(if (<= (sin ky) 1e-302)
(* (sin ky) (/ (sin th) (sin kx)))
(if (<= (sin ky) 5e-6)
(/ (* ky (sin th)) (hypot (sin kx) (sin ky)))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-302) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else if (sin(ky) <= 5e-6) {
tmp = (ky * sin(th)) / hypot(sin(kx), sin(ky));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= 1e-302) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else if (Math.sin(ky) <= 5e-6) {
tmp = (ky * Math.sin(th)) / Math.hypot(Math.sin(kx), Math.sin(ky));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-302: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) elif math.sin(ky) <= 5e-6: tmp = (ky * math.sin(th)) / math.hypot(math.sin(kx), math.sin(ky)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-302) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); elseif (sin(ky) <= 5e-6) tmp = Float64(Float64(ky * sin(th)) / hypot(sin(kx), sin(ky))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 1e-302) tmp = sin(ky) * (sin(th) / sin(kx)); elseif (sin(ky) <= 5e-6) tmp = (ky * sin(th)) / hypot(sin(kx), sin(ky)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-302], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-6], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-302}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{ky \cdot \sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 9.9999999999999996e-303Initial program 92.0%
remove-double-neg92.0%
sin-neg92.0%
neg-mul-192.0%
*-commutative92.0%
associate-*l*92.0%
associate-*l/89.6%
associate-/r/89.6%
associate-*l/92.0%
associate-/r/91.9%
sin-neg91.9%
neg-mul-191.9%
associate-/r*91.9%
associate-/r/92.0%
Simplified99.6%
*-commutative99.6%
clear-num99.5%
un-div-inv99.6%
hypot-udef91.9%
unpow291.9%
unpow291.9%
+-commutative91.9%
unpow291.9%
unpow291.9%
hypot-def99.6%
Applied egg-rr99.6%
associate-/r/99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 30.4%
if 9.9999999999999996e-303 < (sin.f64 ky) < 5.00000000000000041e-6Initial program 89.5%
remove-double-neg89.5%
sin-neg89.5%
neg-mul-189.5%
*-commutative89.5%
associate-*l*89.5%
associate-*l/83.2%
associate-/r/83.2%
associate-*l/89.5%
associate-/r/89.5%
sin-neg89.5%
neg-mul-189.5%
associate-/r*89.5%
associate-/r/89.5%
Simplified99.8%
expm1-log1p-u99.7%
expm1-udef43.2%
hypot-udef39.7%
unpow239.7%
unpow239.7%
+-commutative39.7%
unpow239.7%
unpow239.7%
hypot-def43.2%
Applied egg-rr43.2%
expm1-def99.7%
expm1-log1p99.8%
associate-*l/88.5%
Simplified88.5%
Taylor expanded in ky around 0 88.5%
if 5.00000000000000041e-6 < (sin.f64 ky) Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.7%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.7%
Simplified99.8%
Taylor expanded in kx around 0 62.2%
Final simplification51.5%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.005)
(* (sin th) (fabs (/ ky (sin kx))))
(if (<= (sin kx) 5e-62)
(/ (sin th) (+ 1.0 (* 0.5 (* (/ kx ky) (/ kx ky)))))
(/ (sin ky) (/ (sin kx) (sin th))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.005) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else if (sin(kx) <= 5e-62) {
tmp = sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky))));
} else {
tmp = sin(ky) / (sin(kx) / 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(kx) <= (-0.005d0)) then
tmp = sin(th) * abs((ky / sin(kx)))
else if (sin(kx) <= 5d-62) then
tmp = sin(th) / (1.0d0 + (0.5d0 * ((kx / ky) * (kx / ky))))
else
tmp = sin(ky) / (sin(kx) / sin(th))
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) * Math.abs((ky / Math.sin(kx)));
} else if (Math.sin(kx) <= 5e-62) {
tmp = Math.sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky))));
} else {
tmp = Math.sin(ky) / (Math.sin(kx) / Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.005: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) elif math.sin(kx) <= 5e-62: tmp = math.sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky)))) else: tmp = math.sin(ky) / (math.sin(kx) / math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.005) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); elseif (sin(kx) <= 5e-62) tmp = Float64(sin(th) / Float64(1.0 + Float64(0.5 * Float64(Float64(kx / ky) * Float64(kx / ky))))); else tmp = Float64(sin(ky) / Float64(sin(kx) / sin(th))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.005) tmp = sin(th) * abs((ky / sin(kx))); elseif (sin(kx) <= 5e-62) tmp = sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky)))); else tmp = sin(ky) / (sin(kx) / sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-62], N[(N[Sin[th], $MachinePrecision] / N[(1.0 + N[(0.5 * N[(N[(kx / ky), $MachinePrecision] * N[(kx / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.005:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-62}:\\
\;\;\;\;\frac{\sin th}{1 + 0.5 \cdot \left(\frac{kx}{ky} \cdot \frac{kx}{ky}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0050000000000000001Initial program 99.4%
Taylor expanded in ky around 0 14.8%
add-sqr-sqrt9.6%
sqrt-unprod23.8%
pow223.8%
Applied egg-rr23.8%
unpow223.8%
rem-sqrt-square27.8%
Simplified27.8%
if -0.0050000000000000001 < (sin.f64 kx) < 5.0000000000000002e-62Initial program 86.0%
remove-double-neg86.0%
sin-neg86.0%
neg-mul-186.0%
*-commutative86.0%
associate-*l*86.0%
associate-*l/80.9%
associate-/r/80.9%
associate-*l/86.0%
associate-/r/85.9%
sin-neg85.9%
neg-mul-185.9%
associate-/r*85.9%
associate-/r/86.0%
Simplified99.9%
*-commutative99.9%
clear-num99.9%
un-div-inv99.9%
hypot-udef86.0%
unpow286.0%
unpow286.0%
+-commutative86.0%
unpow286.0%
unpow286.0%
hypot-def99.9%
Applied egg-rr99.9%
Taylor expanded in kx around 0 45.6%
Taylor expanded in ky around 0 45.3%
unpow245.3%
unpow245.3%
times-frac47.7%
Applied egg-rr47.7%
if 5.0000000000000002e-62 < (sin.f64 kx) Initial program 99.5%
Taylor expanded in ky around 0 63.3%
associate-*l/62.1%
associate-/l*63.3%
Applied egg-rr63.3%
Final simplification47.5%
(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%
remove-double-neg93.4%
sin-neg93.4%
neg-mul-193.4%
*-commutative93.4%
associate-*l*93.4%
associate-*l/90.7%
associate-/r/90.7%
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%
expm1-log1p-u99.6%
expm1-udef48.5%
hypot-udef46.8%
unpow246.8%
unpow246.8%
+-commutative46.8%
unpow246.8%
unpow246.8%
hypot-def48.5%
Applied egg-rr48.5%
expm1-def99.6%
expm1-log1p99.7%
associate-*l/94.7%
*-commutative94.7%
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 (<= ky 8.4e-221)
(* (sin th) (fabs (/ ky (sin kx))))
(if (<= ky 8200000.0) (/ (* ky (sin th)) t_1) (/ (* (sin ky) th) t_1)))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (ky <= 8.4e-221) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else if (ky <= 8200000.0) {
tmp = (ky * sin(th)) / t_1;
} else {
tmp = (sin(ky) * th) / t_1;
}
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 (ky <= 8.4e-221) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else if (ky <= 8200000.0) {
tmp = (ky * Math.sin(th)) / t_1;
} else {
tmp = (Math.sin(ky) * th) / t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if ky <= 8.4e-221: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) elif ky <= 8200000.0: tmp = (ky * math.sin(th)) / t_1 else: tmp = (math.sin(ky) * th) / t_1 return tmp
function code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)) tmp = 0.0 if (ky <= 8.4e-221) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); elseif (ky <= 8200000.0) tmp = Float64(Float64(ky * sin(th)) / t_1); else tmp = Float64(Float64(sin(ky) * th) / t_1); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)); tmp = 0.0; if (ky <= 8.4e-221) tmp = sin(th) * abs((ky / sin(kx))); elseif (ky <= 8200000.0) tmp = (ky * sin(th)) / t_1; else tmp = (sin(ky) * th) / t_1; 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[ky, 8.4e-221], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 8200000.0], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] / t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
\mathbf{if}\;ky \leq 8.4 \cdot 10^{-221}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{elif}\;ky \leq 8200000:\\
\;\;\;\;\frac{ky \cdot \sin th}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky \cdot th}{t_1}\\
\end{array}
\end{array}
if ky < 8.4000000000000001e-221Initial program 90.3%
Taylor expanded in ky around 0 34.2%
add-sqr-sqrt13.6%
sqrt-unprod18.9%
pow218.9%
Applied egg-rr18.9%
unpow218.9%
rem-sqrt-square23.0%
Simplified23.0%
if 8.4000000000000001e-221 < ky < 8.2e6Initial program 95.0%
remove-double-neg95.0%
sin-neg95.0%
neg-mul-195.0%
*-commutative95.0%
associate-*l*95.0%
associate-*l/90.6%
associate-/r/90.6%
associate-*l/95.0%
associate-/r/94.9%
sin-neg94.9%
neg-mul-194.9%
associate-/r*94.9%
associate-/r/95.0%
Simplified99.7%
expm1-log1p-u99.6%
expm1-udef42.7%
hypot-udef40.5%
unpow240.5%
unpow240.5%
+-commutative40.5%
unpow240.5%
unpow240.5%
hypot-def42.7%
Applied egg-rr42.7%
expm1-def99.6%
expm1-log1p99.7%
associate-*l/93.1%
Simplified93.1%
Taylor expanded in ky around 0 91.0%
if 8.2e6 < ky Initial program 99.5%
remove-double-neg99.5%
sin-neg99.5%
neg-mul-199.5%
*-commutative99.5%
associate-*l*99.5%
associate-*l/99.4%
associate-/r/99.4%
associate-*l/99.5%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.5%
Simplified99.6%
expm1-log1p-u99.4%
expm1-udef60.2%
hypot-udef60.1%
unpow260.1%
unpow260.1%
+-commutative60.1%
unpow260.1%
unpow260.1%
hypot-def60.2%
Applied egg-rr60.2%
expm1-def99.4%
expm1-log1p99.6%
associate-*l/99.6%
Simplified99.6%
Taylor expanded in th around 0 44.9%
Final simplification39.5%
(FPCore (kx ky th) :precision binary64 (if (<= kx 6.5e-5) (/ (sin th) (+ 1.0 (* 0.5 (pow (/ kx (sin ky)) 2.0)))) (* (sin th) (fabs (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 6.5e-5) {
tmp = sin(th) / (1.0 + (0.5 * pow((kx / sin(ky)), 2.0)));
} else {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (kx <= 6.5d-5) then
tmp = sin(th) / (1.0d0 + (0.5d0 * ((kx / sin(ky)) ** 2.0d0)))
else
tmp = sin(th) * abs((sin(ky) / sin(kx)))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 6.5e-5) {
tmp = Math.sin(th) / (1.0 + (0.5 * Math.pow((kx / Math.sin(ky)), 2.0)));
} else {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 6.5e-5: tmp = math.sin(th) / (1.0 + (0.5 * math.pow((kx / math.sin(ky)), 2.0))) else: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 6.5e-5) tmp = Float64(sin(th) / Float64(1.0 + Float64(0.5 * (Float64(kx / sin(ky)) ^ 2.0)))); else tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 6.5e-5) tmp = sin(th) / (1.0 + (0.5 * ((kx / sin(ky)) ^ 2.0))); else tmp = sin(th) * abs((sin(ky) / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 6.5e-5], N[(N[Sin[th], $MachinePrecision] / N[(1.0 + N[(0.5 * N[Power[N[(kx / N[Sin[ky], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 6.5 \cdot 10^{-5}:\\
\;\;\;\;\frac{\sin th}{1 + 0.5 \cdot {\left(\frac{kx}{\sin ky}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\end{array}
\end{array}
if kx < 6.49999999999999943e-5Initial program 91.2%
remove-double-neg91.2%
sin-neg91.2%
neg-mul-191.2%
*-commutative91.2%
associate-*l*91.2%
associate-*l/87.5%
associate-/r/87.5%
associate-*l/91.2%
associate-/r/91.1%
sin-neg91.1%
neg-mul-191.1%
associate-/r*91.1%
associate-/r/91.2%
Simplified99.8%
*-commutative99.8%
clear-num99.7%
un-div-inv99.7%
hypot-udef91.2%
unpow291.2%
unpow291.2%
+-commutative91.2%
unpow291.2%
unpow291.2%
hypot-def99.7%
Applied egg-rr99.7%
Taylor expanded in kx around 0 36.4%
expm1-log1p-u36.4%
expm1-udef36.4%
add-sqr-sqrt36.4%
pow236.4%
sqrt-div36.4%
unpow236.4%
sqrt-prod10.7%
add-sqr-sqrt36.7%
unpow236.7%
sqrt-prod32.1%
add-sqr-sqrt37.8%
Applied egg-rr37.8%
expm1-def37.8%
expm1-log1p37.8%
Simplified37.8%
if 6.49999999999999943e-5 < kx Initial program 99.5%
Taylor expanded in ky around 0 41.3%
add-sqr-sqrt19.8%
sqrt-unprod27.4%
pow227.4%
Applied egg-rr27.4%
unpow227.4%
rem-sqrt-square31.1%
Simplified31.1%
Final simplification36.0%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 2e-170) (* (sin ky) (/ (sin th) kx)) (/ (sin th) (+ 1.0 (* 0.5 (* (/ kx ky) (/ kx ky)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 2e-170) {
tmp = sin(ky) * (sin(th) / kx);
} else {
tmp = sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky))));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= 2d-170) then
tmp = sin(ky) * (sin(th) / kx)
else
tmp = sin(th) / (1.0d0 + (0.5d0 * ((kx / ky) * (kx / ky))))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= 2e-170) {
tmp = Math.sin(ky) * (Math.sin(th) / kx);
} else {
tmp = Math.sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky))));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 2e-170: tmp = math.sin(ky) * (math.sin(th) / kx) else: tmp = math.sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky)))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 2e-170) tmp = Float64(sin(ky) * Float64(sin(th) / kx)); else tmp = Float64(sin(th) / Float64(1.0 + Float64(0.5 * Float64(Float64(kx / ky) * Float64(kx / ky))))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 2e-170) tmp = sin(ky) * (sin(th) / kx); else tmp = sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky)))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-170], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / kx), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(1.0 + N[(0.5 * N[(N[(kx / ky), $MachinePrecision] * N[(kx / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 2 \cdot 10^{-170}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{1 + 0.5 \cdot \left(\frac{kx}{ky} \cdot \frac{kx}{ky}\right)}\\
\end{array}
\end{array}
if (sin.f64 ky) < 1.99999999999999997e-170Initial program 89.4%
Taylor expanded in ky around 0 37.2%
clear-num37.2%
associate-/r/37.2%
Applied egg-rr37.2%
Taylor expanded in kx around 0 23.4%
Taylor expanded in kx around 0 21.0%
associate-*r/23.4%
Simplified23.4%
if 1.99999999999999997e-170 < (sin.f64 ky) Initial program 99.7%
remove-double-neg99.7%
sin-neg99.7%
neg-mul-199.7%
*-commutative99.7%
associate-*l*99.7%
associate-*l/98.0%
associate-/r/98.0%
associate-*l/99.7%
associate-/r/99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/r/99.7%
Simplified99.8%
*-commutative99.8%
clear-num99.8%
un-div-inv99.7%
hypot-udef99.7%
unpow299.7%
unpow299.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Applied egg-rr99.7%
Taylor expanded in kx around 0 56.6%
Taylor expanded in ky around 0 58.8%
unpow258.8%
unpow258.8%
times-frac59.5%
Applied egg-rr59.5%
Final simplification37.4%
(FPCore (kx ky th) :precision binary64 (if (<= ky 7.2e-50) (* (sin th) (fabs (/ ky (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 7.2e-50) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 7.2d-50) then
tmp = sin(th) * abs((ky / sin(kx)))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 7.2e-50) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 7.2e-50: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 7.2e-50) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 7.2e-50) tmp = sin(th) * abs((ky / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 7.2e-50], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 7.2 \cdot 10^{-50}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 7.19999999999999958e-50Initial program 91.0%
Taylor expanded in ky around 0 35.4%
add-sqr-sqrt18.0%
sqrt-unprod27.0%
pow227.0%
Applied egg-rr27.0%
unpow227.0%
rem-sqrt-square31.3%
Simplified31.3%
if 7.19999999999999958e-50 < ky Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.1%
associate-/r/99.1%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.7%
Taylor expanded in kx around 0 38.4%
Final simplification33.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky 3.8e-84) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3.8e-84) {
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 (ky <= 3.8d-84) 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 (ky <= 3.8e-84) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 3.8e-84: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 3.8e-84) 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 (ky <= 3.8e-84) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 3.8e-84], 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}\;ky \leq 3.8 \cdot 10^{-84}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 3.79999999999999986e-84Initial program 90.7%
Taylor expanded in ky around 0 35.3%
if 3.79999999999999986e-84 < ky Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/98.7%
associate-/r/98.7%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.7%
Taylor expanded in kx around 0 39.2%
Final simplification36.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky 8.5e-84) (/ ky (/ (sin kx) (sin th))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 8.5e-84) {
tmp = ky / (sin(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 <= 8.5d-84) then
tmp = ky / (sin(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 <= 8.5e-84) {
tmp = ky / (Math.sin(kx) / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 8.5e-84: tmp = ky / (math.sin(kx) / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 8.5e-84) tmp = Float64(ky / Float64(sin(kx) / sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 8.5e-84) tmp = ky / (sin(kx) / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 8.5e-84], N[(ky / N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 8.5 \cdot 10^{-84}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 8.4999999999999994e-84Initial program 90.7%
remove-double-neg90.7%
sin-neg90.7%
neg-mul-190.7%
*-commutative90.7%
associate-*l*90.7%
associate-*l/87.2%
associate-/r/87.2%
associate-*l/90.7%
associate-/r/90.5%
sin-neg90.5%
neg-mul-190.5%
associate-/r*90.5%
associate-/r/90.7%
Simplified99.7%
Taylor expanded in ky around 0 33.1%
associate-/l*35.3%
Simplified35.3%
if 8.4999999999999994e-84 < ky Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/98.7%
associate-/r/98.7%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.7%
Taylor expanded in kx around 0 39.2%
Final simplification36.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky 3.6e-170) (* (sin th) (/ ky kx)) (/ (sin th) (+ 1.0 (* 0.5 (* (/ kx ky) (/ kx ky)))))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3.6e-170) {
tmp = sin(th) * (ky / kx);
} else {
tmp = sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky))));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 3.6d-170) then
tmp = sin(th) * (ky / kx)
else
tmp = sin(th) / (1.0d0 + (0.5d0 * ((kx / ky) * (kx / ky))))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3.6e-170) {
tmp = Math.sin(th) * (ky / kx);
} else {
tmp = Math.sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky))));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 3.6e-170: tmp = math.sin(th) * (ky / kx) else: tmp = math.sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky)))) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 3.6e-170) tmp = Float64(sin(th) * Float64(ky / kx)); else tmp = Float64(sin(th) / Float64(1.0 + Float64(0.5 * Float64(Float64(kx / ky) * Float64(kx / ky))))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 3.6e-170) tmp = sin(th) * (ky / kx); else tmp = sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky)))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 3.6e-170], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(1.0 + N[(0.5 * N[(N[(kx / ky), $MachinePrecision] * N[(kx / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 3.6 \cdot 10^{-170}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{1 + 0.5 \cdot \left(\frac{kx}{ky} \cdot \frac{kx}{ky}\right)}\\
\end{array}
\end{array}
if ky < 3.6000000000000003e-170Initial program 89.5%
Taylor expanded in ky around 0 35.6%
Taylor expanded in kx around 0 23.2%
if 3.6000000000000003e-170 < ky Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/98.0%
associate-/r/98.0%
associate-*l/99.6%
associate-/r/99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/r/99.6%
Simplified99.7%
*-commutative99.7%
clear-num99.7%
un-div-inv99.7%
hypot-udef99.6%
unpow299.6%
unpow299.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.7%
Applied egg-rr99.7%
Taylor expanded in kx around 0 40.3%
Taylor expanded in ky around 0 40.8%
unpow240.8%
unpow240.8%
times-frac41.5%
Applied egg-rr41.5%
Final simplification30.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.2e-106) (* (sin th) (/ ky kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.2e-106) {
tmp = sin(th) * (ky / kx);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 1.2d-106) then
tmp = sin(th) * (ky / kx)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.2e-106) {
tmp = Math.sin(th) * (ky / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.2e-106: tmp = math.sin(th) * (ky / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.2e-106) tmp = Float64(sin(th) * Float64(ky / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.2e-106) tmp = sin(th) * (ky / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.2e-106], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.2 \cdot 10^{-106}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.1999999999999999e-106Initial program 90.2%
Taylor expanded in ky around 0 35.1%
Taylor expanded in kx around 0 23.0%
if 1.1999999999999999e-106 < ky Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/98.8%
associate-/r/98.8%
associate-*l/99.6%
associate-/r/99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/r/99.6%
Simplified99.7%
Taylor expanded in kx around 0 40.5%
Final simplification29.0%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.4e-106) (/ ky (/ kx (sin th))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.4e-106) {
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 <= 1.4d-106) 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 <= 1.4e-106) {
tmp = ky / (kx / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.4e-106: tmp = ky / (kx / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.4e-106) 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 <= 1.4e-106) tmp = ky / (kx / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.4e-106], N[(ky / N[(kx / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.4 \cdot 10^{-106}:\\
\;\;\;\;\frac{ky}{\frac{kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.39999999999999994e-106Initial program 90.2%
Taylor expanded in ky around 0 35.1%
Taylor expanded in kx around 0 20.8%
associate-/l*23.1%
Simplified23.1%
if 1.39999999999999994e-106 < ky Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/98.8%
associate-/r/98.8%
associate-*l/99.6%
associate-/r/99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/r/99.6%
Simplified99.7%
Taylor expanded in kx around 0 40.5%
Final simplification29.0%
(FPCore (kx ky th) :precision binary64 (if (<= ky 7.8e-145) (/ th (/ kx ky)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 7.8e-145) {
tmp = th / (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 (ky <= 7.8d-145) then
tmp = th / (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 (ky <= 7.8e-145) {
tmp = th / (kx / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 7.8e-145: tmp = th / (kx / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 7.8e-145) tmp = Float64(th / Float64(kx / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 7.8e-145) tmp = th / (kx / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 7.8e-145], N[(th / N[(kx / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 7.8 \cdot 10^{-145}:\\
\;\;\;\;\frac{th}{\frac{kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 7.80000000000000058e-145Initial program 89.6%
Taylor expanded in ky around 0 35.8%
Taylor expanded in kx around 0 23.6%
Taylor expanded in th around 0 17.3%
*-commutative17.3%
associate-/l*19.8%
Simplified19.8%
if 7.80000000000000058e-145 < ky Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/97.9%
associate-/r/97.9%
associate-*l/99.6%
associate-/r/99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/r/99.6%
Simplified99.7%
Taylor expanded in kx around 0 39.8%
Final simplification27.4%
(FPCore (kx ky th) :precision binary64 (/ ky (/ kx th)))
double code(double kx, double ky, double th) {
return ky / (kx / th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = ky / (kx / th)
end function
public static double code(double kx, double ky, double th) {
return ky / (kx / th);
}
def code(kx, ky, th): return ky / (kx / th)
function code(kx, ky, th) return Float64(ky / Float64(kx / th)) end
function tmp = code(kx, ky, th) tmp = ky / (kx / th); end
code[kx_, ky_, th_] := N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{ky}{\frac{kx}{th}}
\end{array}
Initial program 93.4%
Taylor expanded in ky around 0 26.2%
Taylor expanded in kx around 0 17.3%
Taylor expanded in th around 0 13.4%
associate-/l*14.9%
Simplified14.9%
Final simplification14.9%
herbie shell --seed 2023331
(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)))