
(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 9 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 ky) -0.0002)
(cbrt (sqrt (pow (sin th) 6.0)))
(if (<= (sin ky) 0.002)
(* (sin th) (fabs (/ (sin ky) (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0002) {
tmp = cbrt(sqrt(pow(sin(th), 6.0)));
} else if (sin(ky) <= 0.002) {
tmp = sin(th) * fabs((sin(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.cbrt(Math.sqrt(Math.pow(Math.sin(th), 6.0)));
} else if (Math.sin(ky) <= 0.002) {
tmp = Math.sin(th) * Math.abs((Math.sin(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 = cbrt(sqrt((sin(th) ^ 6.0))); elseif (sin(ky) <= 0.002) tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.0002], N[Power[N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], 6.0], $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.002], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.0002:\\
\;\;\;\;\sqrt[3]{\sqrt{{\sin th}^{6}}}\\
\mathbf{elif}\;\sin ky \leq 0.002:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2.0000000000000001e-4Initial program 99.5%
add-cbrt-cube68.0%
pow368.0%
associate-*l/67.9%
unpow267.9%
unpow267.9%
hypot-define67.9%
Applied egg-rr67.9%
Taylor expanded in kx around 0 3.2%
add-sqr-sqrt2.7%
sqrt-unprod16.5%
pow-prod-up16.5%
metadata-eval16.5%
Applied egg-rr16.5%
if -2.0000000000000001e-4 < (sin.f64 ky) < 2e-3Initial program 86.2%
Taylor expanded in ky around 0 45.8%
add-sqr-sqrt22.8%
sqrt-unprod34.2%
pow234.2%
Applied egg-rr34.2%
unpow234.2%
rem-sqrt-square39.0%
Simplified39.0%
if 2e-3 < (sin.f64 ky) Initial program 99.5%
Taylor expanded in kx around 0 53.1%
Final simplification35.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.0002) (fabs (sin th)) (if (<= (sin ky) 0.002) (* (sin th) (fabs (/ ky (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0002) {
tmp = fabs(sin(th));
} else if (sin(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 (sin(ky) <= (-0.0002d0)) then
tmp = abs(sin(th))
else if (sin(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 (Math.sin(ky) <= -0.0002) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(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 math.sin(ky) <= -0.0002: tmp = math.fabs(math.sin(th)) elif math.sin(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 (sin(ky) <= -0.0002) tmp = abs(sin(th)); elseif (sin(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 (sin(ky) <= -0.0002) tmp = abs(sin(th)); elseif (sin(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[N[Sin[ky], $MachinePrecision], -0.0002], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 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}\;\sin ky \leq -0.0002:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 0.002:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2.0000000000000001e-4Initial program 99.5%
add-cbrt-cube68.0%
pow368.0%
associate-*l/67.9%
unpow267.9%
unpow267.9%
hypot-define67.9%
Applied egg-rr67.9%
Taylor expanded in kx around 0 3.2%
rem-cbrt-cube2.7%
add-sqr-sqrt1.3%
sqrt-unprod22.5%
pow222.5%
Applied egg-rr22.5%
unpow222.5%
rem-sqrt-square31.6%
Simplified31.6%
if -2.0000000000000001e-4 < (sin.f64 ky) < 2e-3Initial program 86.2%
Taylor expanded in ky around 0 41.9%
associate-/l*45.8%
associate-/r/45.8%
Simplified45.8%
add-sqr-sqrt22.8%
sqrt-unprod34.1%
pow234.1%
Applied egg-rr34.1%
unpow234.1%
rem-sqrt-square39.0%
Simplified39.0%
if 2e-3 < (sin.f64 ky) Initial program 99.5%
Taylor expanded in kx around 0 53.1%
Final simplification40.0%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.0002) (cbrt (sqrt (pow (sin th) 6.0))) (if (<= (sin ky) 0.002) (* (sin th) (fabs (/ ky (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0002) {
tmp = cbrt(sqrt(pow(sin(th), 6.0)));
} else if (sin(ky) <= 0.002) {
tmp = sin(th) * fabs((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.cbrt(Math.sqrt(Math.pow(Math.sin(th), 6.0)));
} else if (Math.sin(ky) <= 0.002) {
tmp = Math.sin(th) * Math.abs((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 = cbrt(sqrt((sin(th) ^ 6.0))); elseif (sin(ky) <= 0.002) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.0002], N[Power[N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], 6.0], $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 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}\;\sin ky \leq -0.0002:\\
\;\;\;\;\sqrt[3]{\sqrt{{\sin th}^{6}}}\\
\mathbf{elif}\;\sin ky \leq 0.002:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2.0000000000000001e-4Initial program 99.5%
add-cbrt-cube68.0%
pow368.0%
associate-*l/67.9%
unpow267.9%
unpow267.9%
hypot-define67.9%
Applied egg-rr67.9%
Taylor expanded in kx around 0 3.2%
add-sqr-sqrt2.7%
sqrt-unprod16.5%
pow-prod-up16.5%
metadata-eval16.5%
Applied egg-rr16.5%
if -2.0000000000000001e-4 < (sin.f64 ky) < 2e-3Initial program 86.2%
Taylor expanded in ky around 0 41.9%
associate-/l*45.8%
associate-/r/45.8%
Simplified45.8%
add-sqr-sqrt22.8%
sqrt-unprod34.1%
pow234.1%
Applied egg-rr34.1%
unpow234.1%
rem-sqrt-square39.0%
Simplified39.0%
if 2e-3 < (sin.f64 ky) Initial program 99.5%
Taylor expanded in kx around 0 53.1%
Final simplification35.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.0002) (fabs (sin th)) (if (<= (sin ky) 5e-46) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0002) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 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 (sin(ky) <= (-0.0002d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 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 (Math.sin(ky) <= -0.0002) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 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 math.sin(ky) <= -0.0002: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 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 (sin(ky) <= -0.0002) tmp = abs(sin(th)); elseif (sin(ky) <= 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 (sin(ky) <= -0.0002) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-46) 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[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 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}\;\sin ky \leq -0.0002:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-46}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2.0000000000000001e-4Initial program 99.5%
add-cbrt-cube68.0%
pow368.0%
associate-*l/67.9%
unpow267.9%
unpow267.9%
hypot-define67.9%
Applied egg-rr67.9%
Taylor expanded in kx around 0 3.2%
rem-cbrt-cube2.7%
add-sqr-sqrt1.3%
sqrt-unprod22.5%
pow222.5%
Applied egg-rr22.5%
unpow222.5%
rem-sqrt-square31.6%
Simplified31.6%
if -2.0000000000000001e-4 < (sin.f64 ky) < 4.99999999999999992e-46Initial program 85.0%
Taylor expanded in ky around 0 42.6%
associate-/l*46.9%
associate-/r/46.9%
Simplified46.9%
if 4.99999999999999992e-46 < (sin.f64 ky) Initial program 99.6%
Taylor expanded in kx around 0 54.1%
Final simplification44.6%
(FPCore (kx ky th)
:precision binary64
(if (<= ky 7.4e-109)
(* (sin th) (/ ky kx))
(if (or (<= ky 8.5e+118) (not (<= ky 2.95e+206)))
(sin th)
(fabs (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 7.4e-109) {
tmp = sin(th) * (ky / kx);
} else if ((ky <= 8.5e+118) || !(ky <= 2.95e+206)) {
tmp = sin(th);
} else {
tmp = fabs(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 <= 7.4d-109) then
tmp = sin(th) * (ky / kx)
else if ((ky <= 8.5d+118) .or. (.not. (ky <= 2.95d+206))) then
tmp = sin(th)
else
tmp = abs(sin(th))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 7.4e-109) {
tmp = Math.sin(th) * (ky / kx);
} else if ((ky <= 8.5e+118) || !(ky <= 2.95e+206)) {
tmp = Math.sin(th);
} else {
tmp = Math.abs(Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 7.4e-109: tmp = math.sin(th) * (ky / kx) elif (ky <= 8.5e+118) or not (ky <= 2.95e+206): tmp = math.sin(th) else: tmp = math.fabs(math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 7.4e-109) tmp = Float64(sin(th) * Float64(ky / kx)); elseif ((ky <= 8.5e+118) || !(ky <= 2.95e+206)) tmp = sin(th); else tmp = abs(sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 7.4e-109) tmp = sin(th) * (ky / kx); elseif ((ky <= 8.5e+118) || ~((ky <= 2.95e+206))) tmp = sin(th); else tmp = abs(sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 7.4e-109], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[ky, 8.5e+118], N[Not[LessEqual[ky, 2.95e+206]], $MachinePrecision]], N[Sin[th], $MachinePrecision], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 7.4 \cdot 10^{-109}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\mathbf{elif}\;ky \leq 8.5 \cdot 10^{+118} \lor \neg \left(ky \leq 2.95 \cdot 10^{+206}\right):\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\
\end{array}
\end{array}
if ky < 7.39999999999999961e-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 7.39999999999999961e-109 < ky < 8.50000000000000033e118 or 2.95e206 < ky Initial program 99.7%
Taylor expanded in kx around 0 32.1%
if 8.50000000000000033e118 < ky < 2.95e206Initial program 99.5%
add-cbrt-cube82.3%
pow382.4%
associate-*l/82.4%
unpow282.4%
unpow282.4%
hypot-define82.4%
Applied egg-rr82.4%
Taylor expanded in kx around 0 16.5%
rem-cbrt-cube21.2%
add-sqr-sqrt9.7%
sqrt-unprod17.3%
pow217.3%
Applied egg-rr17.3%
unpow217.3%
rem-sqrt-square25.8%
Simplified25.8%
Final simplification24.4%
(FPCore (kx ky th) :precision binary64 (if (<= ky 2.6e-108) (* (sin th) (/ ky kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 2.6e-108) {
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 <= 2.6d-108) 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 <= 2.6e-108) {
tmp = Math.sin(th) * (ky / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 2.6e-108: tmp = math.sin(th) * (ky / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 2.6e-108) 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 <= 2.6e-108) tmp = sin(th) * (ky / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 2.6e-108], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 2.6 \cdot 10^{-108}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 2.59999999999999984e-108Initial 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 2.59999999999999984e-108 < ky Initial program 99.7%
Taylor expanded in kx around 0 29.1%
Final simplification24.0%
(FPCore (kx ky th) :precision binary64 (sin th))
double code(double kx, double ky, double th) {
return sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = sin(th)
end function
public static double code(double kx, double ky, double th) {
return Math.sin(th);
}
def code(kx, ky, th): return math.sin(th)
function code(kx, ky, th) return sin(th) end
function tmp = code(kx, ky, th) tmp = sin(th); end
code[kx_, ky_, th_] := N[Sin[th], $MachinePrecision]
\begin{array}{l}
\\
\sin th
\end{array}
Initial program 92.8%
Taylor expanded in kx around 0 19.6%
Final simplification19.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 92.8%
add-cbrt-cube59.6%
pow359.6%
associate-*l/59.5%
unpow259.5%
unpow259.5%
hypot-define62.8%
Applied egg-rr62.8%
Taylor expanded in kx around 0 20.4%
Taylor expanded in th around 0 11.7%
Final simplification11.7%
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)))