
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (hypot (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th
\end{array}
Initial program 94.3%
remove-double-neg94.3%
sin-neg94.3%
neg-mul-194.3%
*-commutative94.3%
associate-*l*94.3%
associate-*l/92.2%
associate-/r/92.2%
associate-*l/94.3%
associate-/r/94.2%
sin-neg94.2%
neg-mul-194.2%
associate-/r*94.2%
associate-/r/94.3%
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) 2e-33) (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) <= 2e-33) {
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) <= 2d-33) 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) <= 2e-33) {
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) <= 2e-33: 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) <= 2e-33) 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) <= 2e-33) 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], 2e-33], 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 2 \cdot 10^{-33}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.050000000000000003Initial program 99.5%
Taylor expanded in ky around 0 16.4%
add-sqr-sqrt9.6%
sqrt-unprod26.6%
pow226.6%
Applied egg-rr26.6%
unpow226.6%
rem-sqrt-square32.3%
Simplified32.3%
if -0.050000000000000003 < (sin.f64 kx) < 2.0000000000000001e-33Initial program 89.0%
remove-double-neg89.0%
sin-neg89.0%
neg-mul-189.0%
*-commutative89.0%
associate-*l*89.0%
associate-*l/85.1%
associate-/r/85.1%
associate-*l/89.0%
associate-/r/88.8%
sin-neg88.8%
neg-mul-188.8%
associate-/r*88.8%
associate-/r/89.0%
Simplified99.9%
Taylor expanded in kx around 0 37.9%
if 2.0000000000000001e-33 < (sin.f64 kx) Initial program 99.6%
Taylor expanded in ky around 0 61.0%
Final simplification42.3%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.05) (* (sin th) (fabs (/ ky (sin kx)))) (if (<= (sin kx) 2e-33) (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) <= 2e-33) {
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) <= 2d-33) 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) <= 2e-33) {
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) <= 2e-33: 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) <= 2e-33) 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) <= 2e-33) 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], 2e-33], 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 2 \cdot 10^{-33}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.050000000000000003Initial program 99.5%
Taylor expanded in ky around 0 16.4%
add-sqr-sqrt9.6%
sqrt-unprod26.6%
pow226.6%
Applied egg-rr26.6%
unpow226.6%
rem-sqrt-square32.3%
Simplified32.3%
if -0.050000000000000003 < (sin.f64 kx) < 2.0000000000000001e-33Initial program 89.0%
remove-double-neg89.0%
sin-neg89.0%
neg-mul-189.0%
*-commutative89.0%
associate-*l*89.0%
associate-*l/85.1%
associate-/r/85.1%
associate-*l/89.0%
associate-/r/88.8%
sin-neg88.8%
neg-mul-188.8%
associate-/r*88.8%
associate-/r/89.0%
Simplified99.9%
Taylor expanded in kx around 0 37.9%
if 2.0000000000000001e-33 < (sin.f64 kx) Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.0%
associate-/r/99.0%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.6%
*-commutative99.6%
clear-num99.6%
un-div-inv99.6%
hypot-udef99.6%
unpow299.6%
unpow299.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Applied egg-rr99.6%
associate-/r/99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 60.9%
Final simplification42.3%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.05) (* (sin th) (fabs (/ ky (sin kx)))) (if (<= (sin kx) 2e-33) (sin th) (/ (sin ky) (/ (sin kx) (sin th))))))
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) <= 2e-33) {
tmp = sin(th);
} else {
tmp = sin(ky) / (sin(kx) / sin(th));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.05d0)) then
tmp = sin(th) * abs((ky / sin(kx)))
else if (sin(kx) <= 2d-33) then
tmp = sin(th)
else
tmp = sin(ky) / (sin(kx) / sin(th))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.05) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else if (Math.sin(kx) <= 2e-33) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(ky) / (Math.sin(kx) / Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.05: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) elif math.sin(kx) <= 2e-33: tmp = math.sin(th) else: tmp = math.sin(ky) / (math.sin(kx) / math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.05) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); elseif (sin(kx) <= 2e-33) tmp = sin(th); else tmp = Float64(sin(ky) / Float64(sin(kx) / sin(th))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.05) tmp = sin(th) * abs((ky / sin(kx))); elseif (sin(kx) <= 2e-33) tmp = sin(th); else tmp = sin(ky) / (sin(kx) / sin(th)); 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], 2e-33], N[Sin[th], $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.05:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-33}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.050000000000000003Initial program 99.5%
Taylor expanded in ky around 0 16.4%
add-sqr-sqrt9.6%
sqrt-unprod26.6%
pow226.6%
Applied egg-rr26.6%
unpow226.6%
rem-sqrt-square32.3%
Simplified32.3%
if -0.050000000000000003 < (sin.f64 kx) < 2.0000000000000001e-33Initial program 89.0%
remove-double-neg89.0%
sin-neg89.0%
neg-mul-189.0%
*-commutative89.0%
associate-*l*89.0%
associate-*l/85.1%
associate-/r/85.1%
associate-*l/89.0%
associate-/r/88.8%
sin-neg88.8%
neg-mul-188.8%
associate-/r*88.8%
associate-/r/89.0%
Simplified99.9%
Taylor expanded in kx around 0 37.9%
if 2.0000000000000001e-33 < (sin.f64 kx) Initial program 99.6%
Taylor expanded in ky around 0 61.0%
associate-*l/60.5%
associate-/l*60.9%
Applied egg-rr60.9%
Final simplification42.3%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.05) (* (sin th) (fabs (/ (sin ky) (sin kx)))) (if (<= (sin kx) 2e-33) (sin th) (/ (sin ky) (/ (sin kx) (sin th))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.05) {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
} else if (sin(kx) <= 2e-33) {
tmp = sin(th);
} else {
tmp = sin(ky) / (sin(kx) / sin(th));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.05d0)) then
tmp = sin(th) * abs((sin(ky) / sin(kx)))
else if (sin(kx) <= 2d-33) then
tmp = sin(th)
else
tmp = sin(ky) / (sin(kx) / sin(th))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.05) {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
} else if (Math.sin(kx) <= 2e-33) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(ky) / (Math.sin(kx) / Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.05: tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) elif math.sin(kx) <= 2e-33: tmp = math.sin(th) else: tmp = math.sin(ky) / (math.sin(kx) / math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.05) tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); elseif (sin(kx) <= 2e-33) tmp = sin(th); else tmp = Float64(sin(ky) / Float64(sin(kx) / sin(th))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.05) tmp = sin(th) * abs((sin(ky) / sin(kx))); elseif (sin(kx) <= 2e-33) tmp = sin(th); else tmp = sin(ky) / (sin(kx) / sin(th)); 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[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-33], N[Sin[th], $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.05:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-33}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.050000000000000003Initial program 99.5%
Taylor expanded in ky around 0 15.6%
add-sqr-sqrt9.7%
sqrt-unprod29.5%
pow229.5%
Applied egg-rr29.5%
unpow229.5%
rem-sqrt-square35.0%
Simplified35.0%
if -0.050000000000000003 < (sin.f64 kx) < 2.0000000000000001e-33Initial program 89.0%
remove-double-neg89.0%
sin-neg89.0%
neg-mul-189.0%
*-commutative89.0%
associate-*l*89.0%
associate-*l/85.1%
associate-/r/85.1%
associate-*l/89.0%
associate-/r/88.8%
sin-neg88.8%
neg-mul-188.8%
associate-/r*88.8%
associate-/r/89.0%
Simplified99.9%
Taylor expanded in kx around 0 37.9%
if 2.0000000000000001e-33 < (sin.f64 kx) Initial program 99.6%
Taylor expanded in ky around 0 61.0%
associate-*l/60.5%
associate-/l*60.9%
Applied egg-rr60.9%
Final simplification43.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.3%
remove-double-neg94.3%
sin-neg94.3%
neg-mul-194.3%
*-commutative94.3%
associate-*l*94.3%
associate-*l/92.2%
associate-/r/92.2%
associate-*l/94.3%
associate-/r/94.2%
sin-neg94.2%
neg-mul-194.2%
associate-/r*94.2%
associate-/r/94.3%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef45.4%
hypot-udef43.7%
unpow243.7%
unpow243.7%
+-commutative43.7%
unpow243.7%
unpow243.7%
hypot-def45.4%
Applied egg-rr45.4%
expm1-def99.7%
expm1-log1p99.7%
*-commutative99.7%
associate-*r/95.2%
associate-*l/99.6%
*-commutative99.6%
hypot-def94.1%
unpow294.1%
unpow294.1%
+-commutative94.1%
unpow294.1%
unpow294.1%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(if (<= th 22000.0)
(/
(sin ky)
(* (hypot (sin kx) (sin ky)) (+ (/ 1.0 th) (* th 0.16666666666666666))))
(* (sin th) (/ (sin ky) (fabs (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 22000.0) {
tmp = sin(ky) / (hypot(sin(kx), sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = sin(th) * (sin(ky) / fabs(sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 22000.0) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), Math.sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 22000.0: tmp = math.sin(ky) / (math.hypot(math.sin(kx), math.sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666))) else: tmp = math.sin(th) * (math.sin(ky) / math.fabs(math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 22000.0) tmp = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); else tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 22000.0) tmp = sin(ky) / (hypot(sin(kx), sin(ky)) * ((1.0 / th) + (th * 0.16666666666666666))); else tmp = sin(th) * (sin(ky) / abs(sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 22000.0], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 22000:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\
\end{array}
\end{array}
if th < 22000Initial program 93.2%
remove-double-neg93.2%
sin-neg93.2%
neg-mul-193.2%
*-commutative93.2%
associate-*l*93.2%
associate-*l/90.3%
associate-/r/90.3%
associate-*l/93.2%
associate-/r/93.1%
sin-neg93.1%
neg-mul-193.1%
associate-/r*93.1%
associate-/r/93.2%
Simplified99.7%
associate-*l/93.4%
associate-/l*99.6%
hypot-udef93.1%
unpow293.1%
unpow293.1%
+-commutative93.1%
unpow293.1%
unpow293.1%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 64.8%
+-commutative64.8%
unpow264.8%
unpow264.8%
hypot-def69.3%
associate-*r*69.3%
unpow269.3%
unpow269.3%
hypot-def69.3%
distribute-rgt-out69.3%
Simplified69.3%
if 22000 < th Initial program 97.1%
unpow297.1%
unpow297.1%
hypot-def99.7%
log1p-expm1-u99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 12.8%
expm1-def17.3%
Simplified17.3%
add-sqr-sqrt16.1%
fabs-sqr16.1%
add-sqr-sqrt36.0%
log1p-expm1-u36.0%
Applied egg-rr36.0%
Final simplification59.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.2) (* th (fabs (/ (sin ky) (sin kx)))) (if (<= (sin kx) 2e-33) (sin th) (/ ky (/ (sin kx) (sin th))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.2) {
tmp = th * fabs((sin(ky) / sin(kx)));
} else if (sin(kx) <= 2e-33) {
tmp = sin(th);
} else {
tmp = ky / (sin(kx) / sin(th));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.2d0)) then
tmp = th * abs((sin(ky) / sin(kx)))
else if (sin(kx) <= 2d-33) then
tmp = sin(th)
else
tmp = ky / (sin(kx) / sin(th))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.2) {
tmp = th * Math.abs((Math.sin(ky) / Math.sin(kx)));
} else if (Math.sin(kx) <= 2e-33) {
tmp = Math.sin(th);
} else {
tmp = ky / (Math.sin(kx) / Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.2: tmp = th * math.fabs((math.sin(ky) / math.sin(kx))) elif math.sin(kx) <= 2e-33: tmp = math.sin(th) else: tmp = ky / (math.sin(kx) / math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.2) tmp = Float64(th * abs(Float64(sin(ky) / sin(kx)))); elseif (sin(kx) <= 2e-33) tmp = sin(th); else tmp = Float64(ky / Float64(sin(kx) / sin(th))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.2) tmp = th * abs((sin(ky) / sin(kx))); elseif (sin(kx) <= 2e-33) tmp = sin(th); else tmp = ky / (sin(kx) / sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.2], N[(th * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-33], N[Sin[th], $MachinePrecision], N[(ky / N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.2:\\
\;\;\;\;th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-33}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{\sin th}}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.20000000000000001Initial program 99.5%
Taylor expanded in ky around 0 16.6%
add-sqr-sqrt10.4%
sqrt-unprod29.9%
pow229.9%
Applied egg-rr29.9%
unpow229.9%
rem-sqrt-square34.3%
Simplified34.3%
Taylor expanded in th around 0 23.6%
if -0.20000000000000001 < (sin.f64 kx) < 2.0000000000000001e-33Initial program 89.4%
remove-double-neg89.4%
sin-neg89.4%
neg-mul-189.4%
*-commutative89.4%
associate-*l*89.4%
associate-*l/85.6%
associate-/r/85.6%
associate-*l/89.4%
associate-/r/89.2%
sin-neg89.2%
neg-mul-189.2%
associate-/r*89.2%
associate-/r/89.4%
Simplified99.9%
Taylor expanded in kx around 0 36.8%
if 2.0000000000000001e-33 < (sin.f64 kx) Initial program 99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
*-commutative99.6%
associate-*l*99.6%
associate-*l/99.0%
associate-/r/99.0%
associate-*l/99.6%
associate-/r/99.5%
sin-neg99.5%
neg-mul-199.5%
associate-/r*99.5%
associate-/r/99.6%
Simplified99.6%
Taylor expanded in ky around 0 52.9%
associate-/l*53.4%
Simplified53.4%
Final simplification37.9%
(FPCore (kx ky th) :precision binary64 (if (<= th 22000.0) (/ (sin ky) (/ (hypot (sin kx) (sin ky)) th)) (* (sin th) (/ (sin ky) (fabs (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 22000.0) {
tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th);
} else {
tmp = sin(th) * (sin(ky) / fabs(sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 22000.0) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), Math.sin(ky)) / th);
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 22000.0: tmp = math.sin(ky) / (math.hypot(math.sin(kx), math.sin(ky)) / th) else: tmp = math.sin(th) * (math.sin(ky) / math.fabs(math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 22000.0) tmp = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) / th)); else tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 22000.0) tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th); else tmp = sin(th) * (sin(ky) / abs(sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 22000.0], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 22000:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\
\end{array}
\end{array}
if th < 22000Initial program 93.2%
remove-double-neg93.2%
sin-neg93.2%
neg-mul-193.2%
*-commutative93.2%
associate-*l*93.2%
associate-*l/90.3%
associate-/r/90.3%
associate-*l/93.2%
associate-/r/93.1%
sin-neg93.1%
neg-mul-193.1%
associate-/r*93.1%
associate-/r/93.2%
Simplified99.7%
associate-*l/93.4%
associate-/l*99.6%
hypot-udef93.1%
unpow293.1%
unpow293.1%
+-commutative93.1%
unpow293.1%
unpow293.1%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 64.4%
associate-*l/64.5%
unpow264.5%
unpow264.5%
hypot-def68.9%
*-lft-identity68.9%
Simplified68.9%
if 22000 < th Initial program 97.1%
unpow297.1%
unpow297.1%
hypot-def99.7%
log1p-expm1-u99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 12.8%
expm1-def17.3%
Simplified17.3%
add-sqr-sqrt16.1%
fabs-sqr16.1%
add-sqr-sqrt36.0%
log1p-expm1-u36.0%
Applied egg-rr36.0%
Final simplification59.5%
(FPCore (kx ky th) :precision binary64 (if (<= kx 1.7e-33) (sin th) (* (sin th) (/ (sin ky) (fabs (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.7e-33) {
tmp = sin(th);
} else {
tmp = sin(th) * (sin(ky) / fabs(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 <= 1.7d-33) then
tmp = sin(th)
else
tmp = sin(th) * (sin(ky) / abs(sin(kx)))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.7e-33) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 1.7e-33: tmp = math.sin(th) else: tmp = math.sin(th) * (math.sin(ky) / math.fabs(math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 1.7e-33) tmp = sin(th); else tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 1.7e-33) tmp = sin(th); else tmp = sin(th) * (sin(ky) / abs(sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 1.7e-33], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 1.7 \cdot 10^{-33}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\
\end{array}
\end{array}
if kx < 1.7e-33Initial program 92.3%
remove-double-neg92.3%
sin-neg92.3%
neg-mul-192.3%
*-commutative92.3%
associate-*l*92.3%
associate-*l/89.7%
associate-/r/89.7%
associate-*l/92.3%
associate-/r/92.2%
sin-neg92.2%
neg-mul-192.2%
associate-/r*92.2%
associate-/r/92.3%
Simplified99.8%
Taylor expanded in kx around 0 28.5%
if 1.7e-33 < kx Initial program 99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
log1p-expm1-u99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 34.6%
expm1-def36.3%
Simplified36.3%
add-sqr-sqrt27.6%
fabs-sqr27.6%
add-sqr-sqrt62.1%
log1p-expm1-u62.2%
Applied egg-rr62.2%
Final simplification37.4%
(FPCore (kx ky th) :precision binary64 (if (<= kx 2.4e-33) (sin th) (* (sin th) (fabs (/ ky (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 2.4e-33) {
tmp = sin(th);
} else {
tmp = sin(th) * fabs((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 <= 2.4d-33) then
tmp = sin(th)
else
tmp = sin(th) * abs((ky / sin(kx)))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 2.4e-33) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 2.4e-33: tmp = math.sin(th) else: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 2.4e-33) tmp = sin(th); else tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 2.4e-33) tmp = sin(th); else tmp = sin(th) * abs((ky / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 2.4e-33], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 2.4 \cdot 10^{-33}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\end{array}
\end{array}
if kx < 2.4e-33Initial program 92.3%
remove-double-neg92.3%
sin-neg92.3%
neg-mul-192.3%
*-commutative92.3%
associate-*l*92.3%
associate-*l/89.7%
associate-/r/89.7%
associate-*l/92.3%
associate-/r/92.2%
sin-neg92.2%
neg-mul-192.2%
associate-/r*92.2%
associate-/r/92.3%
Simplified99.8%
Taylor expanded in kx around 0 28.5%
if 2.4e-33 < kx Initial program 99.6%
Taylor expanded in ky around 0 32.1%
add-sqr-sqrt14.4%
sqrt-unprod31.3%
pow231.3%
Applied egg-rr31.3%
unpow231.3%
rem-sqrt-square33.8%
Simplified33.8%
Final simplification29.9%
(FPCore (kx ky th) :precision binary64 (if (<= ky 3.3e-87) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3.3e-87) {
tmp = sin(th) * (ky / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 3.3d-87) then
tmp = sin(th) * (ky / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 3.3e-87) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 3.3e-87: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 3.3e-87) tmp = Float64(sin(th) * Float64(ky / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 3.3e-87) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 3.3e-87], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 3.3 \cdot 10^{-87}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 3.3e-87Initial program 91.6%
Taylor expanded in ky around 0 32.2%
if 3.3e-87 < ky Initial program 99.8%
remove-double-neg99.8%
sin-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-*l*99.8%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.8%
associate-/r/99.7%
sin-neg99.7%
neg-mul-199.7%
associate-/r*99.7%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in kx around 0 36.7%
Final simplification33.6%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.95e-105) (* (sin th) (/ ky kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.95e-105) {
tmp = sin(th) * (ky / kx);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 1.95d-105) then
tmp = sin(th) * (ky / kx)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.95e-105) {
tmp = Math.sin(th) * (ky / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.95e-105: tmp = math.sin(th) * (ky / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.95e-105) tmp = Float64(sin(th) * Float64(ky / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.95e-105) tmp = sin(th) * (ky / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.95e-105], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.95 \cdot 10^{-105}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.95e-105Initial program 91.5%
Taylor expanded in ky around 0 31.5%
Taylor expanded in kx around 0 22.3%
if 1.95e-105 < ky Initial program 99.8%
remove-double-neg99.8%
sin-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-*l*99.8%
associate-*l/99.5%
associate-/r/99.5%
associate-*l/99.8%
associate-/r/99.7%
sin-neg99.7%
neg-mul-199.7%
associate-/r*99.7%
associate-/r/99.8%
Simplified99.7%
Taylor expanded in kx around 0 35.6%
Final simplification26.8%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.6e-130) (/ ky (/ kx th)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.6e-130) {
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.6d-130) 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.6e-130) {
tmp = ky / (kx / th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.6e-130: tmp = ky / (kx / th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.6e-130) 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.6e-130) tmp = ky / (kx / th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.6e-130], N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.6 \cdot 10^{-130}:\\
\;\;\;\;\frac{ky}{\frac{kx}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.6e-130Initial program 91.2%
Taylor expanded in ky around 0 31.8%
Taylor expanded in kx around 0 22.9%
Taylor expanded in th around 0 17.0%
associate-/l*18.8%
Simplified18.8%
if 1.6e-130 < ky Initial program 99.8%
remove-double-neg99.8%
sin-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-*l*99.8%
associate-*l/99.6%
associate-/r/99.6%
associate-*l/99.8%
associate-/r/99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/r/99.8%
Simplified99.7%
Taylor expanded in kx around 0 36.0%
Final simplification24.9%
(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 94.3%
Taylor expanded in ky around 0 23.6%
Taylor expanded in kx around 0 16.4%
Taylor expanded in th around 0 12.6%
associate-/l*13.7%
Simplified13.7%
Final simplification13.7%
herbie shell --seed 2023339
(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)))