
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (hypot (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th
\end{array}
Initial program 93.8%
*-un-lft-identity93.8%
*-commutative93.8%
unpow293.8%
unpow293.8%
hypot-define99.7%
Applied egg-rr99.7%
*-rgt-identity99.7%
hypot-undefine93.8%
unpow293.8%
unpow293.8%
+-commutative93.8%
unpow293.8%
unpow293.8%
hypot-undefine99.7%
Simplified99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.012)
(/ 1.0 (/ (sin ky) (* (sin ky) (sin th))))
(if (or (<= (sin kx) 1.8e-125)
(and (not (<= (sin kx) 7.8e-81)) (<= (sin kx) 8.5e-25)))
(* (sin ky) (/ (sin th) (fabs (sin ky))))
(* (sin th) (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.012) {
tmp = 1.0 / (sin(ky) / (sin(ky) * sin(th)));
} else if ((sin(kx) <= 1.8e-125) || (!(sin(kx) <= 7.8e-81) && (sin(kx) <= 8.5e-25))) {
tmp = sin(ky) * (sin(th) / fabs(sin(ky)));
} 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.012d0)) then
tmp = 1.0d0 / (sin(ky) / (sin(ky) * sin(th)))
else if ((sin(kx) <= 1.8d-125) .or. (.not. (sin(kx) <= 7.8d-81)) .and. (sin(kx) <= 8.5d-25)) then
tmp = sin(ky) * (sin(th) / abs(sin(ky)))
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.012) {
tmp = 1.0 / (Math.sin(ky) / (Math.sin(ky) * Math.sin(th)));
} else if ((Math.sin(kx) <= 1.8e-125) || (!(Math.sin(kx) <= 7.8e-81) && (Math.sin(kx) <= 8.5e-25))) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.abs(Math.sin(ky)));
} 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.012: tmp = 1.0 / (math.sin(ky) / (math.sin(ky) * math.sin(th))) elif (math.sin(kx) <= 1.8e-125) or (not (math.sin(kx) <= 7.8e-81) and (math.sin(kx) <= 8.5e-25)): tmp = math.sin(ky) * (math.sin(th) / math.fabs(math.sin(ky))) 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.012) tmp = Float64(1.0 / Float64(sin(ky) / Float64(sin(ky) * sin(th)))); elseif ((sin(kx) <= 1.8e-125) || (!(sin(kx) <= 7.8e-81) && (sin(kx) <= 8.5e-25))) tmp = Float64(sin(ky) * Float64(sin(th) / abs(sin(ky)))); 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.012) tmp = 1.0 / (sin(ky) / (sin(ky) * sin(th))); elseif ((sin(kx) <= 1.8e-125) || (~((sin(kx) <= 7.8e-81)) && (sin(kx) <= 8.5e-25))) tmp = sin(ky) * (sin(th) / abs(sin(ky))); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.012], N[(1.0 / N[(N[Sin[ky], $MachinePrecision] / N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[Sin[kx], $MachinePrecision], 1.8e-125], And[N[Not[LessEqual[N[Sin[kx], $MachinePrecision], 7.8e-81]], $MachinePrecision], LessEqual[N[Sin[kx], $MachinePrecision], 8.5e-25]]], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $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.012:\\
\;\;\;\;\frac{1}{\frac{\sin ky}{\sin ky \cdot \sin th}}\\
\mathbf{elif}\;\sin kx \leq 1.8 \cdot 10^{-125} \lor \neg \left(\sin kx \leq 7.8 \cdot 10^{-81}\right) \land \sin kx \leq 8.5 \cdot 10^{-25}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\left|\sin ky\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.012Initial program 99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
associate-*l/99.5%
associate-/l*99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in kx around 0 9.1%
associate-*r/20.0%
clear-num20.0%
Applied egg-rr20.0%
if -0.012 < (sin.f64 kx) < 1.8000000000000001e-125 or 7.7999999999999997e-81 < (sin.f64 kx) < 8.49999999999999981e-25Initial program 86.6%
unpow286.6%
sqr-neg86.6%
sin-neg86.6%
sin-neg86.6%
unpow286.6%
associate-*l/84.1%
associate-/l*86.6%
unpow286.6%
Simplified99.9%
Taylor expanded in kx around 0 47.7%
add-sqr-sqrt46.1%
sqrt-unprod74.9%
sqr-sin-a54.4%
metadata-eval54.4%
*-commutative54.4%
associate-/r/54.2%
clear-num54.4%
add-sqr-sqrt54.4%
rem-sqrt-square54.4%
clear-num54.2%
associate-/r/54.4%
metadata-eval54.4%
*-commutative54.4%
sqr-sin-a74.9%
sqrt-unprod46.1%
add-sqr-sqrt84.2%
Applied egg-rr84.2%
if 1.8000000000000001e-125 < (sin.f64 kx) < 7.7999999999999997e-81 or 8.49999999999999981e-25 < (sin.f64 kx) Initial program 99.5%
Taylor expanded in ky around 0 58.7%
Final simplification59.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin kx) -0.012)
(/ 1.0 (/ (sin ky) (* (sin ky) (sin th))))
(if (<= (sin kx) 1.8e-129)
(sin th)
(if (or (<= (sin kx) 1.6e-80) (not (<= (sin kx) 6e-26)))
(* (sin th) (/ (sin ky) (sin kx)))
(fabs (sin th))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.012) {
tmp = 1.0 / (sin(ky) / (sin(ky) * sin(th)));
} else if (sin(kx) <= 1.8e-129) {
tmp = sin(th);
} else if ((sin(kx) <= 1.6e-80) || !(sin(kx) <= 6e-26)) {
tmp = sin(th) * (sin(ky) / sin(kx));
} 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 (sin(kx) <= (-0.012d0)) then
tmp = 1.0d0 / (sin(ky) / (sin(ky) * sin(th)))
else if (sin(kx) <= 1.8d-129) then
tmp = sin(th)
else if ((sin(kx) <= 1.6d-80) .or. (.not. (sin(kx) <= 6d-26))) then
tmp = sin(th) * (sin(ky) / sin(kx))
else
tmp = abs(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.012) {
tmp = 1.0 / (Math.sin(ky) / (Math.sin(ky) * Math.sin(th)));
} else if (Math.sin(kx) <= 1.8e-129) {
tmp = Math.sin(th);
} else if ((Math.sin(kx) <= 1.6e-80) || !(Math.sin(kx) <= 6e-26)) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
} else {
tmp = Math.abs(Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.012: tmp = 1.0 / (math.sin(ky) / (math.sin(ky) * math.sin(th))) elif math.sin(kx) <= 1.8e-129: tmp = math.sin(th) elif (math.sin(kx) <= 1.6e-80) or not (math.sin(kx) <= 6e-26): tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) else: tmp = math.fabs(math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.012) tmp = Float64(1.0 / Float64(sin(ky) / Float64(sin(ky) * sin(th)))); elseif (sin(kx) <= 1.8e-129) tmp = sin(th); elseif ((sin(kx) <= 1.6e-80) || !(sin(kx) <= 6e-26)) tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); else tmp = abs(sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.012) tmp = 1.0 / (sin(ky) / (sin(ky) * sin(th))); elseif (sin(kx) <= 1.8e-129) tmp = sin(th); elseif ((sin(kx) <= 1.6e-80) || ~((sin(kx) <= 6e-26))) tmp = sin(th) * (sin(ky) / sin(kx)); else tmp = abs(sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.012], N[(1.0 / N[(N[Sin[ky], $MachinePrecision] / N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 1.8e-129], N[Sin[th], $MachinePrecision], If[Or[LessEqual[N[Sin[kx], $MachinePrecision], 1.6e-80], N[Not[LessEqual[N[Sin[kx], $MachinePrecision], 6e-26]], $MachinePrecision]], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.012:\\
\;\;\;\;\frac{1}{\frac{\sin ky}{\sin ky \cdot \sin th}}\\
\mathbf{elif}\;\sin kx \leq 1.8 \cdot 10^{-129}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin kx \leq 1.6 \cdot 10^{-80} \lor \neg \left(\sin kx \leq 6 \cdot 10^{-26}\right):\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.012Initial program 99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
associate-*l/99.5%
associate-/l*99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in kx around 0 9.1%
associate-*r/20.0%
clear-num20.0%
Applied egg-rr20.0%
if -0.012 < (sin.f64 kx) < 1.8e-129Initial program 85.1%
unpow285.1%
sqr-neg85.1%
sin-neg85.1%
sin-neg85.1%
unpow285.1%
associate-*l/82.3%
associate-/l*85.0%
unpow285.0%
Simplified99.9%
Taylor expanded in kx around 0 45.4%
if 1.8e-129 < (sin.f64 kx) < 1.5999999999999999e-80 or 6.00000000000000023e-26 < (sin.f64 kx) Initial program 99.5%
Taylor expanded in ky around 0 58.7%
if 1.5999999999999999e-80 < (sin.f64 kx) < 6.00000000000000023e-26Initial program 99.9%
unpow299.9%
sqr-neg99.9%
sin-neg99.9%
sin-neg99.9%
unpow299.9%
associate-*l/99.7%
associate-/l*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in kx around 0 68.1%
add-sqr-sqrt33.9%
sqrt-unprod35.9%
pow235.9%
associate-*r/35.9%
*-commutative35.9%
associate-/l*35.9%
Applied egg-rr35.9%
unpow235.9%
rem-sqrt-square51.6%
*-inverses51.6%
*-rgt-identity51.6%
Simplified51.6%
Final simplification42.9%
(FPCore (kx ky th) :precision binary64 (* (sin ky) (/ (sin th) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
return sin(ky) * (sin(th) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(ky) * (Math.sin(th) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th): return math.sin(ky) * (math.sin(th) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th) return Float64(sin(ky) * Float64(sin(th) / hypot(sin(ky), sin(kx)))) end
function tmp = code(kx, ky, th) tmp = sin(ky) * (sin(th) / hypot(sin(ky), sin(kx))); end
code[kx_, ky_, th_] := N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Initial program 93.8%
unpow293.8%
sqr-neg93.8%
sin-neg93.8%
sin-neg93.8%
unpow293.8%
associate-*l/92.6%
associate-/l*93.8%
unpow293.8%
Simplified99.6%
(FPCore (kx ky th) :precision binary64 (if (<= ky 0.0031) (* (sin th) (/ (sin ky) (hypot ky (sin kx)))) (* (sin ky) (/ (sin th) (fabs (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 0.0031) {
tmp = sin(th) * (sin(ky) / hypot(ky, sin(kx)));
} else {
tmp = sin(ky) * (sin(th) / fabs(sin(ky)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 0.0031) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(ky, Math.sin(kx)));
} else {
tmp = Math.sin(ky) * (Math.sin(th) / Math.abs(Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 0.0031: tmp = math.sin(th) * (math.sin(ky) / math.hypot(ky, math.sin(kx))) else: tmp = math.sin(ky) * (math.sin(th) / math.fabs(math.sin(ky))) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 0.0031) tmp = Float64(sin(th) * Float64(sin(ky) / hypot(ky, sin(kx)))); else tmp = Float64(sin(ky) * Float64(sin(th) / abs(sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 0.0031) tmp = sin(th) * (sin(ky) / hypot(ky, sin(kx))); else tmp = sin(ky) * (sin(th) / abs(sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 0.0031], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 0.0031:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\left|\sin ky\right|}\\
\end{array}
\end{array}
if ky < 0.00309999999999999989Initial program 91.6%
*-un-lft-identity91.6%
*-commutative91.6%
unpow291.6%
unpow291.6%
hypot-define99.7%
Applied egg-rr99.7%
*-rgt-identity99.7%
hypot-undefine91.6%
unpow291.6%
unpow291.6%
+-commutative91.6%
unpow291.6%
unpow291.6%
hypot-undefine99.7%
Simplified99.7%
Taylor expanded in ky around 0 65.1%
if 0.00309999999999999989 < ky Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.4%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 30.7%
add-sqr-sqrt29.3%
sqrt-unprod54.2%
sqr-sin-a54.0%
metadata-eval54.0%
*-commutative54.0%
associate-/r/54.0%
clear-num54.0%
add-sqr-sqrt54.0%
rem-sqrt-square54.0%
clear-num54.0%
associate-/r/54.0%
metadata-eval54.0%
*-commutative54.0%
sqr-sin-a54.2%
sqrt-unprod29.3%
add-sqr-sqrt54.2%
Applied egg-rr54.2%
Final simplification62.1%
(FPCore (kx ky th)
:precision binary64
(if (<= kx 1.3e-131)
(sin th)
(if (or (<= kx 3.6e-80) (not (<= kx 1.7e-24)))
(* (sin th) (/ (sin ky) (sin kx)))
(fabs (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.3e-131) {
tmp = sin(th);
} else if ((kx <= 3.6e-80) || !(kx <= 1.7e-24)) {
tmp = sin(th) * (sin(ky) / sin(kx));
} 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 (kx <= 1.3d-131) then
tmp = sin(th)
else if ((kx <= 3.6d-80) .or. (.not. (kx <= 1.7d-24))) then
tmp = sin(th) * (sin(ky) / sin(kx))
else
tmp = abs(sin(th))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.3e-131) {
tmp = Math.sin(th);
} else if ((kx <= 3.6e-80) || !(kx <= 1.7e-24)) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
} else {
tmp = Math.abs(Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 1.3e-131: tmp = math.sin(th) elif (kx <= 3.6e-80) or not (kx <= 1.7e-24): tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) else: tmp = math.fabs(math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 1.3e-131) tmp = sin(th); elseif ((kx <= 3.6e-80) || !(kx <= 1.7e-24)) tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); else tmp = abs(sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 1.3e-131) tmp = sin(th); elseif ((kx <= 3.6e-80) || ~((kx <= 1.7e-24))) tmp = sin(th) * (sin(ky) / sin(kx)); else tmp = abs(sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 1.3e-131], N[Sin[th], $MachinePrecision], If[Or[LessEqual[kx, 3.6e-80], N[Not[LessEqual[kx, 1.7e-24]], $MachinePrecision]], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 1.3 \cdot 10^{-131}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;kx \leq 3.6 \cdot 10^{-80} \lor \neg \left(kx \leq 1.7 \cdot 10^{-24}\right):\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\
\end{array}
\end{array}
if kx < 1.29999999999999998e-131Initial program 90.2%
unpow290.2%
sqr-neg90.2%
sin-neg90.2%
sin-neg90.2%
unpow290.2%
associate-*l/88.3%
associate-/l*90.1%
unpow290.1%
Simplified99.7%
Taylor expanded in kx around 0 31.9%
if 1.29999999999999998e-131 < kx < 3.6e-80 or 1.69999999999999996e-24 < kx Initial program 99.4%
Taylor expanded in ky around 0 35.4%
if 3.6e-80 < kx < 1.69999999999999996e-24Initial program 99.9%
unpow299.9%
sqr-neg99.9%
sin-neg99.9%
sin-neg99.9%
unpow299.9%
associate-*l/99.7%
associate-/l*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in kx around 0 68.1%
add-sqr-sqrt33.9%
sqrt-unprod35.9%
pow235.9%
associate-*r/35.9%
*-commutative35.9%
associate-/l*35.9%
Applied egg-rr35.9%
unpow235.9%
rem-sqrt-square51.6%
*-inverses51.6%
*-rgt-identity51.6%
Simplified51.6%
Final simplification34.0%
(FPCore (kx ky th)
:precision binary64
(if (<= kx 1.8e-129)
(sin th)
(if (or (<= kx 8.5e-81) (not (<= kx 7.6e-26)))
(* (sin ky) (/ (sin th) (sin kx)))
(fabs (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.8e-129) {
tmp = sin(th);
} else if ((kx <= 8.5e-81) || !(kx <= 7.6e-26)) {
tmp = sin(ky) * (sin(th) / sin(kx));
} 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 (kx <= 1.8d-129) then
tmp = sin(th)
else if ((kx <= 8.5d-81) .or. (.not. (kx <= 7.6d-26))) then
tmp = sin(ky) * (sin(th) / sin(kx))
else
tmp = abs(sin(th))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.8e-129) {
tmp = Math.sin(th);
} else if ((kx <= 8.5e-81) || !(kx <= 7.6e-26)) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.abs(Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 1.8e-129: tmp = math.sin(th) elif (kx <= 8.5e-81) or not (kx <= 7.6e-26): tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) else: tmp = math.fabs(math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 1.8e-129) tmp = sin(th); elseif ((kx <= 8.5e-81) || !(kx <= 7.6e-26)) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); else tmp = abs(sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 1.8e-129) tmp = sin(th); elseif ((kx <= 8.5e-81) || ~((kx <= 7.6e-26))) tmp = sin(ky) * (sin(th) / sin(kx)); else tmp = abs(sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 1.8e-129], N[Sin[th], $MachinePrecision], If[Or[LessEqual[kx, 8.5e-81], N[Not[LessEqual[kx, 7.6e-26]], $MachinePrecision]], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 1.8 \cdot 10^{-129}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;kx \leq 8.5 \cdot 10^{-81} \lor \neg \left(kx \leq 7.6 \cdot 10^{-26}\right):\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\
\end{array}
\end{array}
if kx < 1.8e-129Initial program 90.2%
unpow290.2%
sqr-neg90.2%
sin-neg90.2%
sin-neg90.2%
unpow290.2%
associate-*l/88.3%
associate-/l*90.1%
unpow290.1%
Simplified99.7%
Taylor expanded in kx around 0 31.9%
if 1.8e-129 < kx < 8.5000000000000001e-81 or 7.60000000000000029e-26 < kx Initial program 99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
associate-*l/99.3%
associate-/l*99.4%
unpow299.4%
Simplified99.4%
Taylor expanded in ky around 0 35.3%
if 8.5000000000000001e-81 < kx < 7.60000000000000029e-26Initial program 99.9%
unpow299.9%
sqr-neg99.9%
sin-neg99.9%
sin-neg99.9%
unpow299.9%
associate-*l/99.7%
associate-/l*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in kx around 0 68.1%
add-sqr-sqrt33.9%
sqrt-unprod35.9%
pow235.9%
associate-*r/35.9%
*-commutative35.9%
associate-/l*35.9%
Applied egg-rr35.9%
unpow235.9%
rem-sqrt-square51.6%
*-inverses51.6%
*-rgt-identity51.6%
Simplified51.6%
Final simplification34.0%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ ky (sin kx))))
(if (<= kx 1.3e-125)
(sin th)
(if (<= kx 1.6e-80)
(* (sin th) t_1)
(if (<= kx 2.5e-25) (fabs (sin th)) (* (sin th) (expm1 t_1)))))))
double code(double kx, double ky, double th) {
double t_1 = ky / sin(kx);
double tmp;
if (kx <= 1.3e-125) {
tmp = sin(th);
} else if (kx <= 1.6e-80) {
tmp = sin(th) * t_1;
} else if (kx <= 2.5e-25) {
tmp = fabs(sin(th));
} else {
tmp = sin(th) * expm1(t_1);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = ky / Math.sin(kx);
double tmp;
if (kx <= 1.3e-125) {
tmp = Math.sin(th);
} else if (kx <= 1.6e-80) {
tmp = Math.sin(th) * t_1;
} else if (kx <= 2.5e-25) {
tmp = Math.abs(Math.sin(th));
} else {
tmp = Math.sin(th) * Math.expm1(t_1);
}
return tmp;
}
def code(kx, ky, th): t_1 = ky / math.sin(kx) tmp = 0 if kx <= 1.3e-125: tmp = math.sin(th) elif kx <= 1.6e-80: tmp = math.sin(th) * t_1 elif kx <= 2.5e-25: tmp = math.fabs(math.sin(th)) else: tmp = math.sin(th) * math.expm1(t_1) return tmp
function code(kx, ky, th) t_1 = Float64(ky / sin(kx)) tmp = 0.0 if (kx <= 1.3e-125) tmp = sin(th); elseif (kx <= 1.6e-80) tmp = Float64(sin(th) * t_1); elseif (kx <= 2.5e-25) tmp = abs(sin(th)); else tmp = Float64(sin(th) * expm1(t_1)); end return tmp end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[kx, 1.3e-125], N[Sin[th], $MachinePrecision], If[LessEqual[kx, 1.6e-80], N[(N[Sin[th], $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[kx, 2.5e-25], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(Exp[t$95$1] - 1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{ky}{\sin kx}\\
\mathbf{if}\;kx \leq 1.3 \cdot 10^{-125}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;kx \leq 1.6 \cdot 10^{-80}:\\
\;\;\;\;\sin th \cdot t\_1\\
\mathbf{elif}\;kx \leq 2.5 \cdot 10^{-25}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \mathsf{expm1}\left(t\_1\right)\\
\end{array}
\end{array}
if kx < 1.30000000000000003e-125Initial program 90.2%
unpow290.2%
sqr-neg90.2%
sin-neg90.2%
sin-neg90.2%
unpow290.2%
associate-*l/88.3%
associate-/l*90.1%
unpow290.1%
Simplified99.7%
Taylor expanded in kx around 0 31.9%
if 1.30000000000000003e-125 < kx < 1.5999999999999999e-80Initial program 100.0%
Taylor expanded in ky around 0 72.3%
if 1.5999999999999999e-80 < kx < 2.49999999999999981e-25Initial program 99.9%
unpow299.9%
sqr-neg99.9%
sin-neg99.9%
sin-neg99.9%
unpow299.9%
associate-*l/99.7%
associate-/l*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in kx around 0 68.1%
add-sqr-sqrt33.9%
sqrt-unprod35.9%
pow235.9%
associate-*r/35.9%
*-commutative35.9%
associate-/l*35.9%
Applied egg-rr35.9%
unpow235.9%
rem-sqrt-square51.6%
*-inverses51.6%
*-rgt-identity51.6%
Simplified51.6%
if 2.49999999999999981e-25 < kx Initial program 99.3%
expm1-log1p-u99.3%
expm1-undefine67.3%
unpow267.3%
unpow267.3%
hypot-define67.3%
Applied egg-rr67.3%
expm1-define99.3%
hypot-undefine99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-undefine99.3%
Simplified99.3%
Taylor expanded in ky around 0 28.4%
Final simplification32.8%
(FPCore (kx ky th)
:precision binary64
(if (<= kx 1e-125)
(sin th)
(if (or (<= kx 2.9e-80) (not (<= kx 4.5e-26)))
(* (sin th) (/ ky (sin kx)))
(fabs (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1e-125) {
tmp = sin(th);
} else if ((kx <= 2.9e-80) || !(kx <= 4.5e-26)) {
tmp = sin(th) * (ky / sin(kx));
} 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 (kx <= 1d-125) then
tmp = sin(th)
else if ((kx <= 2.9d-80) .or. (.not. (kx <= 4.5d-26))) then
tmp = sin(th) * (ky / sin(kx))
else
tmp = abs(sin(th))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1e-125) {
tmp = Math.sin(th);
} else if ((kx <= 2.9e-80) || !(kx <= 4.5e-26)) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.abs(Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 1e-125: tmp = math.sin(th) elif (kx <= 2.9e-80) or not (kx <= 4.5e-26): tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.fabs(math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 1e-125) tmp = sin(th); elseif ((kx <= 2.9e-80) || !(kx <= 4.5e-26)) tmp = Float64(sin(th) * Float64(ky / sin(kx))); else tmp = abs(sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 1e-125) tmp = sin(th); elseif ((kx <= 2.9e-80) || ~((kx <= 4.5e-26))) tmp = sin(th) * (ky / sin(kx)); else tmp = abs(sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 1e-125], N[Sin[th], $MachinePrecision], If[Or[LessEqual[kx, 2.9e-80], N[Not[LessEqual[kx, 4.5e-26]], $MachinePrecision]], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 10^{-125}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;kx \leq 2.9 \cdot 10^{-80} \lor \neg \left(kx \leq 4.5 \cdot 10^{-26}\right):\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\
\end{array}
\end{array}
if kx < 1.00000000000000001e-125Initial program 90.2%
unpow290.2%
sqr-neg90.2%
sin-neg90.2%
sin-neg90.2%
unpow290.2%
associate-*l/88.3%
associate-/l*90.1%
unpow290.1%
Simplified99.7%
Taylor expanded in kx around 0 31.9%
if 1.00000000000000001e-125 < kx < 2.89999999999999998e-80 or 4.4999999999999999e-26 < kx Initial program 99.4%
Taylor expanded in ky around 0 30.6%
if 2.89999999999999998e-80 < kx < 4.4999999999999999e-26Initial program 99.9%
unpow299.9%
sqr-neg99.9%
sin-neg99.9%
sin-neg99.9%
unpow299.9%
associate-*l/99.7%
associate-/l*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in kx around 0 68.1%
add-sqr-sqrt33.9%
sqrt-unprod35.9%
pow235.9%
associate-*r/35.9%
*-commutative35.9%
associate-/l*35.9%
Applied egg-rr35.9%
unpow235.9%
rem-sqrt-square51.6%
*-inverses51.6%
*-rgt-identity51.6%
Simplified51.6%
Final simplification32.4%
(FPCore (kx ky th)
:precision binary64
(if (<= kx 1.8e-125)
(sin th)
(if (or (<= kx 4.5e-80) (not (<= kx 1.85e-25)))
(* ky (/ (sin th) (sin kx)))
(fabs (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.8e-125) {
tmp = sin(th);
} else if ((kx <= 4.5e-80) || !(kx <= 1.85e-25)) {
tmp = ky * (sin(th) / sin(kx));
} 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 (kx <= 1.8d-125) then
tmp = sin(th)
else if ((kx <= 4.5d-80) .or. (.not. (kx <= 1.85d-25))) then
tmp = ky * (sin(th) / sin(kx))
else
tmp = abs(sin(th))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.8e-125) {
tmp = Math.sin(th);
} else if ((kx <= 4.5e-80) || !(kx <= 1.85e-25)) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.abs(Math.sin(th));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 1.8e-125: tmp = math.sin(th) elif (kx <= 4.5e-80) or not (kx <= 1.85e-25): tmp = ky * (math.sin(th) / math.sin(kx)) else: tmp = math.fabs(math.sin(th)) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 1.8e-125) tmp = sin(th); elseif ((kx <= 4.5e-80) || !(kx <= 1.85e-25)) tmp = Float64(ky * Float64(sin(th) / sin(kx))); else tmp = abs(sin(th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 1.8e-125) tmp = sin(th); elseif ((kx <= 4.5e-80) || ~((kx <= 1.85e-25))) tmp = ky * (sin(th) / sin(kx)); else tmp = abs(sin(th)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 1.8e-125], N[Sin[th], $MachinePrecision], If[Or[LessEqual[kx, 4.5e-80], N[Not[LessEqual[kx, 1.85e-25]], $MachinePrecision]], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 1.8 \cdot 10^{-125}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;kx \leq 4.5 \cdot 10^{-80} \lor \neg \left(kx \leq 1.85 \cdot 10^{-25}\right):\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\
\end{array}
\end{array}
if kx < 1.8000000000000001e-125Initial program 90.2%
unpow290.2%
sqr-neg90.2%
sin-neg90.2%
sin-neg90.2%
unpow290.2%
associate-*l/88.3%
associate-/l*90.1%
unpow290.1%
Simplified99.7%
Taylor expanded in kx around 0 31.9%
if 1.8000000000000001e-125 < kx < 4.5000000000000003e-80 or 1.85000000000000004e-25 < kx Initial program 99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
associate-*l/99.3%
associate-/l*99.4%
unpow299.4%
Simplified99.4%
Taylor expanded in ky around 0 30.6%
associate-/l*30.6%
Simplified30.6%
if 4.5000000000000003e-80 < kx < 1.85000000000000004e-25Initial program 99.9%
unpow299.9%
sqr-neg99.9%
sin-neg99.9%
sin-neg99.9%
unpow299.9%
associate-*l/99.7%
associate-/l*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in kx around 0 68.1%
add-sqr-sqrt33.9%
sqrt-unprod35.9%
pow235.9%
associate-*r/35.9%
*-commutative35.9%
associate-/l*35.9%
Applied egg-rr35.9%
unpow235.9%
rem-sqrt-square51.6%
*-inverses51.6%
*-rgt-identity51.6%
Simplified51.6%
Final simplification32.4%
(FPCore (kx ky th) :precision binary64 (if (<= ky 1.15e-188) (sqrt (pow th 2.0)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 1.15e-188) {
tmp = sqrt(pow(th, 2.0));
} 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.15d-188) then
tmp = sqrt((th ** 2.0d0))
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.15e-188) {
tmp = Math.sqrt(Math.pow(th, 2.0));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 1.15e-188: tmp = math.sqrt(math.pow(th, 2.0)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 1.15e-188) tmp = sqrt((th ^ 2.0)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 1.15e-188) tmp = sqrt((th ^ 2.0)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.15e-188], N[Sqrt[N[Power[th, 2.0], $MachinePrecision]], $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.15 \cdot 10^{-188}:\\
\;\;\;\;\sqrt{{th}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 1.15e-188Initial program 92.1%
unpow292.1%
sqr-neg92.1%
sin-neg92.1%
sin-neg92.1%
unpow292.1%
associate-*l/90.8%
associate-/l*92.0%
unpow292.0%
Simplified99.6%
Taylor expanded in kx around 0 15.9%
add-sqr-sqrt7.5%
sqrt-unprod27.6%
pow227.6%
associate-*r/30.2%
*-commutative30.2%
associate-/l*27.6%
Applied egg-rr27.6%
*-inverses27.6%
*-commutative27.6%
Simplified27.6%
Taylor expanded in th around 0 19.0%
if 1.15e-188 < ky Initial program 95.9%
unpow295.9%
sqr-neg95.9%
sin-neg95.9%
sin-neg95.9%
unpow295.9%
associate-*l/95.0%
associate-/l*95.9%
unpow295.9%
Simplified99.6%
Taylor expanded in kx around 0 37.8%
(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 93.8%
unpow293.8%
sqr-neg93.8%
sin-neg93.8%
sin-neg93.8%
unpow293.8%
associate-*l/92.6%
associate-/l*93.8%
unpow293.8%
Simplified99.6%
Taylor expanded in kx around 0 25.7%
(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 93.8%
unpow293.8%
sqr-neg93.8%
sin-neg93.8%
sin-neg93.8%
unpow293.8%
associate-*l/92.6%
associate-/l*93.8%
unpow293.8%
Simplified99.6%
Taylor expanded in kx around 0 25.7%
Taylor expanded in th around 0 16.2%
herbie shell --seed 2024111
(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)))