
(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 14 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 94.1%
*-commutative94.1%
clear-num94.1%
+-commutative94.1%
unpow294.1%
unpow294.1%
hypot-udef99.6%
un-div-inv99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -2e-7)
(fabs (sin th))
(if (<= (sin ky) 4e-302)
(* ky (/ (sin th) (sin kx)))
(if (<= (sin ky) 2e-64)
(/ (fabs (/ ky (sin kx))) (/ 1.0 (sin th)))
(sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -2e-7) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 4e-302) {
tmp = ky * (sin(th) / sin(kx));
} else if (sin(ky) <= 2e-64) {
tmp = fabs((ky / sin(kx))) / (1.0 / 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 (sin(ky) <= (-2d-7)) then
tmp = abs(sin(th))
else if (sin(ky) <= 4d-302) then
tmp = ky * (sin(th) / sin(kx))
else if (sin(ky) <= 2d-64) then
tmp = abs((ky / sin(kx))) / (1.0d0 / 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 (Math.sin(ky) <= -2e-7) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 4e-302) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else if (Math.sin(ky) <= 2e-64) {
tmp = Math.abs((ky / Math.sin(kx))) / (1.0 / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -2e-7: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 4e-302: tmp = ky * (math.sin(th) / math.sin(kx)) elif math.sin(ky) <= 2e-64: tmp = math.fabs((ky / math.sin(kx))) / (1.0 / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -2e-7) tmp = abs(sin(th)); elseif (sin(ky) <= 4e-302) tmp = Float64(ky * Float64(sin(th) / sin(kx))); elseif (sin(ky) <= 2e-64) tmp = Float64(abs(Float64(ky / sin(kx))) / Float64(1.0 / sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -2e-7) tmp = abs(sin(th)); elseif (sin(ky) <= 4e-302) tmp = ky * (sin(th) / sin(kx)); elseif (sin(ky) <= 2e-64) tmp = abs((ky / sin(kx))) / (1.0 / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -2e-7], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 4e-302], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-64], N[(N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(1.0 / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -2 \cdot 10^{-7}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 4 \cdot 10^{-302}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-64}:\\
\;\;\;\;\frac{\left|\frac{ky}{\sin kx}\right|}{\frac{1}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1.9999999999999999e-7Initial program 99.7%
associate-/r/99.7%
+-commutative99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in kx around 0 2.9%
associate-/r/2.9%
*-inverses2.9%
*-un-lft-identity2.9%
add-sqr-sqrt1.4%
sqrt-unprod25.3%
pow225.3%
Applied egg-rr25.3%
unpow225.3%
rem-sqrt-square33.7%
Simplified33.7%
if -1.9999999999999999e-7 < (sin.f64 ky) < 3.9999999999999999e-302Initial program 91.3%
associate-/r/91.3%
+-commutative91.3%
unpow291.3%
sqr-neg91.3%
sin-neg91.3%
sin-neg91.3%
unpow291.3%
+-commutative91.3%
Simplified99.6%
clear-num98.4%
associate-/r/99.5%
clear-num99.6%
hypot-udef91.3%
unpow291.3%
unpow291.3%
+-commutative91.3%
unpow291.3%
unpow291.3%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 48.6%
associate-/l*49.5%
*-rgt-identity49.5%
associate-*r/49.5%
associate-/r/49.6%
associate-*l/49.7%
*-lft-identity49.7%
Simplified49.7%
if 3.9999999999999999e-302 < (sin.f64 ky) < 1.99999999999999993e-64Initial program 78.8%
associate-*l/74.5%
+-commutative74.5%
unpow274.5%
unpow274.5%
hypot-udef85.7%
associate-/l*99.6%
div-inv99.5%
associate-/r*99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 58.4%
add-sqr-sqrt51.9%
sqrt-unprod60.5%
pow260.5%
Applied egg-rr60.5%
unpow260.5%
rem-sqrt-square84.1%
Simplified84.1%
if 1.99999999999999993e-64 < (sin.f64 ky) Initial program 99.6%
Taylor expanded in kx around 0 60.6%
Final simplification55.1%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.02)
(* (sin th) (/ (sin ky) (sin kx)))
(if (<= (sin th) 2e-8)
(* th (/ (sin ky) (hypot (sin ky) (sin kx))))
(/ (sin ky) (fabs (/ (sin ky) (sin th)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.02) {
tmp = sin(th) * (sin(ky) / sin(kx));
} else if (sin(th) <= 2e-8) {
tmp = th * (sin(ky) / hypot(sin(ky), sin(kx)));
} else {
tmp = sin(ky) / fabs((sin(ky) / sin(th)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(th) <= -0.02) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
} else if (Math.sin(th) <= 2e-8) {
tmp = th * (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx)));
} else {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / Math.sin(th)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(th) <= -0.02: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) elif math.sin(th) <= 2e-8: tmp = th * (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) else: tmp = math.sin(ky) / math.fabs((math.sin(ky) / math.sin(th))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(th) <= -0.02) tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); elseif (sin(th) <= 2e-8) tmp = Float64(th * Float64(sin(ky) / hypot(sin(ky), sin(kx)))); else tmp = Float64(sin(ky) / abs(Float64(sin(ky) / sin(th)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(th) <= -0.02) tmp = sin(th) * (sin(ky) / sin(kx)); elseif (sin(th) <= 2e-8) tmp = th * (sin(ky) / hypot(sin(ky), sin(kx))); else tmp = sin(ky) / abs((sin(ky) / sin(th))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[th], $MachinePrecision], -0.02], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 2e-8], N[(th * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -0.02:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\mathbf{elif}\;\sin th \leq 2 \cdot 10^{-8}:\\
\;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\end{array}
\end{array}
if (sin.f64 th) < -0.0200000000000000004Initial program 96.5%
Taylor expanded in ky around 0 28.2%
if -0.0200000000000000004 < (sin.f64 th) < 2e-8Initial program 91.4%
associate-*l/87.6%
+-commutative87.6%
unpow287.6%
unpow287.6%
hypot-def89.6%
Simplified89.6%
Taylor expanded in th around 0 89.6%
*-commutative89.6%
Simplified89.6%
associate-/l*99.6%
associate-/r/99.7%
Applied egg-rr99.7%
if 2e-8 < (sin.f64 th) Initial program 97.3%
associate-/r/97.2%
+-commutative97.2%
unpow297.2%
sqr-neg97.2%
sin-neg97.2%
sin-neg97.2%
unpow297.2%
+-commutative97.2%
Simplified99.6%
Taylor expanded in kx around 0 25.4%
add-sqr-sqrt24.6%
sqrt-unprod40.3%
pow240.3%
Applied egg-rr40.3%
unpow240.3%
rem-sqrt-square40.9%
Simplified40.9%
Final simplification67.3%
(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 94.1%
+-commutative94.1%
unpow294.1%
unpow294.1%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))))
(if (or (<= th -0.0036) (not (<= th 0.0062)))
(/ (* (sin th) ky) t_1)
(* th (/ (sin ky) t_1)))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double tmp;
if ((th <= -0.0036) || !(th <= 0.0062)) {
tmp = (sin(th) * ky) / t_1;
} else {
tmp = th * (sin(ky) / t_1);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(ky), Math.sin(kx));
double tmp;
if ((th <= -0.0036) || !(th <= 0.0062)) {
tmp = (Math.sin(th) * ky) / t_1;
} else {
tmp = th * (Math.sin(ky) / t_1);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) tmp = 0 if (th <= -0.0036) or not (th <= 0.0062): tmp = (math.sin(th) * ky) / t_1 else: tmp = th * (math.sin(ky) / t_1) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) tmp = 0.0 if ((th <= -0.0036) || !(th <= 0.0062)) tmp = Float64(Float64(sin(th) * ky) / t_1); else tmp = Float64(th * Float64(sin(ky) / t_1)); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)); tmp = 0.0; if ((th <= -0.0036) || ~((th <= 0.0062))) tmp = (sin(th) * ky) / t_1; else tmp = th * (sin(ky) / t_1); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]}, If[Or[LessEqual[th, -0.0036], N[Not[LessEqual[th, 0.0062]], $MachinePrecision]], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / t$95$1), $MachinePrecision], N[(th * N[(N[Sin[ky], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
\mathbf{if}\;th \leq -0.0036 \lor \neg \left(th \leq 0.0062\right):\\
\;\;\;\;\frac{\sin th \cdot ky}{t_1}\\
\mathbf{else}:\\
\;\;\;\;th \cdot \frac{\sin ky}{t_1}\\
\end{array}
\end{array}
if th < -0.0035999999999999999 or 0.00619999999999999978 < th Initial program 96.9%
associate-*l/96.8%
+-commutative96.8%
unpow296.8%
unpow296.8%
hypot-def99.5%
Simplified99.5%
Taylor expanded in ky around 0 49.7%
if -0.0035999999999999999 < th < 0.00619999999999999978Initial program 91.4%
associate-*l/87.6%
+-commutative87.6%
unpow287.6%
unpow287.6%
hypot-def89.6%
Simplified89.6%
Taylor expanded in th around 0 89.6%
*-commutative89.6%
Simplified89.6%
associate-/l*99.6%
associate-/r/99.7%
Applied egg-rr99.7%
Final simplification74.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -2e-7) (fabs (sin th)) (if (<= (sin ky) 2e-64) (* ky (/ (sin th) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -2e-7) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 2e-64) {
tmp = ky * (sin(th) / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-2d-7)) then
tmp = abs(sin(th))
else if (sin(ky) <= 2d-64) then
tmp = ky * (sin(th) / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -2e-7) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 2e-64) {
tmp = 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) <= -2e-7: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 2e-64: tmp = 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) <= -2e-7) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-64) tmp = Float64(ky * Float64(sin(th) / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -2e-7) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-64) tmp = ky * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -2e-7], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-64], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -2 \cdot 10^{-7}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-64}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1.9999999999999999e-7Initial program 99.7%
associate-/r/99.7%
+-commutative99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in kx around 0 2.9%
associate-/r/2.9%
*-inverses2.9%
*-un-lft-identity2.9%
add-sqr-sqrt1.4%
sqrt-unprod25.3%
pow225.3%
Applied egg-rr25.3%
unpow225.3%
rem-sqrt-square33.7%
Simplified33.7%
if -1.9999999999999999e-7 < (sin.f64 ky) < 1.99999999999999993e-64Initial program 85.4%
associate-/r/85.4%
+-commutative85.4%
unpow285.4%
sqr-neg85.4%
sin-neg85.4%
sin-neg85.4%
unpow285.4%
+-commutative85.4%
Simplified99.6%
clear-num98.4%
associate-/r/99.5%
clear-num99.6%
hypot-udef85.4%
unpow285.4%
unpow285.4%
+-commutative85.4%
unpow285.4%
unpow285.4%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 52.3%
associate-/l*53.7%
*-rgt-identity53.7%
associate-*r/53.7%
associate-/r/53.8%
associate-*l/53.7%
*-lft-identity53.7%
Simplified53.7%
if 1.99999999999999993e-64 < (sin.f64 ky) Initial program 99.6%
Taylor expanded in kx around 0 60.6%
Final simplification50.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky -1.6e-91) (fabs (sin th)) (if (<= ky 1.52e-64) (/ (/ ky kx) (/ 1.0 (sin th))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -1.6e-91) {
tmp = fabs(sin(th));
} else if (ky <= 1.52e-64) {
tmp = (ky / kx) / (1.0 / 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.6d-91)) then
tmp = abs(sin(th))
else if (ky <= 1.52d-64) then
tmp = (ky / kx) / (1.0d0 / 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.6e-91) {
tmp = Math.abs(Math.sin(th));
} else if (ky <= 1.52e-64) {
tmp = (ky / kx) / (1.0 / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -1.6e-91: tmp = math.fabs(math.sin(th)) elif ky <= 1.52e-64: tmp = (ky / kx) / (1.0 / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -1.6e-91) tmp = abs(sin(th)); elseif (ky <= 1.52e-64) tmp = Float64(Float64(ky / kx) / Float64(1.0 / sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -1.6e-91) tmp = abs(sin(th)); elseif (ky <= 1.52e-64) tmp = (ky / kx) / (1.0 / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -1.6e-91], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[ky, 1.52e-64], N[(N[(ky / kx), $MachinePrecision] / N[(1.0 / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -1.6 \cdot 10^{-91}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;ky \leq 1.52 \cdot 10^{-64}:\\
\;\;\;\;\frac{\frac{ky}{kx}}{\frac{1}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -1.59999999999999998e-91Initial program 99.7%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in kx around 0 26.4%
associate-/r/26.5%
*-inverses26.5%
*-un-lft-identity26.5%
add-sqr-sqrt15.3%
sqrt-unprod26.4%
pow226.4%
Applied egg-rr26.4%
unpow226.4%
rem-sqrt-square36.1%
Simplified36.1%
if -1.59999999999999998e-91 < ky < 1.5200000000000001e-64Initial program 82.7%
associate-*l/78.3%
+-commutative78.3%
unpow278.3%
unpow278.3%
hypot-udef85.5%
associate-/l*99.6%
div-inv99.6%
associate-/r*99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 56.3%
Taylor expanded in kx around 0 35.6%
if 1.5200000000000001e-64 < ky Initial program 99.6%
Taylor expanded in kx around 0 36.9%
Final simplification36.2%
(FPCore (kx ky th) :precision binary64 (if (<= ky -170000000.0) (sin th) (if (<= ky 4e-64) (/ (/ ky kx) (/ 1.0 (sin th))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -170000000.0) {
tmp = sin(th);
} else if (ky <= 4e-64) {
tmp = (ky / kx) / (1.0 / 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 <= (-170000000.0d0)) then
tmp = sin(th)
else if (ky <= 4d-64) then
tmp = (ky / kx) / (1.0d0 / 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 <= -170000000.0) {
tmp = Math.sin(th);
} else if (ky <= 4e-64) {
tmp = (ky / kx) / (1.0 / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -170000000.0: tmp = math.sin(th) elif ky <= 4e-64: tmp = (ky / kx) / (1.0 / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -170000000.0) tmp = sin(th); elseif (ky <= 4e-64) tmp = Float64(Float64(ky / kx) / Float64(1.0 / sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -170000000.0) tmp = sin(th); elseif (ky <= 4e-64) tmp = (ky / kx) / (1.0 / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -170000000.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 4e-64], N[(N[(ky / kx), $MachinePrecision] / N[(1.0 / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -170000000:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 4 \cdot 10^{-64}:\\
\;\;\;\;\frac{\frac{ky}{kx}}{\frac{1}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -1.7e8 or 3.99999999999999986e-64 < ky Initial program 99.7%
Taylor expanded in kx around 0 34.8%
if -1.7e8 < ky < 3.99999999999999986e-64Initial program 86.0%
associate-*l/81.5%
+-commutative81.5%
unpow281.5%
unpow281.5%
hypot-udef87.3%
associate-/l*99.6%
div-inv99.5%
associate-/r*99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 52.9%
Taylor expanded in kx around 0 31.5%
Final simplification33.4%
(FPCore (kx ky th) :precision binary64 (if (<= ky -170000000.0) (sin th) (if (<= ky 2.25e-69) (+ 1.0 (+ (sin th) -1.0)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -170000000.0) {
tmp = sin(th);
} else if (ky <= 2.25e-69) {
tmp = 1.0 + (sin(th) + -1.0);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= (-170000000.0d0)) then
tmp = sin(th)
else if (ky <= 2.25d-69) then
tmp = 1.0d0 + (sin(th) + (-1.0d0))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -170000000.0) {
tmp = Math.sin(th);
} else if (ky <= 2.25e-69) {
tmp = 1.0 + (Math.sin(th) + -1.0);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -170000000.0: tmp = math.sin(th) elif ky <= 2.25e-69: tmp = 1.0 + (math.sin(th) + -1.0) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -170000000.0) tmp = sin(th); elseif (ky <= 2.25e-69) tmp = Float64(1.0 + Float64(sin(th) + -1.0)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -170000000.0) tmp = sin(th); elseif (ky <= 2.25e-69) tmp = 1.0 + (sin(th) + -1.0); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -170000000.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 2.25e-69], N[(1.0 + N[(N[Sin[th], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -170000000:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 2.25 \cdot 10^{-69}:\\
\;\;\;\;1 + \left(\sin th + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -1.7e8 or 2.25000000000000005e-69 < ky Initial program 99.7%
Taylor expanded in kx around 0 34.6%
if -1.7e8 < ky < 2.25000000000000005e-69Initial program 85.8%
associate-/r/85.8%
+-commutative85.8%
unpow285.8%
sqr-neg85.8%
sin-neg85.8%
sin-neg85.8%
unpow285.8%
+-commutative85.8%
Simplified99.6%
Taylor expanded in kx around 0 11.1%
associate-/r/11.2%
*-inverses11.2%
*-un-lft-identity11.2%
expm1-log1p-u11.1%
Applied egg-rr11.1%
expm1-udef25.6%
log1p-udef25.6%
add-exp-log25.6%
Applied egg-rr25.6%
associate--l+25.5%
Simplified25.5%
Final simplification31.0%
(FPCore (kx ky th) :precision binary64 (if (<= ky -6.2e-6) (sin th) (if (<= ky 5.6e-71) (+ (+ (sin th) 1.0) -1.0) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -6.2e-6) {
tmp = sin(th);
} else if (ky <= 5.6e-71) {
tmp = (sin(th) + 1.0) + -1.0;
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= (-6.2d-6)) then
tmp = sin(th)
else if (ky <= 5.6d-71) then
tmp = (sin(th) + 1.0d0) + (-1.0d0)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -6.2e-6) {
tmp = Math.sin(th);
} else if (ky <= 5.6e-71) {
tmp = (Math.sin(th) + 1.0) + -1.0;
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -6.2e-6: tmp = math.sin(th) elif ky <= 5.6e-71: tmp = (math.sin(th) + 1.0) + -1.0 else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -6.2e-6) tmp = sin(th); elseif (ky <= 5.6e-71) tmp = Float64(Float64(sin(th) + 1.0) + -1.0); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -6.2e-6) tmp = sin(th); elseif (ky <= 5.6e-71) tmp = (sin(th) + 1.0) + -1.0; else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -6.2e-6], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 5.6e-71], N[(N[(N[Sin[th], $MachinePrecision] + 1.0), $MachinePrecision] + -1.0), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -6.2 \cdot 10^{-6}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 5.6 \cdot 10^{-71}:\\
\;\;\;\;\left(\sin th + 1\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -6.1999999999999999e-6 or 5.60000000000000001e-71 < ky Initial program 99.7%
Taylor expanded in kx around 0 34.0%
if -6.1999999999999999e-6 < ky < 5.60000000000000001e-71Initial program 85.4%
associate-/r/85.4%
+-commutative85.4%
unpow285.4%
sqr-neg85.4%
sin-neg85.4%
sin-neg85.4%
unpow285.4%
+-commutative85.4%
Simplified99.6%
Taylor expanded in kx around 0 11.4%
associate-/r/11.5%
*-inverses11.5%
*-un-lft-identity11.5%
expm1-log1p-u11.4%
Applied egg-rr11.4%
expm1-udef26.3%
log1p-udef26.3%
add-exp-log26.3%
Applied egg-rr26.3%
Final simplification31.0%
(FPCore (kx ky th) :precision binary64 (if (<= ky -170000000.0) (sin th) (if (<= ky 1.6e-64) (/ ky (/ kx (sin th))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -170000000.0) {
tmp = sin(th);
} else if (ky <= 1.6e-64) {
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 <= (-170000000.0d0)) then
tmp = sin(th)
else if (ky <= 1.6d-64) 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 <= -170000000.0) {
tmp = Math.sin(th);
} else if (ky <= 1.6e-64) {
tmp = ky / (kx / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -170000000.0: tmp = math.sin(th) elif ky <= 1.6e-64: tmp = ky / (kx / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -170000000.0) tmp = sin(th); elseif (ky <= 1.6e-64) 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 <= -170000000.0) tmp = sin(th); elseif (ky <= 1.6e-64) tmp = ky / (kx / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -170000000.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 1.6e-64], N[(ky / N[(kx / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -170000000:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 1.6 \cdot 10^{-64}:\\
\;\;\;\;\frac{ky}{\frac{kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -1.7e8 or 1.59999999999999988e-64 < ky Initial program 99.7%
Taylor expanded in kx around 0 34.8%
if -1.7e8 < ky < 1.59999999999999988e-64Initial program 86.0%
associate-*l/81.5%
+-commutative81.5%
unpow281.5%
unpow281.5%
hypot-udef87.3%
associate-/l*99.6%
div-inv99.5%
associate-/r*99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 52.9%
Taylor expanded in kx around 0 30.2%
associate-/l*31.4%
Simplified31.4%
Final simplification33.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 94.1%
Taylor expanded in kx around 0 25.2%
Final simplification25.2%
(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 94.1%
associate-/r/94.1%
+-commutative94.1%
unpow294.1%
sqr-neg94.1%
sin-neg94.1%
sin-neg94.1%
unpow294.1%
+-commutative94.1%
Simplified99.6%
Taylor expanded in th around 0 48.5%
+-commutative48.5%
unpow248.5%
unpow248.5%
hypot-def52.7%
associate-*r*52.7%
unpow252.7%
unpow252.7%
hypot-def52.7%
distribute-rgt-out52.7%
Simplified52.7%
Taylor expanded in kx around 0 16.3%
Final simplification16.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 94.1%
associate-/r/94.1%
+-commutative94.1%
unpow294.1%
sqr-neg94.1%
sin-neg94.1%
sin-neg94.1%
unpow294.1%
+-commutative94.1%
Simplified99.6%
Taylor expanded in kx around 0 25.1%
Taylor expanded in th around 0 15.8%
Final simplification15.8%
herbie shell --seed 2023285
(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)))