
(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 17 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 ky) (sin kx)) (sin ky))))
double code(double kx, double ky, double th) {
return sin(th) / (hypot(sin(ky), sin(kx)) / sin(ky));
}
public static double code(double kx, double ky, double th) {
return Math.sin(th) / (Math.hypot(Math.sin(ky), Math.sin(kx)) / Math.sin(ky));
}
def code(kx, ky, th): return math.sin(th) / (math.hypot(math.sin(ky), math.sin(kx)) / math.sin(ky))
function code(kx, ky, th) return Float64(sin(th) / Float64(hypot(sin(ky), sin(kx)) / sin(ky))) end
function tmp = code(kx, ky, th) tmp = sin(th) / (hypot(sin(ky), sin(kx)) / sin(ky)); end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}}
\end{array}
Initial program 92.8%
unpow292.8%
sqr-neg92.8%
sin-neg92.8%
sin-neg92.8%
unpow292.8%
associate-*l/90.8%
associate-/l*92.8%
unpow292.8%
Simplified99.6%
associate-*r/96.3%
hypot-undefine90.8%
unpow290.8%
unpow290.8%
+-commutative90.8%
associate-*l/92.8%
*-commutative92.8%
clear-num92.9%
un-div-inv92.9%
+-commutative92.9%
unpow292.9%
unpow292.9%
hypot-undefine99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))))
(if (<= (sin ky) -0.71)
(/ th (/ t_1 (sin ky)))
(if (<= (sin ky) -0.5)
(fabs (sin th))
(if (<= (sin ky) -0.002)
(/ th (* t_1 (/ 1.0 (sin ky))))
(if (<= (sin ky) 0.008) (/ (sin th) (* t_1 (/ 1.0 ky))) (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double tmp;
if (sin(ky) <= -0.71) {
tmp = th / (t_1 / sin(ky));
} else if (sin(ky) <= -0.5) {
tmp = fabs(sin(th));
} else if (sin(ky) <= -0.002) {
tmp = th / (t_1 * (1.0 / sin(ky)));
} else if (sin(ky) <= 0.008) {
tmp = sin(th) / (t_1 * (1.0 / ky));
} else {
tmp = sin(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(ky) <= -0.71) {
tmp = th / (t_1 / Math.sin(ky));
} else if (Math.sin(ky) <= -0.5) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= -0.002) {
tmp = th / (t_1 * (1.0 / Math.sin(ky)));
} else if (Math.sin(ky) <= 0.008) {
tmp = Math.sin(th) / (t_1 * (1.0 / ky));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) tmp = 0 if math.sin(ky) <= -0.71: tmp = th / (t_1 / math.sin(ky)) elif math.sin(ky) <= -0.5: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= -0.002: tmp = th / (t_1 * (1.0 / math.sin(ky))) elif math.sin(ky) <= 0.008: tmp = math.sin(th) / (t_1 * (1.0 / ky)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) tmp = 0.0 if (sin(ky) <= -0.71) tmp = Float64(th / Float64(t_1 / sin(ky))); elseif (sin(ky) <= -0.5) tmp = abs(sin(th)); elseif (sin(ky) <= -0.002) tmp = Float64(th / Float64(t_1 * Float64(1.0 / sin(ky)))); elseif (sin(ky) <= 0.008) tmp = Float64(sin(th) / Float64(t_1 * Float64(1.0 / ky))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)); tmp = 0.0; if (sin(ky) <= -0.71) tmp = th / (t_1 / sin(ky)); elseif (sin(ky) <= -0.5) tmp = abs(sin(th)); elseif (sin(ky) <= -0.002) tmp = th / (t_1 * (1.0 / sin(ky))); elseif (sin(ky) <= 0.008) tmp = sin(th) / (t_1 * (1.0 / ky)); else tmp = sin(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[LessEqual[N[Sin[ky], $MachinePrecision], -0.71], N[(th / N[(t$95$1 / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -0.5], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -0.002], N[(th / N[(t$95$1 * N[(1.0 / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.008], N[(N[Sin[th], $MachinePrecision] / N[(t$95$1 * N[(1.0 / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
\mathbf{if}\;\sin ky \leq -0.71:\\
\;\;\;\;\frac{th}{\frac{t\_1}{\sin ky}}\\
\mathbf{elif}\;\sin ky \leq -0.5:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq -0.002:\\
\;\;\;\;\frac{th}{t\_1 \cdot \frac{1}{\sin ky}}\\
\mathbf{elif}\;\sin ky \leq 0.008:\\
\;\;\;\;\frac{\sin th}{t\_1 \cdot \frac{1}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.70999999999999996Initial program 99.8%
unpow299.8%
sqr-neg99.8%
sin-neg99.8%
sin-neg99.8%
unpow299.8%
associate-*l/99.7%
associate-/l*99.6%
unpow299.6%
Simplified99.5%
associate-*r/99.6%
hypot-undefine99.7%
unpow299.7%
unpow299.7%
+-commutative99.7%
associate-*l/99.8%
*-commutative99.8%
clear-num99.7%
un-div-inv99.8%
+-commutative99.8%
unpow299.8%
unpow299.8%
hypot-undefine99.6%
Applied egg-rr99.6%
Taylor expanded in th around 0 55.5%
if -0.70999999999999996 < (sin.f64 ky) < -0.5Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.9%
associate-/l*99.7%
unpow299.7%
Simplified99.7%
Taylor expanded in kx around 0 2.5%
add-sqr-sqrt1.5%
sqrt-unprod37.5%
pow237.5%
Applied egg-rr37.5%
unpow237.5%
rem-sqrt-square45.1%
associate-*r/45.1%
associate-*l/45.2%
*-inverses45.2%
*-lft-identity45.2%
Simplified45.2%
if -0.5 < (sin.f64 ky) < -2e-3Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.7%
associate-/l*99.5%
unpow299.5%
Simplified99.5%
associate-*r/99.6%
hypot-undefine99.7%
unpow299.7%
unpow299.7%
+-commutative99.7%
associate-*l/99.6%
*-commutative99.6%
clear-num99.7%
un-div-inv99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-undefine99.7%
Applied egg-rr99.7%
div-inv99.7%
Applied egg-rr99.7%
Taylor expanded in th around 0 67.8%
if -2e-3 < (sin.f64 ky) < 0.0080000000000000002Initial program 86.0%
unpow286.0%
sqr-neg86.0%
sin-neg86.0%
sin-neg86.0%
unpow286.0%
associate-*l/81.9%
associate-/l*86.0%
unpow286.0%
Simplified99.7%
associate-*r/93.0%
hypot-undefine81.9%
unpow281.9%
unpow281.9%
+-commutative81.9%
associate-*l/86.0%
*-commutative86.0%
clear-num86.0%
un-div-inv86.0%
+-commutative86.0%
unpow286.0%
unpow286.0%
hypot-undefine99.7%
Applied egg-rr99.7%
div-inv99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 99.2%
if 0.0080000000000000002 < (sin.f64 ky) Initial program 99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
associate-*l/99.6%
associate-/l*99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in kx around 0 62.1%
Final simplification79.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (* (sin ky) (fabs (/ (sin th) (sin ky))))))
(if (<= (sin ky) -0.78)
t_1
(if (<= (sin ky) -0.5)
(fabs (sin th))
(if (<= (sin ky) -0.002)
t_1
(if (<= (sin ky) 1e-104)
(* (sin ky) (* (sin th) (/ 1.0 (sin kx))))
(sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = sin(ky) * fabs((sin(th) / sin(ky)));
double tmp;
if (sin(ky) <= -0.78) {
tmp = t_1;
} else if (sin(ky) <= -0.5) {
tmp = fabs(sin(th));
} else if (sin(ky) <= -0.002) {
tmp = t_1;
} else if (sin(ky) <= 1e-104) {
tmp = sin(ky) * (sin(th) * (1.0 / 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 = sin(ky) * abs((sin(th) / sin(ky)))
if (sin(ky) <= (-0.78d0)) then
tmp = t_1
else if (sin(ky) <= (-0.5d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= (-0.002d0)) then
tmp = t_1
else if (sin(ky) <= 1d-104) then
tmp = sin(ky) * (sin(th) * (1.0d0 / 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.sin(ky) * Math.abs((Math.sin(th) / Math.sin(ky)));
double tmp;
if (Math.sin(ky) <= -0.78) {
tmp = t_1;
} else if (Math.sin(ky) <= -0.5) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= -0.002) {
tmp = t_1;
} else if (Math.sin(ky) <= 1e-104) {
tmp = Math.sin(ky) * (Math.sin(th) * (1.0 / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(ky) * math.fabs((math.sin(th) / math.sin(ky))) tmp = 0 if math.sin(ky) <= -0.78: tmp = t_1 elif math.sin(ky) <= -0.5: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= -0.002: tmp = t_1 elif math.sin(ky) <= 1e-104: tmp = math.sin(ky) * (math.sin(th) * (1.0 / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = Float64(sin(ky) * abs(Float64(sin(th) / sin(ky)))) tmp = 0.0 if (sin(ky) <= -0.78) tmp = t_1; elseif (sin(ky) <= -0.5) tmp = abs(sin(th)); elseif (sin(ky) <= -0.002) tmp = t_1; elseif (sin(ky) <= 1e-104) tmp = Float64(sin(ky) * Float64(sin(th) * Float64(1.0 / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(ky) * abs((sin(th) / sin(ky))); tmp = 0.0; if (sin(ky) <= -0.78) tmp = t_1; elseif (sin(ky) <= -0.5) tmp = abs(sin(th)); elseif (sin(ky) <= -0.002) tmp = t_1; elseif (sin(ky) <= 1e-104) tmp = sin(ky) * (sin(th) * (1.0 / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.78], t$95$1, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.5], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -0.002], t$95$1, If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-104], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] * N[(1.0 / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin ky \cdot \left|\frac{\sin th}{\sin ky}\right|\\
\mathbf{if}\;\sin ky \leq -0.78:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\sin ky \leq -0.5:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq -0.002:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\sin ky \leq 10^{-104}:\\
\;\;\;\;\sin ky \cdot \left(\sin th \cdot \frac{1}{\sin kx}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.78000000000000003 or -0.5 < (sin.f64 ky) < -2e-3Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.7%
associate-/l*99.6%
unpow299.6%
Simplified99.5%
Taylor expanded in kx around 0 3.2%
add-sqr-sqrt0.8%
sqrt-unprod35.9%
pow235.9%
Applied egg-rr35.9%
unpow235.9%
rem-sqrt-square53.4%
Simplified53.4%
if -0.78000000000000003 < (sin.f64 ky) < -0.5Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.8%
associate-/l*99.7%
unpow299.7%
Simplified99.6%
Taylor expanded in kx around 0 2.3%
add-sqr-sqrt1.4%
sqrt-unprod31.7%
pow231.7%
Applied egg-rr31.7%
unpow231.7%
rem-sqrt-square37.7%
associate-*r/37.7%
associate-*l/37.8%
*-inverses37.8%
*-lft-identity37.8%
Simplified37.8%
if -2e-3 < (sin.f64 ky) < 9.99999999999999927e-105Initial program 84.4%
unpow284.4%
sqr-neg84.4%
sin-neg84.4%
sin-neg84.4%
unpow284.4%
associate-*l/80.7%
associate-/l*84.5%
unpow284.5%
Simplified99.7%
clear-num99.5%
hypot-undefine84.4%
unpow284.4%
unpow284.4%
+-commutative84.4%
associate-/r/84.4%
+-commutative84.4%
unpow284.4%
unpow284.4%
hypot-undefine99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 49.7%
if 9.99999999999999927e-105 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.5%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 59.0%
Final simplification52.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.005)
(sin th)
(if (<= (sin th) 0.004)
(* (sin ky) (/ th (hypot (sin ky) (sin kx))))
(if (<= (sin th) 0.74)
(* (sin ky) (fabs (/ (sin th) (sin ky))))
(* (sin ky) (fabs (/ (sin th) (sin kx))))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.005) {
tmp = sin(th);
} else if (sin(th) <= 0.004) {
tmp = sin(ky) * (th / hypot(sin(ky), sin(kx)));
} else if (sin(th) <= 0.74) {
tmp = sin(ky) * fabs((sin(th) / sin(ky)));
} else {
tmp = sin(ky) * fabs((sin(th) / sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(th) <= -0.005) {
tmp = Math.sin(th);
} else if (Math.sin(th) <= 0.004) {
tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(ky), Math.sin(kx)));
} else if (Math.sin(th) <= 0.74) {
tmp = Math.sin(ky) * Math.abs((Math.sin(th) / Math.sin(ky)));
} else {
tmp = Math.sin(ky) * Math.abs((Math.sin(th) / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(th) <= -0.005: tmp = math.sin(th) elif math.sin(th) <= 0.004: tmp = math.sin(ky) * (th / math.hypot(math.sin(ky), math.sin(kx))) elif math.sin(th) <= 0.74: tmp = math.sin(ky) * math.fabs((math.sin(th) / math.sin(ky))) else: tmp = math.sin(ky) * math.fabs((math.sin(th) / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(th) <= -0.005) tmp = sin(th); elseif (sin(th) <= 0.004) tmp = Float64(sin(ky) * Float64(th / hypot(sin(ky), sin(kx)))); elseif (sin(th) <= 0.74) tmp = Float64(sin(ky) * abs(Float64(sin(th) / sin(ky)))); else tmp = Float64(sin(ky) * abs(Float64(sin(th) / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(th) <= -0.005) tmp = sin(th); elseif (sin(th) <= 0.004) tmp = sin(ky) * (th / hypot(sin(ky), sin(kx))); elseif (sin(th) <= 0.74) tmp = sin(ky) * abs((sin(th) / sin(ky))); else tmp = sin(ky) * abs((sin(th) / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[th], $MachinePrecision], -0.005], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.004], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.74], N[(N[Sin[ky], $MachinePrecision] * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -0.005:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin th \leq 0.004:\\
\;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{elif}\;\sin th \leq 0.74:\\
\;\;\;\;\sin ky \cdot \left|\frac{\sin th}{\sin ky}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \left|\frac{\sin th}{\sin kx}\right|\\
\end{array}
\end{array}
if (sin.f64 th) < -0.0050000000000000001Initial program 96.6%
unpow296.6%
sqr-neg96.6%
sin-neg96.6%
sin-neg96.6%
unpow296.6%
associate-*l/96.6%
associate-/l*96.7%
unpow296.7%
Simplified99.7%
Taylor expanded in kx around 0 26.8%
if -0.0050000000000000001 < (sin.f64 th) < 0.0040000000000000001Initial program 94.0%
unpow294.0%
sqr-neg94.0%
sin-neg94.0%
sin-neg94.0%
unpow294.0%
associate-*l/89.6%
associate-/l*94.0%
unpow294.0%
Simplified99.7%
Taylor expanded in th around 0 98.6%
if 0.0040000000000000001 < (sin.f64 th) < 0.73999999999999999Initial program 85.7%
unpow285.7%
sqr-neg85.7%
sin-neg85.7%
sin-neg85.7%
unpow285.7%
associate-*l/86.0%
associate-/l*85.7%
unpow285.7%
Simplified99.4%
Taylor expanded in kx around 0 22.7%
add-sqr-sqrt21.4%
sqrt-unprod50.4%
pow250.4%
Applied egg-rr50.4%
unpow250.4%
rem-sqrt-square59.4%
Simplified59.4%
if 0.73999999999999999 < (sin.f64 th) Initial program 89.0%
unpow289.0%
sqr-neg89.0%
sin-neg89.0%
sin-neg89.0%
unpow289.0%
associate-*l/88.8%
associate-/l*88.7%
unpow288.7%
Simplified99.4%
clear-num99.3%
hypot-undefine88.6%
unpow288.6%
unpow288.6%
+-commutative88.6%
associate-/r/88.7%
+-commutative88.7%
unpow288.7%
unpow288.7%
hypot-undefine99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 35.7%
add-sqr-sqrt34.7%
sqrt-unprod50.9%
pow250.9%
associate-*l/50.9%
*-un-lft-identity50.9%
Applied egg-rr50.9%
unpow250.9%
rem-sqrt-square51.9%
Simplified51.9%
Final simplification68.5%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.005)
(sin th)
(if (<= (sin th) 0.004)
(/ th (/ (hypot (sin ky) (sin kx)) (sin ky)))
(if (<= (sin th) 0.74)
(* (sin ky) (fabs (/ (sin th) (sin ky))))
(* (sin ky) (fabs (/ (sin th) (sin kx))))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.005) {
tmp = sin(th);
} else if (sin(th) <= 0.004) {
tmp = th / (hypot(sin(ky), sin(kx)) / sin(ky));
} else if (sin(th) <= 0.74) {
tmp = sin(ky) * fabs((sin(th) / sin(ky)));
} else {
tmp = sin(ky) * fabs((sin(th) / sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(th) <= -0.005) {
tmp = Math.sin(th);
} else if (Math.sin(th) <= 0.004) {
tmp = th / (Math.hypot(Math.sin(ky), Math.sin(kx)) / Math.sin(ky));
} else if (Math.sin(th) <= 0.74) {
tmp = Math.sin(ky) * Math.abs((Math.sin(th) / Math.sin(ky)));
} else {
tmp = Math.sin(ky) * Math.abs((Math.sin(th) / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(th) <= -0.005: tmp = math.sin(th) elif math.sin(th) <= 0.004: tmp = th / (math.hypot(math.sin(ky), math.sin(kx)) / math.sin(ky)) elif math.sin(th) <= 0.74: tmp = math.sin(ky) * math.fabs((math.sin(th) / math.sin(ky))) else: tmp = math.sin(ky) * math.fabs((math.sin(th) / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(th) <= -0.005) tmp = sin(th); elseif (sin(th) <= 0.004) tmp = Float64(th / Float64(hypot(sin(ky), sin(kx)) / sin(ky))); elseif (sin(th) <= 0.74) tmp = Float64(sin(ky) * abs(Float64(sin(th) / sin(ky)))); else tmp = Float64(sin(ky) * abs(Float64(sin(th) / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(th) <= -0.005) tmp = sin(th); elseif (sin(th) <= 0.004) tmp = th / (hypot(sin(ky), sin(kx)) / sin(ky)); elseif (sin(th) <= 0.74) tmp = sin(ky) * abs((sin(th) / sin(ky))); else tmp = sin(ky) * abs((sin(th) / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[th], $MachinePrecision], -0.005], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.004], N[(th / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.74], N[(N[Sin[ky], $MachinePrecision] * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -0.005:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin th \leq 0.004:\\
\;\;\;\;\frac{th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}}\\
\mathbf{elif}\;\sin th \leq 0.74:\\
\;\;\;\;\sin ky \cdot \left|\frac{\sin th}{\sin ky}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \left|\frac{\sin th}{\sin kx}\right|\\
\end{array}
\end{array}
if (sin.f64 th) < -0.0050000000000000001Initial program 96.6%
unpow296.6%
sqr-neg96.6%
sin-neg96.6%
sin-neg96.6%
unpow296.6%
associate-*l/96.6%
associate-/l*96.7%
unpow296.7%
Simplified99.7%
Taylor expanded in kx around 0 26.8%
if -0.0050000000000000001 < (sin.f64 th) < 0.0040000000000000001Initial program 94.0%
unpow294.0%
sqr-neg94.0%
sin-neg94.0%
sin-neg94.0%
unpow294.0%
associate-*l/89.6%
associate-/l*94.0%
unpow294.0%
Simplified99.7%
associate-*r/92.7%
hypot-undefine89.6%
unpow289.6%
unpow289.6%
+-commutative89.6%
associate-*l/94.0%
*-commutative94.0%
clear-num94.1%
un-div-inv94.1%
+-commutative94.1%
unpow294.1%
unpow294.1%
hypot-undefine99.8%
Applied egg-rr99.8%
Taylor expanded in th around 0 98.7%
if 0.0040000000000000001 < (sin.f64 th) < 0.73999999999999999Initial program 85.7%
unpow285.7%
sqr-neg85.7%
sin-neg85.7%
sin-neg85.7%
unpow285.7%
associate-*l/86.0%
associate-/l*85.7%
unpow285.7%
Simplified99.4%
Taylor expanded in kx around 0 22.7%
add-sqr-sqrt21.4%
sqrt-unprod50.4%
pow250.4%
Applied egg-rr50.4%
unpow250.4%
rem-sqrt-square59.4%
Simplified59.4%
if 0.73999999999999999 < (sin.f64 th) Initial program 89.0%
unpow289.0%
sqr-neg89.0%
sin-neg89.0%
sin-neg89.0%
unpow289.0%
associate-*l/88.8%
associate-/l*88.7%
unpow288.7%
Simplified99.4%
clear-num99.3%
hypot-undefine88.6%
unpow288.6%
unpow288.6%
+-commutative88.6%
associate-/r/88.7%
+-commutative88.7%
unpow288.7%
unpow288.7%
hypot-undefine99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 35.7%
add-sqr-sqrt34.7%
sqrt-unprod50.9%
pow250.9%
associate-*l/50.9%
*-un-lft-identity50.9%
Applied egg-rr50.9%
unpow250.9%
rem-sqrt-square51.9%
Simplified51.9%
Final simplification68.5%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.45)
(fabs (sin th))
(if (<= (sin ky) 1e-104)
(* (sin ky) (* (sin th) (/ 1.0 (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.45) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 1e-104) {
tmp = sin(ky) * (sin(th) * (1.0 / 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.45d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-104) then
tmp = sin(ky) * (sin(th) * (1.0d0 / 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.45) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-104) {
tmp = Math.sin(ky) * (Math.sin(th) * (1.0 / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.45: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-104: tmp = math.sin(ky) * (math.sin(th) * (1.0 / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.45) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-104) tmp = Float64(sin(ky) * Float64(sin(th) * Float64(1.0 / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.45) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-104) tmp = sin(ky) * (sin(th) * (1.0 / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.45], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-104], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] * N[(1.0 / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.45:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-104}:\\
\;\;\;\;\sin ky \cdot \left(\sin th \cdot \frac{1}{\sin kx}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.450000000000000011Initial program 99.8%
unpow299.8%
sqr-neg99.8%
sin-neg99.8%
sin-neg99.8%
unpow299.8%
associate-*l/99.8%
associate-/l*99.7%
unpow299.7%
Simplified99.6%
Taylor expanded in kx around 0 3.0%
add-sqr-sqrt2.2%
sqrt-unprod24.6%
pow224.6%
Applied egg-rr24.6%
unpow224.6%
rem-sqrt-square26.6%
associate-*r/26.6%
associate-*l/26.6%
*-inverses26.6%
*-lft-identity26.6%
Simplified26.6%
if -0.450000000000000011 < (sin.f64 ky) < 9.99999999999999927e-105Initial program 86.6%
unpow286.6%
sqr-neg86.6%
sin-neg86.6%
sin-neg86.6%
unpow286.6%
associate-*l/83.4%
associate-/l*86.6%
unpow286.6%
Simplified99.6%
clear-num99.5%
hypot-undefine86.5%
unpow286.5%
unpow286.5%
+-commutative86.5%
associate-/r/86.5%
+-commutative86.5%
unpow286.5%
unpow286.5%
hypot-undefine99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 43.3%
if 9.99999999999999927e-105 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.5%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 59.0%
Final simplification45.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.45) (fabs (sin th)) (if (<= (sin ky) 1e-104) (* (sin ky) (/ (sin th) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.45) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 1e-104) {
tmp = sin(ky) * (sin(th) / 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.45d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-104) then
tmp = sin(ky) * (sin(th) / 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.45) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-104) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.45: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-104: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.45) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-104) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.45) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-104) tmp = sin(ky) * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.45], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-104], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.45:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-104}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.450000000000000011Initial program 99.8%
unpow299.8%
sqr-neg99.8%
sin-neg99.8%
sin-neg99.8%
unpow299.8%
associate-*l/99.8%
associate-/l*99.7%
unpow299.7%
Simplified99.6%
Taylor expanded in kx around 0 3.0%
add-sqr-sqrt2.2%
sqrt-unprod24.6%
pow224.6%
Applied egg-rr24.6%
unpow224.6%
rem-sqrt-square26.6%
associate-*r/26.6%
associate-*l/26.6%
*-inverses26.6%
*-lft-identity26.6%
Simplified26.6%
if -0.450000000000000011 < (sin.f64 ky) < 9.99999999999999927e-105Initial program 86.6%
unpow286.6%
sqr-neg86.6%
sin-neg86.6%
sin-neg86.6%
unpow286.6%
associate-*l/83.4%
associate-/l*86.6%
unpow286.6%
Simplified99.6%
Taylor expanded in ky around 0 43.3%
if 9.99999999999999927e-105 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.5%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 59.0%
Final simplification45.7%
(FPCore (kx ky th) :precision binary64 (* (sin ky) (/ (sin th) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
return sin(ky) * (sin(th) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(ky) * (Math.sin(th) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th): return math.sin(ky) * (math.sin(th) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th) return Float64(sin(ky) * Float64(sin(th) / hypot(sin(ky), sin(kx)))) end
function tmp = code(kx, ky, th) tmp = sin(ky) * (sin(th) / hypot(sin(ky), sin(kx))); end
code[kx_, ky_, th_] := N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Initial program 92.8%
unpow292.8%
sqr-neg92.8%
sin-neg92.8%
sin-neg92.8%
unpow292.8%
associate-*l/90.8%
associate-/l*92.8%
unpow292.8%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.002) (fabs (sin th)) (if (<= (sin ky) 5e-151) (* ky (/ (log1p th) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.002) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 5e-151) {
tmp = ky * (log1p(th) / 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.002) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 5e-151) {
tmp = ky * (Math.log1p(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.002: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 5e-151: tmp = ky * (math.log1p(th) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.002) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-151) tmp = Float64(ky * Float64(log1p(th) / sin(kx))); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.002], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-151], N[(ky * N[(N[Log[1 + th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.002:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-151}:\\
\;\;\;\;ky \cdot \frac{\mathsf{log1p}\left(th\right)}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2e-3Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.7%
associate-/l*99.6%
unpow299.6%
Simplified99.5%
Taylor expanded in kx around 0 3.0%
add-sqr-sqrt2.1%
sqrt-unprod24.7%
pow224.7%
Applied egg-rr24.7%
unpow224.7%
rem-sqrt-square27.7%
associate-*r/27.6%
associate-*l/27.7%
*-inverses27.7%
*-lft-identity27.7%
Simplified27.7%
if -2e-3 < (sin.f64 ky) < 5.00000000000000003e-151Initial program 83.1%
unpow283.1%
sqr-neg83.1%
sin-neg83.1%
sin-neg83.1%
unpow283.1%
associate-*l/79.1%
associate-/l*83.2%
unpow283.2%
Simplified99.7%
add-log-exp24.9%
Applied egg-rr75.8%
Taylor expanded in ky around 0 42.1%
Taylor expanded in th around 0 23.5%
+-commutative23.0%
Simplified23.5%
Taylor expanded in ky around 0 23.5%
log1p-define30.3%
associate-/l*32.0%
Simplified32.0%
if 5.00000000000000003e-151 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.6%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 58.9%
Final simplification40.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.002) (fabs (sin th)) (if (<= (sin ky) 1e-104) (* ky (/ (sin th) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.002) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 1e-104) {
tmp = ky * (sin(th) / 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.002d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-104) then
tmp = ky * (sin(th) / 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.002) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-104) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.002: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-104: tmp = ky * (math.sin(th) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.002) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-104) tmp = Float64(ky * Float64(sin(th) / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.002) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-104) tmp = ky * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.002], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-104], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.002:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-104}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2e-3Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.7%
associate-/l*99.6%
unpow299.6%
Simplified99.5%
Taylor expanded in kx around 0 3.0%
add-sqr-sqrt2.1%
sqrt-unprod24.7%
pow224.7%
Applied egg-rr24.7%
unpow224.7%
rem-sqrt-square27.7%
associate-*r/27.6%
associate-*l/27.7%
*-inverses27.7%
*-lft-identity27.7%
Simplified27.7%
if -2e-3 < (sin.f64 ky) < 9.99999999999999927e-105Initial program 84.4%
unpow284.4%
sqr-neg84.4%
sin-neg84.4%
sin-neg84.4%
unpow284.4%
associate-*l/80.7%
associate-/l*84.5%
unpow284.5%
Simplified99.7%
Taylor expanded in ky around 0 48.1%
associate-/l*49.7%
Simplified49.7%
if 9.99999999999999927e-105 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.5%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 59.0%
Final simplification47.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.002) (fabs (sin th)) (if (<= (sin ky) 5e-151) (* ky (/ th (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.002) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 5e-151) {
tmp = ky * (th / 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.002d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 5d-151) then
tmp = ky * (th / 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.002) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 5e-151) {
tmp = ky * (th / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.002: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 5e-151: tmp = ky * (th / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.002) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-151) tmp = Float64(ky * Float64(th / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.002) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-151) tmp = ky * (th / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.002], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-151], N[(ky * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.002:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-151}:\\
\;\;\;\;ky \cdot \frac{th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2e-3Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/99.7%
associate-/l*99.6%
unpow299.6%
Simplified99.5%
Taylor expanded in kx around 0 3.0%
add-sqr-sqrt2.1%
sqrt-unprod24.7%
pow224.7%
Applied egg-rr24.7%
unpow224.7%
rem-sqrt-square27.7%
associate-*r/27.6%
associate-*l/27.7%
*-inverses27.7%
*-lft-identity27.7%
Simplified27.7%
if -2e-3 < (sin.f64 ky) < 5.00000000000000003e-151Initial program 83.1%
unpow283.1%
sqr-neg83.1%
sin-neg83.1%
sin-neg83.1%
unpow283.1%
associate-*l/79.1%
associate-/l*83.2%
unpow283.2%
Simplified99.7%
clear-num99.5%
hypot-undefine83.1%
unpow283.1%
unpow283.1%
+-commutative83.1%
associate-/r/83.1%
+-commutative83.1%
unpow283.1%
unpow283.1%
hypot-undefine99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 50.9%
Taylor expanded in th around 0 32.5%
Taylor expanded in ky around 0 31.0%
associate-/l*32.5%
Simplified32.5%
if 5.00000000000000003e-151 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.6%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 58.9%
Final simplification40.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 5e-151) (* th (/ (sin ky) kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 5e-151) {
tmp = th * (sin(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 (sin(ky) <= 5d-151) then
tmp = th * (sin(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 (Math.sin(ky) <= 5e-151) {
tmp = th * (Math.sin(ky) / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 5e-151: tmp = th * (math.sin(ky) / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 5e-151) tmp = Float64(th * Float64(sin(ky) / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 5e-151) tmp = th * (sin(ky) / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-151], N[(th * N[(N[Sin[ky], $MachinePrecision] / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 5 \cdot 10^{-151}:\\
\;\;\;\;th \cdot \frac{\sin ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 5.00000000000000003e-151Initial program 89.1%
unpow289.1%
sqr-neg89.1%
sin-neg89.1%
sin-neg89.1%
unpow289.1%
associate-*l/86.5%
associate-/l*89.0%
unpow289.0%
Simplified99.6%
clear-num99.5%
hypot-undefine88.9%
unpow288.9%
unpow288.9%
+-commutative88.9%
associate-/r/88.9%
+-commutative88.9%
unpow288.9%
unpow288.9%
hypot-undefine99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 34.8%
Taylor expanded in th around 0 22.5%
Taylor expanded in kx around 0 18.9%
associate-/l*19.9%
Simplified19.9%
if 5.00000000000000003e-151 < (sin.f64 ky) Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.6%
associate-/l*99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in kx around 0 58.9%
Final simplification33.8%
(FPCore (kx ky th) :precision binary64 (if (<= ky 4.6e-151) (* ky (/ th (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.6e-151) {
tmp = ky * (th / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 4.6d-151) then
tmp = ky * (th / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 4.6e-151) {
tmp = ky * (th / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 4.6e-151: tmp = ky * (th / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 4.6e-151) tmp = Float64(ky * Float64(th / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 4.6e-151) tmp = ky * (th / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 4.6e-151], N[(ky * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 4.6 \cdot 10^{-151}:\\
\;\;\;\;ky \cdot \frac{th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 4.59999999999999992e-151Initial program 89.5%
unpow289.5%
sqr-neg89.5%
sin-neg89.5%
sin-neg89.5%
unpow289.5%
associate-*l/87.1%
associate-/l*89.5%
unpow289.5%
Simplified99.6%
clear-num99.4%
hypot-undefine89.4%
unpow289.4%
unpow289.4%
+-commutative89.4%
associate-/r/89.4%
+-commutative89.4%
unpow289.4%
unpow289.4%
hypot-undefine99.5%
Applied egg-rr99.5%
Taylor expanded in ky around 0 34.1%
Taylor expanded in th around 0 22.4%
Taylor expanded in ky around 0 20.0%
associate-/l*20.9%
Simplified20.9%
if 4.59999999999999992e-151 < ky Initial program 99.7%
unpow299.7%
sqr-neg99.7%
sin-neg99.7%
sin-neg99.7%
unpow299.7%
associate-*l/98.5%
associate-/l*99.7%
unpow299.7%
Simplified99.6%
Taylor expanded in kx around 0 42.9%
Final simplification28.0%
(FPCore (kx ky th) :precision binary64 (if (<= kx 7.8e-7) (sin th) (log (+ th 1.0))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 7.8e-7) {
tmp = sin(th);
} else {
tmp = log((th + 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 <= 7.8d-7) then
tmp = sin(th)
else
tmp = log((th + 1.0d0))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 7.8e-7) {
tmp = Math.sin(th);
} else {
tmp = Math.log((th + 1.0));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 7.8e-7: tmp = math.sin(th) else: tmp = math.log((th + 1.0)) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 7.8e-7) tmp = sin(th); else tmp = log(Float64(th + 1.0)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 7.8e-7) tmp = sin(th); else tmp = log((th + 1.0)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 7.8e-7], N[Sin[th], $MachinePrecision], N[Log[N[(th + 1.0), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 7.8 \cdot 10^{-7}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\log \left(th + 1\right)\\
\end{array}
\end{array}
if kx < 7.80000000000000049e-7Initial program 91.1%
unpow291.1%
sqr-neg91.1%
sin-neg91.1%
sin-neg91.1%
unpow291.1%
associate-*l/88.5%
associate-/l*91.0%
unpow291.0%
Simplified99.7%
Taylor expanded in kx around 0 29.0%
if 7.80000000000000049e-7 < kx Initial program 99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
associate-*l/99.5%
associate-/l*99.4%
unpow299.4%
Simplified99.3%
Taylor expanded in kx around 0 9.2%
add-log-exp20.9%
Applied egg-rr20.9%
Taylor expanded in th around 0 18.6%
+-commutative18.6%
Simplified18.6%
Final simplification26.8%
(FPCore (kx ky th) :precision binary64 (if (<= th 1.75) th (log th)))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 1.75) {
tmp = th;
} else {
tmp = log(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 (th <= 1.75d0) then
tmp = th
else
tmp = log(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 1.75) {
tmp = th;
} else {
tmp = Math.log(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 1.75: tmp = th else: tmp = math.log(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 1.75) tmp = th; else tmp = log(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 1.75) tmp = th; else tmp = log(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 1.75], th, N[Log[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 1.75:\\
\;\;\;\;th\\
\mathbf{else}:\\
\;\;\;\;\log th\\
\end{array}
\end{array}
if th < 1.75Initial program 91.5%
unpow291.5%
sqr-neg91.5%
sin-neg91.5%
sin-neg91.5%
unpow291.5%
associate-*l/88.8%
associate-/l*91.5%
unpow291.5%
Simplified99.7%
Taylor expanded in kx around 0 21.1%
Taylor expanded in th around 0 16.0%
if 1.75 < th Initial program 96.7%
unpow296.7%
sqr-neg96.7%
sin-neg96.7%
sin-neg96.7%
unpow296.7%
associate-*l/96.7%
associate-/l*96.6%
unpow296.6%
Simplified99.5%
Taylor expanded in kx around 0 35.6%
add-log-exp35.3%
Applied egg-rr35.3%
Taylor expanded in th around 0 6.0%
+-commutative6.0%
Simplified6.0%
Taylor expanded in th around inf 6.0%
mul-1-neg6.0%
log-rec6.0%
remove-double-neg6.0%
Simplified6.0%
Final simplification13.5%
(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%
unpow292.8%
sqr-neg92.8%
sin-neg92.8%
sin-neg92.8%
unpow292.8%
associate-*l/90.8%
associate-/l*92.8%
unpow292.8%
Simplified99.6%
Taylor expanded in kx around 0 24.8%
Final simplification24.8%
(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%
unpow292.8%
sqr-neg92.8%
sin-neg92.8%
sin-neg92.8%
unpow292.8%
associate-*l/90.8%
associate-/l*92.8%
unpow292.8%
Simplified99.6%
Taylor expanded in kx around 0 24.8%
Taylor expanded in th around 0 12.6%
Final simplification12.6%
herbie shell --seed 2024081
(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)))