
(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 th) (/ (hypot (sin kx) (sin ky)) (sin ky))))
double code(double kx, double ky, double th) {
return sin(th) / (hypot(sin(kx), sin(ky)) / sin(ky));
}
public static double code(double kx, double ky, double th) {
return Math.sin(th) / (Math.hypot(Math.sin(kx), Math.sin(ky)) / Math.sin(ky));
}
def code(kx, ky, th): return math.sin(th) / (math.hypot(math.sin(kx), math.sin(ky)) / math.sin(ky))
function code(kx, ky, th) return Float64(sin(th) / Float64(hypot(sin(kx), sin(ky)) / sin(ky))) end
function tmp = code(kx, ky, th) tmp = sin(th) / (hypot(sin(kx), sin(ky)) / sin(ky)); end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin ky}}
\end{array}
Initial program 94.6%
*-commutative94.6%
clear-num94.6%
+-commutative94.6%
unpow294.6%
unpow294.6%
hypot-udef99.6%
un-div-inv99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (fabs (sin th))))
(if (<= (sin ky) -0.25)
t_1
(if (<= (sin ky) -0.05)
(/ (sin ky) (fabs (/ (sin ky) (sin th))))
(if (<= (sin ky) -2e-8)
t_1
(if (<= (sin ky) 2e-124) (* (sin th) (/ ky (sin kx))) (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = fabs(sin(th));
double tmp;
if (sin(ky) <= -0.25) {
tmp = t_1;
} else if (sin(ky) <= -0.05) {
tmp = sin(ky) / fabs((sin(ky) / sin(th)));
} else if (sin(ky) <= -2e-8) {
tmp = t_1;
} else if (sin(ky) <= 2e-124) {
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) :: t_1
real(8) :: tmp
t_1 = abs(sin(th))
if (sin(ky) <= (-0.25d0)) then
tmp = t_1
else if (sin(ky) <= (-0.05d0)) then
tmp = sin(ky) / abs((sin(ky) / sin(th)))
else if (sin(ky) <= (-2d-8)) then
tmp = t_1
else if (sin(ky) <= 2d-124) 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 t_1 = Math.abs(Math.sin(th));
double tmp;
if (Math.sin(ky) <= -0.25) {
tmp = t_1;
} else if (Math.sin(ky) <= -0.05) {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / Math.sin(th)));
} else if (Math.sin(ky) <= -2e-8) {
tmp = t_1;
} else if (Math.sin(ky) <= 2e-124) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.fabs(math.sin(th)) tmp = 0 if math.sin(ky) <= -0.25: tmp = t_1 elif math.sin(ky) <= -0.05: tmp = math.sin(ky) / math.fabs((math.sin(ky) / math.sin(th))) elif math.sin(ky) <= -2e-8: tmp = t_1 elif math.sin(ky) <= 2e-124: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = abs(sin(th)) tmp = 0.0 if (sin(ky) <= -0.25) tmp = t_1; elseif (sin(ky) <= -0.05) tmp = Float64(sin(ky) / abs(Float64(sin(ky) / sin(th)))); elseif (sin(ky) <= -2e-8) tmp = t_1; elseif (sin(ky) <= 2e-124) tmp = Float64(sin(th) * Float64(ky / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = abs(sin(th)); tmp = 0.0; if (sin(ky) <= -0.25) tmp = t_1; elseif (sin(ky) <= -0.05) tmp = sin(ky) / abs((sin(ky) / sin(th))); elseif (sin(ky) <= -2e-8) tmp = t_1; elseif (sin(ky) <= 2e-124) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.25], t$95$1, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.05], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -2e-8], t$95$1, If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-124], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\sin th\right|\\
\mathbf{if}\;\sin ky \leq -0.25:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\sin ky \leq -0.05:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\mathbf{elif}\;\sin ky \leq -2 \cdot 10^{-8}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-124}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.25 or -0.050000000000000003 < (sin.f64 ky) < -2e-8Initial program 99.5%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
+-commutative99.5%
Simplified99.6%
Taylor expanded in kx around 0 2.6%
associate-/r/2.6%
*-inverses2.6%
*-un-lft-identity2.6%
add-sqr-sqrt1.2%
sqrt-unprod21.4%
pow221.4%
Applied egg-rr21.4%
unpow221.4%
rem-sqrt-square34.8%
Simplified34.8%
if -0.25 < (sin.f64 ky) < -0.050000000000000003Initial program 99.8%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in kx around 0 3.3%
add-sqr-sqrt0.7%
sqrt-unprod59.8%
pow259.8%
Applied egg-rr59.8%
unpow259.8%
rem-sqrt-square74.2%
Simplified74.2%
if -2e-8 < (sin.f64 ky) < 1.99999999999999987e-124Initial program 87.1%
+-commutative87.1%
unpow287.1%
unpow287.1%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 58.8%
if 1.99999999999999987e-124 < (sin.f64 ky) Initial program 99.6%
Taylor expanded in kx around 0 58.9%
Final simplification53.1%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))))
(if (or (<= (sin th) -5e-7) (not (<= (sin th) 1e-17)))
(/ (* (sin th) ky) t_1)
(/ (sin ky) (/ t_1 th)))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double tmp;
if ((sin(th) <= -5e-7) || !(sin(th) <= 1e-17)) {
tmp = (sin(th) * ky) / t_1;
} else {
tmp = sin(ky) / (t_1 / th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(ky), Math.sin(kx));
double tmp;
if ((Math.sin(th) <= -5e-7) || !(Math.sin(th) <= 1e-17)) {
tmp = (Math.sin(th) * ky) / t_1;
} else {
tmp = Math.sin(ky) / (t_1 / th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) tmp = 0 if (math.sin(th) <= -5e-7) or not (math.sin(th) <= 1e-17): tmp = (math.sin(th) * ky) / t_1 else: tmp = math.sin(ky) / (t_1 / th) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) tmp = 0.0 if ((sin(th) <= -5e-7) || !(sin(th) <= 1e-17)) tmp = Float64(Float64(sin(th) * ky) / t_1); else tmp = Float64(sin(ky) / Float64(t_1 / th)); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)); tmp = 0.0; if ((sin(th) <= -5e-7) || ~((sin(th) <= 1e-17))) tmp = (sin(th) * ky) / t_1; else tmp = sin(ky) / (t_1 / th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]}, If[Or[LessEqual[N[Sin[th], $MachinePrecision], -5e-7], N[Not[LessEqual[N[Sin[th], $MachinePrecision], 1e-17]], $MachinePrecision]], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[(t$95$1 / th), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
\mathbf{if}\;\sin th \leq -5 \cdot 10^{-7} \lor \neg \left(\sin th \leq 10^{-17}\right):\\
\;\;\;\;\frac{\sin th \cdot ky}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\frac{t_1}{th}}\\
\end{array}
\end{array}
if (sin.f64 th) < -4.99999999999999977e-7 or 1.00000000000000007e-17 < (sin.f64 th) Initial program 92.2%
associate-*l/92.2%
+-commutative92.2%
unpow292.2%
unpow292.2%
hypot-def99.4%
Simplified99.4%
Taylor expanded in ky around 0 54.8%
if -4.99999999999999977e-7 < (sin.f64 th) < 1.00000000000000007e-17Initial program 97.2%
associate-/r/97.1%
+-commutative97.1%
unpow297.1%
sqr-neg97.1%
sin-neg97.1%
sin-neg97.1%
unpow297.1%
+-commutative97.1%
Simplified99.8%
Taylor expanded in th around 0 99.7%
Final simplification76.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.05)
(fabs (sin th))
(if (<= (sin th) 2e-8)
(* th (/ (sin ky) (hypot (sin ky) (sin kx))))
(/ (sin ky) (fabs (/ (sin ky) (sin th)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.05) {
tmp = fabs(sin(th));
} else if (sin(th) <= 2e-8) {
tmp = th * (sin(ky) / hypot(sin(ky), sin(kx)));
} else {
tmp = sin(ky) / fabs((sin(ky) / sin(th)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(th) <= -0.05) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(th) <= 2e-8) {
tmp = th * (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx)));
} else {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / Math.sin(th)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(th) <= -0.05: tmp = math.fabs(math.sin(th)) elif math.sin(th) <= 2e-8: tmp = th * (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) else: tmp = math.sin(ky) / math.fabs((math.sin(ky) / math.sin(th))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(th) <= -0.05) tmp = abs(sin(th)); elseif (sin(th) <= 2e-8) tmp = Float64(th * Float64(sin(ky) / hypot(sin(ky), sin(kx)))); else tmp = Float64(sin(ky) / abs(Float64(sin(ky) / sin(th)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(th) <= -0.05) tmp = abs(sin(th)); elseif (sin(th) <= 2e-8) tmp = th * (sin(ky) / hypot(sin(ky), sin(kx))); else tmp = sin(ky) / abs((sin(ky) / sin(th))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[th], $MachinePrecision], -0.05], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 2e-8], N[(th * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -0.05:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin th \leq 2 \cdot 10^{-8}:\\
\;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\end{array}
\end{array}
if (sin.f64 th) < -0.050000000000000003Initial program 92.8%
associate-/r/92.8%
+-commutative92.8%
unpow292.8%
sqr-neg92.8%
sin-neg92.8%
sin-neg92.8%
unpow292.8%
+-commutative92.8%
Simplified99.5%
Taylor expanded in kx around 0 24.3%
associate-/r/24.4%
*-inverses24.4%
*-un-lft-identity24.4%
add-sqr-sqrt0.0%
sqrt-unprod26.5%
pow226.5%
Applied egg-rr26.5%
unpow226.5%
rem-sqrt-square26.5%
Simplified26.5%
if -0.050000000000000003 < (sin.f64 th) < 2e-8Initial program 97.2%
+-commutative97.2%
unpow297.2%
unpow297.2%
hypot-def99.7%
Simplified99.7%
Taylor expanded in th around 0 98.9%
if 2e-8 < (sin.f64 th) Initial program 91.4%
associate-/r/91.2%
+-commutative91.2%
unpow291.2%
sqr-neg91.2%
sin-neg91.2%
sin-neg91.2%
unpow291.2%
+-commutative91.2%
Simplified99.3%
Taylor expanded in kx around 0 21.2%
add-sqr-sqrt20.4%
sqrt-unprod39.9%
pow239.9%
Applied egg-rr39.9%
unpow239.9%
rem-sqrt-square44.3%
Simplified44.3%
Final simplification68.4%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.05)
(fabs (sin th))
(if (<= (sin th) 2e-8)
(/ th (/ (hypot (sin kx) (sin ky)) (sin ky)))
(/ (sin ky) (fabs (/ (sin ky) (sin th)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.05) {
tmp = fabs(sin(th));
} else if (sin(th) <= 2e-8) {
tmp = th / (hypot(sin(kx), sin(ky)) / sin(ky));
} else {
tmp = sin(ky) / fabs((sin(ky) / sin(th)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(th) <= -0.05) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(th) <= 2e-8) {
tmp = th / (Math.hypot(Math.sin(kx), Math.sin(ky)) / Math.sin(ky));
} else {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / Math.sin(th)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(th) <= -0.05: tmp = math.fabs(math.sin(th)) elif math.sin(th) <= 2e-8: tmp = th / (math.hypot(math.sin(kx), math.sin(ky)) / math.sin(ky)) else: tmp = math.sin(ky) / math.fabs((math.sin(ky) / math.sin(th))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(th) <= -0.05) tmp = abs(sin(th)); elseif (sin(th) <= 2e-8) tmp = Float64(th / Float64(hypot(sin(kx), sin(ky)) / sin(ky))); else tmp = Float64(sin(ky) / abs(Float64(sin(ky) / sin(th)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(th) <= -0.05) tmp = abs(sin(th)); elseif (sin(th) <= 2e-8) tmp = th / (hypot(sin(kx), sin(ky)) / sin(ky)); else tmp = sin(ky) / abs((sin(ky) / sin(th))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[th], $MachinePrecision], -0.05], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 2e-8], N[(th / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -0.05:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin th \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{th}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\end{array}
\end{array}
if (sin.f64 th) < -0.050000000000000003Initial program 92.8%
associate-/r/92.8%
+-commutative92.8%
unpow292.8%
sqr-neg92.8%
sin-neg92.8%
sin-neg92.8%
unpow292.8%
+-commutative92.8%
Simplified99.5%
Taylor expanded in kx around 0 24.3%
associate-/r/24.4%
*-inverses24.4%
*-un-lft-identity24.4%
add-sqr-sqrt0.0%
sqrt-unprod26.5%
pow226.5%
Applied egg-rr26.5%
unpow226.5%
rem-sqrt-square26.5%
Simplified26.5%
if -0.050000000000000003 < (sin.f64 th) < 2e-8Initial program 97.2%
*-commutative97.2%
clear-num97.1%
+-commutative97.1%
unpow297.1%
unpow297.1%
hypot-udef99.6%
un-div-inv99.7%
Applied egg-rr99.7%
Taylor expanded in th around 0 98.9%
if 2e-8 < (sin.f64 th) Initial program 91.4%
associate-/r/91.2%
+-commutative91.2%
unpow291.2%
sqr-neg91.2%
sin-neg91.2%
sin-neg91.2%
unpow291.2%
+-commutative91.2%
Simplified99.3%
Taylor expanded in kx around 0 21.2%
add-sqr-sqrt20.4%
sqrt-unprod39.9%
pow239.9%
Applied egg-rr39.9%
unpow239.9%
rem-sqrt-square44.3%
Simplified44.3%
Final simplification68.4%
(FPCore (kx ky th) :precision binary64 (* (sin th) (/ (sin ky) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
return sin(th) * (sin(ky) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th): return math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th) return Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), sin(kx)))) end
function tmp = code(kx, ky, th) tmp = sin(th) * (sin(ky) / hypot(sin(ky), sin(kx))); end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Initial program 94.6%
+-commutative94.6%
unpow294.6%
unpow294.6%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(if (or (<= th -0.22) (not (<= th 0.23)))
(/ (* (sin th) ky) (hypot (sin ky) (sin kx)))
(/
(/ (sin ky) (hypot (sin kx) (sin ky)))
(+ (/ 1.0 th) (* th 0.16666666666666666)))))
double code(double kx, double ky, double th) {
double tmp;
if ((th <= -0.22) || !(th <= 0.23)) {
tmp = (sin(th) * ky) / hypot(sin(ky), sin(kx));
} else {
tmp = (sin(ky) / hypot(sin(kx), sin(ky))) / ((1.0 / th) + (th * 0.16666666666666666));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if ((th <= -0.22) || !(th <= 0.23)) {
tmp = (Math.sin(th) * ky) / Math.hypot(Math.sin(ky), Math.sin(kx));
} else {
tmp = (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky))) / ((1.0 / th) + (th * 0.16666666666666666));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (th <= -0.22) or not (th <= 0.23): tmp = (math.sin(th) * ky) / math.hypot(math.sin(ky), math.sin(kx)) else: tmp = (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) / ((1.0 / th) + (th * 0.16666666666666666)) return tmp
function code(kx, ky, th) tmp = 0.0 if ((th <= -0.22) || !(th <= 0.23)) tmp = Float64(Float64(sin(th) * ky) / hypot(sin(ky), sin(kx))); else tmp = Float64(Float64(sin(ky) / hypot(sin(kx), sin(ky))) / Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((th <= -0.22) || ~((th <= 0.23))) tmp = (sin(th) * ky) / hypot(sin(ky), sin(kx)); else tmp = (sin(ky) / hypot(sin(kx), sin(ky))) / ((1.0 / th) + (th * 0.16666666666666666)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[th, -0.22], N[Not[LessEqual[th, 0.23]], $MachinePrecision]], N[(N[(N[Sin[th], $MachinePrecision] * ky), $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq -0.22 \lor \neg \left(th \leq 0.23\right):\\
\;\;\;\;\frac{\sin th \cdot ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}}{\frac{1}{th} + th \cdot 0.16666666666666666}\\
\end{array}
\end{array}
if th < -0.220000000000000001 or 0.23000000000000001 < th Initial program 91.9%
associate-*l/91.9%
+-commutative91.9%
unpow291.9%
unpow291.9%
hypot-def99.4%
Simplified99.4%
Taylor expanded in ky around 0 53.5%
if -0.220000000000000001 < th < 0.23000000000000001Initial program 97.3%
associate-*l/94.9%
+-commutative94.9%
unpow294.9%
unpow294.9%
hypot-udef95.7%
associate-/l*99.7%
div-inv99.5%
associate-/r*99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 99.3%
*-commutative99.3%
Simplified99.3%
Final simplification76.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -2e-8) (fabs (sin th)) (if (<= (sin ky) 2e-124) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -2e-8) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 2e-124) {
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) <= (-2d-8)) then
tmp = abs(sin(th))
else if (sin(ky) <= 2d-124) 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) <= -2e-8) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 2e-124) {
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) <= -2e-8: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 2e-124: 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) <= -2e-8) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-124) 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) <= -2e-8) tmp = abs(sin(th)); elseif (sin(ky) <= 2e-124) 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], -2e-8], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-124], 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 -2 \cdot 10^{-8}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-124}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2e-8Initial program 99.5%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
+-commutative99.5%
Simplified99.6%
Taylor expanded in kx around 0 2.7%
associate-/r/2.7%
*-inverses2.7%
*-un-lft-identity2.7%
add-sqr-sqrt1.3%
sqrt-unprod19.7%
pow219.7%
Applied egg-rr19.7%
unpow219.7%
rem-sqrt-square33.0%
Simplified33.0%
if -2e-8 < (sin.f64 ky) < 1.99999999999999987e-124Initial program 87.1%
+-commutative87.1%
unpow287.1%
unpow287.1%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 58.8%
if 1.99999999999999987e-124 < (sin.f64 ky) Initial program 99.6%
Taylor expanded in kx around 0 58.9%
Final simplification51.6%
(FPCore (kx ky th) :precision binary64 (if (or (<= ky -2e-163) (not (<= ky 2.5e+139))) (fabs (sin th)) (/ (sin th) (+ 1.0 (* 0.5 (* (/ kx ky) (/ kx ky)))))))
double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -2e-163) || !(ky <= 2.5e+139)) {
tmp = fabs(sin(th));
} else {
tmp = sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky))));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((ky <= (-2d-163)) .or. (.not. (ky <= 2.5d+139))) then
tmp = abs(sin(th))
else
tmp = sin(th) / (1.0d0 + (0.5d0 * ((kx / ky) * (kx / ky))))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -2e-163) || !(ky <= 2.5e+139)) {
tmp = Math.abs(Math.sin(th));
} else {
tmp = Math.sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky))));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (ky <= -2e-163) or not (ky <= 2.5e+139): tmp = math.fabs(math.sin(th)) else: tmp = math.sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky)))) return tmp
function code(kx, ky, th) tmp = 0.0 if ((ky <= -2e-163) || !(ky <= 2.5e+139)) tmp = abs(sin(th)); else tmp = Float64(sin(th) / Float64(1.0 + Float64(0.5 * Float64(Float64(kx / ky) * Float64(kx / ky))))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((ky <= -2e-163) || ~((ky <= 2.5e+139))) tmp = abs(sin(th)); else tmp = sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky)))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, -2e-163], N[Not[LessEqual[ky, 2.5e+139]], $MachinePrecision]], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] / N[(1.0 + N[(0.5 * N[(N[(kx / ky), $MachinePrecision] * N[(kx / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -2 \cdot 10^{-163} \lor \neg \left(ky \leq 2.5 \cdot 10^{+139}\right):\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin th}{1 + 0.5 \cdot \left(\frac{kx}{ky} \cdot \frac{kx}{ky}\right)}\\
\end{array}
\end{array}
if ky < -1.99999999999999985e-163 or 2.50000000000000015e139 < ky Initial program 99.2%
associate-/r/99.1%
+-commutative99.1%
unpow299.1%
sqr-neg99.1%
sin-neg99.1%
sin-neg99.1%
unpow299.1%
+-commutative99.1%
Simplified99.6%
Taylor expanded in kx around 0 21.0%
associate-/r/21.0%
*-inverses21.0%
*-un-lft-identity21.0%
add-sqr-sqrt10.7%
sqrt-unprod26.2%
pow226.2%
Applied egg-rr26.2%
unpow226.2%
rem-sqrt-square32.3%
Simplified32.3%
if -1.99999999999999985e-163 < ky < 2.50000000000000015e139Initial program 89.7%
*-commutative89.7%
clear-num89.7%
+-commutative89.7%
unpow289.7%
unpow289.7%
hypot-udef99.6%
un-div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in kx around 0 34.7%
associate-*r/34.7%
unpow234.7%
Simplified34.7%
Taylor expanded in ky around 0 34.9%
unpow234.9%
unpow234.9%
times-frac38.4%
Simplified38.4%
Final simplification35.2%
(FPCore (kx ky th) :precision binary64 (/ (sin th) (+ 1.0 (* 0.5 (* (/ kx ky) (/ kx ky))))))
double code(double kx, double ky, double th) {
return sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky))));
}
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) / (1.0d0 + (0.5d0 * ((kx / ky) * (kx / ky))))
end function
public static double code(double kx, double ky, double th) {
return Math.sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky))));
}
def code(kx, ky, th): return math.sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky))))
function code(kx, ky, th) return Float64(sin(th) / Float64(1.0 + Float64(0.5 * Float64(Float64(kx / ky) * Float64(kx / ky))))) end
function tmp = code(kx, ky, th) tmp = sin(th) / (1.0 + (0.5 * ((kx / ky) * (kx / ky)))); end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] / N[(1.0 + N[(0.5 * N[(N[(kx / ky), $MachinePrecision] * N[(kx / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin th}{1 + 0.5 \cdot \left(\frac{kx}{ky} \cdot \frac{kx}{ky}\right)}
\end{array}
Initial program 94.6%
*-commutative94.6%
clear-num94.6%
+-commutative94.6%
unpow294.6%
unpow294.6%
hypot-udef99.6%
un-div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in kx around 0 27.3%
associate-*r/27.3%
unpow227.3%
Simplified27.3%
Taylor expanded in ky around 0 27.5%
unpow227.5%
unpow227.5%
times-frac29.8%
Simplified29.8%
Final simplification29.8%
(FPCore (kx ky th) :precision binary64 (if (<= kx 1.95e-42) (sin th) (+ (+ (sin th) 1.0) -1.0)))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.95e-42) {
tmp = sin(th);
} else {
tmp = (sin(th) + 1.0) + -1.0;
}
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.95d-42) then
tmp = sin(th)
else
tmp = (sin(th) + 1.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 1.95e-42) {
tmp = Math.sin(th);
} else {
tmp = (Math.sin(th) + 1.0) + -1.0;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 1.95e-42: tmp = math.sin(th) else: tmp = (math.sin(th) + 1.0) + -1.0 return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 1.95e-42) tmp = sin(th); else tmp = Float64(Float64(sin(th) + 1.0) + -1.0); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 1.95e-42) tmp = sin(th); else tmp = (sin(th) + 1.0) + -1.0; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 1.95e-42], N[Sin[th], $MachinePrecision], N[(N[(N[Sin[th], $MachinePrecision] + 1.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 1.95 \cdot 10^{-42}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\left(\sin th + 1\right) + -1\\
\end{array}
\end{array}
if kx < 1.9500000000000001e-42Initial program 92.8%
Taylor expanded in kx around 0 28.0%
if 1.9500000000000001e-42 < kx Initial program 99.5%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
+-commutative99.5%
Simplified99.6%
Taylor expanded in kx around 0 10.4%
associate-/r/10.4%
*-inverses10.4%
*-un-lft-identity10.4%
expm1-log1p-u10.4%
Applied egg-rr10.4%
expm1-udef19.4%
log1p-udef19.4%
add-exp-log19.4%
+-commutative19.4%
Applied egg-rr19.4%
Final simplification25.7%
(FPCore (kx ky th) :precision binary64 (if (<= ky -1.1e-32) (expm1 th) (if (<= ky 4.2e-140) (log1p 0.0) (expm1 th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -1.1e-32) {
tmp = expm1(th);
} else if (ky <= 4.2e-140) {
tmp = log1p(0.0);
} else {
tmp = expm1(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -1.1e-32) {
tmp = Math.expm1(th);
} else if (ky <= 4.2e-140) {
tmp = Math.log1p(0.0);
} else {
tmp = Math.expm1(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -1.1e-32: tmp = math.expm1(th) elif ky <= 4.2e-140: tmp = math.log1p(0.0) else: tmp = math.expm1(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -1.1e-32) tmp = expm1(th); elseif (ky <= 4.2e-140) tmp = log1p(0.0); else tmp = expm1(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[ky, -1.1e-32], N[(Exp[th] - 1), $MachinePrecision], If[LessEqual[ky, 4.2e-140], N[Log[1 + 0.0], $MachinePrecision], N[(Exp[th] - 1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -1.1 \cdot 10^{-32}:\\
\;\;\;\;\mathsf{expm1}\left(th\right)\\
\mathbf{elif}\;ky \leq 4.2 \cdot 10^{-140}:\\
\;\;\;\;\mathsf{log1p}\left(0\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(th\right)\\
\end{array}
\end{array}
if ky < -1.1e-32 or 4.20000000000000035e-140 < ky Initial program 99.6%
associate-/r/99.5%
+-commutative99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in kx around 0 32.1%
associate-/r/32.1%
*-inverses32.1%
*-un-lft-identity32.1%
expm1-log1p-u32.1%
Applied egg-rr32.1%
Taylor expanded in th around 0 19.8%
if -1.1e-32 < ky < 4.20000000000000035e-140Initial program 86.1%
associate-/r/86.2%
+-commutative86.2%
unpow286.2%
sqr-neg86.2%
sin-neg86.2%
sin-neg86.2%
unpow286.2%
+-commutative86.2%
Simplified99.6%
Taylor expanded in kx around 0 8.0%
associate-/r/8.0%
*-inverses8.0%
*-un-lft-identity8.0%
log1p-expm1-u8.0%
Applied egg-rr8.0%
add-cube-cbrt7.9%
pow37.9%
Applied egg-rr7.9%
Taylor expanded in th around 0 24.4%
Final simplification21.5%
(FPCore (kx ky th) :precision binary64 (if (<= ky -960000000.0) (sin th) (if (<= ky 1.25e-242) (log1p 0.0) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -960000000.0) {
tmp = sin(th);
} else if (ky <= 1.25e-242) {
tmp = log1p(0.0);
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -960000000.0) {
tmp = Math.sin(th);
} else if (ky <= 1.25e-242) {
tmp = Math.log1p(0.0);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -960000000.0: tmp = math.sin(th) elif ky <= 1.25e-242: tmp = math.log1p(0.0) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -960000000.0) tmp = sin(th); elseif (ky <= 1.25e-242) tmp = log1p(0.0); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[ky, -960000000.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 1.25e-242], N[Log[1 + 0.0], $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -960000000:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 1.25 \cdot 10^{-242}:\\
\;\;\;\;\mathsf{log1p}\left(0\right)\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -9.6e8 or 1.25e-242 < ky Initial program 97.3%
Taylor expanded in kx around 0 32.8%
if -9.6e8 < ky < 1.25e-242Initial program 89.2%
associate-/r/89.1%
+-commutative89.1%
unpow289.1%
sqr-neg89.1%
sin-neg89.1%
sin-neg89.1%
unpow289.1%
+-commutative89.1%
Simplified99.6%
Taylor expanded in kx around 0 3.7%
associate-/r/3.7%
*-inverses3.7%
*-un-lft-identity3.7%
log1p-expm1-u3.7%
Applied egg-rr3.7%
add-cube-cbrt3.7%
pow33.7%
Applied egg-rr3.7%
Taylor expanded in th around 0 23.4%
Final simplification29.7%
(FPCore (kx ky th) :precision binary64 (expm1 th))
double code(double kx, double ky, double th) {
return expm1(th);
}
public static double code(double kx, double ky, double th) {
return Math.expm1(th);
}
def code(kx, ky, th): return math.expm1(th)
function code(kx, ky, th) return expm1(th) end
code[kx_, ky_, th_] := N[(Exp[th] - 1), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{expm1}\left(th\right)
\end{array}
Initial program 94.6%
associate-/r/94.6%
+-commutative94.6%
unpow294.6%
sqr-neg94.6%
sin-neg94.6%
sin-neg94.6%
unpow294.6%
+-commutative94.6%
Simplified99.6%
Taylor expanded in kx around 0 23.2%
associate-/r/23.3%
*-inverses23.3%
*-un-lft-identity23.3%
expm1-log1p-u23.3%
Applied egg-rr23.3%
Taylor expanded in th around 0 14.3%
Final simplification14.3%
(FPCore (kx ky th) :precision binary64 th)
double code(double kx, double ky, double th) {
return th;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = th
end function
public static double code(double kx, double ky, double th) {
return th;
}
def code(kx, ky, th): return th
function code(kx, ky, th) return th end
function tmp = code(kx, ky, th) tmp = th; end
code[kx_, ky_, th_] := th
\begin{array}{l}
\\
th
\end{array}
Initial program 94.6%
associate-/r/94.6%
+-commutative94.6%
unpow294.6%
sqr-neg94.6%
sin-neg94.6%
sin-neg94.6%
unpow294.6%
+-commutative94.6%
Simplified99.6%
Taylor expanded in kx around 0 23.2%
Taylor expanded in th around 0 13.7%
Final simplification13.7%
herbie shell --seed 2023272
(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)))