
(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 16 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 92.8%
remove-double-neg92.8%
sin-neg92.8%
neg-mul-192.8%
*-commutative92.8%
associate-*l*92.8%
associate-*l/91.9%
associate-/r/91.9%
associate-*l/92.8%
associate-/r/92.7%
sin-neg92.7%
neg-mul-192.7%
associate-/r*92.7%
associate-/r/92.8%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.05)
(* (sin th) (fabs (/ ky (sin kx))))
(if (<= (sin kx) 4e-142)
(sin th)
(if (<= (sin kx) 2e-66)
(/ (sin ky) (/ kx (sin th)))
(if (<= (sin kx) 1e-44) (sin th) (* (sin th) (/ (sin ky) (sin kx))))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.05) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else if (sin(kx) <= 4e-142) {
tmp = sin(th);
} else if (sin(kx) <= 2e-66) {
tmp = sin(ky) / (kx / sin(th));
} else if (sin(kx) <= 1e-44) {
tmp = sin(th);
} else {
tmp = sin(th) * (sin(ky) / sin(kx));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.05d0)) then
tmp = sin(th) * abs((ky / sin(kx)))
else if (sin(kx) <= 4d-142) then
tmp = sin(th)
else if (sin(kx) <= 2d-66) then
tmp = sin(ky) / (kx / sin(th))
else if (sin(kx) <= 1d-44) then
tmp = sin(th)
else
tmp = sin(th) * (sin(ky) / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.05) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else if (Math.sin(kx) <= 4e-142) {
tmp = Math.sin(th);
} else if (Math.sin(kx) <= 2e-66) {
tmp = Math.sin(ky) / (kx / Math.sin(th));
} else if (Math.sin(kx) <= 1e-44) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.05: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) elif math.sin(kx) <= 4e-142: tmp = math.sin(th) elif math.sin(kx) <= 2e-66: tmp = math.sin(ky) / (kx / math.sin(th)) elif math.sin(kx) <= 1e-44: tmp = math.sin(th) else: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.05) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); elseif (sin(kx) <= 4e-142) tmp = sin(th); elseif (sin(kx) <= 2e-66) tmp = Float64(sin(ky) / Float64(kx / sin(th))); elseif (sin(kx) <= 1e-44) tmp = sin(th); else tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.05) tmp = sin(th) * abs((ky / sin(kx))); elseif (sin(kx) <= 4e-142) tmp = sin(th); elseif (sin(kx) <= 2e-66) tmp = sin(ky) / (kx / sin(th)); elseif (sin(kx) <= 1e-44) tmp = sin(th); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.05], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 4e-142], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-66], N[(N[Sin[ky], $MachinePrecision] / N[(kx / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-44], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.05:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 4 \cdot 10^{-142}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-66}:\\
\;\;\;\;\frac{\sin ky}{\frac{kx}{\sin th}}\\
\mathbf{elif}\;\sin kx \leq 10^{-44}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.050000000000000003Initial program 99.3%
Taylor expanded in ky around 0 10.5%
associate-/l*10.5%
associate-/r/10.5%
Simplified10.5%
add-sqr-sqrt7.6%
sqrt-unprod14.8%
pow214.8%
Applied egg-rr14.8%
unpow214.8%
rem-sqrt-square18.0%
Simplified18.0%
if -0.050000000000000003 < (sin.f64 kx) < 4.0000000000000002e-142 or 2e-66 < (sin.f64 kx) < 9.99999999999999953e-45Initial program 83.5%
Taylor expanded in kx around 0 33.7%
if 4.0000000000000002e-142 < (sin.f64 kx) < 2e-66Initial program 99.7%
Taylor expanded in ky around 0 48.0%
Taylor expanded in kx around 0 48.0%
associate-/l*48.1%
Simplified48.1%
if 9.99999999999999953e-45 < (sin.f64 kx) Initial program 99.4%
Taylor expanded in ky around 0 61.6%
Final simplification38.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.05)
(* (sin th) (fabs (/ ky (sin kx))))
(if (<= (sin kx) 4e-142)
(sin th)
(if (<= (sin kx) 2e-66)
(/ (sin ky) (/ kx (sin th)))
(if (<= (sin kx) 1e-44) (sin th) (* (sin ky) (/ (sin th) (sin kx))))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.05) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else if (sin(kx) <= 4e-142) {
tmp = sin(th);
} else if (sin(kx) <= 2e-66) {
tmp = sin(ky) / (kx / sin(th));
} else if (sin(kx) <= 1e-44) {
tmp = sin(th);
} else {
tmp = sin(ky) * (sin(th) / sin(kx));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.05d0)) then
tmp = sin(th) * abs((ky / sin(kx)))
else if (sin(kx) <= 4d-142) then
tmp = sin(th)
else if (sin(kx) <= 2d-66) then
tmp = sin(ky) / (kx / sin(th))
else if (sin(kx) <= 1d-44) then
tmp = sin(th)
else
tmp = sin(ky) * (sin(th) / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.05) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else if (Math.sin(kx) <= 4e-142) {
tmp = Math.sin(th);
} else if (Math.sin(kx) <= 2e-66) {
tmp = Math.sin(ky) / (kx / Math.sin(th));
} else if (Math.sin(kx) <= 1e-44) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.05: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) elif math.sin(kx) <= 4e-142: tmp = math.sin(th) elif math.sin(kx) <= 2e-66: tmp = math.sin(ky) / (kx / math.sin(th)) elif math.sin(kx) <= 1e-44: tmp = math.sin(th) else: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.05) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); elseif (sin(kx) <= 4e-142) tmp = sin(th); elseif (sin(kx) <= 2e-66) tmp = Float64(sin(ky) / Float64(kx / sin(th))); elseif (sin(kx) <= 1e-44) tmp = sin(th); else tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.05) tmp = sin(th) * abs((ky / sin(kx))); elseif (sin(kx) <= 4e-142) tmp = sin(th); elseif (sin(kx) <= 2e-66) tmp = sin(ky) / (kx / sin(th)); elseif (sin(kx) <= 1e-44) tmp = sin(th); else tmp = sin(ky) * (sin(th) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.05], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 4e-142], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-66], N[(N[Sin[ky], $MachinePrecision] / N[(kx / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-44], N[Sin[th], $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.05:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 4 \cdot 10^{-142}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-66}:\\
\;\;\;\;\frac{\sin ky}{\frac{kx}{\sin th}}\\
\mathbf{elif}\;\sin kx \leq 10^{-44}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.050000000000000003Initial program 99.3%
Taylor expanded in ky around 0 10.5%
associate-/l*10.5%
associate-/r/10.5%
Simplified10.5%
add-sqr-sqrt7.6%
sqrt-unprod14.8%
pow214.8%
Applied egg-rr14.8%
unpow214.8%
rem-sqrt-square18.0%
Simplified18.0%
if -0.050000000000000003 < (sin.f64 kx) < 4.0000000000000002e-142 or 2e-66 < (sin.f64 kx) < 9.99999999999999953e-45Initial program 83.5%
Taylor expanded in kx around 0 33.7%
if 4.0000000000000002e-142 < (sin.f64 kx) < 2e-66Initial program 99.7%
Taylor expanded in ky around 0 48.0%
Taylor expanded in kx around 0 48.0%
associate-/l*48.1%
Simplified48.1%
if 9.99999999999999953e-45 < (sin.f64 kx) Initial program 99.4%
Taylor expanded in ky around 0 61.6%
Taylor expanded in ky around inf 60.3%
*-commutative60.3%
associate-*l/61.6%
Simplified61.6%
Final simplification38.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.05)
(* (sin th) (fabs (/ ky (sin kx))))
(if (<= (sin kx) 4e-142)
(sin th)
(if (<= (sin kx) 2e-66)
(/ (sin ky) (/ kx (sin th)))
(if (<= (sin kx) 1e-44)
(/ (* (sin ky) (sin th)) (sin ky))
(* (sin ky) (/ (sin th) (sin kx))))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.05) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else if (sin(kx) <= 4e-142) {
tmp = sin(th);
} else if (sin(kx) <= 2e-66) {
tmp = sin(ky) / (kx / sin(th));
} else if (sin(kx) <= 1e-44) {
tmp = (sin(ky) * sin(th)) / sin(ky);
} else {
tmp = sin(ky) * (sin(th) / sin(kx));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.05d0)) then
tmp = sin(th) * abs((ky / sin(kx)))
else if (sin(kx) <= 4d-142) then
tmp = sin(th)
else if (sin(kx) <= 2d-66) then
tmp = sin(ky) / (kx / sin(th))
else if (sin(kx) <= 1d-44) then
tmp = (sin(ky) * sin(th)) / sin(ky)
else
tmp = sin(ky) * (sin(th) / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.05) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else if (Math.sin(kx) <= 4e-142) {
tmp = Math.sin(th);
} else if (Math.sin(kx) <= 2e-66) {
tmp = Math.sin(ky) / (kx / Math.sin(th));
} else if (Math.sin(kx) <= 1e-44) {
tmp = (Math.sin(ky) * Math.sin(th)) / Math.sin(ky);
} else {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.05: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) elif math.sin(kx) <= 4e-142: tmp = math.sin(th) elif math.sin(kx) <= 2e-66: tmp = math.sin(ky) / (kx / math.sin(th)) elif math.sin(kx) <= 1e-44: tmp = (math.sin(ky) * math.sin(th)) / math.sin(ky) else: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.05) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); elseif (sin(kx) <= 4e-142) tmp = sin(th); elseif (sin(kx) <= 2e-66) tmp = Float64(sin(ky) / Float64(kx / sin(th))); elseif (sin(kx) <= 1e-44) tmp = Float64(Float64(sin(ky) * sin(th)) / sin(ky)); else tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.05) tmp = sin(th) * abs((ky / sin(kx))); elseif (sin(kx) <= 4e-142) tmp = sin(th); elseif (sin(kx) <= 2e-66) tmp = sin(ky) / (kx / sin(th)); elseif (sin(kx) <= 1e-44) tmp = (sin(ky) * sin(th)) / sin(ky); else tmp = sin(ky) * (sin(th) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.05], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 4e-142], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-66], N[(N[Sin[ky], $MachinePrecision] / N[(kx / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-44], N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.05:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 4 \cdot 10^{-142}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-66}:\\
\;\;\;\;\frac{\sin ky}{\frac{kx}{\sin th}}\\
\mathbf{elif}\;\sin kx \leq 10^{-44}:\\
\;\;\;\;\frac{\sin ky \cdot \sin th}{\sin ky}\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.050000000000000003Initial program 99.3%
Taylor expanded in ky around 0 10.5%
associate-/l*10.5%
associate-/r/10.5%
Simplified10.5%
add-sqr-sqrt7.6%
sqrt-unprod14.8%
pow214.8%
Applied egg-rr14.8%
unpow214.8%
rem-sqrt-square18.0%
Simplified18.0%
if -0.050000000000000003 < (sin.f64 kx) < 4.0000000000000002e-142Initial program 83.0%
Taylor expanded in kx around 0 33.7%
if 4.0000000000000002e-142 < (sin.f64 kx) < 2e-66Initial program 99.7%
Taylor expanded in ky around 0 48.0%
Taylor expanded in kx around 0 48.0%
associate-/l*48.1%
Simplified48.1%
if 2e-66 < (sin.f64 kx) < 9.99999999999999953e-45Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef68.4%
Applied egg-rr68.4%
expm1-def100.0%
expm1-log1p100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in kx around 0 35.1%
if 9.99999999999999953e-45 < (sin.f64 kx) Initial program 99.4%
Taylor expanded in ky around 0 61.6%
Taylor expanded in ky around inf 60.3%
*-commutative60.3%
associate-*l/61.6%
Simplified61.6%
Final simplification38.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.05)
(fabs (* (sin ky) (/ th (sin kx))))
(if (<= (sin kx) 4e-142)
(sin th)
(if (<= (sin kx) 2e-66)
(/ (sin ky) (/ kx (sin th)))
(if (<= (sin kx) 1e-39) (sin th) (* (sin th) (/ ky (sin kx))))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.05) {
tmp = fabs((sin(ky) * (th / sin(kx))));
} else if (sin(kx) <= 4e-142) {
tmp = sin(th);
} else if (sin(kx) <= 2e-66) {
tmp = sin(ky) / (kx / sin(th));
} else if (sin(kx) <= 1e-39) {
tmp = sin(th);
} else {
tmp = sin(th) * (ky / sin(kx));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.05d0)) then
tmp = abs((sin(ky) * (th / sin(kx))))
else if (sin(kx) <= 4d-142) then
tmp = sin(th)
else if (sin(kx) <= 2d-66) then
tmp = sin(ky) / (kx / sin(th))
else if (sin(kx) <= 1d-39) then
tmp = sin(th)
else
tmp = sin(th) * (ky / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.05) {
tmp = Math.abs((Math.sin(ky) * (th / Math.sin(kx))));
} else if (Math.sin(kx) <= 4e-142) {
tmp = Math.sin(th);
} else if (Math.sin(kx) <= 2e-66) {
tmp = Math.sin(ky) / (kx / Math.sin(th));
} else if (Math.sin(kx) <= 1e-39) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (ky / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.05: tmp = math.fabs((math.sin(ky) * (th / math.sin(kx)))) elif math.sin(kx) <= 4e-142: tmp = math.sin(th) elif math.sin(kx) <= 2e-66: tmp = math.sin(ky) / (kx / math.sin(th)) elif math.sin(kx) <= 1e-39: tmp = math.sin(th) else: tmp = math.sin(th) * (ky / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.05) tmp = abs(Float64(sin(ky) * Float64(th / sin(kx)))); elseif (sin(kx) <= 4e-142) tmp = sin(th); elseif (sin(kx) <= 2e-66) tmp = Float64(sin(ky) / Float64(kx / sin(th))); elseif (sin(kx) <= 1e-39) tmp = sin(th); else tmp = Float64(sin(th) * Float64(ky / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.05) tmp = abs((sin(ky) * (th / sin(kx)))); elseif (sin(kx) <= 4e-142) tmp = sin(th); elseif (sin(kx) <= 2e-66) tmp = sin(ky) / (kx / sin(th)); elseif (sin(kx) <= 1e-39) tmp = sin(th); else tmp = sin(th) * (ky / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.05], N[Abs[N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 4e-142], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-66], N[(N[Sin[ky], $MachinePrecision] / N[(kx / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-39], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.05:\\
\;\;\;\;\left|\sin ky \cdot \frac{th}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 4 \cdot 10^{-142}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-66}:\\
\;\;\;\;\frac{\sin ky}{\frac{kx}{\sin th}}\\
\mathbf{elif}\;\sin kx \leq 10^{-39}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.050000000000000003Initial program 99.3%
Taylor expanded in ky around 0 10.1%
Taylor expanded in th around 0 11.0%
add-sqr-sqrt8.4%
sqrt-unprod15.1%
pow215.1%
associate-/l*15.1%
div-inv15.1%
clear-num15.1%
Applied egg-rr15.1%
unpow215.1%
rem-sqrt-square20.3%
associate-*r/20.3%
associate-*l/20.3%
*-commutative20.3%
Simplified20.3%
if -0.050000000000000003 < (sin.f64 kx) < 4.0000000000000002e-142 or 2e-66 < (sin.f64 kx) < 9.99999999999999929e-40Initial program 83.7%
Taylor expanded in kx around 0 33.4%
if 4.0000000000000002e-142 < (sin.f64 kx) < 2e-66Initial program 99.7%
Taylor expanded in ky around 0 48.0%
Taylor expanded in kx around 0 48.0%
associate-/l*48.1%
Simplified48.1%
if 9.99999999999999929e-40 < (sin.f64 kx) Initial program 99.4%
Taylor expanded in ky around 0 54.4%
associate-/l*55.7%
associate-/r/55.7%
Simplified55.7%
Final simplification37.2%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.05)
(* th (/ (sin ky) (fabs (sin kx))))
(if (<= (sin kx) 4e-142)
(sin th)
(if (<= (sin kx) 2e-66)
(/ (sin ky) (/ kx (sin th)))
(if (<= (sin kx) 1e-39) (sin th) (* (sin th) (/ ky (sin kx))))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.05) {
tmp = th * (sin(ky) / fabs(sin(kx)));
} else if (sin(kx) <= 4e-142) {
tmp = sin(th);
} else if (sin(kx) <= 2e-66) {
tmp = sin(ky) / (kx / sin(th));
} else if (sin(kx) <= 1e-39) {
tmp = sin(th);
} else {
tmp = sin(th) * (ky / sin(kx));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.05d0)) then
tmp = th * (sin(ky) / abs(sin(kx)))
else if (sin(kx) <= 4d-142) then
tmp = sin(th)
else if (sin(kx) <= 2d-66) then
tmp = sin(ky) / (kx / sin(th))
else if (sin(kx) <= 1d-39) then
tmp = sin(th)
else
tmp = sin(th) * (ky / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.05) {
tmp = th * (Math.sin(ky) / Math.abs(Math.sin(kx)));
} else if (Math.sin(kx) <= 4e-142) {
tmp = Math.sin(th);
} else if (Math.sin(kx) <= 2e-66) {
tmp = Math.sin(ky) / (kx / Math.sin(th));
} else if (Math.sin(kx) <= 1e-39) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (ky / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.05: tmp = th * (math.sin(ky) / math.fabs(math.sin(kx))) elif math.sin(kx) <= 4e-142: tmp = math.sin(th) elif math.sin(kx) <= 2e-66: tmp = math.sin(ky) / (kx / math.sin(th)) elif math.sin(kx) <= 1e-39: tmp = math.sin(th) else: tmp = math.sin(th) * (ky / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.05) tmp = Float64(th * Float64(sin(ky) / abs(sin(kx)))); elseif (sin(kx) <= 4e-142) tmp = sin(th); elseif (sin(kx) <= 2e-66) tmp = Float64(sin(ky) / Float64(kx / sin(th))); elseif (sin(kx) <= 1e-39) tmp = sin(th); else tmp = Float64(sin(th) * Float64(ky / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.05) tmp = th * (sin(ky) / abs(sin(kx))); elseif (sin(kx) <= 4e-142) tmp = sin(th); elseif (sin(kx) <= 2e-66) tmp = sin(ky) / (kx / sin(th)); elseif (sin(kx) <= 1e-39) tmp = sin(th); else tmp = sin(th) * (ky / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.05], N[(th * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 4e-142], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-66], N[(N[Sin[ky], $MachinePrecision] / N[(kx / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1e-39], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.05:\\
\;\;\;\;th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\
\mathbf{elif}\;\sin kx \leq 4 \cdot 10^{-142}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-66}:\\
\;\;\;\;\frac{\sin ky}{\frac{kx}{\sin th}}\\
\mathbf{elif}\;\sin kx \leq 10^{-39}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.050000000000000003Initial program 99.3%
Taylor expanded in ky around 0 10.1%
add-sqr-sqrt7.5%
sqrt-unprod20.0%
pow220.0%
Applied egg-rr20.0%
unpow220.0%
rem-sqrt-square22.9%
Simplified22.9%
Taylor expanded in th around 0 18.7%
fabs-div18.7%
rem-square-sqrt10.6%
fabs-sqr10.6%
rem-square-sqrt30.1%
Simplified30.1%
if -0.050000000000000003 < (sin.f64 kx) < 4.0000000000000002e-142 or 2e-66 < (sin.f64 kx) < 9.99999999999999929e-40Initial program 83.7%
Taylor expanded in kx around 0 33.4%
if 4.0000000000000002e-142 < (sin.f64 kx) < 2e-66Initial program 99.7%
Taylor expanded in ky around 0 48.0%
Taylor expanded in kx around 0 48.0%
associate-/l*48.1%
Simplified48.1%
if 9.99999999999999929e-40 < (sin.f64 kx) Initial program 99.4%
Taylor expanded in ky around 0 54.4%
associate-/l*55.7%
associate-/r/55.7%
Simplified55.7%
Final simplification39.7%
(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 92.8%
expm1-log1p-u92.6%
expm1-udef43.4%
Applied egg-rr46.0%
expm1-def99.6%
expm1-log1p99.7%
*-commutative99.7%
associate-*r/95.2%
associate-*l/99.6%
*-commutative99.6%
hypot-def92.7%
unpow292.7%
unpow292.7%
+-commutative92.7%
unpow292.7%
unpow292.7%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin kx) (sin ky))))
(if (<= ky 1.05e-221)
(* (sin th) (fabs (/ ky (sin kx))))
(if (<= ky 0.0038)
(/ (* ky (sin th)) t_1)
(if (or (<= ky 5.35e+179) (not (<= ky 1.3e+220)))
(* (sin th) (/ (sin ky) (fabs (sin ky))))
(/ (* (sin ky) th) t_1))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (ky <= 1.05e-221) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else if (ky <= 0.0038) {
tmp = (ky * sin(th)) / t_1;
} else if ((ky <= 5.35e+179) || !(ky <= 1.3e+220)) {
tmp = sin(th) * (sin(ky) / fabs(sin(ky)));
} else {
tmp = (sin(ky) * th) / t_1;
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(kx), Math.sin(ky));
double tmp;
if (ky <= 1.05e-221) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else if (ky <= 0.0038) {
tmp = (ky * Math.sin(th)) / t_1;
} else if ((ky <= 5.35e+179) || !(ky <= 1.3e+220)) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(ky)));
} else {
tmp = (Math.sin(ky) * th) / t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if ky <= 1.05e-221: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) elif ky <= 0.0038: tmp = (ky * math.sin(th)) / t_1 elif (ky <= 5.35e+179) or not (ky <= 1.3e+220): tmp = math.sin(th) * (math.sin(ky) / math.fabs(math.sin(ky))) else: tmp = (math.sin(ky) * th) / t_1 return tmp
function code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)) tmp = 0.0 if (ky <= 1.05e-221) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); elseif (ky <= 0.0038) tmp = Float64(Float64(ky * sin(th)) / t_1); elseif ((ky <= 5.35e+179) || !(ky <= 1.3e+220)) tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(ky)))); else tmp = Float64(Float64(sin(ky) * th) / t_1); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)); tmp = 0.0; if (ky <= 1.05e-221) tmp = sin(th) * abs((ky / sin(kx))); elseif (ky <= 0.0038) tmp = (ky * sin(th)) / t_1; elseif ((ky <= 5.35e+179) || ~((ky <= 1.3e+220))) tmp = sin(th) * (sin(ky) / abs(sin(ky))); else tmp = (sin(ky) * th) / t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[ky, 1.05e-221], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 0.0038], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[Or[LessEqual[ky, 5.35e+179], N[Not[LessEqual[ky, 1.3e+220]], $MachinePrecision]], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] / t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
\mathbf{if}\;ky \leq 1.05 \cdot 10^{-221}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{elif}\;ky \leq 0.0038:\\
\;\;\;\;\frac{ky \cdot \sin th}{t\_1}\\
\mathbf{elif}\;ky \leq 5.35 \cdot 10^{+179} \lor \neg \left(ky \leq 1.3 \cdot 10^{+220}\right):\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin ky\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky \cdot th}{t\_1}\\
\end{array}
\end{array}
if ky < 1.05e-221Initial program 90.5%
Taylor expanded in ky around 0 26.5%
associate-/l*29.1%
associate-/r/29.1%
Simplified29.1%
add-sqr-sqrt10.5%
sqrt-unprod15.7%
pow215.7%
Applied egg-rr15.7%
unpow215.7%
rem-sqrt-square18.7%
Simplified18.7%
if 1.05e-221 < ky < 0.00379999999999999999Initial program 91.5%
expm1-log1p-u91.3%
expm1-udef24.8%
Applied egg-rr27.9%
expm1-def99.7%
expm1-log1p99.7%
associate-*l/92.0%
Simplified92.0%
Taylor expanded in ky around 0 90.6%
if 0.00379999999999999999 < ky < 5.35000000000000012e179 or 1.29999999999999997e220 < ky Initial program 99.7%
unpow299.7%
unpow299.7%
hypot-def99.8%
expm1-log1p-u99.5%
Applied egg-rr99.5%
Taylor expanded in kx around 0 26.2%
expm1-log1p-u26.3%
add-sqr-sqrt24.7%
fabs-sqr24.7%
add-sqr-sqrt63.1%
Applied egg-rr63.1%
if 5.35000000000000012e179 < ky < 1.29999999999999997e220Initial program 99.2%
expm1-log1p-u99.2%
expm1-udef39.7%
Applied egg-rr39.7%
expm1-def99.2%
expm1-log1p99.2%
associate-*l/99.0%
Simplified99.0%
Taylor expanded in th around 0 74.5%
Final simplification39.6%
(FPCore (kx ky th)
:precision binary64
(if (<= kx 4.2e-142)
(sin th)
(if (<= kx 8e-66)
(/ (sin ky) (/ kx (sin th)))
(if (<= kx 5.9e-39)
(/ (* (sin ky) (sin th)) (sin ky))
(* (sin th) (fabs (/ (sin ky) (sin kx))))))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 4.2e-142) {
tmp = sin(th);
} else if (kx <= 8e-66) {
tmp = sin(ky) / (kx / sin(th));
} else if (kx <= 5.9e-39) {
tmp = (sin(ky) * sin(th)) / sin(ky);
} else {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (kx <= 4.2d-142) then
tmp = sin(th)
else if (kx <= 8d-66) then
tmp = sin(ky) / (kx / sin(th))
else if (kx <= 5.9d-39) then
tmp = (sin(ky) * sin(th)) / sin(ky)
else
tmp = sin(th) * abs((sin(ky) / sin(kx)))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 4.2e-142) {
tmp = Math.sin(th);
} else if (kx <= 8e-66) {
tmp = Math.sin(ky) / (kx / Math.sin(th));
} else if (kx <= 5.9e-39) {
tmp = (Math.sin(ky) * Math.sin(th)) / Math.sin(ky);
} else {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 4.2e-142: tmp = math.sin(th) elif kx <= 8e-66: tmp = math.sin(ky) / (kx / math.sin(th)) elif kx <= 5.9e-39: tmp = (math.sin(ky) * math.sin(th)) / math.sin(ky) else: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 4.2e-142) tmp = sin(th); elseif (kx <= 8e-66) tmp = Float64(sin(ky) / Float64(kx / sin(th))); elseif (kx <= 5.9e-39) tmp = Float64(Float64(sin(ky) * sin(th)) / sin(ky)); else tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 4.2e-142) tmp = sin(th); elseif (kx <= 8e-66) tmp = sin(ky) / (kx / sin(th)); elseif (kx <= 5.9e-39) tmp = (sin(ky) * sin(th)) / sin(ky); else tmp = sin(th) * abs((sin(ky) / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 4.2e-142], N[Sin[th], $MachinePrecision], If[LessEqual[kx, 8e-66], N[(N[Sin[ky], $MachinePrecision] / N[(kx / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[kx, 5.9e-39], N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 4.2 \cdot 10^{-142}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;kx \leq 8 \cdot 10^{-66}:\\
\;\;\;\;\frac{\sin ky}{\frac{kx}{\sin th}}\\
\mathbf{elif}\;kx \leq 5.9 \cdot 10^{-39}:\\
\;\;\;\;\frac{\sin ky \cdot \sin th}{\sin ky}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\end{array}
\end{array}
if kx < 4.1999999999999999e-142Initial program 89.4%
Taylor expanded in kx around 0 23.5%
if 4.1999999999999999e-142 < kx < 7.9999999999999998e-66Initial program 99.7%
Taylor expanded in ky around 0 48.0%
Taylor expanded in kx around 0 48.0%
associate-/l*48.1%
Simplified48.1%
if 7.9999999999999998e-66 < kx < 5.8999999999999998e-39Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef52.6%
Applied egg-rr52.6%
expm1-def100.0%
expm1-log1p100.0%
associate-*l/99.6%
Simplified99.6%
Taylor expanded in kx around 0 27.2%
if 5.8999999999999998e-39 < kx Initial program 99.4%
Taylor expanded in ky around 0 41.6%
add-sqr-sqrt18.2%
sqrt-unprod29.3%
pow229.3%
Applied egg-rr29.3%
unpow229.3%
rem-sqrt-square33.2%
Simplified33.2%
Final simplification27.3%
(FPCore (kx ky th)
:precision binary64
(if (<= ky 9.2e-222)
(* (sin th) (fabs (/ ky (sin kx))))
(if (<= ky 0.0025)
(/ (* ky (sin th)) (hypot (sin kx) (sin ky)))
(* (sin th) (/ (sin ky) (fabs (sin ky)))))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 9.2e-222) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else if (ky <= 0.0025) {
tmp = (ky * sin(th)) / hypot(sin(kx), sin(ky));
} else {
tmp = sin(th) * (sin(ky) / fabs(sin(ky)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 9.2e-222) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else if (ky <= 0.0025) {
tmp = (ky * Math.sin(th)) / Math.hypot(Math.sin(kx), Math.sin(ky));
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 9.2e-222: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) elif ky <= 0.0025: tmp = (ky * math.sin(th)) / math.hypot(math.sin(kx), math.sin(ky)) else: tmp = math.sin(th) * (math.sin(ky) / math.fabs(math.sin(ky))) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 9.2e-222) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); elseif (ky <= 0.0025) tmp = Float64(Float64(ky * sin(th)) / hypot(sin(kx), sin(ky))); else tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 9.2e-222) tmp = sin(th) * abs((ky / sin(kx))); elseif (ky <= 0.0025) tmp = (ky * sin(th)) / hypot(sin(kx), sin(ky)); else tmp = sin(th) * (sin(ky) / abs(sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 9.2e-222], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 0.0025], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 9.2 \cdot 10^{-222}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{elif}\;ky \leq 0.0025:\\
\;\;\;\;\frac{ky \cdot \sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin ky\right|}\\
\end{array}
\end{array}
if ky < 9.2000000000000005e-222Initial program 90.5%
Taylor expanded in ky around 0 26.5%
associate-/l*29.1%
associate-/r/29.1%
Simplified29.1%
add-sqr-sqrt10.5%
sqrt-unprod15.7%
pow215.7%
Applied egg-rr15.7%
unpow215.7%
rem-sqrt-square18.7%
Simplified18.7%
if 9.2000000000000005e-222 < ky < 0.00250000000000000005Initial program 91.5%
expm1-log1p-u91.3%
expm1-udef24.8%
Applied egg-rr27.9%
expm1-def99.7%
expm1-log1p99.7%
associate-*l/92.0%
Simplified92.0%
Taylor expanded in ky around 0 90.6%
if 0.00250000000000000005 < ky Initial program 99.6%
unpow299.6%
unpow299.6%
hypot-def99.7%
expm1-log1p-u99.5%
Applied egg-rr99.5%
Taylor expanded in kx around 0 24.1%
expm1-log1p-u24.2%
add-sqr-sqrt22.7%
fabs-sqr22.7%
add-sqr-sqrt58.1%
Applied egg-rr58.1%
Final simplification38.0%
(FPCore (kx ky th) :precision binary64 (if (<= ky 0.00195) (* (sin th) (fabs (/ (sin ky) (sin kx)))) (* (sin th) (/ (sin ky) (fabs (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 0.00195) {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
} else {
tmp = sin(th) * (sin(ky) / fabs(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 (ky <= 0.00195d0) then
tmp = sin(th) * abs((sin(ky) / sin(kx)))
else
tmp = sin(th) * (sin(ky) / abs(sin(ky)))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 0.00195) {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 0.00195: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) else: tmp = math.sin(th) * (math.sin(ky) / math.fabs(math.sin(ky))) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 0.00195) tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); else tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 0.00195) tmp = sin(th) * abs((sin(ky) / sin(kx))); else tmp = sin(th) * (sin(ky) / abs(sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 0.00195], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 0.00195:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin ky\right|}\\
\end{array}
\end{array}
if ky < 0.0019499999999999999Initial program 90.7%
Taylor expanded in ky around 0 33.2%
add-sqr-sqrt16.3%
sqrt-unprod25.2%
pow225.2%
Applied egg-rr25.2%
unpow225.2%
rem-sqrt-square28.5%
Simplified28.5%
if 0.0019499999999999999 < ky Initial program 99.6%
unpow299.6%
unpow299.6%
hypot-def99.7%
expm1-log1p-u99.5%
Applied egg-rr99.5%
Taylor expanded in kx around 0 24.1%
expm1-log1p-u24.2%
add-sqr-sqrt22.7%
fabs-sqr22.7%
add-sqr-sqrt58.1%
Applied egg-rr58.1%
Final simplification35.4%
(FPCore (kx ky th) :precision binary64 (if (<= ky 0.002) (* (sin th) (fabs (/ ky (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 0.002) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 0.002d0) then
tmp = sin(th) * abs((ky / sin(kx)))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 0.002) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 0.002: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 0.002) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 0.002) tmp = sin(th) * abs((ky / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 0.002], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 0.002:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 2e-3Initial program 90.7%
Taylor expanded in ky around 0 28.9%
associate-/l*31.5%
associate-/r/31.5%
Simplified31.5%
add-sqr-sqrt15.6%
sqrt-unprod23.5%
pow223.5%
Applied egg-rr23.5%
unpow223.5%
rem-sqrt-square26.9%
Simplified26.9%
if 2e-3 < ky Initial program 99.6%
Taylor expanded in kx around 0 24.2%
Final simplification26.2%
(FPCore (kx ky th) :precision binary64 (if (<= ky 9.5e-46) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 9.5e-46) {
tmp = sin(th) * (ky / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 9.5d-46) then
tmp = sin(th) * (ky / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 9.5e-46) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 9.5e-46: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 9.5e-46) tmp = Float64(sin(th) * Float64(ky / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 9.5e-46) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 9.5e-46], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 9.5 \cdot 10^{-46}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 9.49999999999999993e-46Initial program 90.2%
Taylor expanded in ky around 0 28.5%
associate-/l*31.2%
associate-/r/31.2%
Simplified31.2%
if 9.49999999999999993e-46 < ky Initial program 99.6%
Taylor expanded in kx around 0 28.6%
Final simplification30.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky 4.8e-109) (* (sin th) (/ ky kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.8e-109) {
tmp = sin(th) * (ky / kx);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 4.8d-109) then
tmp = sin(th) * (ky / kx)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.8e-109) {
tmp = Math.sin(th) * (ky / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 4.8e-109: tmp = math.sin(th) * (ky / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 4.8e-109) tmp = Float64(sin(th) * Float64(ky / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 4.8e-109) tmp = sin(th) * (ky / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 4.8e-109], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 4.8 \cdot 10^{-109}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 4.79999999999999977e-109Initial program 89.6%
Taylor expanded in ky around 0 26.8%
associate-/l*29.7%
associate-/r/29.7%
Simplified29.7%
Taylor expanded in kx around 0 21.6%
if 4.79999999999999977e-109 < ky Initial program 99.7%
Taylor expanded in kx around 0 29.1%
Final simplification24.0%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.25e-122) (/ ky (/ kx th)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.25e-122) {
tmp = ky / (kx / 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.25d-122) then
tmp = ky / (kx / 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.25e-122) {
tmp = ky / (kx / th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.25e-122: tmp = ky / (kx / th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.25e-122) tmp = Float64(ky / Float64(kx / th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.25e-122) tmp = ky / (kx / th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.25e-122], N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.25 \cdot 10^{-122}:\\
\;\;\;\;\frac{ky}{\frac{kx}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.25e-122Initial program 89.3%
Taylor expanded in ky around 0 26.8%
associate-/l*29.7%
associate-/r/29.7%
Simplified29.7%
Taylor expanded in kx around 0 21.4%
Taylor expanded in th around 0 14.6%
associate-/l*17.6%
Simplified17.6%
if 1.25e-122 < ky Initial program 99.7%
Taylor expanded in kx around 0 29.3%
Final simplification21.5%
(FPCore (kx ky th) :precision binary64 (/ ky (/ kx th)))
double code(double kx, double ky, double th) {
return ky / (kx / th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = ky / (kx / th)
end function
public static double code(double kx, double ky, double th) {
return ky / (kx / th);
}
def code(kx, ky, th): return ky / (kx / th)
function code(kx, ky, th) return Float64(ky / Float64(kx / th)) end
function tmp = code(kx, ky, th) tmp = ky / (kx / th); end
code[kx_, ky_, th_] := N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{ky}{\frac{kx}{th}}
\end{array}
Initial program 92.8%
Taylor expanded in ky around 0 22.8%
associate-/l*24.8%
associate-/r/24.8%
Simplified24.8%
Taylor expanded in kx around 0 16.8%
Taylor expanded in th around 0 11.7%
associate-/l*13.8%
Simplified13.8%
Final simplification13.8%
herbie shell --seed 2024039
(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)))