
(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 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 94.4%
+-commutative94.4%
unpow294.4%
unpow294.4%
hypot-undefine99.8%
Applied egg-rr99.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.0002) (- (sin th)) (if (<= (sin ky) 0.2) (/ ky (/ (hypot ky (sin kx)) (sin th))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0002) {
tmp = -sin(th);
} else if (sin(ky) <= 0.2) {
tmp = ky / (hypot(ky, sin(kx)) / sin(th));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.0002) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 0.2) {
tmp = ky / (Math.hypot(ky, Math.sin(kx)) / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.0002: tmp = -math.sin(th) elif math.sin(ky) <= 0.2: tmp = ky / (math.hypot(ky, math.sin(kx)) / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.0002) tmp = Float64(-sin(th)); elseif (sin(ky) <= 0.2) tmp = Float64(ky / Float64(hypot(ky, sin(kx)) / sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.0002) tmp = -sin(th); elseif (sin(ky) <= 0.2) tmp = ky / (hypot(ky, sin(kx)) / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.0002], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 0.2], N[(ky / N[(N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.0002:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 0.2:\\
\;\;\;\;\frac{ky}{\frac{\mathsf{hypot}\left(ky, \sin kx\right)}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2.0000000000000001e-4Initial program 99.8%
unpow299.8%
sqr-neg99.8%
sin-neg99.8%
sin-neg99.8%
unpow299.8%
associate-*l/99.8%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.7%
Taylor expanded in ky around 0 7.3%
Taylor expanded in ky around 0 32.8%
Taylor expanded in ky around -inf 60.3%
neg-mul-160.3%
Simplified60.3%
if -2.0000000000000001e-4 < (sin.f64 ky) < 0.20000000000000001Initial program 88.8%
unpow288.8%
sqr-neg88.8%
sin-neg88.8%
sin-neg88.8%
unpow288.8%
associate-*l/87.8%
associate-/l*88.6%
+-commutative88.6%
unpow288.6%
sin-neg88.6%
sin-neg88.6%
Simplified99.6%
Taylor expanded in ky around 0 94.3%
clear-num94.3%
un-div-inv94.4%
Applied egg-rr94.4%
Taylor expanded in ky around 0 94.7%
if 0.20000000000000001 < (sin.f64 ky) Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.4%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 59.4%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.0002) (- (sin th)) (if (<= (sin ky) 0.2) (* ky (/ (sin th) (hypot ky (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0002) {
tmp = -sin(th);
} else if (sin(ky) <= 0.2) {
tmp = ky * (sin(th) / hypot(ky, sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.0002) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 0.2) {
tmp = ky * (Math.sin(th) / Math.hypot(ky, Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.0002: tmp = -math.sin(th) elif math.sin(ky) <= 0.2: tmp = ky * (math.sin(th) / math.hypot(ky, math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.0002) tmp = Float64(-sin(th)); elseif (sin(ky) <= 0.2) tmp = Float64(ky * Float64(sin(th) / hypot(ky, sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.0002) tmp = -sin(th); elseif (sin(ky) <= 0.2) tmp = ky * (sin(th) / hypot(ky, sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.0002], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 0.2], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.0002:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 0.2:\\
\;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2.0000000000000001e-4Initial program 99.8%
unpow299.8%
sqr-neg99.8%
sin-neg99.8%
sin-neg99.8%
unpow299.8%
associate-*l/99.8%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.7%
Taylor expanded in ky around 0 7.3%
Taylor expanded in ky around 0 32.8%
Taylor expanded in ky around -inf 60.3%
neg-mul-160.3%
Simplified60.3%
if -2.0000000000000001e-4 < (sin.f64 ky) < 0.20000000000000001Initial program 88.8%
unpow288.8%
sqr-neg88.8%
sin-neg88.8%
sin-neg88.8%
unpow288.8%
associate-*l/87.8%
associate-/l*88.6%
+-commutative88.6%
unpow288.6%
sin-neg88.6%
sin-neg88.6%
Simplified99.6%
Taylor expanded in ky around 0 94.3%
Taylor expanded in ky around 0 94.6%
if 0.20000000000000001 < (sin.f64 ky) Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.4%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 59.4%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.0002) (- (sin th)) (if (<= (sin ky) 1e-67) (/ (* ky (sin th)) (fabs (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0002) {
tmp = -sin(th);
} else if (sin(ky) <= 1e-67) {
tmp = (ky * sin(th)) / fabs(sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.0002d0)) then
tmp = -sin(th)
else if (sin(ky) <= 1d-67) then
tmp = (ky * sin(th)) / abs(sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.0002) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 1e-67) {
tmp = (ky * Math.sin(th)) / Math.abs(Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.0002: tmp = -math.sin(th) elif math.sin(ky) <= 1e-67: tmp = (ky * math.sin(th)) / math.fabs(math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.0002) tmp = Float64(-sin(th)); elseif (sin(ky) <= 1e-67) tmp = Float64(Float64(ky * sin(th)) / abs(sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.0002) tmp = -sin(th); elseif (sin(ky) <= 1e-67) tmp = (ky * sin(th)) / abs(sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.0002], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-67], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.0002:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 10^{-67}:\\
\;\;\;\;\frac{ky \cdot \sin th}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2.0000000000000001e-4Initial program 99.8%
unpow299.8%
sqr-neg99.8%
sin-neg99.8%
sin-neg99.8%
unpow299.8%
associate-*l/99.8%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.7%
Taylor expanded in ky around 0 7.3%
Taylor expanded in ky around 0 32.8%
Taylor expanded in ky around -inf 60.3%
neg-mul-160.3%
Simplified60.3%
if -2.0000000000000001e-4 < (sin.f64 ky) < 9.99999999999999943e-68Initial program 87.3%
unpow287.3%
sqr-neg87.3%
sin-neg87.3%
sin-neg87.3%
unpow287.3%
associate-*l/86.2%
associate-/l*87.1%
+-commutative87.1%
unpow287.1%
sin-neg87.1%
sin-neg87.1%
Simplified99.6%
Taylor expanded in ky around 0 47.6%
add-sqr-sqrt38.0%
sqrt-unprod73.5%
pow273.5%
Applied egg-rr73.5%
unpow273.5%
rem-sqrt-square79.1%
Simplified79.1%
if 9.99999999999999943e-68 < (sin.f64 ky) Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.3%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 57.0%
(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 94.4%
unpow294.4%
sqr-neg94.4%
sin-neg94.4%
sin-neg94.4%
unpow294.4%
associate-*l/93.9%
associate-/l*94.3%
+-commutative94.3%
unpow294.3%
sin-neg94.3%
sin-neg94.3%
Simplified99.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.0002) (- (sin th)) (if (<= (sin ky) 1e-75) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0002) {
tmp = -sin(th);
} else if (sin(ky) <= 1e-75) {
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 (sin(ky) <= (-0.0002d0)) then
tmp = -sin(th)
else if (sin(ky) <= 1d-75) 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 (Math.sin(ky) <= -0.0002) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 1e-75) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.0002: tmp = -math.sin(th) elif math.sin(ky) <= 1e-75: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.0002) tmp = Float64(-sin(th)); elseif (sin(ky) <= 1e-75) 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 (sin(ky) <= -0.0002) tmp = -sin(th); elseif (sin(ky) <= 1e-75) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.0002], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-75], 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}\;\sin ky \leq -0.0002:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 10^{-75}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2.0000000000000001e-4Initial program 99.8%
unpow299.8%
sqr-neg99.8%
sin-neg99.8%
sin-neg99.8%
unpow299.8%
associate-*l/99.8%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.7%
Taylor expanded in ky around 0 7.3%
Taylor expanded in ky around 0 32.8%
Taylor expanded in ky around -inf 60.3%
neg-mul-160.3%
Simplified60.3%
if -2.0000000000000001e-4 < (sin.f64 ky) < 9.9999999999999996e-76Initial program 87.3%
Taylor expanded in ky around 0 50.4%
if 9.9999999999999996e-76 < (sin.f64 ky) Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.3%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 57.0%
Final simplification55.2%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.0002) (- (sin th)) (if (<= (sin ky) 1e-75) (* ky (/ (sin th) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0002) {
tmp = -sin(th);
} else if (sin(ky) <= 1e-75) {
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) <= (-0.0002d0)) then
tmp = -sin(th)
else if (sin(ky) <= 1d-75) 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) <= -0.0002) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 1e-75) {
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) <= -0.0002: tmp = -math.sin(th) elif math.sin(ky) <= 1e-75: 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) <= -0.0002) tmp = Float64(-sin(th)); elseif (sin(ky) <= 1e-75) 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) <= -0.0002) tmp = -sin(th); elseif (sin(ky) <= 1e-75) 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], -0.0002], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-75], 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 -0.0002:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 10^{-75}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2.0000000000000001e-4Initial program 99.8%
unpow299.8%
sqr-neg99.8%
sin-neg99.8%
sin-neg99.8%
unpow299.8%
associate-*l/99.8%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.7%
Taylor expanded in ky around 0 7.3%
Taylor expanded in ky around 0 32.8%
Taylor expanded in ky around -inf 60.3%
neg-mul-160.3%
Simplified60.3%
if -2.0000000000000001e-4 < (sin.f64 ky) < 9.9999999999999996e-76Initial program 87.3%
unpow287.3%
sqr-neg87.3%
sin-neg87.3%
sin-neg87.3%
unpow287.3%
associate-*l/86.2%
associate-/l*87.1%
+-commutative87.1%
unpow287.1%
sin-neg87.1%
sin-neg87.1%
Simplified99.6%
Taylor expanded in ky around 0 47.6%
associate-/l*50.4%
Simplified50.4%
if 9.9999999999999996e-76 < (sin.f64 ky) Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.3%
associate-/l*99.6%
+-commutative99.6%
unpow299.6%
sin-neg99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in kx around 0 57.0%
(FPCore (kx ky th) :precision binary64 (if (<= th 0.00026) (* (/ (sin ky) (hypot (sin ky) (sin kx))) th) (/ ky (/ (hypot ky (sin kx)) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.00026) {
tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th;
} else {
tmp = ky / (hypot(ky, sin(kx)) / sin(th));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.00026) {
tmp = (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * th;
} else {
tmp = ky / (Math.hypot(ky, Math.sin(kx)) / Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 0.00026: tmp = (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * th else: tmp = ky / (math.hypot(ky, math.sin(kx)) / math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 0.00026) tmp = Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * th); else tmp = Float64(ky / Float64(hypot(ky, sin(kx)) / sin(th))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 0.00026) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th; else tmp = ky / (hypot(ky, sin(kx)) / sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 0.00026], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], N[(ky / N[(N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 0.00026:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\frac{\mathsf{hypot}\left(ky, \sin kx\right)}{\sin th}}\\
\end{array}
\end{array}
if th < 2.59999999999999977e-4Initial program 95.1%
+-commutative95.1%
unpow295.1%
unpow295.1%
hypot-undefine99.8%
Applied egg-rr99.8%
Taylor expanded in th around 0 59.7%
if 2.59999999999999977e-4 < th Initial program 92.5%
unpow292.5%
sqr-neg92.5%
sin-neg92.5%
sin-neg92.5%
unpow292.5%
associate-*l/92.3%
associate-/l*92.4%
+-commutative92.4%
unpow292.4%
sin-neg92.4%
sin-neg92.4%
Simplified99.6%
Taylor expanded in ky around 0 49.8%
clear-num49.9%
un-div-inv49.9%
Applied egg-rr49.9%
Taylor expanded in ky around 0 69.3%
(FPCore (kx ky th) :precision binary64 (if (<= th 0.000106) (* (sin ky) (/ th (hypot (sin ky) (sin kx)))) (/ ky (/ (hypot ky (sin kx)) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.000106) {
tmp = sin(ky) * (th / hypot(sin(ky), sin(kx)));
} else {
tmp = ky / (hypot(ky, sin(kx)) / sin(th));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 0.000106) {
tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(ky), Math.sin(kx)));
} else {
tmp = ky / (Math.hypot(ky, Math.sin(kx)) / Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 0.000106: tmp = math.sin(ky) * (th / math.hypot(math.sin(ky), math.sin(kx))) else: tmp = ky / (math.hypot(ky, math.sin(kx)) / math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 0.000106) tmp = Float64(sin(ky) * Float64(th / hypot(sin(ky), sin(kx)))); else tmp = Float64(ky / Float64(hypot(ky, sin(kx)) / sin(th))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 0.000106) tmp = sin(ky) * (th / hypot(sin(ky), sin(kx))); else tmp = ky / (hypot(ky, sin(kx)) / sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 0.000106], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(ky / N[(N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 0.000106:\\
\;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\frac{\mathsf{hypot}\left(ky, \sin kx\right)}{\sin th}}\\
\end{array}
\end{array}
if th < 1.06e-4Initial program 95.1%
unpow295.1%
sqr-neg95.1%
sin-neg95.1%
sin-neg95.1%
unpow295.1%
associate-*l/94.4%
associate-/l*95.0%
+-commutative95.0%
unpow295.0%
sin-neg95.0%
sin-neg95.0%
Simplified99.6%
Taylor expanded in th around 0 59.6%
if 1.06e-4 < th Initial program 92.5%
unpow292.5%
sqr-neg92.5%
sin-neg92.5%
sin-neg92.5%
unpow292.5%
associate-*l/92.3%
associate-/l*92.4%
+-commutative92.4%
unpow292.4%
sin-neg92.4%
sin-neg92.4%
Simplified99.6%
Taylor expanded in ky around 0 49.8%
clear-num49.9%
un-div-inv49.9%
Applied egg-rr49.9%
Taylor expanded in ky around 0 69.3%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.05e-99) (* ky (/ (sin th) kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.05e-99) {
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 <= 1.05d-99) 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 <= 1.05e-99) {
tmp = ky * (Math.sin(th) / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.05e-99: tmp = ky * (math.sin(th) / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.05e-99) 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 <= 1.05e-99) tmp = ky * (sin(th) / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.05e-99], N[(ky * N[(N[Sin[th], $MachinePrecision] / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.05 \cdot 10^{-99}:\\
\;\;\;\;ky \cdot \frac{\sin th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.04999999999999992e-99Initial program 91.9%
unpow291.9%
sqr-neg91.9%
sin-neg91.9%
sin-neg91.9%
unpow291.9%
associate-*l/91.1%
associate-/l*91.8%
+-commutative91.8%
unpow291.8%
sin-neg91.8%
sin-neg91.8%
Simplified99.7%
Taylor expanded in ky around 0 30.9%
Taylor expanded in kx around 0 21.1%
associate-/l*22.8%
Simplified22.8%
if 1.04999999999999992e-99 < ky Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.5%
+-commutative99.5%
unpow299.5%
sin-neg99.5%
sin-neg99.5%
Simplified99.6%
Taylor expanded in kx around 0 36.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky 9e-80) (* ky (/ th (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 9e-80) {
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 <= 9d-80) 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 <= 9e-80) {
tmp = ky * (th / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 9e-80: tmp = ky * (th / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 9e-80) 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 <= 9e-80) tmp = ky * (th / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 9e-80], N[(ky * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 9 \cdot 10^{-80}:\\
\;\;\;\;ky \cdot \frac{th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 9.0000000000000006e-80Initial program 92.1%
unpow292.1%
sqr-neg92.1%
sin-neg92.1%
sin-neg92.1%
unpow292.1%
associate-*l/91.4%
associate-/l*92.1%
+-commutative92.1%
unpow292.1%
sin-neg92.1%
sin-neg92.1%
Simplified99.7%
Taylor expanded in ky around 0 63.6%
Taylor expanded in th around 0 31.5%
Taylor expanded in ky around 0 20.0%
associate-/l*21.7%
Simplified21.7%
if 9.0000000000000006e-80 < ky Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.5%
+-commutative99.5%
unpow299.5%
sin-neg99.5%
sin-neg99.5%
Simplified99.6%
Taylor expanded in kx around 0 35.2%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.7e-111) (* ky (/ th kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.7e-111) {
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.7d-111) 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.7e-111) {
tmp = ky * (th / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.7e-111: tmp = ky * (th / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.7e-111) 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.7e-111) tmp = ky * (th / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.7e-111], N[(ky * N[(th / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.7 \cdot 10^{-111}:\\
\;\;\;\;ky \cdot \frac{th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.69999999999999998e-111Initial program 91.8%
unpow291.8%
sqr-neg91.8%
sin-neg91.8%
sin-neg91.8%
unpow291.8%
associate-*l/91.0%
associate-/l*91.7%
+-commutative91.7%
unpow291.7%
sin-neg91.7%
sin-neg91.7%
Simplified99.7%
Taylor expanded in ky around 0 62.0%
Taylor expanded in th around 0 31.2%
Taylor expanded in ky around 0 20.2%
associate-/l*22.0%
Simplified22.0%
Taylor expanded in kx around 0 18.6%
if 1.69999999999999998e-111 < ky Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.5%
+-commutative99.5%
unpow299.5%
sin-neg99.5%
sin-neg99.5%
Simplified99.6%
Taylor expanded in kx around 0 36.9%
(FPCore (kx ky th) :precision binary64 (if (<= ky 6.5e-67) (* ky (/ th kx)) th))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 6.5e-67) {
tmp = ky * (th / kx);
} else {
tmp = th;
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 6.5d-67) then
tmp = ky * (th / kx)
else
tmp = th
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 6.5e-67) {
tmp = ky * (th / kx);
} else {
tmp = th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 6.5e-67: tmp = ky * (th / kx) else: tmp = th return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 6.5e-67) tmp = Float64(ky * Float64(th / kx)); else tmp = th; end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 6.5e-67) tmp = ky * (th / kx); else tmp = th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 6.5e-67], N[(ky * N[(th / kx), $MachinePrecision]), $MachinePrecision], th]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 6.5 \cdot 10^{-67}:\\
\;\;\;\;ky \cdot \frac{th}{kx}\\
\mathbf{else}:\\
\;\;\;\;th\\
\end{array}
\end{array}
if ky < 6.4999999999999997e-67Initial program 92.1%
unpow292.1%
sqr-neg92.1%
sin-neg92.1%
sin-neg92.1%
unpow292.1%
associate-*l/91.4%
associate-/l*92.1%
+-commutative92.1%
unpow292.1%
sin-neg92.1%
sin-neg92.1%
Simplified99.7%
Taylor expanded in ky around 0 63.6%
Taylor expanded in th around 0 31.5%
Taylor expanded in ky around 0 20.0%
associate-/l*21.7%
Simplified21.7%
Taylor expanded in kx around 0 18.5%
if 6.4999999999999997e-67 < ky Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.6%
associate-/l*99.5%
+-commutative99.5%
unpow299.5%
sin-neg99.5%
sin-neg99.5%
Simplified99.6%
Taylor expanded in kx around 0 35.2%
Taylor expanded in th around 0 13.6%
(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.4%
unpow294.4%
sqr-neg94.4%
sin-neg94.4%
sin-neg94.4%
unpow294.4%
associate-*l/93.9%
associate-/l*94.3%
+-commutative94.3%
unpow294.3%
sin-neg94.3%
sin-neg94.3%
Simplified99.6%
Taylor expanded in kx around 0 22.1%
Taylor expanded in th around 0 11.3%
herbie shell --seed 2024166
(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)))