
(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 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (hypot (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th
\end{array}
Initial program 92.5%
+-commutative92.5%
unpow292.5%
unpow292.5%
hypot-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.6)
(/ (sin ky) (fabs (/ (sin ky) (sin th))))
(if (<= (sin ky) -2e-49)
(fabs (sin th))
(if (<= (sin ky) -2e-132)
(/ 1.0 (/ (sin kx) (* (sin ky) (sin th))))
(if (<= (sin ky) -5e-161)
(/ (* ky th) (hypot (sin ky) (sin kx)))
(if (<= (sin ky) 1e-210) (* (sin th) (/ ky (sin kx))) (sin th)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.6) {
tmp = sin(ky) / fabs((sin(ky) / sin(th)));
} else if (sin(ky) <= -2e-49) {
tmp = fabs(sin(th));
} else if (sin(ky) <= -2e-132) {
tmp = 1.0 / (sin(kx) / (sin(ky) * sin(th)));
} else if (sin(ky) <= -5e-161) {
tmp = (ky * th) / hypot(sin(ky), sin(kx));
} else if (sin(ky) <= 1e-210) {
tmp = sin(th) * (ky / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.6) {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / Math.sin(th)));
} else if (Math.sin(ky) <= -2e-49) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= -2e-132) {
tmp = 1.0 / (Math.sin(kx) / (Math.sin(ky) * Math.sin(th)));
} else if (Math.sin(ky) <= -5e-161) {
tmp = (ky * th) / Math.hypot(Math.sin(ky), Math.sin(kx));
} else if (Math.sin(ky) <= 1e-210) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.6: tmp = math.sin(ky) / math.fabs((math.sin(ky) / math.sin(th))) elif math.sin(ky) <= -2e-49: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= -2e-132: tmp = 1.0 / (math.sin(kx) / (math.sin(ky) * math.sin(th))) elif math.sin(ky) <= -5e-161: tmp = (ky * th) / math.hypot(math.sin(ky), math.sin(kx)) elif math.sin(ky) <= 1e-210: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.6) tmp = Float64(sin(ky) / abs(Float64(sin(ky) / sin(th)))); elseif (sin(ky) <= -2e-49) tmp = abs(sin(th)); elseif (sin(ky) <= -2e-132) tmp = Float64(1.0 / Float64(sin(kx) / Float64(sin(ky) * sin(th)))); elseif (sin(ky) <= -5e-161) tmp = Float64(Float64(ky * th) / hypot(sin(ky), sin(kx))); elseif (sin(ky) <= 1e-210) tmp = Float64(sin(th) * Float64(ky / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.6) tmp = sin(ky) / abs((sin(ky) / sin(th))); elseif (sin(ky) <= -2e-49) tmp = abs(sin(th)); elseif (sin(ky) <= -2e-132) tmp = 1.0 / (sin(kx) / (sin(ky) * sin(th))); elseif (sin(ky) <= -5e-161) tmp = (ky * th) / hypot(sin(ky), sin(kx)); elseif (sin(ky) <= 1e-210) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.6], 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-49], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -2e-132], N[(1.0 / N[(N[Sin[kx], $MachinePrecision] / N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -5e-161], N[(N[(ky * th), $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-210], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.6:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\mathbf{elif}\;\sin ky \leq -2 \cdot 10^{-49}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq -2 \cdot 10^{-132}:\\
\;\;\;\;\frac{1}{\frac{\sin kx}{\sin ky \cdot \sin th}}\\
\mathbf{elif}\;\sin ky \leq -5 \cdot 10^{-161}:\\
\;\;\;\;\frac{ky \cdot th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{elif}\;\sin ky \leq 10^{-210}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.599999999999999978Initial 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 3.1%
add-sqr-sqrt1.2%
sqrt-unprod24.1%
pow224.1%
Applied egg-rr24.1%
unpow224.1%
rem-sqrt-square32.0%
Simplified32.0%
if -0.599999999999999978 < (sin.f64 ky) < -1.99999999999999987e-49Initial 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 3.1%
associate-/r/3.1%
*-inverses3.1%
*-un-lft-identity3.1%
add-sqr-sqrt1.1%
sqrt-unprod28.3%
pow228.3%
Applied egg-rr28.3%
unpow228.3%
rem-sqrt-square40.4%
Simplified40.4%
if -1.99999999999999987e-49 < (sin.f64 ky) < -2e-132Initial program 99.4%
Taylor expanded in ky around 0 48.2%
associate-*l/48.4%
clear-num48.7%
*-commutative48.7%
Applied egg-rr48.7%
if -2e-132 < (sin.f64 ky) < -4.9999999999999999e-161Initial program 99.2%
associate-*l/99.2%
+-commutative99.2%
unpow299.2%
unpow299.2%
hypot-def99.8%
Simplified99.8%
Taylor expanded in th around 0 77.8%
*-commutative77.8%
Simplified77.8%
Taylor expanded in ky around 0 77.8%
*-commutative77.8%
Simplified77.8%
if -4.9999999999999999e-161 < (sin.f64 ky) < 1e-210Initial program 77.4%
Taylor expanded in ky around 0 55.0%
if 1e-210 < (sin.f64 ky) Initial program 93.8%
+-commutative93.8%
unpow293.8%
unpow293.8%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 60.9%
Final simplification51.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.02)
(/
(sin ky)
(* (hypot (sin ky) (sin kx)) (+ (/ 1.0 th) (* th 0.16666666666666666))))
(if (<= (sin ky) 0.0002)
(/
(sin th)
(* (hypot (sin kx) (sin ky)) (+ (* ky 0.16666666666666666) (/ 1.0 ky))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.02) {
tmp = sin(ky) / (hypot(sin(ky), sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666)));
} else if (sin(ky) <= 0.0002) {
tmp = sin(th) / (hypot(sin(kx), sin(ky)) * ((ky * 0.16666666666666666) + (1.0 / ky)));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.02) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(ky), Math.sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666)));
} else if (Math.sin(ky) <= 0.0002) {
tmp = Math.sin(th) / (Math.hypot(Math.sin(kx), Math.sin(ky)) * ((ky * 0.16666666666666666) + (1.0 / ky)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.02: tmp = math.sin(ky) / (math.hypot(math.sin(ky), math.sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666))) elif math.sin(ky) <= 0.0002: tmp = math.sin(th) / (math.hypot(math.sin(kx), math.sin(ky)) * ((ky * 0.16666666666666666) + (1.0 / ky))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.02) tmp = Float64(sin(ky) / Float64(hypot(sin(ky), sin(kx)) * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); elseif (sin(ky) <= 0.0002) tmp = Float64(sin(th) / Float64(hypot(sin(kx), sin(ky)) * Float64(Float64(ky * 0.16666666666666666) + Float64(1.0 / ky)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.02) tmp = sin(ky) / (hypot(sin(ky), sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666))); elseif (sin(ky) <= 0.0002) tmp = sin(th) / (hypot(sin(kx), sin(ky)) * ((ky * 0.16666666666666666) + (1.0 / ky))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.0002], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(N[(ky * 0.16666666666666666), $MachinePrecision] + N[(1.0 / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.02:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{elif}\;\sin ky \leq 0.0002:\\
\;\;\;\;\frac{\sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(ky \cdot 0.16666666666666666 + \frac{1}{ky}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0200000000000000004Initial 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 th around 0 62.0%
+-commutative62.0%
unpow262.0%
unpow262.0%
hypot-def62.0%
associate-*r*62.0%
unpow262.0%
unpow262.0%
hypot-def62.0%
distribute-rgt-out62.0%
Simplified62.0%
if -0.0200000000000000004 < (sin.f64 ky) < 2.0000000000000001e-4Initial program 84.7%
+-commutative84.7%
unpow284.7%
unpow284.7%
hypot-def99.7%
Simplified99.7%
*-commutative99.7%
clear-num99.6%
un-div-inv99.7%
hypot-udef84.6%
unpow284.6%
unpow284.6%
+-commutative84.6%
unpow284.6%
unpow284.6%
hypot-def99.7%
Applied egg-rr99.7%
div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 98.7%
if 2.0000000000000001e-4 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 64.4%
Final simplification80.0%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin kx) (sin ky))))
(if (<= (sin ky) -0.01)
(* th (/ (sin ky) t_1))
(if (<= (sin ky) 0.0002) (/ (sin th) (* t_1 (/ 1.0 ky))) (sin th)))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (sin(ky) <= -0.01) {
tmp = th * (sin(ky) / t_1);
} else if (sin(ky) <= 0.0002) {
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(kx), Math.sin(ky));
double tmp;
if (Math.sin(ky) <= -0.01) {
tmp = th * (Math.sin(ky) / t_1);
} else if (Math.sin(ky) <= 0.0002) {
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(kx), math.sin(ky)) tmp = 0 if math.sin(ky) <= -0.01: tmp = th * (math.sin(ky) / t_1) elif math.sin(ky) <= 0.0002: 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(kx), sin(ky)) tmp = 0.0 if (sin(ky) <= -0.01) tmp = Float64(th * Float64(sin(ky) / t_1)); elseif (sin(ky) <= 0.0002) 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(kx), sin(ky)); tmp = 0.0; if (sin(ky) <= -0.01) tmp = th * (sin(ky) / t_1); elseif (sin(ky) <= 0.0002) 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[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.01], N[(th * N[(N[Sin[ky], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.0002], 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 kx, \sin ky\right)\\
\mathbf{if}\;\sin ky \leq -0.01:\\
\;\;\;\;th \cdot \frac{\sin ky}{t_1}\\
\mathbf{elif}\;\sin ky \leq 0.0002:\\
\;\;\;\;\frac{\sin th}{t_1 \cdot \frac{1}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0100000000000000002Initial program 99.5%
associate-*l/99.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-def99.5%
Simplified99.5%
Taylor expanded in th around 0 60.8%
*-commutative60.8%
Simplified60.8%
associate-/l*60.8%
associate-/r/60.8%
hypot-udef60.8%
+-commutative60.8%
hypot-udef60.8%
Applied egg-rr60.8%
if -0.0100000000000000002 < (sin.f64 ky) < 2.0000000000000001e-4Initial program 84.5%
+-commutative84.5%
unpow284.5%
unpow284.5%
hypot-def99.7%
Simplified99.7%
*-commutative99.7%
clear-num99.6%
un-div-inv99.7%
hypot-udef84.5%
unpow284.5%
unpow284.5%
+-commutative84.5%
unpow284.5%
unpow284.5%
hypot-def99.7%
Applied egg-rr99.7%
div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 98.9%
if 2.0000000000000001e-4 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 64.4%
Final simplification79.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.01)
(/
(sin ky)
(* (hypot (sin ky) (sin kx)) (+ (/ 1.0 th) (* th 0.16666666666666666))))
(if (<= (sin ky) 0.0002)
(/ (sin th) (* (hypot (sin kx) (sin ky)) (/ 1.0 ky)))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.01) {
tmp = sin(ky) / (hypot(sin(ky), sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666)));
} else if (sin(ky) <= 0.0002) {
tmp = sin(th) / (hypot(sin(kx), sin(ky)) * (1.0 / ky));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.01) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(ky), Math.sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666)));
} else if (Math.sin(ky) <= 0.0002) {
tmp = Math.sin(th) / (Math.hypot(Math.sin(kx), Math.sin(ky)) * (1.0 / ky));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.01: tmp = math.sin(ky) / (math.hypot(math.sin(ky), math.sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666))) elif math.sin(ky) <= 0.0002: tmp = math.sin(th) / (math.hypot(math.sin(kx), math.sin(ky)) * (1.0 / ky)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.01) tmp = Float64(sin(ky) / Float64(hypot(sin(ky), sin(kx)) * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); elseif (sin(ky) <= 0.0002) tmp = Float64(sin(th) / Float64(hypot(sin(kx), sin(ky)) * Float64(1.0 / ky))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.01) tmp = sin(ky) / (hypot(sin(ky), sin(kx)) * ((1.0 / th) + (th * 0.16666666666666666))); elseif (sin(ky) <= 0.0002) tmp = sin(th) / (hypot(sin(kx), sin(ky)) * (1.0 / ky)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.01], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.0002], N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] * N[(1.0 / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.01:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{elif}\;\sin ky \leq 0.0002:\\
\;\;\;\;\frac{\sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \frac{1}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0100000000000000002Initial 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 th around 0 61.2%
+-commutative61.2%
unpow261.2%
unpow261.2%
hypot-def61.2%
associate-*r*61.2%
unpow261.2%
unpow261.2%
hypot-def61.2%
distribute-rgt-out61.2%
Simplified61.2%
if -0.0100000000000000002 < (sin.f64 ky) < 2.0000000000000001e-4Initial program 84.5%
+-commutative84.5%
unpow284.5%
unpow284.5%
hypot-def99.7%
Simplified99.7%
*-commutative99.7%
clear-num99.6%
un-div-inv99.7%
hypot-udef84.5%
unpow284.5%
unpow284.5%
+-commutative84.5%
unpow284.5%
unpow284.5%
hypot-def99.7%
Applied egg-rr99.7%
div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 98.9%
if 2.0000000000000001e-4 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 64.4%
Final simplification79.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.04)
(/ (sin th) (/ (sin kx) (sin ky)))
(if (<= (sin th) 2e-22)
(* th (/ (sin ky) (hypot (sin kx) (sin ky))))
(/ (sin ky) (fabs (/ (sin ky) (sin th)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.04) {
tmp = sin(th) / (sin(kx) / sin(ky));
} else if (sin(th) <= 2e-22) {
tmp = th * (sin(ky) / hypot(sin(kx), 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.04) {
tmp = Math.sin(th) / (Math.sin(kx) / Math.sin(ky));
} else if (Math.sin(th) <= 2e-22) {
tmp = th * (Math.sin(ky) / Math.hypot(Math.sin(kx), 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.04: tmp = math.sin(th) / (math.sin(kx) / math.sin(ky)) elif math.sin(th) <= 2e-22: tmp = th * (math.sin(ky) / math.hypot(math.sin(kx), 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.04) tmp = Float64(sin(th) / Float64(sin(kx) / sin(ky))); elseif (sin(th) <= 2e-22) tmp = Float64(th * Float64(sin(ky) / hypot(sin(kx), 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.04) tmp = sin(th) / (sin(kx) / sin(ky)); elseif (sin(th) <= 2e-22) tmp = th * (sin(ky) / hypot(sin(kx), 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.04], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 2e-22], N[(th * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $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.04:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\
\mathbf{elif}\;\sin th \leq 2 \cdot 10^{-22}:\\
\;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\end{array}
\end{array}
if (sin.f64 th) < -0.0400000000000000008Initial program 88.3%
+-commutative88.3%
unpow288.3%
unpow288.3%
hypot-def99.6%
Simplified99.6%
*-commutative99.6%
clear-num99.4%
un-div-inv99.6%
hypot-udef88.4%
unpow288.4%
unpow288.4%
+-commutative88.4%
unpow288.4%
unpow288.4%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 18.8%
if -0.0400000000000000008 < (sin.f64 th) < 2.0000000000000001e-22Initial program 93.4%
associate-*l/91.4%
+-commutative91.4%
unpow291.4%
unpow291.4%
hypot-def93.8%
Simplified93.8%
Taylor expanded in th around 0 93.6%
*-commutative93.6%
Simplified93.6%
associate-/l*99.4%
associate-/r/99.5%
hypot-udef93.2%
+-commutative93.2%
hypot-udef99.5%
Applied egg-rr99.5%
if 2.0000000000000001e-22 < (sin.f64 th) Initial program 94.0%
associate-/r/93.9%
+-commutative93.9%
unpow293.9%
sqr-neg93.9%
sin-neg93.9%
sin-neg93.9%
unpow293.9%
+-commutative93.9%
Simplified99.6%
Taylor expanded in kx around 0 31.2%
add-sqr-sqrt30.3%
sqrt-unprod49.2%
pow249.2%
Applied egg-rr49.2%
unpow249.2%
rem-sqrt-square54.9%
Simplified54.9%
Final simplification71.1%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -2e-49) (fabs (sin th)) (if (<= (sin ky) 1e-210) (/ (sin th) (/ (sin kx) (sin ky))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -2e-49) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 1e-210) {
tmp = sin(th) / (sin(kx) / sin(ky));
} 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-49)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-210) then
tmp = sin(th) / (sin(kx) / sin(ky))
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-49) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-210) {
tmp = Math.sin(th) / (Math.sin(kx) / Math.sin(ky));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -2e-49: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-210: tmp = math.sin(th) / (math.sin(kx) / math.sin(ky)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -2e-49) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-210) tmp = Float64(sin(th) / Float64(sin(kx) / sin(ky))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -2e-49) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-210) tmp = sin(th) / (sin(kx) / sin(ky)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -2e-49], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-210], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -2 \cdot 10^{-49}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-210}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1.99999999999999987e-49Initial 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 3.1%
associate-/r/3.1%
*-inverses3.1%
*-un-lft-identity3.1%
add-sqr-sqrt1.6%
sqrt-unprod22.3%
pow222.3%
Applied egg-rr22.3%
unpow222.3%
rem-sqrt-square29.5%
Simplified29.5%
if -1.99999999999999987e-49 < (sin.f64 ky) < 1e-210Initial program 84.0%
+-commutative84.0%
unpow284.0%
unpow284.0%
hypot-def99.7%
Simplified99.7%
*-commutative99.7%
clear-num99.5%
un-div-inv99.7%
hypot-udef84.0%
unpow284.0%
unpow284.0%
+-commutative84.0%
unpow284.0%
unpow284.0%
hypot-def99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 50.4%
if 1e-210 < (sin.f64 ky) Initial program 93.8%
+-commutative93.8%
unpow293.8%
unpow293.8%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 60.9%
Final simplification48.0%
(FPCore (kx ky th) :precision binary64 (if (or (<= th -260.0) (not (<= th 0.00155))) (/ (* ky (sin th)) (hypot (sin ky) (sin kx))) (* th (/ (sin ky) (hypot (sin kx) (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if ((th <= -260.0) || !(th <= 0.00155)) {
tmp = (ky * sin(th)) / hypot(sin(ky), sin(kx));
} else {
tmp = th * (sin(ky) / hypot(sin(kx), sin(ky)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if ((th <= -260.0) || !(th <= 0.00155)) {
tmp = (ky * Math.sin(th)) / Math.hypot(Math.sin(ky), Math.sin(kx));
} else {
tmp = th * (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (th <= -260.0) or not (th <= 0.00155): tmp = (ky * math.sin(th)) / math.hypot(math.sin(ky), math.sin(kx)) else: tmp = th * (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) return tmp
function code(kx, ky, th) tmp = 0.0 if ((th <= -260.0) || !(th <= 0.00155)) tmp = Float64(Float64(ky * sin(th)) / hypot(sin(ky), sin(kx))); else tmp = Float64(th * Float64(sin(ky) / hypot(sin(kx), sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((th <= -260.0) || ~((th <= 0.00155))) tmp = (ky * sin(th)) / hypot(sin(ky), sin(kx)); else tmp = th * (sin(ky) / hypot(sin(kx), sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[th, -260.0], N[Not[LessEqual[th, 0.00155]], $MachinePrecision]], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(th * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq -260 \lor \neg \left(th \leq 0.00155\right):\\
\;\;\;\;\frac{ky \cdot \sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\end{array}
\end{array}
if th < -260 or 0.00154999999999999995 < th Initial program 91.4%
associate-*l/91.3%
+-commutative91.3%
unpow291.3%
unpow291.3%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 55.5%
if -260 < th < 0.00154999999999999995Initial program 93.5%
associate-*l/91.5%
+-commutative91.5%
unpow291.5%
unpow291.5%
hypot-def93.9%
Simplified93.9%
Taylor expanded in th around 0 92.9%
*-commutative92.9%
Simplified92.9%
associate-/l*98.5%
associate-/r/98.6%
hypot-udef92.4%
+-commutative92.4%
hypot-udef98.6%
Applied egg-rr98.6%
Final simplification78.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -2e-49) (fabs (sin th)) (if (<= (sin ky) 1e-210) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -2e-49) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 1e-210) {
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-49)) then
tmp = abs(sin(th))
else if (sin(ky) <= 1d-210) 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-49) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 1e-210) {
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-49: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 1e-210: 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-49) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-210) 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-49) tmp = abs(sin(th)); elseif (sin(ky) <= 1e-210) 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-49], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-210], 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^{-49}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 10^{-210}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1.99999999999999987e-49Initial 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 3.1%
associate-/r/3.1%
*-inverses3.1%
*-un-lft-identity3.1%
add-sqr-sqrt1.6%
sqrt-unprod22.3%
pow222.3%
Applied egg-rr22.3%
unpow222.3%
rem-sqrt-square29.5%
Simplified29.5%
if -1.99999999999999987e-49 < (sin.f64 ky) < 1e-210Initial program 84.0%
Taylor expanded in ky around 0 50.4%
if 1e-210 < (sin.f64 ky) Initial program 93.8%
+-commutative93.8%
unpow293.8%
unpow293.8%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 60.9%
Final simplification48.0%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -1e-152)
(sqrt (* th th))
(if (<= (sin ky) 5e-214)
(/ ky (* (sin kx) (+ (/ 1.0 th) (* th 0.16666666666666666))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -1e-152) {
tmp = sqrt((th * th));
} else if (sin(ky) <= 5e-214) {
tmp = ky / (sin(kx) * ((1.0 / th) + (th * 0.16666666666666666)));
} 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) <= (-1d-152)) then
tmp = sqrt((th * th))
else if (sin(ky) <= 5d-214) then
tmp = ky / (sin(kx) * ((1.0d0 / th) + (th * 0.16666666666666666d0)))
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) <= -1e-152) {
tmp = Math.sqrt((th * th));
} else if (Math.sin(ky) <= 5e-214) {
tmp = ky / (Math.sin(kx) * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -1e-152: tmp = math.sqrt((th * th)) elif math.sin(ky) <= 5e-214: tmp = ky / (math.sin(kx) * ((1.0 / th) + (th * 0.16666666666666666))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -1e-152) tmp = sqrt(Float64(th * th)); elseif (sin(ky) <= 5e-214) tmp = Float64(ky / Float64(sin(kx) * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -1e-152) tmp = sqrt((th * th)); elseif (sin(ky) <= 5e-214) tmp = ky / (sin(kx) * ((1.0 / th) + (th * 0.16666666666666666))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-152], N[Sqrt[N[(th * th), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-214], N[(ky / N[(N[Sin[kx], $MachinePrecision] * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -1 \cdot 10^{-152}:\\
\;\;\;\;\sqrt{th \cdot th}\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-214}:\\
\;\;\;\;\frac{ky}{\sin kx \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1.00000000000000007e-152Initial 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 3.1%
associate-/r/3.1%
*-inverses3.1%
*-un-lft-identity3.1%
add-sqr-sqrt1.5%
sqrt-unprod25.2%
pow225.2%
Applied egg-rr25.2%
Taylor expanded in th around 0 17.6%
unpow217.6%
Simplified17.6%
if -1.00000000000000007e-152 < (sin.f64 ky) < 4.9999999999999998e-214Initial program 79.4%
associate-/r/79.3%
+-commutative79.3%
unpow279.3%
sqr-neg79.3%
sin-neg79.3%
sin-neg79.3%
unpow279.3%
+-commutative79.3%
Simplified99.7%
Taylor expanded in th around 0 39.2%
+-commutative39.2%
unpow239.2%
unpow239.2%
hypot-def49.1%
associate-*r*49.1%
unpow249.1%
unpow249.1%
hypot-def49.3%
distribute-rgt-out49.3%
Simplified49.3%
Taylor expanded in ky around 0 41.3%
if 4.9999999999999998e-214 < (sin.f64 ky) Initial program 92.9%
+-commutative92.9%
unpow292.9%
unpow292.9%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 60.7%
Final simplification39.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -2e-135)
(fabs (sin th))
(if (<= (sin ky) 5e-214)
(/ ky (* (sin kx) (+ (/ 1.0 th) (* th 0.16666666666666666))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -2e-135) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 5e-214) {
tmp = ky / (sin(kx) * ((1.0 / th) + (th * 0.16666666666666666)));
} 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-135)) then
tmp = abs(sin(th))
else if (sin(ky) <= 5d-214) then
tmp = ky / (sin(kx) * ((1.0d0 / th) + (th * 0.16666666666666666d0)))
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-135) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 5e-214) {
tmp = ky / (Math.sin(kx) * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -2e-135: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 5e-214: tmp = ky / (math.sin(kx) * ((1.0 / th) + (th * 0.16666666666666666))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -2e-135) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-214) tmp = Float64(ky / Float64(sin(kx) * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -2e-135) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-214) tmp = ky / (sin(kx) * ((1.0 / th) + (th * 0.16666666666666666))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -2e-135], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-214], N[(ky / N[(N[Sin[kx], $MachinePrecision] * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -2 \cdot 10^{-135}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-214}:\\
\;\;\;\;\frac{ky}{\sin kx \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2.0000000000000001e-135Initial 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 3.1%
associate-/r/3.1%
*-inverses3.1%
*-un-lft-identity3.1%
add-sqr-sqrt1.5%
sqrt-unprod23.9%
pow223.9%
Applied egg-rr23.9%
unpow223.9%
rem-sqrt-square28.8%
Simplified28.8%
if -2.0000000000000001e-135 < (sin.f64 ky) < 4.9999999999999998e-214Initial program 80.5%
associate-/r/80.3%
+-commutative80.3%
unpow280.3%
sqr-neg80.3%
sin-neg80.3%
sin-neg80.3%
unpow280.3%
+-commutative80.3%
Simplified99.7%
Taylor expanded in th around 0 42.3%
+-commutative42.3%
unpow242.3%
unpow242.3%
hypot-def51.7%
associate-*r*51.7%
unpow251.7%
unpow251.7%
hypot-def51.8%
distribute-rgt-out51.8%
Simplified51.8%
Taylor expanded in ky around 0 41.0%
if 4.9999999999999998e-214 < (sin.f64 ky) Initial program 92.9%
+-commutative92.9%
unpow292.9%
unpow292.9%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 60.7%
Final simplification44.1%
(FPCore (kx ky th) :precision binary64 (if (<= ky -6.6e+15) (sin th) (if (<= ky 1.9e-212) (/ ky (/ (sin kx) th)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -6.6e+15) {
tmp = sin(th);
} else if (ky <= 1.9e-212) {
tmp = ky / (sin(kx) / th);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= (-6.6d+15)) then
tmp = sin(th)
else if (ky <= 1.9d-212) then
tmp = ky / (sin(kx) / th)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -6.6e+15) {
tmp = Math.sin(th);
} else if (ky <= 1.9e-212) {
tmp = ky / (Math.sin(kx) / th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -6.6e+15: tmp = math.sin(th) elif ky <= 1.9e-212: tmp = ky / (math.sin(kx) / th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -6.6e+15) tmp = sin(th); elseif (ky <= 1.9e-212) tmp = Float64(ky / Float64(sin(kx) / th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -6.6e+15) tmp = sin(th); elseif (ky <= 1.9e-212) tmp = ky / (sin(kx) / th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -6.6e+15], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 1.9e-212], N[(ky / N[(N[Sin[kx], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -6.6 \cdot 10^{+15}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 1.9 \cdot 10^{-212}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -6.6e15 or 1.90000000000000011e-212 < ky Initial program 95.6%
+-commutative95.6%
unpow295.6%
unpow295.6%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 37.5%
if -6.6e15 < ky < 1.90000000000000011e-212Initial program 86.7%
associate-*l/84.5%
+-commutative84.5%
unpow284.5%
unpow284.5%
hypot-def94.7%
Simplified94.7%
Taylor expanded in th around 0 46.5%
*-commutative46.5%
Simplified46.5%
Taylor expanded in ky around 0 30.6%
associate-/l*32.3%
Simplified32.3%
Final simplification35.7%
(FPCore (kx ky th) :precision binary64 (if (<= ky -3.5e+40) (sin th) (if (<= ky 7.2e-214) (sqrt (* th th)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -3.5e+40) {
tmp = sin(th);
} else if (ky <= 7.2e-214) {
tmp = sqrt((th * th));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= (-3.5d+40)) then
tmp = sin(th)
else if (ky <= 7.2d-214) then
tmp = sqrt((th * th))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -3.5e+40) {
tmp = Math.sin(th);
} else if (ky <= 7.2e-214) {
tmp = Math.sqrt((th * th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -3.5e+40: tmp = math.sin(th) elif ky <= 7.2e-214: tmp = math.sqrt((th * th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -3.5e+40) tmp = sin(th); elseif (ky <= 7.2e-214) tmp = sqrt(Float64(th * th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -3.5e+40) tmp = sin(th); elseif (ky <= 7.2e-214) tmp = sqrt((th * th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -3.5e+40], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 7.2e-214], N[Sqrt[N[(th * th), $MachinePrecision]], $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -3.5 \cdot 10^{+40}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 7.2 \cdot 10^{-214}:\\
\;\;\;\;\sqrt{th \cdot th}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -3.4999999999999999e40 or 7.2e-214 < ky Initial program 95.5%
+-commutative95.5%
unpow295.5%
unpow295.5%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 37.9%
if -3.4999999999999999e40 < ky < 7.2e-214Initial program 87.4%
associate-/r/87.4%
+-commutative87.4%
unpow287.4%
sqr-neg87.4%
sin-neg87.4%
sin-neg87.4%
unpow287.4%
+-commutative87.4%
Simplified99.6%
Taylor expanded in kx around 0 5.9%
associate-/r/5.9%
*-inverses5.9%
*-un-lft-identity5.9%
add-sqr-sqrt2.7%
sqrt-unprod29.2%
pow229.2%
Applied egg-rr29.2%
Taylor expanded in th around 0 26.6%
unpow226.6%
Simplified26.6%
Final simplification33.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 92.5%
+-commutative92.5%
unpow292.5%
unpow292.5%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 26.3%
Final simplification26.3%
(FPCore (kx ky th) :precision binary64 (/ 1.0 (+ (/ 1.0 th) (* th 0.16666666666666666))))
double code(double kx, double ky, double th) {
return 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = 1.0d0 / ((1.0d0 / th) + (th * 0.16666666666666666d0))
end function
public static double code(double kx, double ky, double th) {
return 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
}
def code(kx, ky, th): return 1.0 / ((1.0 / th) + (th * 0.16666666666666666))
function code(kx, ky, th) return Float64(1.0 / Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666))) end
function tmp = code(kx, ky, th) tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666)); end
code[kx_, ky_, th_] := N[(1.0 / N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1}{th} + th \cdot 0.16666666666666666}
\end{array}
Initial program 92.5%
associate-/r/92.4%
+-commutative92.4%
unpow292.4%
sqr-neg92.4%
sin-neg92.4%
sin-neg92.4%
unpow292.4%
+-commutative92.4%
Simplified99.6%
Taylor expanded in th around 0 51.1%
+-commutative51.1%
unpow251.1%
unpow251.1%
hypot-def54.4%
associate-*r*54.4%
unpow254.4%
unpow254.4%
hypot-def54.5%
distribute-rgt-out54.5%
Simplified54.5%
Taylor expanded in kx around 0 15.0%
Final simplification15.0%
(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.5%
associate-/r/92.4%
+-commutative92.4%
unpow292.4%
sqr-neg92.4%
sin-neg92.4%
sin-neg92.4%
unpow292.4%
+-commutative92.4%
Simplified99.6%
Taylor expanded in kx around 0 26.2%
Taylor expanded in th around 0 14.7%
Final simplification14.7%
herbie shell --seed 2023279
(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)))