
(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 13 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.6%
+-commutative93.6%
unpow293.6%
unpow293.6%
hypot-undefine99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin th) (sin kx))))
(if (<= (sin kx) -0.06)
(* ky (fabs t_1))
(if (<= (sin kx) 5e-76) (sin th) (* (sin ky) t_1)))))
double code(double kx, double ky, double th) {
double t_1 = sin(th) / sin(kx);
double tmp;
if (sin(kx) <= -0.06) {
tmp = ky * fabs(t_1);
} else if (sin(kx) <= 5e-76) {
tmp = sin(th);
} else {
tmp = sin(ky) * t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = sin(th) / sin(kx)
if (sin(kx) <= (-0.06d0)) then
tmp = ky * abs(t_1)
else if (sin(kx) <= 5d-76) then
tmp = sin(th)
else
tmp = sin(ky) * t_1
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(th) / Math.sin(kx);
double tmp;
if (Math.sin(kx) <= -0.06) {
tmp = ky * Math.abs(t_1);
} else if (Math.sin(kx) <= 5e-76) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(ky) * t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(th) / math.sin(kx) tmp = 0 if math.sin(kx) <= -0.06: tmp = ky * math.fabs(t_1) elif math.sin(kx) <= 5e-76: tmp = math.sin(th) else: tmp = math.sin(ky) * t_1 return tmp
function code(kx, ky, th) t_1 = Float64(sin(th) / sin(kx)) tmp = 0.0 if (sin(kx) <= -0.06) tmp = Float64(ky * abs(t_1)); elseif (sin(kx) <= 5e-76) tmp = sin(th); else tmp = Float64(sin(ky) * t_1); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(th) / sin(kx); tmp = 0.0; if (sin(kx) <= -0.06) tmp = ky * abs(t_1); elseif (sin(kx) <= 5e-76) tmp = sin(th); else tmp = sin(ky) * t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[kx], $MachinePrecision], -0.06], N[(ky * N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-76], N[Sin[th], $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin th}{\sin kx}\\
\mathbf{if}\;\sin kx \leq -0.06:\\
\;\;\;\;ky \cdot \left|t\_1\right|\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-76}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot t\_1\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.059999999999999998Initial program 99.4%
associate-*l/99.4%
associate-/l*99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
unpow299.5%
sin-neg99.5%
sin-neg99.5%
sqr-neg99.5%
unpow299.5%
Simplified99.4%
Taylor expanded in ky around 0 11.7%
associate-/l*11.7%
Simplified11.7%
add-sqr-sqrt3.3%
sqrt-unprod28.6%
pow228.6%
Applied egg-rr28.6%
unpow228.6%
rem-sqrt-square29.5%
Simplified29.5%
if -0.059999999999999998 < (sin.f64 kx) < 4.9999999999999998e-76Initial program 87.0%
associate-*l/80.4%
associate-/l*86.9%
unpow286.9%
sqr-neg86.9%
sin-neg86.9%
sin-neg86.9%
unpow286.9%
unpow286.9%
sin-neg86.9%
sin-neg86.9%
sqr-neg86.9%
unpow286.9%
Simplified99.8%
Taylor expanded in kx around 0 40.0%
if 4.9999999999999998e-76 < (sin.f64 kx) Initial program 99.5%
associate-*l/98.8%
associate-/l*99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
unpow299.4%
sin-neg99.4%
sin-neg99.4%
sqr-neg99.4%
unpow299.4%
Simplified99.4%
Taylor expanded in ky around 0 71.3%
Final simplification44.4%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.06) (* ky (fabs (/ (sin th) (sin kx)))) (if (<= (sin kx) 5e-76) (sin th) (/ (sin th) (/ (sin kx) (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.06) {
tmp = ky * fabs((sin(th) / sin(kx)));
} else if (sin(kx) <= 5e-76) {
tmp = sin(th);
} else {
tmp = sin(th) / (sin(kx) / sin(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(kx) <= (-0.06d0)) then
tmp = ky * abs((sin(th) / sin(kx)))
else if (sin(kx) <= 5d-76) then
tmp = sin(th)
else
tmp = sin(th) / (sin(kx) / sin(ky))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.06) {
tmp = ky * Math.abs((Math.sin(th) / Math.sin(kx)));
} else if (Math.sin(kx) <= 5e-76) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) / (Math.sin(kx) / Math.sin(ky));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.06: tmp = ky * math.fabs((math.sin(th) / math.sin(kx))) elif math.sin(kx) <= 5e-76: tmp = math.sin(th) else: tmp = math.sin(th) / (math.sin(kx) / math.sin(ky)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.06) tmp = Float64(ky * abs(Float64(sin(th) / sin(kx)))); elseif (sin(kx) <= 5e-76) tmp = sin(th); else tmp = Float64(sin(th) / Float64(sin(kx) / sin(ky))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.06) tmp = ky * abs((sin(th) / sin(kx))); elseif (sin(kx) <= 5e-76) tmp = sin(th); else tmp = sin(th) / (sin(kx) / sin(ky)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.06], N[(ky * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-76], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.06:\\
\;\;\;\;ky \cdot \left|\frac{\sin th}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-76}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.059999999999999998Initial program 99.4%
associate-*l/99.4%
associate-/l*99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
unpow299.5%
sin-neg99.5%
sin-neg99.5%
sqr-neg99.5%
unpow299.5%
Simplified99.4%
Taylor expanded in ky around 0 11.7%
associate-/l*11.7%
Simplified11.7%
add-sqr-sqrt3.3%
sqrt-unprod28.6%
pow228.6%
Applied egg-rr28.6%
unpow228.6%
rem-sqrt-square29.5%
Simplified29.5%
if -0.059999999999999998 < (sin.f64 kx) < 4.9999999999999998e-76Initial program 87.0%
associate-*l/80.4%
associate-/l*86.9%
unpow286.9%
sqr-neg86.9%
sin-neg86.9%
sin-neg86.9%
unpow286.9%
unpow286.9%
sin-neg86.9%
sin-neg86.9%
sqr-neg86.9%
unpow286.9%
Simplified99.8%
Taylor expanded in kx around 0 40.0%
if 4.9999999999999998e-76 < (sin.f64 kx) Initial program 99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-undefine99.5%
Applied egg-rr99.5%
*-commutative99.5%
clear-num99.4%
un-div-inv99.4%
Applied egg-rr99.4%
Taylor expanded in ky around 0 71.3%
Final simplification44.4%
(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.6%
associate-*l/90.4%
associate-/l*93.6%
unpow293.6%
sqr-neg93.6%
sin-neg93.6%
sin-neg93.6%
unpow293.6%
unpow293.6%
sin-neg93.6%
sin-neg93.6%
sqr-neg93.6%
unpow293.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.06) (* ky (fabs (/ (sin th) (sin kx)))) (if (<= (sin kx) 5e-76) (sin th) (/ (sin th) (/ (sin kx) ky)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.06) {
tmp = ky * fabs((sin(th) / sin(kx)));
} else if (sin(kx) <= 5e-76) {
tmp = sin(th);
} else {
tmp = sin(th) / (sin(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(kx) <= (-0.06d0)) then
tmp = ky * abs((sin(th) / sin(kx)))
else if (sin(kx) <= 5d-76) then
tmp = sin(th)
else
tmp = sin(th) / (sin(kx) / ky)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.06) {
tmp = ky * Math.abs((Math.sin(th) / Math.sin(kx)));
} else if (Math.sin(kx) <= 5e-76) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) / (Math.sin(kx) / ky);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.06: tmp = ky * math.fabs((math.sin(th) / math.sin(kx))) elif math.sin(kx) <= 5e-76: tmp = math.sin(th) else: tmp = math.sin(th) / (math.sin(kx) / ky) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.06) tmp = Float64(ky * abs(Float64(sin(th) / sin(kx)))); elseif (sin(kx) <= 5e-76) tmp = sin(th); else tmp = Float64(sin(th) / Float64(sin(kx) / ky)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.06) tmp = ky * abs((sin(th) / sin(kx))); elseif (sin(kx) <= 5e-76) tmp = sin(th); else tmp = sin(th) / (sin(kx) / ky); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.06], N[(ky * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 5e-76], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.06:\\
\;\;\;\;ky \cdot \left|\frac{\sin th}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 5 \cdot 10^{-76}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.059999999999999998Initial program 99.4%
associate-*l/99.4%
associate-/l*99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
unpow299.5%
sin-neg99.5%
sin-neg99.5%
sqr-neg99.5%
unpow299.5%
Simplified99.4%
Taylor expanded in ky around 0 11.7%
associate-/l*11.7%
Simplified11.7%
add-sqr-sqrt3.3%
sqrt-unprod28.6%
pow228.6%
Applied egg-rr28.6%
unpow228.6%
rem-sqrt-square29.5%
Simplified29.5%
if -0.059999999999999998 < (sin.f64 kx) < 4.9999999999999998e-76Initial program 87.0%
associate-*l/80.4%
associate-/l*86.9%
unpow286.9%
sqr-neg86.9%
sin-neg86.9%
sin-neg86.9%
unpow286.9%
unpow286.9%
sin-neg86.9%
sin-neg86.9%
sqr-neg86.9%
unpow286.9%
Simplified99.8%
Taylor expanded in kx around 0 40.0%
if 4.9999999999999998e-76 < (sin.f64 kx) Initial program 99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-undefine99.5%
Applied egg-rr99.5%
*-commutative99.5%
clear-num99.4%
un-div-inv99.4%
Applied egg-rr99.4%
Taylor expanded in ky around 0 65.4%
Final simplification43.0%
(FPCore (kx ky th) :precision binary64 (if (<= ky 8.5e-8) (* (/ 1.0 (hypot (sin ky) (sin kx))) (* ky (sin th))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 8.5e-8) {
tmp = (1.0 / hypot(sin(ky), sin(kx))) * (ky * sin(th));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 8.5e-8) {
tmp = (1.0 / Math.hypot(Math.sin(ky), Math.sin(kx))) * (ky * Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 8.5e-8: tmp = (1.0 / math.hypot(math.sin(ky), math.sin(kx))) * (ky * math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 8.5e-8) tmp = Float64(Float64(1.0 / hypot(sin(ky), sin(kx))) * Float64(ky * sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 8.5e-8) tmp = (1.0 / hypot(sin(ky), sin(kx))) * (ky * sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 8.5e-8], N[(N[(1.0 / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 8.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \left(ky \cdot \sin th\right)\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 8.49999999999999935e-8Initial program 91.9%
+-commutative91.9%
unpow291.9%
unpow291.9%
hypot-undefine99.7%
Applied egg-rr99.7%
associate-*l/95.1%
clear-num95.0%
Applied egg-rr95.0%
associate-/r/94.9%
Simplified94.9%
Taylor expanded in ky around 0 60.3%
if 8.49999999999999935e-8 < ky Initial program 99.7%
associate-*l/99.6%
associate-/l*99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
unpow299.5%
sin-neg99.5%
sin-neg99.5%
sqr-neg99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in kx around 0 32.2%
Final simplification54.1%
(FPCore (kx ky th) :precision binary64 (let* ((t_1 (/ 1.0 (hypot (sin ky) (sin kx))))) (if (<= ky 0.32) (* t_1 (* ky (sin th))) (* t_1 (* (sin ky) th)))))
double code(double kx, double ky, double th) {
double t_1 = 1.0 / hypot(sin(ky), sin(kx));
double tmp;
if (ky <= 0.32) {
tmp = t_1 * (ky * sin(th));
} else {
tmp = t_1 * (sin(ky) * th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = 1.0 / Math.hypot(Math.sin(ky), Math.sin(kx));
double tmp;
if (ky <= 0.32) {
tmp = t_1 * (ky * Math.sin(th));
} else {
tmp = t_1 * (Math.sin(ky) * th);
}
return tmp;
}
def code(kx, ky, th): t_1 = 1.0 / math.hypot(math.sin(ky), math.sin(kx)) tmp = 0 if ky <= 0.32: tmp = t_1 * (ky * math.sin(th)) else: tmp = t_1 * (math.sin(ky) * th) return tmp
function code(kx, ky, th) t_1 = Float64(1.0 / hypot(sin(ky), sin(kx))) tmp = 0.0 if (ky <= 0.32) tmp = Float64(t_1 * Float64(ky * sin(th))); else tmp = Float64(t_1 * Float64(sin(ky) * th)); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = 1.0 / hypot(sin(ky), sin(kx)); tmp = 0.0; if (ky <= 0.32) tmp = t_1 * (ky * sin(th)); else tmp = t_1 * (sin(ky) * th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(1.0 / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ky, 0.32], N[(t$95$1 * N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{1}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{if}\;ky \leq 0.32:\\
\;\;\;\;t\_1 \cdot \left(ky \cdot \sin th\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(\sin ky \cdot th\right)\\
\end{array}
\end{array}
if ky < 0.320000000000000007Initial program 91.9%
+-commutative91.9%
unpow291.9%
unpow291.9%
hypot-undefine99.7%
Applied egg-rr99.7%
associate-*l/95.1%
clear-num95.0%
Applied egg-rr95.0%
associate-/r/95.0%
Simplified95.0%
Taylor expanded in ky around 0 60.5%
if 0.320000000000000007 < ky Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-undefine99.6%
Applied egg-rr99.6%
associate-*l/99.5%
clear-num99.4%
Applied egg-rr99.4%
associate-/r/99.5%
Simplified99.5%
Taylor expanded in th around 0 58.9%
Final simplification60.1%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.35e-82) (* ky (/ (sin th) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.35e-82) {
tmp = ky * (sin(th) / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 1.35d-82) then
tmp = ky * (sin(th) / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.35e-82) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.35e-82: tmp = ky * (math.sin(th) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.35e-82) tmp = Float64(ky * Float64(sin(th) / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.35e-82) tmp = ky * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.35e-82], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.35 \cdot 10^{-82}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.3500000000000001e-82Initial program 91.4%
associate-*l/87.7%
associate-/l*91.4%
unpow291.4%
sqr-neg91.4%
sin-neg91.4%
sin-neg91.4%
unpow291.4%
unpow291.4%
sin-neg91.4%
sin-neg91.4%
sqr-neg91.4%
unpow291.4%
Simplified99.6%
Taylor expanded in ky around 0 29.1%
associate-/l*31.3%
Simplified31.3%
if 1.3500000000000001e-82 < ky Initial program 99.7%
associate-*l/97.5%
associate-/l*99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
sqr-neg99.6%
unpow299.6%
Simplified99.5%
Taylor expanded in kx around 0 35.7%
Final simplification32.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.95e-85) (/ (sin th) (/ (sin kx) ky)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.95e-85) {
tmp = sin(th) / (sin(kx) / ky);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 1.95d-85) then
tmp = sin(th) / (sin(kx) / ky)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.95e-85) {
tmp = Math.sin(th) / (Math.sin(kx) / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.95e-85: tmp = math.sin(th) / (math.sin(kx) / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.95e-85) tmp = Float64(sin(th) / Float64(sin(kx) / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.95e-85) tmp = sin(th) / (sin(kx) / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.95e-85], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.95 \cdot 10^{-85}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.94999999999999994e-85Initial program 91.4%
+-commutative91.4%
unpow291.4%
unpow291.4%
hypot-undefine99.7%
Applied egg-rr99.7%
*-commutative99.7%
clear-num99.6%
un-div-inv99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 31.3%
if 1.94999999999999994e-85 < ky Initial program 99.7%
associate-*l/97.5%
associate-/l*99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
sqr-neg99.6%
unpow299.6%
Simplified99.5%
Taylor expanded in kx around 0 35.7%
Final simplification32.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.55e-133) (* ky (/ th (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.55e-133) {
tmp = ky * (th / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 1.55d-133) then
tmp = ky * (th / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.55e-133) {
tmp = ky * (th / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.55e-133: tmp = ky * (th / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.55e-133) tmp = Float64(ky * Float64(th / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.55e-133) tmp = ky * (th / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.55e-133], N[(ky * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.55 \cdot 10^{-133}:\\
\;\;\;\;ky \cdot \frac{th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.55000000000000008e-133Initial program 91.0%
associate-*l/87.7%
associate-/l*91.0%
unpow291.0%
sqr-neg91.0%
sin-neg91.0%
sin-neg91.0%
unpow291.0%
unpow291.0%
sin-neg91.0%
sin-neg91.0%
sqr-neg91.0%
unpow291.0%
Simplified99.6%
Taylor expanded in ky around 0 27.0%
associate-/l*29.3%
Simplified29.3%
Taylor expanded in th around 0 17.6%
if 1.55000000000000008e-133 < ky Initial program 99.7%
associate-*l/96.5%
associate-/l*99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
sqr-neg99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 34.0%
Final simplification22.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky 3.8e-85) (* ky (/ (sin th) kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3.8e-85) {
tmp = ky * (sin(th) / 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-85) then
tmp = ky * (sin(th) / 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-85) {
tmp = ky * (Math.sin(th) / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 3.8e-85: tmp = ky * (math.sin(th) / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 3.8e-85) tmp = Float64(ky * Float64(sin(th) / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 3.8e-85) tmp = ky * (sin(th) / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 3.8e-85], N[(ky * N[(N[Sin[th], $MachinePrecision] / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 3.8 \cdot 10^{-85}:\\
\;\;\;\;ky \cdot \frac{\sin th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 3.7999999999999999e-85Initial program 91.4%
associate-*l/87.7%
associate-/l*91.4%
unpow291.4%
sqr-neg91.4%
sin-neg91.4%
sin-neg91.4%
unpow291.4%
unpow291.4%
sin-neg91.4%
sin-neg91.4%
sqr-neg91.4%
unpow291.4%
Simplified99.6%
Taylor expanded in ky around 0 29.1%
associate-/l*31.3%
Simplified31.3%
Taylor expanded in kx around 0 23.3%
if 3.7999999999999999e-85 < ky Initial program 99.7%
associate-*l/97.5%
associate-/l*99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
sqr-neg99.6%
unpow299.6%
Simplified99.5%
Taylor expanded in kx around 0 35.7%
Final simplification26.7%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.2e-119) (* ky (/ th kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.2e-119) {
tmp = ky * (th / 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-119) then
tmp = ky * (th / 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-119) {
tmp = ky * (th / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.2e-119: tmp = ky * (th / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.2e-119) tmp = Float64(ky * Float64(th / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.2e-119) tmp = ky * (th / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.2e-119], N[(ky * N[(th / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.2 \cdot 10^{-119}:\\
\;\;\;\;ky \cdot \frac{th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.20000000000000004e-119Initial program 91.0%
associate-*l/87.7%
associate-/l*91.0%
unpow291.0%
sqr-neg91.0%
sin-neg91.0%
sin-neg91.0%
unpow291.0%
unpow291.0%
sin-neg91.0%
sin-neg91.0%
sqr-neg91.0%
unpow291.0%
Simplified99.6%
Taylor expanded in ky around 0 27.0%
associate-/l*29.3%
Simplified29.3%
Taylor expanded in th around 0 17.6%
Taylor expanded in kx around 0 14.2%
associate-/l*16.5%
Simplified16.5%
if 1.20000000000000004e-119 < ky Initial program 99.7%
associate-*l/96.5%
associate-/l*99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
sqr-neg99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 34.0%
Final simplification21.8%
(FPCore (kx ky th) :precision binary64 (* ky (/ th kx)))
double code(double kx, double ky, double th) {
return ky * (th / kx);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = ky * (th / kx)
end function
public static double code(double kx, double ky, double th) {
return ky * (th / kx);
}
def code(kx, ky, th): return ky * (th / kx)
function code(kx, ky, th) return Float64(ky * Float64(th / kx)) end
function tmp = code(kx, ky, th) tmp = ky * (th / kx); end
code[kx_, ky_, th_] := N[(ky * N[(th / kx), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
ky \cdot \frac{th}{kx}
\end{array}
Initial program 93.6%
associate-*l/90.4%
associate-/l*93.6%
unpow293.6%
sqr-neg93.6%
sin-neg93.6%
sin-neg93.6%
unpow293.6%
unpow293.6%
sin-neg93.6%
sin-neg93.6%
sqr-neg93.6%
unpow293.6%
Simplified99.6%
Taylor expanded in ky around 0 23.8%
associate-/l*25.3%
Simplified25.3%
Taylor expanded in th around 0 15.2%
Taylor expanded in kx around 0 11.8%
associate-/l*13.4%
Simplified13.4%
Final simplification13.4%
herbie shell --seed 2024052
(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)))